Changeset 133 for trunk/dll/mainwnd.c
- Timestamp:
- May 25, 2005, 1:28:12 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/mainwnd.c
r130 r133 13 13 01 Aug 04 SHL Rework lstrip/rstrip usage 14 14 23 May 05 SHL Use QWL_USER 15 23 May 05 SHL Use datamin.h 15 16 16 17 ***********************************************************************/ … … 28 29 #include <ctype.h> 29 30 #include <share.h> 31 30 32 #include "fm3dll.h" 31 33 #include "fm3dlg.h" 32 34 #include "fm3str.h" 33 35 #include "tools.h" 34 // #include "xor.h" // SHL 36 #include "datamin.h" 35 37 36 38 #pragma data_seg(DATA1) … … 55 57 #pragma alloc_text(MAINOBJ,MainObjectWndProc,MakeMainObjWin) 56 58 57 extern TOOL 59 extern TOOL *toolhead; 58 60 59 61 USHORT firsttool = 0; 60 62 61 62 MRESULT EXPENTRY MainObjectWndProc (HWND hwnd,ULONG msg,MPARAM mp1, MPARAM mp2) { 63 64 switch(msg) { 65 case UM_SETUP: 66 case UM_SETUP2: 67 case UM_SETUP3: 68 case UM_SETUP4: 69 case UM_SETUP5: 70 /* 71 * feed setup messages to main window 72 */ 73 PostMsg(hwndMain,msg,mp1,mp2); 74 return 0; 75 76 case UM_SETUP6: 77 /* 78 * handle bubble help requests from drive bar buttons 79 */ 80 { 81 char dv[3],d; 82 HWND hwndB = (HWND)mp1; 83 USHORT id; 84 85 id = WinQueryWindowUShort(hwndB,QWS_ID); 86 *dv = 0; 87 WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwndB,QW_PARENT), 88 id + 50), 89 sizeof(dv), 90 dv); 91 d = toupper(*dv); 92 if(isalpha(d) && d > 'B' && 93 !(driveflags[d - 'A'] & (DRIVE_CDROM | DRIVE_INVALID | 94 DRIVE_SLOW)) && 95 (!hwndBubble || 96 WinQueryWindowULong(hwndBubble,QWL_USER) != hwndB) && 97 !WinQueryCapture(HWND_DESKTOP)) { 98 99 FSALLOCATE fsa; 100 CHAR s[90],szQty[38],*pszUM; 101 ULONG ulPctFree; 102 float fltFreeQty; 103 104 if(!DosQueryFSInfo((d - 'A') + 1, 105 FSIL_ALLOC, 106 &fsa, 107 sizeof(FSALLOCATE))) { 108 fltFreeQty = (float)fsa.cUnitAvail * 109 (fsa.cSectorUnit * fsa.cbSector); 110 if(fltFreeQty >= (1024 * 1024)) { 111 fltFreeQty /= (1024 * 1024); 112 pszUM = "mb"; 113 } 114 else if(fltFreeQty >= 1024) { 115 fltFreeQty /= 1024; 116 pszUM = "kb"; 117 } 118 else 119 pszUM = "b"; 120 ulPctFree = (fsa.cUnit && fsa.cUnitAvail) ? 121 (fsa.cUnitAvail * 100) / fsa.cUnit : 0; 122 commafmt(szQty, 123 sizeof(szQty), 124 (ULONG)fltFreeQty); 125 sprintf(s, 126 "%s%s (%lu%%) free", 127 szQty, 128 pszUM, 129 ulPctFree); 130 } 131 if((!hwndBubble || 132 WinQueryWindowULong(hwndBubble,QWL_USER) != hwndB) && 133 !WinQueryCapture(HWND_DESKTOP)) 134 WinSendMsg(hwndB, 135 UM_SETUP6, 136 MPFROMP(s), 137 MPVOID); 138 } 139 } 140 return 0; 141 142 case UM_SETDIR: 143 { 144 CHAR s[8] = " :\\OS2"; 145 ULONG bd; 146 147 if(DosQuerySysInfo(QSV_BOOT_DRIVE, 148 QSV_BOOT_DRIVE, 149 (PVOID)&bd, 150 (ULONG)sizeof(ULONG))) 151 bd = 3L; 152 *s = (CHAR)bd + '@'; 153 WinSendMsg(hwndMain, 154 UM_SETDIR, 155 MPFROMP(s), 156 MPFROMLONG(1L)); 157 if(!mp1) { 158 s[3] = 0; 159 WinSendMsg(hwndMain, 160 UM_SETDIR, 161 MPFROMP(s), 162 MPVOID); 163 } 164 PostMsg(MainObjectHwnd, 165 UM_RESTORE, 166 MPFROMLONG(1L), 167 MPFROMLONG(1L)); 168 } 169 return 0; 170 171 case UM_RESTORE: 172 if(mp2) { 173 switch((ULONG)mp2) { 174 case 1: 175 TileChildren(hwndMain,TRUE); 176 break; 177 case 2: 178 CloseDirCnrChildren(hwndMain); 179 break; 180 } 181 } 182 else { 183 fNoTileUpdate = TRUE; 184 WinEnableWindow(WinQueryWindow(hwndMain,QW_PARENT),FALSE); 185 RestoreDirCnrState(hwndMain,(char *)mp1,FALSE); 186 WinEnableWindow(WinQueryWindow(hwndMain,QW_PARENT),TRUE); 187 fNoTileUpdate = FALSE; 188 if(mp1) 189 free((char *)mp1); 190 if(fAutoTile) 191 TileChildren(hwndMain,TRUE); 192 } 193 return 0; 194 195 case UM_NOTIFY: 196 /* 197 * bring up notify messages for various windows 198 */ 199 if(mp1) 200 return MRFROMLONG(DoNotify((char *)mp1)); 201 return 0; 202 203 case WM_DESTROY: 204 if(!PostMsg((HWND)0,WM_QUIT,MPVOID,MPVOID)) 205 WinSendMsg((HWND)0,WM_QUIT,MPVOID,MPVOID); 206 break; 63 MRESULT EXPENTRY MainObjectWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 64 { 65 66 switch (msg) 67 { 68 case UM_SETUP: 69 case UM_SETUP2: 70 case UM_SETUP3: 71 case UM_SETUP4: 72 case UM_SETUP5: 73 /* 74 * feed setup messages to main window 75 */ 76 PostMsg(hwndMain, msg, mp1, mp2); 77 return 0; 78 79 case UM_SETUP6: 80 /* 81 * handle bubble help requests from drive bar buttons 82 */ 83 { 84 char dv[3], d; 85 HWND hwndB = (HWND) mp1; 86 USHORT id; 87 88 id = WinQueryWindowUShort(hwndB, QWS_ID); 89 *dv = 0; 90 WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwndB, QW_PARENT), 91 id + 50), 92 sizeof(dv), 93 dv); 94 d = toupper(*dv); 95 if (isalpha(d) && d > 'B' && 96 !(driveflags[d - 'A'] & (DRIVE_CDROM | DRIVE_INVALID | 97 DRIVE_SLOW)) && 98 (!hwndBubble || 99 WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) && 100 !WinQueryCapture(HWND_DESKTOP)) 101 { 102 103 FSALLOCATE fsa; 104 CHAR s[90], szQty[38], *pszUM; 105 ULONG ulPctFree; 106 float fltFreeQty; 107 108 if (!DosQueryFSInfo((d - 'A') + 1, 109 FSIL_ALLOC, 110 &fsa, 111 sizeof(FSALLOCATE))) 112 { 113 fltFreeQty = (float) fsa.cUnitAvail * 114 (fsa.cSectorUnit * fsa.cbSector); 115 if (fltFreeQty >= (1024 * 1024)) 116 { 117 fltFreeQty /= (1024 * 1024); 118 pszUM = "mb"; 119 } 120 else if (fltFreeQty >= 1024) 121 { 122 fltFreeQty /= 1024; 123 pszUM = "kb"; 124 } 125 else 126 pszUM = "b"; 127 ulPctFree = (fsa.cUnit && fsa.cUnitAvail) ? 128 (fsa.cUnitAvail * 100) / fsa.cUnit : 0; 129 commafmt(szQty, 130 sizeof(szQty), 131 (ULONG) fltFreeQty); 132 sprintf(s, 133 "%s%s (%lu%%) free", 134 szQty, 135 pszUM, 136 ulPctFree); 207 137 } 208 return WinDefWindowProc(hwnd,msg,mp1,mp2); 138 if ((!hwndBubble || 139 WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) && 140 !WinQueryCapture(HWND_DESKTOP)) 141 WinSendMsg(hwndB, 142 UM_SETUP6, 143 MPFROMP(s), 144 MPVOID); 145 } 146 } 147 return 0; 148 149 case UM_SETDIR: 150 { 151 CHAR s[8] = " :\\OS2"; 152 ULONG bd; 153 154 if (DosQuerySysInfo(QSV_BOOT_DRIVE, 155 QSV_BOOT_DRIVE, 156 (PVOID) & bd, 157 (ULONG) sizeof(ULONG))) 158 bd = 3L; 159 *s = (CHAR) bd + '@'; 160 WinSendMsg(hwndMain, 161 UM_SETDIR, 162 MPFROMP(s), 163 MPFROMLONG(1L)); 164 if (!mp1) 165 { 166 s[3] = 0; 167 WinSendMsg(hwndMain, 168 UM_SETDIR, 169 MPFROMP(s), 170 MPVOID); 171 } 172 PostMsg(MainObjectHwnd, 173 UM_RESTORE, 174 MPFROMLONG(1L), 175 MPFROMLONG(1L)); 176 } 177 return 0; 178 179 case UM_RESTORE: 180 if (mp2) 181 { 182 switch ((ULONG) mp2) 183 { 184 case 1: 185 TileChildren(hwndMain, TRUE); 186 break; 187 case 2: 188 CloseDirCnrChildren(hwndMain); 189 break; 190 } 191 } 192 else 193 { 194 fNoTileUpdate = TRUE; 195 WinEnableWindow(WinQueryWindow(hwndMain, QW_PARENT), FALSE); 196 RestoreDirCnrState(hwndMain, (char *) mp1, FALSE); 197 WinEnableWindow(WinQueryWindow(hwndMain, QW_PARENT), TRUE); 198 fNoTileUpdate = FALSE; 199 if (mp1) 200 free((char *) mp1); 201 if (fAutoTile) 202 TileChildren(hwndMain, TRUE); 203 } 204 return 0; 205 206 case UM_NOTIFY: 207 /* 208 * bring up notify messages for various windows 209 */ 210 if (mp1) 211 return MRFROMLONG(DoNotify((char *) mp1)); 212 return 0; 213 214 case WM_DESTROY: 215 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID)) 216 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID); 217 break; 218 } 219 return WinDefWindowProc(hwnd, msg, mp1, mp2); 209 220 } 210 221 211 212 VOID MakeMainObjWin (VOID *args) { 213 214 HAB hab2; 215 HMQ hmq2; 216 QMSG qmsg2; 217 218 priority_bumped(); 219 hab2 = WinInitialize(0); 220 if(hab2) { 221 hmq2 = WinCreateMsgQueue(hab2,128); 222 if(hmq2) { 223 DosError(FERR_DISABLEHARDERR); 224 WinRegisterClass(hab2, 225 GetPString(IDS_WCOBJECTWINDOW), 226 MainObjectWndProc, 227 0, 228 sizeof(PVOID)); 229 MainObjectHwnd = WinCreateWindow(HWND_OBJECT, 230 GetPString(IDS_WCOBJECTWINDOW), 231 (PSZ)NULL, 232 0, 233 0L, 234 0L, 235 0L, 236 0L, 237 0L, 222 VOID MakeMainObjWin(VOID * args) 223 { 224 225 HAB hab2; 226 HMQ hmq2; 227 QMSG qmsg2; 228 229 priority_bumped(); 230 hab2 = WinInitialize(0); 231 if (hab2) 232 { 233 hmq2 = WinCreateMsgQueue(hab2, 128); 234 if (hmq2) 235 { 236 DosError(FERR_DISABLEHARDERR); 237 WinRegisterClass(hab2, 238 GetPString(IDS_WCOBJECTWINDOW), 239 MainObjectWndProc, 240 0, 241 sizeof(PVOID)); 242 MainObjectHwnd = WinCreateWindow(HWND_OBJECT, 243 GetPString(IDS_WCOBJECTWINDOW), 244 (PSZ) NULL, 245 0, 246 0L, 247 0L, 248 0L, 249 0L, 250 0L, 238 251 HWND_TOP, 239 252 OBJ_FRAME, 240 NULL, 241 NULL); 242 if(MainObjectHwnd) { 243 WinSetWindowPtr(MainObjectHwnd,QWL_USER,args); 244 while(WinGetMsg(hab2,&qmsg2,(HWND)0,0,0)) 245 WinDispatchMsg(hab2,&qmsg2); 246 WinDestroyWindow(MainObjectHwnd); 247 } 248 WinDestroyMsgQueue(hmq2); 253 NULL, 254 NULL); 255 if (MainObjectHwnd) 256 { 257 WinSetWindowPtr(MainObjectHwnd, QWL_USER, args); 258 while (WinGetMsg(hab2, &qmsg2, (HWND) 0, 0, 0)) 259 WinDispatchMsg(hab2, &qmsg2); 260 WinDestroyWindow(MainObjectHwnd); 261 } 262 WinDestroyMsgQueue(hmq2); 263 } 264 WinTerminate(hab2); 265 } 266 } 267 268 MRESULT EXPENTRY IdealButtonProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 269 { 270 271 switch (msg) 272 { 273 case WM_MOUSEMOVE: 274 BubbleHelp(hwnd, 275 TRUE, 276 FALSE, 277 FALSE, 278 GetPString(IDS_IDEALBUTTONHELP)); 279 break; 280 } 281 return PFNWPButton(hwnd, msg, mp1, mp2); 282 } 283 284 HWND TopWindow(HWND hwndParent, HWND exclude) 285 { 286 287 HENUM henum; 288 HWND hwndC = (HWND) 0; 289 USHORT id; 290 291 if (hwndParent) 292 { 293 henum = WinBeginEnumWindows(hwndMain); 294 while ((hwndC = WinGetNextWindow(henum)) != NULLHANDLE) 295 { 296 if (hwndC != exclude) 297 { 298 id = WinQueryWindowUShort(hwndC, QWS_ID); 299 if (id) 300 break; 301 } 302 } 303 WinEndEnumWindows(henum); 304 } 305 return hwndC; 306 } 307 308 HWND TopWindowName(HWND hwndParent, HWND exclude, CHAR * ret) 309 { 310 311 HENUM henum; 312 HWND hwndC = (HWND) 0, hwndDir, hwndClient; 313 USHORT id; 314 PCNRITEM pci = NULL; 315 316 if (ret) 317 { 318 *ret = 0; 319 if (hwndParent) 320 { 321 henum = WinBeginEnumWindows(hwndMain); 322 while ((hwndC = WinGetNextWindow(henum)) != NULLHANDLE) 323 { 324 // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tree = %lu\rExclude = %lu\rFound = %lu",hwndTree,exclude,hwndC); 325 if (hwndC != exclude && 326 hwndC != hwndTree) 327 { 328 id = WinQueryWindowUShort(hwndC, QWS_ID); 329 if (id) 330 { 331 hwndClient = WinWindowFromID(hwndC, FID_CLIENT); 332 if (hwndClient) 333 { 334 hwndDir = WinWindowFromID(hwndClient, DIR_CNR); 335 if (hwndDir) 336 { 337 if (fLookInDir) 338 { 339 pci = (PCNRITEM) WinSendMsg(hwndDir, 340 CM_QUERYRECORDEMPHASIS, 341 MPFROMLONG(CMA_FIRST), 342 MPFROMSHORT(CRA_CURSORED)); 343 if (pci && 344 (INT) pci != -1) 345 break; 249 346 } 250 WinTerminate(hab2); 347 if (WinSendMsg(hwndClient, 348 UM_CONTAINERDIR, 349 MPFROMP(ret), 350 MPVOID)) 351 { 352 MakeValidDir(ret); 353 // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tree = %lu\rExclude = %lu\rFound = %lu\r\"%s\"",hwndTree,exclude,hwndC,ret); 354 WinEndEnumWindows(henum); 355 return hwndC; 356 } 357 } 358 } 359 } 251 360 } 361 } 362 WinEndEnumWindows(henum); 363 if (!pci || 364 (INT) pci == -1) 365 { 366 hwndC = hwndTree; 367 pci = (PCNRITEM) WinSendMsg(WinWindowFromID(WinWindowFromID( 368 hwndTree, 369 FID_CLIENT), 370 TREE_CNR), 371 CM_QUERYRECORDEMPHASIS, 372 MPFROMLONG(CMA_FIRST), 373 MPFROMSHORT(CRA_CURSORED)); 374 } 375 if (pci && 376 (INT) pci != -1) 377 { 378 strcpy(ret, pci -> szFileName); 379 MakeValidDir(ret); 380 } 381 else 382 save_dir2(ret); 383 } 384 } 385 return hwndC; 252 386 } 253 387 254 255 MRESULT EXPENTRY IdealButtonProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) { 256 257 switch(msg) { 258 case WM_MOUSEMOVE: 259 BubbleHelp(hwnd, 260 TRUE, 261 FALSE, 262 FALSE, 263 GetPString(IDS_IDEALBUTTONHELP)); 264 break; 265 } 266 return PFNWPButton(hwnd,msg,mp1,mp2); 267 } 268 269 270 HWND TopWindow (HWND hwndParent,HWND exclude) { 271 272 HENUM henum; 273 HWND hwndC = (HWND)0; 274 USHORT id; 275 276 if(hwndParent) { 277 henum = WinBeginEnumWindows(hwndMain); 278 while((hwndC = WinGetNextWindow(henum)) != NULLHANDLE) { 279 if(hwndC != exclude) { 280 id = WinQueryWindowUShort(hwndC,QWS_ID); 281 if(id) 282 break; 283 } 284 } 285 WinEndEnumWindows(henum); 286 } 287 return hwndC; 288 } 289 290 291 HWND TopWindowName (HWND hwndParent,HWND exclude,CHAR *ret) { 292 293 HENUM henum; 294 HWND hwndC = (HWND)0,hwndDir,hwndClient; 295 USHORT id; 296 PCNRITEM pci = NULL; 297 298 if(ret) { 299 *ret = 0; 300 if(hwndParent) { 301 henum = WinBeginEnumWindows(hwndMain); 302 while((hwndC = WinGetNextWindow(henum)) != NULLHANDLE) { 303 // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tree = %lu\rExclude = %lu\rFound = %lu",hwndTree,exclude,hwndC); 304 if(hwndC != exclude && 305 hwndC != hwndTree) { 306 id = WinQueryWindowUShort(hwndC,QWS_ID); 307 if(id) { 308 hwndClient = WinWindowFromID(hwndC,FID_CLIENT); 309 if(hwndClient) { 310 hwndDir = WinWindowFromID(hwndClient,DIR_CNR); 311 if(hwndDir) { 312 if(fLookInDir) { 313 pci = (PCNRITEM)WinSendMsg(hwndDir, 314 CM_QUERYRECORDEMPHASIS, 315 MPFROMLONG(CMA_FIRST), 316 MPFROMSHORT(CRA_CURSORED)); 317 if(pci && 318 (INT)pci != -1) 319 break; 320 } 321 if(WinSendMsg(hwndClient, 322 UM_CONTAINERDIR, 323 MPFROMP(ret), 324 MPVOID)) { 325 MakeValidDir(ret); 326 // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tree = %lu\rExclude = %lu\rFound = %lu\r\"%s\"",hwndTree,exclude,hwndC,ret); 327 WinEndEnumWindows(henum); 328 return hwndC; 329 } 330 } 331 } 332 } 333 } 334 } 335 WinEndEnumWindows(henum); 336 if(!pci || 337 (INT)pci == -1) { 338 hwndC = hwndTree; 339 pci = (PCNRITEM)WinSendMsg(WinWindowFromID(WinWindowFromID( 340 hwndTree, 341 FID_CLIENT), 342 TREE_CNR), 343 CM_QUERYRECORDEMPHASIS, 344 MPFROMLONG(CMA_FIRST), 345 MPFROMSHORT(CRA_CURSORED)); 346 } 347 if(pci && 348 (INT)pci != -1) { 349 strcpy(ret,pci->szFileName); 350 MakeValidDir(ret); 351 } 352 else 353 save_dir2(ret); 354 } 355 } 356 return hwndC; 357 } 358 359 360 ULONG CountDirCnrs (HWND hwndParent) { 388 ULONG CountDirCnrs(HWND hwndParent) 389 { 361 390 362 391 HENUM henum; 363 HWND hwndF = (HWND)0,hwndC,hwndDir;392 HWND hwndF = (HWND) 0, hwndC, hwndDir; 364 393 ULONG ret = 0; 365 394 366 395 henum = WinBeginEnumWindows(hwndParent); 367 while((hwndF = WinGetNextWindow(henum)) != NULLHANDLE) { 368 hwndC = WinWindowFromID(hwndF,FID_CLIENT); 369 if(hwndC) { 370 hwndDir = WinWindowFromID(hwndC,DIR_CNR); 371 if(hwndDir) 372 ret++; 396 while ((hwndF = WinGetNextWindow(henum)) != NULLHANDLE) 397 { 398 hwndC = WinWindowFromID(hwndF, FID_CLIENT); 399 if (hwndC) 400 { 401 hwndDir = WinWindowFromID(hwndC, DIR_CNR); 402 if (hwndDir) 403 ret++; 373 404 } 374 405 } … … 377 408 } 378 409 379 380 HWND FindDirCnrByName (CHAR *directory,BOOL restore){381 382 HENUM 383 HWND hwndF = (HWND)0,hwndC,hwndDir;384 CHAR 385 386 if (hwndMain)410 HWND FindDirCnrByName(CHAR * directory, BOOL restore) 411 { 412 413 HENUM henum; 414 HWND hwndF = (HWND) 0, hwndC, hwndDir; 415 CHAR retstr[CCHMAXPATH]; 416 417 if (hwndMain) 387 418 { 388 419 henum = WinBeginEnumWindows(hwndMain); 389 while ((hwndF = WinGetNextWindow(henum)) != NULLHANDLE)390 { 391 hwndC = WinWindowFromID(hwndF, FID_CLIENT);392 if (hwndC)393 { 394 hwndDir = WinWindowFromID(hwndC, DIR_CNR);395 if (hwndDir)420 while ((hwndF = WinGetNextWindow(henum)) != NULLHANDLE) 421 { 422 hwndC = WinWindowFromID(hwndF, FID_CLIENT); 423 if (hwndC) 424 { 425 hwndDir = WinWindowFromID(hwndC, DIR_CNR); 426 if (hwndDir) 396 427 { 397 428 *retstr = 0; 398 429 WinSendMsg(hwndC, 399 430 UM_CONTAINERDIR, 400 401 402 if(*retstr &&403 !stricmp(retstr,directory))431 MPFROMP(retstr), 432 MPVOID); 433 if (*retstr && 434 !stricmp(retstr, directory)) 404 435 { 405 if (restore)406 407 408 409 410 411 412 413 SWP_ACTIVATE | SWP_ZORDER);436 if (restore) 437 WinSetWindowPos(hwndF, 438 HWND_TOP, 439 0, 440 0, 441 0, 442 0, 443 SWP_RESTORE | SWP_SHOW | 444 SWP_ACTIVATE | SWP_ZORDER); 414 445 break; 415 416 446 } 447 } 417 448 } 418 449 } … … 422 453 } 423 454 424 425 VOID SetToggleChecks (HWND hwndMenu){455 VOID SetToggleChecks(HWND hwndMenu) 456 { 426 457 427 458 WinCheckMenuItem(hwndMenu, 428 429 459 IDM_TEXTTOOLS, 460 fTextTools); 430 461 WinCheckMenuItem(hwndMenu, 431 432 462 IDM_TOOLTITLES, 463 fToolTitles); 433 464 WinCheckMenuItem(hwndMenu, 434 435 465 IDM_USERLIST, 466 fUserComboBox); 436 467 WinCheckMenuItem(hwndMenu, 437 438 468 IDM_TOOLSUBMENU, 469 fToolbar); 439 470 WinCheckMenuItem(hwndMenu, 440 441 471 IDM_AUTOVIEWSUBMENU, 472 fAutoView); 442 473 WinCheckMenuItem(hwndMenu, 443 444 474 IDM_AUTOVIEWFILE, 475 !fComments); 445 476 WinCheckMenuItem(hwndMenu, 446 447 477 IDM_AUTOVIEWCOMMENTS, 478 fComments); 448 479 WinCheckMenuItem(hwndMenu, 449 450 480 IDM_MOREBUTTONS, 481 fMoreButtons); 451 482 WinCheckMenuItem(hwndMenu, 452 453 483 IDM_DRIVEBAR, 484 fDrivebar); 454 485 WinCheckMenuItem(hwndMenu, 455 456 486 IDM_AUTOTILE, 487 fAutoTile); 457 488 WinCheckMenuItem(hwndMenu, 458 459 489 IDM_TILEBACKWARDS, 490 fTileBackwards); 460 491 } 461 492 462 463 VOID ResizeTools (HWND hwnd) { 464 465 register ULONG butx = 18L; 466 INT attrib = SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER | SWP_NOREDRAW, 467 noattrib; 468 register TOOL *tool,*starttool; 469 SWP *swp; 470 register ULONG numtools,x; 471 472 if(!fToolbar) 473 return; 474 noattrib = attrib; 475 noattrib &= (~(SWP_SHOW | SWP_ZORDER)); 476 noattrib |= SWP_HIDE; 477 /* count tools */ 478 tool = toolhead; 479 for(numtools = 0L;tool;numtools++) 480 tool = tool->next; 481 /* allocate swp array for WinSetMultWindowPos */ 482 swp = malloc(sizeof(SWP) * (numtools + 2)); 483 if(swp) { 484 memset(swp,0,sizeof(SWP) * (numtools + 2)); 485 for(x = 0;x < numtools + 2L;x++) { 486 swp[x].hwndInsertBehind = HWND_TOP; 487 swp[x].fl = attrib; 488 swp[x].y = (fToolTitles) ? 14L : 3L; 489 swp[x].cx = 32L; 490 swp[x].cy = 32L; 493 VOID ResizeTools(HWND hwnd) 494 { 495 496 register ULONG butx = 18L; 497 INT attrib = SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER | SWP_NOREDRAW, 498 noattrib; 499 register TOOL *tool, *starttool; 500 SWP *swp; 501 register ULONG numtools, x; 502 503 if (!fToolbar) 504 return; 505 noattrib = attrib; 506 noattrib &= (~(SWP_SHOW | SWP_ZORDER)); 507 noattrib |= SWP_HIDE; 508 /* count tools */ 509 tool = toolhead; 510 for (numtools = 0L; tool; numtools++) 511 tool = tool -> next; 512 /* allocate swp array for WinSetMultWindowPos */ 513 swp = malloc(sizeof(SWP) * (numtools + 2)); 514 if (swp) 515 { 516 memset(swp, 0, sizeof(SWP) * (numtools + 2)); 517 for (x = 0; x < numtools + 2L; x++) 518 { 519 swp[x].hwndInsertBehind = HWND_TOP; 520 swp[x].fl = attrib; 521 swp[x].y = (fToolTitles) ? 14L : 3L; 522 swp[x].cx = 32L; 523 swp[x].cy = 32L; 524 } 525 swp[0].x = swp[1].x = 2L; 526 swp[0].y = (fTextTools) ? 14L : 18L; 527 swp[1].y = (fTextTools) ? 1L : 2L; 528 swp[0].cx = swp[1].cx = 14L; 529 swp[0].cy = swp[1].cy = 14L; 530 swp[0].hwnd = WinWindowFromID(hwnd, IDM_TOOLLEFT); 531 swp[1].hwnd = WinWindowFromID(hwnd, IDM_TOOLRIGHT); 532 x = 2L; 533 tool = find_tool(firsttool); 534 if (!tool) 535 tool = toolhead; 536 starttool = tool; 537 while (tool) 538 { 539 if (!(tool -> flags & T_INVISIBLE)) 540 { 541 swp[x].x = butx; 542 if (fTextTools || (tool -> flags & T_TEXT)) 543 { 544 butx += 55L; 545 swp[x].cx = 54L; 546 swp[x].cy = 24L; 547 swp[x].y = 3L; 548 } 549 else 550 butx += 33L; 551 if (tool -> flags & T_SEPARATOR) 552 butx += 12; 553 } 554 else 555 swp[x].fl = noattrib; 556 swp[x].hwnd = WinWindowFromID(hwnd, tool -> id); 557 x++; 558 tool = tool -> next; 559 } 560 tool = toolhead; 561 while (tool && tool != starttool) 562 { 563 swp[x].x = butx; 564 if (!(tool -> flags & T_INVISIBLE)) 565 { 566 if (fTextTools || (tool -> flags & T_TEXT)) 567 { 568 butx += 55L; 569 swp[x].cx = 54L; 570 swp[x].cy = 24L; 571 swp[x].y = 3L; 572 } 573 else 574 butx += 33L; 575 if (tool -> flags & T_SEPARATOR) 576 butx += 12; 577 } 578 else 579 swp[x].fl = noattrib; 580 swp[x].hwnd = WinWindowFromID(hwnd, tool -> id); 581 x++; 582 tool = tool -> next; 583 } 584 WinSetMultWindowPos(WinQueryAnchorBlock(hwnd), swp, numtools + 2L); 585 if (!fTextTools && fToolTitles) 586 { 587 for (x = 2L; x < numtools + 2L; x++) 588 { 589 if (fTextTools || !fToolTitles) 590 swp[x].fl = noattrib; 591 else 592 { 593 tool = find_tool(WinQueryWindowUShort(swp[x].hwnd, QWS_ID)); 594 if (tool && (tool -> flags & T_TEXT)) 595 swp[x].fl = noattrib; 596 else 597 { 598 swp[x].hwndInsertBehind = HWND_TOP; 599 swp[x].y = 1L; 600 swp[x].cy = 10L; 601 } 602 } 603 swp[x].hwnd = WinWindowFromID(hwnd, 604 WinQueryWindowUShort(swp[x].hwnd, QWS_ID) + 605 25000); 606 } 607 WinSetMultWindowPos(WinQueryAnchorBlock(hwnd), &swp[2], numtools); 608 } 609 free(swp); 610 } 611 WinInvalidateRect(hwnd, NULL, TRUE); 612 } 613 614 MRESULT EXPENTRY DropDownListProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 615 { 616 617 PFNWP oldproc = (PFNWP) INSTDATA(hwnd); 618 static HWND hwndMenu = (HWND) 0; 619 USHORT id; 620 static BOOL emphasized = FALSE; 621 622 switch (msg) 623 { 624 case WM_MOUSEMOVE: 625 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); 626 break; 627 628 case WM_CHAR: 629 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL)); 630 break; 631 632 case WM_MENUEND: 633 if (hwndMenu == (HWND) mp2) 634 { 635 WinDestroyWindow(hwndMenu); 636 hwndMenu = (HWND) 0; 637 } 638 break; 639 640 case WM_CONTEXTMENU: 641 { 642 MRESULT ret = MRFROMSHORT(TRUE); 643 644 if (hwndMenu) 645 WinDestroyWindow(hwndMenu); 646 hwndMenu = (HWND) 0; 647 id = WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID); 648 switch (id) 649 { 650 case MAIN_CMDLIST: 651 WinPostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd, 652 QW_PARENT), 653 QW_PARENT), 654 FID_CLIENT), 655 WM_COMMAND, 656 MPFROM2SHORT(IDM_EDITCOMMANDS, 0), 657 MPVOID); 658 break; 659 case MAIN_USERLIST: 660 case MAIN_SETUPLIST: 661 hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id); 662 if (hwndMenu) 663 PopupMenu(hwnd, 664 WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd, 665 QW_PARENT), 666 QW_PARENT), 667 FID_CLIENT), 668 hwndMenu); 669 break; 670 default: 671 ret = FALSE; 672 break; 673 } 674 return ret; 675 } 676 677 case WM_CONTROL: 678 if (hwndStatus2) 679 { 680 switch (SHORT1FROMMP(mp1)) 681 { 682 case CBID_EDIT: 683 id = WinQueryWindowUShort(hwnd, QWS_ID); 684 switch (SHORT2FROMMP(mp1)) 685 { 686 case EN_SETFOCUS: 687 switch (id) 688 { 689 case MAIN_CMDLIST: 690 WinSetWindowText(hwndStatus2, 691 GetPString(IDS_CMDLISTHELP)); 692 break; 693 case MAIN_SETUPLIST: 694 WinSetWindowText(hwndStatus2, 695 GetPString(IDS_SETUPLISTHELP)); 696 break; 697 case MAIN_USERLIST: 698 WinSetWindowText(hwndStatus2, 699 GetPString(IDS_USERLISTHELP)); 700 break; 701 case MAIN_DRIVELIST: 702 WinSetWindowText(hwndStatus2, 703 GetPString(IDS_DRIVELISTHELP)); 704 break; 705 case MAIN_BUTTONLIST: 706 WinSetWindowText(hwndStatus2, 707 GetPString(IDS_BUTTONLISTHELP)); 708 break; 709 default: 710 break; 711 } 712 break; 713 714 default: 715 break; 716 } 717 } 718 break; 719 720 default: 721 break; 722 } 723 break; 724 725 case WM_BEGINDRAG: 726 id = WinQueryWindowUShort(hwnd, QWS_ID); 727 // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"%u %s %u",id,(id == CBID_EDIT) ? "TRUE" : "FALSE",WinQueryWindowUShort(WinQueryWindow(hwnd,QW_PARENT),QWS_ID) == MAIN_USERLIST); 728 if (id == CBID_EDIT && 729 WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID) == 730 MAIN_USERLIST) 731 { 732 733 CHAR path[CCHMAXPATH]; 734 735 *path = 0; 736 WinQueryWindowText(hwnd, CCHMAXPATH, path); 737 bstrip(path); 738 // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Dragging: %s",path); 739 if (*path && !IsRoot(path)) 740 DragOne(hwnd, (HWND) 0, path, FALSE); 741 return 0; 742 } 743 break; 744 745 case DM_DRAGOVER: 746 id = WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID); 747 if (id == MAIN_USERLIST) 748 { 749 if (!emphasized) 750 { 751 emphasized = TRUE; 752 DrawTargetEmphasis(hwnd, emphasized); 753 } 754 if (AcceptOneDrop(mp1, mp2)) 755 return MRFROM2SHORT(DOR_DROP, 756 DO_MOVE); 757 return MRFROM2SHORT(DOR_NEVERDROP, 0); 758 } 759 break; 760 761 case DM_DRAGLEAVE: 762 id = WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID); 763 if (id == MAIN_USERLIST) 764 { 765 if (emphasized) 766 { 767 emphasized = FALSE; 768 DrawTargetEmphasis(hwnd, emphasized); 769 } 770 } 771 break; 772 773 case DM_DROPHELP: 774 id = WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID); 775 if (id == MAIN_USERLIST) 776 { 777 DropHelp(mp1, mp2, hwnd, GetPString(IDS_USERLISTDROPHELP)); 778 return 0; 779 } 780 break; 781 782 case DM_DROP: 783 id = WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID); 784 if (id == MAIN_USERLIST) 785 { 786 787 char szFrom[CCHMAXPATH + 2]; 788 789 if (emphasized) 790 { 791 emphasized = FALSE; 792 DrawTargetEmphasis(hwnd, emphasized); 793 } 794 if (GetOneDrop(mp1, 795 mp2, 796 szFrom, 797 sizeof(szFrom))) 798 { 799 MakeValidDir(szFrom); 800 WinSetWindowText(hwnd, 801 szFrom); 802 PostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd, 803 QW_PARENT), 804 QW_PARENT), 805 FID_CLIENT), 806 UM_COMMAND, 807 MPFROM2SHORT(IDM_ADDTOUSERLIST, 0), 808 MPVOID); 809 return 0; 810 } 811 } 812 break; 813 814 case WM_DESTROY: 815 if (hwndMenu) 816 WinDestroyWindow(hwndMenu); 817 hwndMenu = (HWND) 0; 818 break; 819 } 820 821 return oldproc(hwnd, msg, mp1, mp2); 822 } 823 824 void BubbleHelp(HWND hwnd, BOOL other, BOOL drive, BOOL above, char *help) 825 { 826 827 if (help && *help && 828 ((drive && fDrivebarHelp) || 829 (other && fOtherHelp) || 830 (!other && !drive && fToolbarHelp))) 831 { 832 if ((!hwndBubble || 833 WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) && 834 !WinQueryCapture(HWND_DESKTOP)) 835 MakeBubble(hwnd, 836 above, 837 help); 838 } 839 } 840 841 VOID MakeBubble(HWND hwnd, BOOL above, CHAR * help) 842 { 843 844 if (!hwnd || !help || !*help) 845 return; 846 847 if (hwndBubble) 848 WinDestroyWindow(hwndBubble); 849 850 { 851 HWND hwndActive; 852 char ucClassname[8]; 853 854 hwndActive = WinQueryActiveWindow(HWND_DESKTOP); 855 if (hwndActive) 856 { 857 /* don't bring up help if window isn't active */ 858 if (!WinIsChild(hwnd, hwndActive)) 859 return; 860 } 861 hwndActive = WinQueryFocus(HWND_DESKTOP); 862 if (WinQueryClassName(hwndActive, sizeof(ucClassname), ucClassname)) 863 { 864 /* don't bring up help if a menu is active */ 865 if (!strcmp(ucClassname, "#4")) 866 return; 867 } 868 } 869 870 hwndBubble = WinCreateWindow(HWND_DESKTOP, 871 GetPString(IDS_WCBUBBLE), 872 help, 873 WS_CLIPSIBLINGS | SS_TEXT | 874 DT_CENTER | DT_VCENTER, 875 0, 876 0, 877 0, 878 0, 879 HWND_DESKTOP, 880 HWND_TOP, 881 MAIN_HELP, 882 NULL, 883 NULL); 884 if (hwndBubble) 885 { 886 887 HPS hps; 888 POINTL aptl[TXTBOX_COUNT], ptl, tptl; 889 LONG lxScreen, sx, sy, extra = 0, lyScreen; 890 char *p, *pp, *wp; 891 SWP swp; 892 893 WinQueryWindowPos(hwnd, &swp); 894 lyScreen = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN); 895 lxScreen = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN); 896 WinSetWindowULong(hwndBubble, QWL_USER, hwnd); 897 SetPresParams(hwndBubble, 898 NULL, 899 NULL, 900 NULL, 901 GetPString(IDS_8HELVTEXT)); 902 hps = WinGetPS(hwndBubble); 903 p = help; 904 tptl.x = tptl.y = 0; 905 while (p && *p) 906 { 907 wp = NULL; 908 pp = strchr(p, '\r'); 909 if (pp) 910 { 911 wp = pp; 912 *pp = 0; 913 pp++; 914 } 915 GpiQueryTextBox(hps, strlen(p), p, TXTBOX_COUNT, aptl); 916 tptl.x = max(aptl[TXTBOX_TOPRIGHT].x, tptl.x); 917 if (tptl.y) 918 tptl.y += extra; 919 else 920 extra = aptl[TXTBOX_TOPLEFT].y / 4; 921 tptl.y += aptl[TXTBOX_TOPLEFT].y; 922 if (wp) 923 *wp = '\r'; 924 p = pp; 925 } 926 WinSetWindowULong(hwndBubble, QWL_USER + 4, extra); 927 WinReleasePS(hps); 928 ptl.x = ptl.y = 0; 929 WinMapWindowPoints(hwnd, HWND_DESKTOP, &ptl, 1); 930 if (above) 931 { 932 sy = ptl.y + swp.cy + 4; 933 if (sy + tptl.y + 12 > lyScreen) 934 { 935 above = FALSE; 936 sy = ptl.y - (tptl.y + 14); 937 } 938 } 939 else 940 sy = ptl.y - (tptl.y + 14); 941 if (ptl.x > (lxScreen / 2)) 942 sx = (ptl.x - tptl.x) - 16; 943 else 944 sx = ptl.x + (54 * (above == FALSE)) + 2; 945 if (sx < 0) 946 sx = 0; 947 if (sx + tptl.x + 14 > lxScreen) 948 sx = lxScreen - (tptl.x + 14); 949 if (sy < 0) 950 { 951 sy = ptl.y + swp.cy + 4; 952 if (sy + tptl.y + 12 > lyScreen) 953 sy = 0; 954 } 955 WinSetWindowPos(hwndBubble, HWND_TOP, sx, sy, 956 tptl.x + 14, 957 tptl.y + 12, 958 SWP_DEACTIVATE | SWP_SHOW | SWP_ZORDER | 959 SWP_MOVE | SWP_SIZE); 960 } 961 } 962 963 MRESULT EXPENTRY BubbleProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 964 { 965 966 switch (msg) 967 { 968 case WM_SETFOCUS: 969 if (mp2) 970 PostMsg(hwnd, 971 UM_FOCUSME, 972 mp1, 973 MPVOID); 974 break; 975 976 case UM_FOCUSME: 977 WinSetFocus(HWND_DESKTOP, 978 (HWND) mp1); 979 return 0; 980 981 case WM_MOUSEMOVE: 982 WinShowWindow(hwnd, FALSE); 983 break; 984 985 case UM_TIMER: 986 { 987 POINTL ptl; 988 989 WinQueryPointerPos(HWND_DESKTOP, &ptl); 990 if (WinWindowFromPoint(HWND_DESKTOP, &ptl, TRUE) != 991 WinQueryWindowULong(hwnd, QWL_USER) || 992 !WinIsWindowVisible(hwnd)) 993 WinDestroyWindow(hwnd); 994 } 995 return 0; 996 997 case WM_PAINT: 998 { 999 HPS hps; 1000 SWP swp; 1001 POINTL ptl, aptl[TXTBOX_COUNT]; 1002 CHAR *s, *p, *pp, *wp; 1003 ULONG extra, tlen, y; 1004 1005 hps = WinBeginPaint(hwnd, (HPS) 0, NULL); 1006 if (hps) 1007 { 1008 WinQueryWindowPos(hwnd, &swp); 1009 GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, 0); 1010 GpiSetColor(hps, ((255 << 16) | (255 << 8) | 198)); 1011 GpiSetBackMix(hps, BM_LEAVEALONE); 1012 GpiSetMix(hps, FM_OVERPAINT); 1013 ptl.x = ptl.y = 0; 1014 GpiMove(hps, &ptl); 1015 ptl.x = swp.cx - 1; 1016 ptl.y = swp.cy - 1; 1017 GpiBox(hps, DRO_OUTLINEFILL, &ptl, 0, 0); 1018 tlen = WinQueryWindowTextLength(hwnd); 1019 if (tlen) 1020 { 1021 s = malloc(tlen + 2); 1022 if (s) 1023 { 1024 WinQueryWindowText(hwnd, tlen + 1, s); 1025 if (*s) 1026 { 1027 p = s; 1028 y = swp.cy - 3; 1029 extra = WinQueryWindowULong(hwnd, QWL_USER + 4); 1030 GpiSetColor(hps, 0); 1031 GpiSetMix(hps, FM_OVERPAINT); 1032 while (p && *p) 1033 { 1034 wp = NULL; 1035 pp = strchr(p, '\r'); 1036 if (pp) 1037 { 1038 wp = pp; 1039 *pp = 0; 1040 pp++; 491 1041 } 492 swp[0].x = swp[1].x = 2L; 493 swp[0].y = (fTextTools) ? 14L : 18L; 494 swp[1].y = (fTextTools) ? 1L : 2L; 495 swp[0].cx = swp[1].cx = 14L; 496 swp[0].cy = swp[1].cy = 14L; 497 swp[0].hwnd = WinWindowFromID(hwnd,IDM_TOOLLEFT); 498 swp[1].hwnd = WinWindowFromID(hwnd,IDM_TOOLRIGHT); 499 x = 2L; 500 tool = find_tool(firsttool); 501 if(!tool) 502 tool = toolhead; 503 starttool = tool; 504 while(tool) { 505 if(!(tool->flags & T_INVISIBLE)) { 506 swp[x].x = butx; 507 if(fTextTools || (tool->flags & T_TEXT)) { 508 butx += 55L; 509 swp[x].cx = 54L; 510 swp[x].cy = 24L; 511 swp[x].y = 3L; 512 } 513 else 514 butx += 33L; 515 if(tool->flags & T_SEPARATOR) 516 butx += 12; 517 } 518 else 519 swp[x].fl = noattrib; 520 swp[x].hwnd = WinWindowFromID(hwnd,tool->id); 521 x++; 522 tool = tool->next; 523 } 524 tool = toolhead; 525 while(tool && tool != starttool) { 526 swp[x].x = butx; 527 if(!(tool->flags & T_INVISIBLE)) { 528 if(fTextTools || (tool->flags & T_TEXT)) { 529 butx += 55L; 530 swp[x].cx = 54L; 531 swp[x].cy = 24L; 532 swp[x].y = 3L; 533 } 534 else 535 butx += 33L; 536 if(tool->flags & T_SEPARATOR) 537 butx += 12; 538 } 539 else 540 swp[x].fl = noattrib; 541 swp[x].hwnd = WinWindowFromID(hwnd,tool->id); 542 x++; 543 tool = tool->next; 544 } 545 WinSetMultWindowPos(WinQueryAnchorBlock(hwnd),swp,numtools + 2L); 546 if(!fTextTools && fToolTitles) { 547 for(x = 2L;x < numtools + 2L;x++) { 548 if(fTextTools || !fToolTitles) 549 swp[x].fl = noattrib; 550 else { 551 tool = find_tool(WinQueryWindowUShort(swp[x].hwnd,QWS_ID)); 552 if(tool && (tool->flags & T_TEXT)) 553 swp[x].fl = noattrib; 554 else { 555 swp[x].hwndInsertBehind = HWND_TOP; 556 swp[x].y = 1L; 557 swp[x].cy = 10L; 558 } 559 } 560 swp[x].hwnd = WinWindowFromID(hwnd, 561 WinQueryWindowUShort(swp[x].hwnd,QWS_ID) + 562 25000); 563 } 564 WinSetMultWindowPos(WinQueryAnchorBlock(hwnd),&swp[2],numtools); 565 } 566 free(swp); 1042 GpiQueryTextBox(hps, strlen(p), p, TXTBOX_COUNT, aptl); 1043 ptl.x = 7; 1044 y -= aptl[TXTBOX_TOPLEFT].y; 1045 if (p != s) 1046 y -= extra; 1047 ptl.y = y; 1048 GpiCharStringAt(hps, &ptl, strlen(p), p); 1049 if (wp) 1050 *wp = '\r'; 1051 p = pp; 1052 } 1053 } 1054 free(s); 1055 } 567 1056 } 568 WinInvalidateRect(hwnd,NULL,TRUE); 1057 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE)) && 1058 swp.cx > 6 && swp.cy > 6) 1059 { 1060 GpiSetColor(hps, CLR_WHITE); 1061 ptl.x = 1; 1062 ptl.y = 1; 1063 GpiMove(hps, &ptl); 1064 ptl.y = swp.cy - 2; 1065 GpiLine(hps, &ptl); 1066 ptl.x = swp.cx - 2; 1067 GpiLine(hps, &ptl); 1068 ptl.x = 2; 1069 ptl.y = 2; 1070 GpiMove(hps, &ptl); 1071 ptl.y = swp.cy - 3; 1072 GpiLine(hps, &ptl); 1073 ptl.x = swp.cx - 3; 1074 GpiLine(hps, &ptl); 1075 GpiSetColor(hps, CLR_BROWN); 1076 ptl.x = 1; 1077 ptl.y = 1; 1078 GpiMove(hps, &ptl); 1079 ptl.x = swp.cx - 2; 1080 GpiLine(hps, &ptl); 1081 ptl.y = swp.cy - 2; 1082 GpiLine(hps, &ptl); 1083 ptl.x = 2; 1084 ptl.y = 2; 1085 GpiMove(hps, &ptl); 1086 ptl.x = swp.cx - 3; 1087 GpiLine(hps, &ptl); 1088 ptl.y = swp.cy - 3; 1089 GpiLine(hps, &ptl); 1090 } 1091 WinEndPaint(hps); 1092 } 1093 } 1094 return 0; 1095 1096 case WM_CLOSE: 1097 WinDestroyWindow(hwnd); 1098 return 0; 1099 1100 case WM_DESTROY: 1101 hwndBubble = (HWND) 0; 1102 break; 1103 } 1104 return PFNWPStatic(hwnd, msg, mp1, mp2); 569 1105 } 570 1106 571 572 MRESULT EXPENTRY DropDownListProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) { 573 574 PFNWP oldproc = (PFNWP)INSTDATA(hwnd); 575 static HWND hwndMenu = (HWND)0; 576 USHORT id; 577 static BOOL emphasized = FALSE; 578 579 switch(msg) { 580 case WM_MOUSEMOVE: 581 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); 582 break; 583 584 case WM_CHAR: 585 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL)); 586 break; 587 588 case WM_MENUEND: 589 if(hwndMenu == (HWND)mp2) { 590 WinDestroyWindow(hwndMenu); 591 hwndMenu = (HWND)0; 592 } 593 break; 594 595 case WM_CONTEXTMENU: 596 { 597 MRESULT ret = MRFROMSHORT(TRUE); 598 599 if(hwndMenu) 600 WinDestroyWindow(hwndMenu); 601 hwndMenu = (HWND)0; 602 id = WinQueryWindowUShort(WinQueryWindow(hwnd,QW_PARENT),QWS_ID); 603 switch(id) { 604 case MAIN_CMDLIST: 605 WinPostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd, 606 QW_PARENT), 607 QW_PARENT), 608 FID_CLIENT), 609 WM_COMMAND, 610 MPFROM2SHORT(IDM_EDITCOMMANDS,0), 611 MPVOID); 612 break; 613 case MAIN_USERLIST: 614 case MAIN_SETUPLIST: 615 hwndMenu = WinLoadMenu(HWND_DESKTOP,FM3ModHandle,id); 616 if(hwndMenu) 617 PopupMenu(hwnd, 618 WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd, 619 QW_PARENT), 620 QW_PARENT), 621 FID_CLIENT), 622 hwndMenu); 623 break; 624 default: 625 ret = FALSE; 626 break; 627 } 628 return ret; 629 } 630 631 case WM_CONTROL: 632 if(hwndStatus2) { 633 switch(SHORT1FROMMP(mp1)) { 634 case CBID_EDIT: 635 id = WinQueryWindowUShort(hwnd,QWS_ID); 636 switch(SHORT2FROMMP(mp1)) { 637 case EN_SETFOCUS: 638 switch(id) { 639 case MAIN_CMDLIST: 640 WinSetWindowText(hwndStatus2, 641 GetPString(IDS_CMDLISTHELP)); 642 break; 643 case MAIN_SETUPLIST: 644 WinSetWindowText(hwndStatus2, 645 GetPString(IDS_SETUPLISTHELP)); 646 break; 647 case MAIN_USERLIST: 648 WinSetWindowText(hwndStatus2, 649 GetPString(IDS_USERLISTHELP)); 650 break; 651 case MAIN_DRIVELIST: 652 WinSetWindowText(hwndStatus2, 653 GetPString(IDS_DRIVELISTHELP)); 654 break; 655 case MAIN_BUTTONLIST: 656 WinSetWindowText(hwndStatus2, 657 GetPString(IDS_BUTTONLISTHELP)); 658 break; 659 default: 660 break; 661 } 662 break; 663 664 default: 665 break; 666 } 667 } 668 break; 669 670 default: 671 break; 672 } 673 break; 674 675 case WM_BEGINDRAG: 676 id = WinQueryWindowUShort(hwnd,QWS_ID); 677 // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"%u %s %u",id,(id == CBID_EDIT) ? "TRUE" : "FALSE",WinQueryWindowUShort(WinQueryWindow(hwnd,QW_PARENT),QWS_ID) == MAIN_USERLIST); 678 if(id == CBID_EDIT && 679 WinQueryWindowUShort(WinQueryWindow(hwnd,QW_PARENT),QWS_ID) == 680 MAIN_USERLIST) { 681 682 CHAR path[CCHMAXPATH]; 683 684 *path = 0; 685 WinQueryWindowText(hwnd,CCHMAXPATH,path); 686 bstrip(path); 687 // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Dragging: %s",path); 688 if(*path && !IsRoot(path)) 689 DragOne(hwnd,(HWND)0,path,FALSE); 690 return 0; 691 } 692 break; 693 694 case DM_DRAGOVER: 695 id = WinQueryWindowUShort(WinQueryWindow(hwnd,QW_PARENT),QWS_ID); 696 if(id == MAIN_USERLIST) { 697 if(!emphasized) { 698 emphasized = TRUE; 699 DrawTargetEmphasis(hwnd,emphasized); 700 } 701 if(AcceptOneDrop(mp1,mp2)) 702 return MRFROM2SHORT(DOR_DROP, 703 DO_MOVE); 704 return MRFROM2SHORT(DOR_NEVERDROP,0); 705 } 706 break; 707 708 case DM_DRAGLEAVE: 709 id = WinQueryWindowUShort(WinQueryWindow(hwnd,QW_PARENT),QWS_ID); 710 if(id == MAIN_USERLIST) { 711 if(emphasized) { 712 emphasized = FALSE; 713 DrawTargetEmphasis(hwnd,emphasized); 714 } 715 } 716 break; 717 718 case DM_DROPHELP: 719 id = WinQueryWindowUShort(WinQueryWindow(hwnd,QW_PARENT),QWS_ID); 720 if(id == MAIN_USERLIST) { 721 DropHelp(mp1,mp2,hwnd,GetPString(IDS_USERLISTDROPHELP)); 722 return 0; 723 } 724 break; 725 726 case DM_DROP: 727 id = WinQueryWindowUShort(WinQueryWindow(hwnd,QW_PARENT),QWS_ID); 728 if(id == MAIN_USERLIST) { 729 730 char szFrom[CCHMAXPATH + 2]; 731 732 if(emphasized) { 733 emphasized = FALSE; 734 DrawTargetEmphasis(hwnd,emphasized); 735 } 736 if(GetOneDrop(mp1, 737 mp2, 738 szFrom, 739 sizeof(szFrom))) { 740 MakeValidDir(szFrom); 741 WinSetWindowText(hwnd, 742 szFrom); 743 PostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd, 744 QW_PARENT), 745 QW_PARENT), 746 FID_CLIENT), 747 UM_COMMAND, 748 MPFROM2SHORT(IDM_ADDTOUSERLIST,0), 749 MPVOID); 750 return 0; 751 } 752 } 753 break; 754 755 case WM_DESTROY: 756 if(hwndMenu) 757 WinDestroyWindow(hwndMenu); 758 hwndMenu = (HWND)0; 759 break; 1107 MRESULT EXPENTRY LEDProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 1108 { 1109 1110 switch (msg) 1111 { 1112 case WM_CREATE: 1113 { 1114 MRESULT mr = PFNWPStatic(hwnd, msg, mp1, mp2); 1115 HBITMAP hbmold = (HBITMAP) 0; 1116 HPS hps = (HPS) 0; 1117 1118 switch (WinQueryWindowUShort(hwnd, QWS_ID)) 1119 { 1120 case MAIN_LED: 1121 hps = WinGetPS(hwnd); 1122 hbmold = (HBITMAP) WinSendMsg(hwnd, 1123 SM_QUERYHANDLE, 1124 MPVOID, 1125 MPVOID); 1126 if (!fBlueLED) 1127 { 1128 hbmLEDon = GpiLoadBitmap(hps, 1129 0, 1130 LEDON_BMP, 1131 12, 1132 12); 1133 hbmLEDoff = GpiLoadBitmap(hps, 1134 0, 1135 LEDOFF_BMP, 1136 12, 1137 12); 760 1138 } 761 762 return oldproc(hwnd,msg,mp1,mp2); 1139 else 1140 { 1141 hbmLEDon = GpiLoadBitmap(hps, 1142 0, 1143 LEDON2_BMP, 1144 12, 1145 12); 1146 hbmLEDoff = GpiLoadBitmap(hps, 1147 0, 1148 LEDOFF2_BMP, 1149 12, 1150 12); 1151 } 1152 if (hbmLEDoff && 1153 hbmLEDon) 1154 WinSendMsg(hwnd, 1155 SM_SETHANDLE, 1156 MPFROMLONG(hbmLEDoff), 1157 MPVOID); 1158 else 1159 { 1160 if (hbmLEDoff) 1161 GpiDeleteBitmap(hbmLEDoff); 1162 if (hbmLEDon) 1163 GpiDeleteBitmap(hbmLEDon); 1164 } 1165 if (hbmold && 1166 hbmLEDon && 1167 hbmLEDoff && 1168 hbmold != hbmLEDon && 1169 hbmold != hbmLEDoff) 1170 GpiDeleteBitmap(hbmold); 1171 if (hps) 1172 WinReleasePS(hps); 1173 break; 1174 default: 1175 SetPresParams(hwnd, 1176 &RGBGREY, 1177 &RGBBLACK, 1178 &RGBGREY, 1179 GetPString(IDS_6HELVTEXT)); 1180 break; 1181 } 1182 return mr; 1183 } 1184 1185 case WM_SETFOCUS: 1186 if (mp2) 1187 PostMsg(hwnd, 1188 UM_FOCUSME, 1189 mp1, 1190 MPVOID); 1191 break; 1192 1193 case UM_FOCUSME: 1194 WinSetFocus(HWND_DESKTOP, 1195 (HWND) mp1); 1196 return 0; 1197 1198 case WM_MOUSEMOVE: 1199 BubbleHelp(hwnd, 1200 TRUE, 1201 FALSE, 1202 FALSE, 1203 GetPString(IDS_LEDHELP)); 1204 if (!fNoFinger) 1205 { 1206 WinSetPointer(HWND_DESKTOP, hptrFinger); 1207 return MRFROMLONG(TRUE); 1208 } 1209 break; 1210 1211 case WM_BUTTON1CLICK: 1212 PostMsg(WinQueryWindow(hwnd, QW_PARENT), 1213 WM_COMMAND, 1214 MPFROM2SHORT(IDM_SHOWNOTEWND, 0), 1215 MPVOID); 1216 break; 1217 1218 case WM_BUTTON2CLICK: 1219 PostMsg(WinQueryWindow(hwnd, QW_PARENT), 1220 WM_COMMAND, 1221 MPFROM2SHORT(IDM_HIDENOTEWND, 0), 1222 MPVOID); 1223 break; 1224 1225 case WM_CHORD: 1226 case WM_BUTTON3CLICK: 1227 PostMsg(WinQueryWindow(hwnd, QW_PARENT), 1228 WM_COMMAND, 1229 MPFROM2SHORT(IDM_WINDOWDLG, 0), 1230 MPVOID); 1231 break; 1232 } 1233 return PFNWPStatic(hwnd, msg, mp1, mp2); 763 1234 } 764 1235 765 766 void BubbleHelp (HWND hwnd,BOOL other,BOOL drive,BOOL above,char *help) { 767 768 if(help && *help && 769 ((drive && fDrivebarHelp) || 770 (other && fOtherHelp) || 771 (!other && !drive && fToolbarHelp))) { 772 if((!hwndBubble || 773 WinQueryWindowULong(hwndBubble,QWL_USER) != hwnd) && 774 !WinQueryCapture(HWND_DESKTOP)) 775 MakeBubble(hwnd, 776 above, 777 help); 1236 MRESULT EXPENTRY ChildButtonProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 1237 { 1238 1239 USHORT id; 1240 register TOOL *tool; 1241 static HWND hwndMenu = (HWND) 0; 1242 1243 switch (msg) 1244 { 1245 case WM_BUTTON1DOWN: 1246 case WM_BUTTON2DOWN: 1247 case WM_BUTTON3DOWN: 1248 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); 1249 break; 1250 1251 case WM_MOUSEMOVE: 1252 if (fToolbarHelp) 1253 { 1254 if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) && 1255 !WinQueryCapture(HWND_DESKTOP)) 1256 { 1257 id = WinQueryWindowUShort(hwnd, QWS_ID); 1258 tool = find_tool(id); 1259 if (tool && tool -> help && *tool -> help) 1260 { 1261 1262 char s[128]; 1263 1264 strcpy(s, tool -> help); 1265 if (tool -> flags & T_DROPABLE) 1266 strcat(s, GetPString(IDS_DROPONMETEXT)); 1267 MakeBubble(hwnd, FALSE, s); 778 1268 } 1269 } 1270 } 1271 break; 1272 1273 case WM_COMMAND: 1274 switch (SHORT1FROMMP(mp1)) 1275 { 1276 case IDM_HELP: 1277 if (hwndHelp) 1278 WinSendMsg(hwndHelp, 1279 HM_DISPLAY_HELP, 1280 MPFROM2SHORT(HELP_TOOLBAR, 0), 1281 MPFROMSHORT(HM_RESOURCEID)); 1282 break; 1283 1284 case IDM_HIDEANYTOOL: /* hide any tool */ 1285 case IDM_HIDETOOL: /* hide tool */ 1286 if (SHORT1FROMMP(mp1) == IDM_HIDETOOL) 1287 id = WinQueryWindowUShort(hwnd, QWS_ID); 1288 else 1289 id = (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, 1290 PickToolProc, FM3ModHandle, 1291 PICKBTN_FRAME, 1292 GetPString(IDS_HIDETEXT)); 1293 if (id) 1294 { 1295 tool = find_tool(id); 1296 if (tool) 1297 { 1298 tool -> flags |= T_INVISIBLE; 1299 fToolsChanged = TRUE; 1300 } 1301 } 1302 break; 1303 1304 case IDM_SHOWTOOLS: /* show all tools */ 1305 tool = toolhead; 1306 while (tool) 1307 { 1308 tool -> flags &= (~T_INVISIBLE); 1309 tool = tool -> next; 1310 fToolsChanged = TRUE; 1311 } 1312 break; 1313 1314 case IDM_DELETEANYTOOL: /* delete any button */ 1315 case IDM_DELETETOOL: /* delete button */ 1316 if (SHORT1FROMMP(mp1) == IDM_DELETETOOL) 1317 id = WinQueryWindowUShort(hwnd, QWS_ID); 1318 else 1319 id = (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, PickToolProc, FM3ModHandle, 1320 PICKBTN_FRAME, 1321 GetPString(IDS_DELETETEXT)); 1322 if (id) 1323 PostMsg(WinQueryWindow(hwnd, QW_PARENT), UM_SETUP, 1324 MPFROM2SHORT(id, 0), MPVOID); 1325 return 0; 1326 1327 case IDM_EDITANYTOOL: /* edit any button */ 1328 case IDM_EDITTOOL: /* edit button */ 1329 if (SHORT1FROMMP(mp1) == IDM_EDITTOOL) 1330 id = WinQueryWindowUShort(hwnd, QWS_ID); 1331 else 1332 id = (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, PickToolProc, FM3ModHandle, 1333 PICKBTN_FRAME, 1334 GetPString(IDS_EDITTEXT)); 1335 if (id) 1336 { 1337 tool = find_tool(id); 1338 if (tool) 1339 { 1340 if (WinDlgBox(HWND_DESKTOP, hwnd, AddToolProc, FM3ModHandle, 1341 ADDBTN_FRAME, (PVOID) tool)) 1342 WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd, 1343 QW_PARENT), QW_PARENT), FID_CLIENT), 1344 WM_COMMAND, MPFROM2SHORT(IDM_CREATETOOL, 0), 1345 MPFROM2SHORT(id, 0)); 1346 } 1347 } 1348 break; 1349 1350 case IDM_ADDTOOL: /* add tool */ 1351 id = (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, AddToolProc, FM3ModHandle, 1352 ADDBTN_FRAME, MPVOID); 1353 if (id && id != (USHORT) - 1) 1354 WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd, 1355 QW_PARENT), QW_PARENT), FID_CLIENT), 1356 WM_COMMAND, MPFROM2SHORT(IDM_CREATETOOL, 0), 1357 MPFROM2SHORT(id, 0)); 1358 break; 1359 1360 case IDM_REORDERTOOLS: /* reorder tools */ 1361 WinDlgBox(HWND_DESKTOP, 1362 hwnd, 1363 ReOrderToolsProc, 1364 FM3ModHandle, 1365 RE_FRAME, 1366 MPVOID); 1367 break; 1368 1369 case IDM_SAVETOOLS: 1370 case IDM_LOADTOOLS: 1371 if (WinDlgBox(HWND_DESKTOP, 1372 hwnd, 1373 ToolIODlgProc, 1374 FM3ModHandle, 1375 SVBTN_FRAME, 1376 (PVOID) (SHORT1FROMMP(mp1) == IDM_SAVETOOLS) ? 1377 "TRUE" : NULL)) 1378 BuildTools(hwndToolback, TRUE); 1379 break; 1380 } 1381 ResizeTools(WinQueryWindow(hwnd, QW_PARENT)); 1382 return 0; 1383 1384 case WM_MENUEND: 1385 if (hwndMenu == (HWND) mp2) 1386 { 1387 WinDestroyWindow(hwndMenu); 1388 hwndMenu = (HWND) 0; 1389 } 1390 break; 1391 1392 case WM_CONTEXTMENU: 1393 DosEnterCritSec(); 1394 if (!hwndMenu) 1395 hwndMenu = WinLoadMenu(hwnd, FM3ModHandle, ID_BUTTONMENU); 1396 DosExitCritSec(); 1397 SetPresParams(hwndMenu, 1398 NULL, 1399 NULL, 1400 NULL, 1401 GetPString(IDS_10SYSPROTEXT)); 1402 if (PopupMenu(hwnd, hwnd, hwndMenu)) 1403 WinShowWindow(hwndMenu, TRUE); 1404 return MRFROMSHORT(TRUE); 1405 1406 case DM_DRAGOVER: 1407 { 1408 PDRAGINFO pDInfo; /* Pointer to DRAGINFO */ 1409 1410 pDInfo = (PDRAGINFO) mp1; /* Get DRAGINFO pointer */ 1411 DrgAccessDraginfo(pDInfo); /* Access DRAGINFO */ 1412 id = WinQueryWindowUShort(hwnd, QWS_ID); 1413 tool = find_tool(id); 1414 if (!tool) 1415 { 1416 DrgFreeDraginfo(pDInfo); 1417 return (MRFROM2SHORT(DOR_NEVERDROP, 0)); /* Drop not valid */ 1418 } 1419 if (!(tool -> flags & T_DROPABLE)) 1420 { 1421 DrgFreeDraginfo(pDInfo); 1422 return (MRFROM2SHORT(DOR_NEVERDROP, 0)); /* Drop not valid */ 1423 } 1424 { 1425 PDRAGITEM pDItem; /* Pointer to DRAGITEM */ 1426 1427 pDItem = DrgQueryDragitemPtr(pDInfo, /* Access DRAGITEM */ 1428 0); /* Index to DRAGITEM */ 1429 if (DrgVerifyRMF(pDItem, /* Check valid rendering */ 1430 DRM_OS2FILE, /* mechanisms and data */ 1431 NULL)) 1432 { /* formats */ 1433 if (!(tool -> flags & T_EMPHASIZED)) 1434 { 1435 tool -> flags |= T_EMPHASIZED; 1436 DrawTargetEmphasis(hwnd, ((tool -> flags & T_EMPHASIZED) != 0)); 1437 DrgFreeDraginfo(pDInfo); 1438 } 1439 return (MRFROM2SHORT(DOR_DROP, /* Return okay to drop */ 1440 DO_MOVE)); /* Move operation valid */ 1441 } 1442 DrgFreeDraginfo(pDInfo); 1443 } 1444 } 1445 return (MRFROM2SHORT(DOR_NEVERDROP, 0)); /* Drop not valid */ 1446 1447 case DM_DROPHELP: 1448 id = WinQueryWindowUShort(hwnd, QWS_ID); 1449 tool = find_tool(id); 1450 PFNWPButton(hwnd, msg, mp1, mp2); 1451 DropHelp(mp1, mp2, hwnd, GetPString(IDS_TOOLDROPHELP)); 1452 return 0; 1453 1454 case DM_DRAGLEAVE: 1455 id = WinQueryWindowUShort(hwnd, QWS_ID); 1456 tool = find_tool(id); 1457 if (tool && (tool -> flags & T_DROPABLE)) 1458 { 1459 if (tool -> flags & T_EMPHASIZED) 1460 { 1461 tool -> flags &= (~T_EMPHASIZED); 1462 DrawTargetEmphasis(hwnd, ((tool -> flags & T_EMPHASIZED) != 0)); 1463 } 1464 } 1465 break; 1466 1467 case DM_DROP: 1468 id = WinQueryWindowUShort(hwnd, QWS_ID); 1469 tool = find_tool(id); 1470 if (tool && (tool -> flags & T_DROPABLE) != 0) 1471 { 1472 1473 LISTINFO *li; 1474 CNRDRAGINFO cdi; 1475 1476 if (tool -> flags & T_EMPHASIZED) 1477 { 1478 DrawTargetEmphasis(hwnd, ((tool -> flags & T_EMPHASIZED) != 0)); 1479 tool -> flags &= (~T_EMPHASIZED); 1480 } 1481 memset(&cdi, 0, sizeof(cdi)); 1482 cdi.pRecord = NULL; 1483 cdi.pDragInfo = mp1; 1484 li = DoFileDrop(hwnd, 1485 NULL, 1486 FALSE, 1487 mp1, 1488 MPFROMP(&cdi)); 1489 if (li) 1490 { 1491 li -> type = id; 1492 if (!li -> list || !li -> list[0]) 1493 FreeListInfo(li); 1494 else 1495 { 1496 1497 HWND hwndActive; 1498 1499 hwndActive = TopWindow(hwndMain, (HWND) 0); 1500 if (hwndActive) 1501 { 1502 if (!WinSendMsg(hwndActive, UM_COMMAND, MPFROMP(li), MPVOID)) 1503 FreeListInfo(li); 1504 } 1505 else 1506 FreeListInfo(li); 1507 } 1508 } 1509 } 1510 return 0; 1511 1512 case WM_CLOSE: 1513 WinDestroyWindow(hwnd); 1514 return 0; 1515 } 1516 return PFNWPButton(hwnd, msg, mp1, mp2); 779 1517 } 780 1518 781 782 VOID MakeBubble (HWND hwnd,BOOL above,CHAR *help) { 783 784 if(!hwnd || !help || !*help) 785 return; 786 787 if(hwndBubble) 788 WinDestroyWindow(hwndBubble); 789 790 { 791 HWND hwndActive; 792 char ucClassname[8]; 793 794 hwndActive = WinQueryActiveWindow(HWND_DESKTOP); 795 if(hwndActive) { 796 /* don't bring up help if window isn't active */ 797 if(!WinIsChild(hwnd,hwndActive)) 798 return; 799 } 800 hwndActive = WinQueryFocus(HWND_DESKTOP); 801 if(WinQueryClassName(hwndActive,sizeof(ucClassname),ucClassname)) { 802 /* don't bring up help if a menu is active */ 803 if(!strcmp(ucClassname,"#4")) 804 return; 805 } 806 } 807 808 hwndBubble = WinCreateWindow(HWND_DESKTOP, 809 GetPString(IDS_WCBUBBLE), 810 help, 811 WS_CLIPSIBLINGS | SS_TEXT | 812 DT_CENTER | DT_VCENTER, 813 0, 814 0, 815 0, 816 0, 817 HWND_DESKTOP, 818 HWND_TOP, 819 MAIN_HELP, 820 NULL, 821 NULL); 822 if(hwndBubble) { 823 824 HPS hps; 825 POINTL aptl[TXTBOX_COUNT],ptl,tptl; 826 LONG lxScreen,sx,sy,extra = 0,lyScreen; 827 char *p,*pp,*wp; 828 SWP swp; 829 830 WinQueryWindowPos(hwnd,&swp); 831 lyScreen = WinQuerySysValue(HWND_DESKTOP,SV_CYSCREEN); 832 lxScreen = WinQuerySysValue(HWND_DESKTOP,SV_CXSCREEN); 833 WinSetWindowULong(hwndBubble,QWL_USER,hwnd); 834 SetPresParams(hwndBubble, 835 NULL, 836 NULL, 837 NULL, 838 GetPString(IDS_8HELVTEXT)); 839 hps = WinGetPS(hwndBubble); 840 p = help; 841 tptl.x = tptl.y = 0; 842 while(p && *p) { 843 wp = NULL; 844 pp = strchr(p,'\r'); 845 if(pp) { 846 wp = pp; 847 *pp = 0; 848 pp++; 849 } 850 GpiQueryTextBox(hps,strlen(p),p,TXTBOX_COUNT,aptl); 851 tptl.x = max(aptl[TXTBOX_TOPRIGHT].x,tptl.x); 852 if(tptl.y) 853 tptl.y += extra; 854 else 855 extra = aptl[TXTBOX_TOPLEFT].y / 4; 856 tptl.y += aptl[TXTBOX_TOPLEFT].y; 857 if(wp) 858 *wp = '\r'; 859 p = pp; 860 } 861 WinSetWindowULong(hwndBubble,4,extra); 862 WinReleasePS(hps); 863 ptl.x = ptl.y = 0; 864 WinMapWindowPoints(hwnd,HWND_DESKTOP,&ptl,1); 865 if(above) { 866 sy = ptl.y + swp.cy + 4; 867 if(sy + tptl.y + 12 > lyScreen) { 868 above = FALSE; 869 sy = ptl.y - (tptl.y + 14); 870 } 871 } 872 else 873 sy = ptl.y - (tptl.y + 14); 874 if(ptl.x > (lxScreen / 2)) 875 sx = (ptl.x - tptl.x) - 16; 876 else 877 sx = ptl.x + (54 * (above == FALSE)) + 2; 878 if(sx < 0) 879 sx = 0; 880 if(sx + tptl.x + 14 > lxScreen) 881 sx = lxScreen - (tptl.x + 14); 882 if(sy < 0) { 883 sy = ptl.y + swp.cy + 4; 884 if(sy + tptl.y + 12 > lyScreen) 885 sy = 0; 886 } 887 WinSetWindowPos(hwndBubble,HWND_TOP,sx,sy, 888 tptl.x + 14, 889 tptl.y + 12, 890 SWP_DEACTIVATE | SWP_SHOW | SWP_ZORDER | 891 SWP_MOVE | SWP_SIZE); 892 } 893 } 894 895 896 MRESULT EXPENTRY BubbleProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) { 897 898 switch(msg) { 899 case WM_SETFOCUS: 900 if(mp2) 901 PostMsg(hwnd, 902 UM_FOCUSME, 903 mp1, 904 MPVOID); 905 break; 906 907 case UM_FOCUSME: 908 WinSetFocus(HWND_DESKTOP, 909 (HWND)mp1); 910 return 0; 911 912 case WM_MOUSEMOVE: 913 WinShowWindow(hwnd,FALSE); 914 break; 915 916 case UM_TIMER: 917 { 918 POINTL ptl; 919 920 WinQueryPointerPos(HWND_DESKTOP,&ptl); 921 if(WinWindowFromPoint(HWND_DESKTOP,&ptl,TRUE) != 922 WinQueryWindowULong(hwnd,QWL_USER) || 923 !WinIsWindowVisible(hwnd)) 924 WinDestroyWindow(hwnd); 925 } 926 return 0; 927 928 case WM_PAINT: 929 { 930 HPS hps; 931 SWP swp; 932 POINTL ptl,aptl[TXTBOX_COUNT]; 933 CHAR *s,*p,*pp,*wp; 934 ULONG extra,tlen,y; 935 936 hps = WinBeginPaint(hwnd,(HPS)0,NULL); 937 if(hps) { 938 WinQueryWindowPos(hwnd,&swp); 939 GpiCreateLogColorTable(hps,0,LCOLF_RGB,0,0,0); 940 GpiSetColor(hps,((255 << 16) | (255 << 8) | 198)); 941 GpiSetBackMix(hps,BM_LEAVEALONE); 942 GpiSetMix(hps,FM_OVERPAINT); 943 ptl.x = ptl.y = 0; 944 GpiMove(hps,&ptl); 945 ptl.x = swp.cx - 1; 946 ptl.y = swp.cy - 1; 947 GpiBox(hps,DRO_OUTLINEFILL,&ptl,0,0); 948 tlen = WinQueryWindowTextLength(hwnd); 949 if(tlen) { 950 s = malloc(tlen + 2); 951 if(s) { 952 WinQueryWindowText(hwnd,tlen + 1,s); 953 if(*s) { 954 p = s; 955 y = swp.cy - 3; 956 extra = WinQueryWindowULong(hwnd,4); 957 GpiSetColor(hps,0); 958 GpiSetMix(hps,FM_OVERPAINT); 959 while(p && *p) { 960 wp = NULL; 961 pp = strchr(p,'\r'); 962 if(pp) { 963 wp = pp; 964 *pp = 0; 965 pp++; 966 } 967 GpiQueryTextBox(hps,strlen(p),p,TXTBOX_COUNT,aptl); 968 ptl.x = 7; 969 y -= aptl[TXTBOX_TOPLEFT].y; 970 if(p != s) 971 y -= extra; 972 ptl.y = y; 973 GpiCharStringAt(hps,&ptl,strlen(p),p); 974 if(wp) 975 *wp = '\r'; 976 p = pp; 977 } 978 } 979 free(s); 980 } 981 } 982 if(!(swp.fl & (SWP_HIDE | SWP_MINIMIZE)) && 983 swp.cx > 6 && swp.cy > 6) { 984 GpiSetColor(hps,CLR_WHITE); 985 ptl.x = 1; 986 ptl.y = 1; 987 GpiMove(hps,&ptl); 988 ptl.y = swp.cy - 2; 989 GpiLine(hps,&ptl); 990 ptl.x = swp.cx - 2; 991 GpiLine(hps,&ptl); 992 ptl.x = 2; 993 ptl.y = 2; 994 GpiMove(hps,&ptl); 995 ptl.y = swp.cy - 3; 996 GpiLine(hps,&ptl); 997 ptl.x = swp.cx - 3; 998 GpiLine(hps,&ptl); 999 GpiSetColor(hps,CLR_BROWN); 1000 ptl.x = 1; 1001 ptl.y = 1; 1002 GpiMove(hps,&ptl); 1003 ptl.x = swp.cx - 2; 1004 GpiLine(hps,&ptl); 1005 ptl.y = swp.cy - 2; 1006 GpiLine(hps,&ptl); 1007 ptl.x = 2; 1008 ptl.y = 2; 1009 GpiMove(hps,&ptl); 1010 ptl.x = swp.cx - 3; 1011 GpiLine(hps,&ptl); 1012 ptl.y = swp.cy - 3; 1013 GpiLine(hps,&ptl); 1014 } 1015 WinEndPaint(hps); 1016 } 1017 } 1018 return 0; 1019 1020 case WM_CLOSE: 1021 WinDestroyWindow(hwnd); 1022 return 0; 1023 1024 case WM_DESTROY: 1025 hwndBubble = (HWND)0; 1026 break; 1027 } 1028 return PFNWPStatic(hwnd,msg,mp1,mp2); 1029 } 1030 1031 1032 MRESULT EXPENTRY LEDProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) { 1033 1034 switch(msg) { 1035 case WM_CREATE: 1036 { 1037 MRESULT mr = PFNWPStatic(hwnd,msg,mp1,mp2); 1038 HBITMAP hbmold = (HBITMAP)0; 1039 HPS hps = (HPS)0; 1040 1041 switch(WinQueryWindowUShort(hwnd,QWS_ID)) { 1042 case MAIN_LED: 1043 hps = WinGetPS(hwnd); 1044 hbmold = (HBITMAP)WinSendMsg(hwnd, 1045 SM_QUERYHANDLE, 1046 MPVOID, 1047 MPVOID); 1048 if(!fBlueLED) { 1049 hbmLEDon = GpiLoadBitmap(hps, 1050 0, 1051 LEDON_BMP, 1052 12, 1053 12); 1054 hbmLEDoff = GpiLoadBitmap(hps, 1055 0, 1056 LEDOFF_BMP, 1057 12, 1058 12); 1059 } 1060 else { 1061 hbmLEDon = GpiLoadBitmap(hps, 1062 0, 1063 LEDON2_BMP, 1064 12, 1065 12); 1066 hbmLEDoff = GpiLoadBitmap(hps, 1067 0, 1068 LEDOFF2_BMP, 1069 12, 1070 12); 1071 } 1072 if(hbmLEDoff && 1073 hbmLEDon) 1074 WinSendMsg(hwnd, 1075 SM_SETHANDLE, 1076 MPFROMLONG(hbmLEDoff), 1077 MPVOID); 1078 else { 1079 if(hbmLEDoff) 1080 GpiDeleteBitmap(hbmLEDoff); 1081 if(hbmLEDon) 1082 GpiDeleteBitmap(hbmLEDon); 1083 } 1084 if(hbmold && 1085 hbmLEDon && 1086 hbmLEDoff && 1087 hbmold != hbmLEDon && 1088 hbmold != hbmLEDoff) 1089 GpiDeleteBitmap(hbmold); 1090 if(hps) 1091 WinReleasePS(hps); 1092 break; 1093 default: 1094 SetPresParams(hwnd, 1095 &RGBGREY, 1096 &RGBBLACK, 1097 &RGBGREY, 1098 GetPString(IDS_6HELVTEXT)); 1099 break; 1100 } 1101 return mr; 1102 } 1103 1104 case WM_SETFOCUS: 1105 if(mp2) 1106 PostMsg(hwnd, 1107 UM_FOCUSME, 1108 mp1, 1109 MPVOID); 1110 break; 1111 1112 case UM_FOCUSME: 1113 WinSetFocus(HWND_DESKTOP, 1114 (HWND)mp1); 1115 return 0; 1116 1117 case WM_MOUSEMOVE: 1118 BubbleHelp(hwnd, 1119 TRUE, 1120 FALSE, 1121 FALSE, 1122 GetPString(IDS_LEDHELP)); 1123 if(!fNoFinger) { 1124 WinSetPointer(HWND_DESKTOP,hptrFinger); 1125 return MRFROMLONG(TRUE); 1126 } 1127 break; 1128 1129 case WM_BUTTON1CLICK: 1130 PostMsg(WinQueryWindow(hwnd,QW_PARENT), 1131 WM_COMMAND, 1132 MPFROM2SHORT(IDM_SHOWNOTEWND,0), 1133 MPVOID); 1134 break; 1135 1136 case WM_BUTTON2CLICK: 1137 PostMsg(WinQueryWindow(hwnd,QW_PARENT), 1138 WM_COMMAND, 1139 MPFROM2SHORT(IDM_HIDENOTEWND,0), 1140 MPVOID); 1141 break; 1142 1143 case WM_CHORD: 1144 case WM_BUTTON3CLICK: 1145 PostMsg(WinQueryWindow(hwnd,QW_PARENT), 1146 WM_COMMAND, 1147 MPFROM2SHORT(IDM_WINDOWDLG,0), 1148 MPVOID); 1149 break; 1150 } 1151 return PFNWPStatic(hwnd,msg,mp1,mp2); 1152 } 1153 1154 1155 MRESULT EXPENTRY ChildButtonProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) { 1156 1157 USHORT id; 1158 register TOOL *tool; 1159 static HWND hwndMenu = (HWND)0; 1160 1161 switch(msg) { 1162 case WM_BUTTON1DOWN: 1163 case WM_BUTTON2DOWN: 1164 case WM_BUTTON3DOWN: 1165 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); 1166 break; 1167 1168 case WM_MOUSEMOVE: 1169 if(fToolbarHelp) { 1170 if((!hwndBubble || WinQueryWindowULong(hwndBubble,QWL_USER) != hwnd) && 1171 !WinQueryCapture(HWND_DESKTOP)) { 1172 id = WinQueryWindowUShort(hwnd,QWS_ID); 1173 tool = find_tool(id); 1174 if(tool && tool->help && *tool->help) { 1175 1176 char s[128]; 1177 1178 strcpy(s,tool->help); 1179 if(tool->flags & T_DROPABLE) 1180 strcat(s,GetPString(IDS_DROPONMETEXT)); 1181 MakeBubble(hwnd,FALSE,s); 1182 } 1183 } 1184 } 1185 break; 1186 1187 case WM_COMMAND: 1188 switch(SHORT1FROMMP(mp1)) { 1189 case IDM_HELP: 1190 if(hwndHelp) 1191 WinSendMsg(hwndHelp, 1192 HM_DISPLAY_HELP, 1193 MPFROM2SHORT(HELP_TOOLBAR,0), 1194 MPFROMSHORT(HM_RESOURCEID)); 1195 break; 1196 1197 case IDM_HIDEANYTOOL: /* hide any tool */ 1198 case IDM_HIDETOOL: /* hide tool */ 1199 if(SHORT1FROMMP(mp1) == IDM_HIDETOOL) 1200 id = WinQueryWindowUShort(hwnd,QWS_ID); 1201 else 1202 id = (USHORT)WinDlgBox(HWND_DESKTOP,hwnd, 1203 PickToolProc,FM3ModHandle, 1204 PICKBTN_FRAME, 1205 GetPString(IDS_HIDETEXT)); 1206 if(id) { 1207 tool = find_tool(id); 1208 if(tool) { 1209 tool->flags |= T_INVISIBLE; 1210 fToolsChanged = TRUE; 1211 } 1212 } 1213 break; 1214 1215 case IDM_SHOWTOOLS: /* show all tools */ 1216 tool = toolhead; 1217 while(tool) { 1218 tool->flags &= (~T_INVISIBLE); 1219 tool = tool->next; 1220 fToolsChanged = TRUE; 1221 } 1222 break; 1223 1224 case IDM_DELETEANYTOOL: /* delete any button */ 1225 case IDM_DELETETOOL: /* delete button */ 1226 if(SHORT1FROMMP(mp1) == IDM_DELETETOOL) 1227 id = WinQueryWindowUShort(hwnd,QWS_ID); 1228 else 1229 id = (USHORT)WinDlgBox(HWND_DESKTOP,hwnd,PickToolProc,FM3ModHandle, 1230 PICKBTN_FRAME, 1231 GetPString(IDS_DELETETEXT)); 1232 if(id) 1233 PostMsg(WinQueryWindow(hwnd,QW_PARENT),UM_SETUP, 1234 MPFROM2SHORT(id,0),MPVOID); 1235 return 0; 1236 1237 case IDM_EDITANYTOOL: /* edit any button */ 1238 case IDM_EDITTOOL: /* edit button */ 1239 if(SHORT1FROMMP(mp1) == IDM_EDITTOOL) 1240 id = WinQueryWindowUShort(hwnd,QWS_ID); 1241 else 1242 id = (USHORT)WinDlgBox(HWND_DESKTOP,hwnd,PickToolProc,FM3ModHandle, 1243 PICKBTN_FRAME, 1244 GetPString(IDS_EDITTEXT)); 1245 if(id) { 1246 tool = find_tool(id); 1247 if(tool) { 1248 if(WinDlgBox(HWND_DESKTOP,hwnd,AddToolProc,FM3ModHandle, 1249 ADDBTN_FRAME,(PVOID)tool)) 1250 WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd, 1251 QW_PARENT),QW_PARENT),FID_CLIENT), 1252 WM_COMMAND,MPFROM2SHORT(IDM_CREATETOOL,0), 1253 MPFROM2SHORT(id,0)); 1254 } 1255 } 1256 break; 1257 1258 case IDM_ADDTOOL: /* add tool */ 1259 id = (USHORT)WinDlgBox(HWND_DESKTOP,hwnd,AddToolProc,FM3ModHandle, 1260 ADDBTN_FRAME,MPVOID); 1261 if(id && id != (USHORT)-1) 1262 WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd, 1263 QW_PARENT),QW_PARENT),FID_CLIENT), 1264 WM_COMMAND,MPFROM2SHORT(IDM_CREATETOOL,0), 1265 MPFROM2SHORT(id,0)); 1266 break; 1267 1268 case IDM_REORDERTOOLS: /* reorder tools */ 1269 WinDlgBox(HWND_DESKTOP, 1270 hwnd, 1271 ReOrderToolsProc, 1272 FM3ModHandle, 1273 RE_FRAME, 1274 MPVOID); 1275 break; 1276 1277 case IDM_SAVETOOLS: 1278 case IDM_LOADTOOLS: 1279 if(WinDlgBox(HWND_DESKTOP, 1280 hwnd, 1281 ToolIODlgProc, 1282 FM3ModHandle, 1283 SVBTN_FRAME, 1284 (PVOID)(SHORT1FROMMP(mp1) == IDM_SAVETOOLS) ? 1285 "TRUE" : NULL)) 1286 BuildTools(hwndToolback,TRUE); 1287 break; 1288 } 1289 ResizeTools(WinQueryWindow(hwnd,QW_PARENT)); 1290 return 0; 1291 1292 case WM_MENUEND: 1293 if(hwndMenu == (HWND)mp2) { 1294 WinDestroyWindow(hwndMenu); 1295 hwndMenu = (HWND)0; 1296 } 1297 break; 1298 1299 case WM_CONTEXTMENU: 1300 DosEnterCritSec(); 1301 if(!hwndMenu) 1302 hwndMenu = WinLoadMenu(hwnd,FM3ModHandle,ID_BUTTONMENU); 1303 DosExitCritSec(); 1304 SetPresParams(hwndMenu, 1305 NULL, 1306 NULL, 1307 NULL, 1308 GetPString(IDS_10SYSPROTEXT)); 1309 if(PopupMenu(hwnd,hwnd,hwndMenu)) 1310 WinShowWindow(hwndMenu,TRUE); 1311 return MRFROMSHORT(TRUE); 1312 1313 case DM_DRAGOVER: 1314 { 1315 PDRAGINFO pDInfo; /* Pointer to DRAGINFO */ 1316 1317 pDInfo = (PDRAGINFO)mp1; /* Get DRAGINFO pointer */ 1318 DrgAccessDraginfo(pDInfo); /* Access DRAGINFO */ 1319 id = WinQueryWindowUShort(hwnd,QWS_ID); 1320 tool = find_tool(id); 1321 if(!tool) { 1322 DrgFreeDraginfo(pDInfo); 1323 return(MRFROM2SHORT(DOR_NEVERDROP,0)); /* Drop not valid */ 1324 } 1325 if(!(tool->flags & T_DROPABLE)) { 1326 DrgFreeDraginfo(pDInfo); 1327 return(MRFROM2SHORT(DOR_NEVERDROP,0)); /* Drop not valid */ 1328 } 1329 { 1330 PDRAGITEM pDItem; /* Pointer to DRAGITEM */ 1331 1332 pDItem = DrgQueryDragitemPtr(pDInfo, /* Access DRAGITEM */ 1333 0); /* Index to DRAGITEM */ 1334 if(DrgVerifyRMF(pDItem, /* Check valid rendering */ 1335 DRM_OS2FILE, /* mechanisms and data */ 1336 NULL)) { /* formats */ 1337 if(!(tool->flags & T_EMPHASIZED)) { 1338 tool->flags |= T_EMPHASIZED; 1339 DrawTargetEmphasis(hwnd,((tool->flags & T_EMPHASIZED) != 0)); 1340 DrgFreeDraginfo(pDInfo); 1341 } 1342 return(MRFROM2SHORT(DOR_DROP, /* Return okay to drop */ 1343 DO_MOVE)); /* Move operation valid */ 1344 } 1345 DrgFreeDraginfo(pDInfo); 1346 } 1347 } 1348 return(MRFROM2SHORT(DOR_NEVERDROP,0)); /* Drop not valid */ 1349 1350 case DM_DROPHELP: 1351 id = WinQueryWindowUShort(hwnd,QWS_ID); 1352 tool = find_tool(id); 1353 PFNWPButton(hwnd,msg,mp1,mp2); 1354 DropHelp(mp1,mp2,hwnd,GetPString(IDS_TOOLDROPHELP)); 1355 return 0; 1356 1357 case DM_DRAGLEAVE: 1358 id = WinQueryWindowUShort(hwnd,QWS_ID); 1359 tool = find_tool(id); 1360 if(tool && (tool->flags & T_DROPABLE)) { 1361 if(tool->flags & T_EMPHASIZED) { 1362 tool->flags &= (~T_EMPHASIZED); 1363 DrawTargetEmphasis(hwnd,((tool->flags & T_EMPHASIZED) != 0)); 1364 } 1365 } 1366 break; 1367 1368 case DM_DROP: 1369 id = WinQueryWindowUShort(hwnd,QWS_ID); 1370 tool = find_tool(id); 1371 if(tool && (tool->flags & T_DROPABLE) != 0) { 1372 1373 LISTINFO *li; 1374 CNRDRAGINFO cdi; 1375 1376 if(tool->flags & T_EMPHASIZED) { 1377 DrawTargetEmphasis(hwnd,((tool->flags & T_EMPHASIZED) != 0)); 1378 tool->flags &= (~T_EMPHASIZED); 1379 } 1380 memset(&cdi,0,sizeof(cdi)); 1381 cdi.pRecord = NULL; 1382 cdi.pDragInfo = mp1; 1383 li = DoFileDrop(hwnd, 1384 NULL, 1385 FALSE, 1386 mp1, 1387 MPFROMP(&cdi)); 1388 if(li) { 1389 li->type = id; 1390 if(!li->list || !li->list[0]) 1391 FreeListInfo(li); 1392 else { 1393 1394 HWND hwndActive; 1395 1396 hwndActive = TopWindow(hwndMain,(HWND)0); 1397 if(hwndActive) { 1398 if(!WinSendMsg(hwndActive,UM_COMMAND,MPFROMP(li),MPVOID)) 1399 FreeListInfo(li); 1400 } 1401 else 1402 FreeListInfo(li); 1403 } 1404 } 1405 } 1406 return 0; 1407 1408 case WM_CLOSE: 1409 WinDestroyWindow(hwnd); 1410 return 0; 1411 } 1412 return PFNWPButton(hwnd,msg,mp1,mp2); 1413 } 1414 1415 1416 VOID BuildTools (HWND hwndT,BOOL resize) { 1417 1418 register TOOL *tool; 1419 register ULONG ctrlxpos = 18L; 1420 CHAR s[33]; 1421 HENUM henum; 1422 HWND hwndTool; 1423 1424 henum = WinBeginEnumWindows(hwndT); 1425 while((hwndTool = WinGetNextWindow(henum)) != NULLHANDLE) 1426 WinDestroyWindow(hwndTool); 1427 WinEndEnumWindows(henum); 1428 if(!fToolbar) { 1429 load_quicktools(); 1430 load_tools(NULL); 1431 return; 1432 } 1433 if(!toolhead) 1434 load_tools(NULL); 1435 tool = toolhead; 1436 while(tool) { 1437 sprintf(s,"#%u",tool->id); 1438 hwndTool = (HWND)0; 1439 if(!fTextTools) { 1440 if(!(tool->flags & T_MYICON)) 1441 hwndTool = WinCreateWindow(hwndT, 1442 GetPString(IDS_WCTOOLBUTTONS), 1443 s, 1519 VOID BuildTools(HWND hwndT, BOOL resize) 1520 { 1521 1522 register TOOL *tool; 1523 register ULONG ctrlxpos = 18L; 1524 CHAR s[33]; 1525 HENUM henum; 1526 HWND hwndTool; 1527 1528 henum = WinBeginEnumWindows(hwndT); 1529 while ((hwndTool = WinGetNextWindow(henum)) != NULLHANDLE) 1530 WinDestroyWindow(hwndTool); 1531 WinEndEnumWindows(henum); 1532 if (!fToolbar) 1533 { 1534 load_quicktools(); 1535 load_tools(NULL); 1536 return; 1537 } 1538 if (!toolhead) 1539 load_tools(NULL); 1540 tool = toolhead; 1541 while (tool) 1542 { 1543 sprintf(s, "#%u", tool -> id); 1544 hwndTool = (HWND) 0; 1545 if (!fTextTools) 1546 { 1547 if (!(tool -> flags & T_MYICON)) 1548 hwndTool = WinCreateWindow(hwndT, 1549 GetPString(IDS_WCTOOLBUTTONS), 1550 s, 1444 1551 BS_NOPOINTERFOCUS | 1445 1552 BS_BITMAP | BS_PUSHBUTTON, 1446 ctrlxpos, 1447 14, 1448 32, 1449 32, 1450 hwndT, 1451 HWND_TOP, 1452 tool->id, 1453 NULL, 1454 NULL); 1455 if(!hwndTool) { 1456 1457 HBITMAP hbm; 1458 1459 hbm = LoadBitmapFromFileNum(tool->id); 1460 if(hbm) { 1461 1462 BTNCDATA btc; 1463 1464 memset(&btc,0,sizeof(btc)); 1465 btc.cb = sizeof(btc); 1466 btc.hImage = hbm; 1467 hwndTool = WinCreateWindow(hwndT, 1468 GetPString(IDS_WCTOOLBUTTONS), 1469 NullStr, 1553 ctrlxpos, 1554 14, 1555 32, 1556 32, 1557 hwndT, 1558 HWND_TOP, 1559 tool -> id, 1560 NULL, 1561 NULL); 1562 if (!hwndTool) 1563 { 1564 1565 HBITMAP hbm; 1566 1567 hbm = LoadBitmapFromFileNum(tool -> id); 1568 if (hbm) 1569 { 1570 1571 BTNCDATA btc; 1572 1573 memset(&btc, 0, sizeof(btc)); 1574 btc.cb = sizeof(btc); 1575 btc.hImage = hbm; 1576 hwndTool = WinCreateWindow(hwndT, 1577 GetPString(IDS_WCTOOLBUTTONS), 1578 NullStr, 1470 1579 BS_NOPOINTERFOCUS | 1471 1580 BS_BITMAP | BS_PUSHBUTTON, 1472 ctrlxpos, 1473 14, 1474 32, 1475 32, 1476 hwndT, 1477 HWND_TOP, 1478 tool->id, 1479 &btc, 1480 NULL); 1481 if(!hwndTool) 1482 GpiDeleteBitmap(hbm); 1483 } 1484 } 1485 if(hwndTool) 1486 tool->flags &= (~T_TEXT); 1487 } 1488 if(!hwndTool) { 1581 ctrlxpos, 1582 14, 1583 32, 1584 32, 1585 hwndT, 1586 HWND_TOP, 1587 tool -> id, 1588 &btc, 1589 NULL); 1590 if (!hwndTool) 1591 GpiDeleteBitmap(hbm); 1592 } 1593 } 1594 if (hwndTool) 1595 tool -> flags &= (~T_TEXT); 1596 } 1597 if (!hwndTool) 1598 { 1489 1599 WinCreateWindow(hwndT, 1490 GetPString(IDS_WCTOOLBUTTONS), 1491 (!tool->text && tool->id >= IDM_COMMANDSTART && 1492 tool->id < IDM_QUICKTOOLSTART) ? 1493 command_title(tool->id - IDM_COMMANDSTART) : 1494 tool->text, 1495 BS_NOPOINTERFOCUS | BS_PUSHBUTTON, 1496 ctrlxpos, 1497 2, 1498 54, 1499 24, 1500 hwndT, 1501 HWND_TOP, 1502 tool->id, 1503 NULL, 1504 NULL); 1505 tool->flags |= T_TEXT; 1506 } 1507 if(fToolTitles && !fTextTools) { 1600 GetPString(IDS_WCTOOLBUTTONS), 1601 (!tool -> text && tool -> id >= IDM_COMMANDSTART && 1602 tool -> id < IDM_QUICKTOOLSTART) ? 1603 command_title(tool -> id - IDM_COMMANDSTART) : 1604 tool -> text, 1605 BS_NOPOINTERFOCUS | BS_PUSHBUTTON, 1606 ctrlxpos, 1607 2, 1608 54, 1609 24, 1610 hwndT, 1611 HWND_TOP, 1612 tool -> id, 1613 NULL, 1614 NULL); 1615 tool -> flags |= T_TEXT; 1616 } 1617 if (fToolTitles && !fTextTools) 1618 { 1508 1619 WinCreateWindow(hwndT, 1509 WC_STATIC, 1510 tool->text, 1511 SS_TEXT | DT_LEFT | DT_VCENTER, 1512 ctrlxpos, 1513 1, 1514 32, 1515 10, 1516 hwndT, 1517 HWND_TOP, 1518 tool->id + 25000, 1519 NULL, 1520 NULL); 1521 SetPresParams(WinWindowFromID(hwndT,tool->id + 25000), 1522 &RGBGREY, 1523 &RGBBLACK, 1524 &RGBGREY, 1525 GetPString(IDS_2SYSTEMVIOTEXT)); 1526 } 1527 ctrlxpos += ((tool->flags & T_TEXT) ? 55L : 33L); 1528 SetPresParams(WinWindowFromID(hwndT,tool->id), 1529 NULL, 1530 NULL, 1531 NULL, 1532 GetPString(IDS_8HELVTEXT)); 1533 tool = tool->next; 1620 WC_STATIC, 1621 tool -> text, 1622 SS_TEXT | DT_LEFT | DT_VCENTER, 1623 ctrlxpos, 1624 1, 1625 32, 1626 10, 1627 hwndT, 1628 HWND_TOP, 1629 tool -> id + 25000, 1630 NULL, 1631 NULL); 1632 SetPresParams(WinWindowFromID(hwndT, tool -> id + 25000), 1633 &RGBGREY, 1634 &RGBBLACK, 1635 &RGBGREY, 1636 GetPString(IDS_2SYSTEMVIOTEXT)); 1637 } 1638 ctrlxpos += ((tool -> flags & T_TEXT) ? 55L : 33L); 1639 SetPresParams(WinWindowFromID(hwndT, tool -> id), 1640 NULL, 1641 NULL, 1642 NULL, 1643 GetPString(IDS_8HELVTEXT)); 1644 tool = tool -> next; 1645 } 1646 WinCreateWindow(hwndT, 1647 WC_BUTTON, 1648 "#6010", 1649 BS_NOPOINTERFOCUS | 1650 BS_BITMAP | BS_PUSHBUTTON, 1651 1, 1652 19, 1653 14, 1654 13, 1655 hwndT, 1656 HWND_TOP, 1657 IDM_TOOLLEFT, 1658 NULL, 1659 NULL); 1660 WinCreateWindow(hwndT, 1661 WC_BUTTON, 1662 "#6011", 1663 BS_NOPOINTERFOCUS | 1664 BS_BITMAP | BS_PUSHBUTTON, 1665 1, 1666 4, 1667 14, 1668 13, 1669 hwndT, 1670 HWND_TOP, 1671 IDM_TOOLRIGHT, 1672 NULL, 1673 NULL); 1674 if (resize) 1675 ResizeTools(hwndT); 1676 } 1677 1678 MRESULT EXPENTRY CommandLineProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 1679 { 1680 1681 PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER); 1682 static BOOL lbup = FALSE; 1683 1684 switch (msg) 1685 { 1686 case UM_FOCUSME: 1687 WinSetFocus(HWND_DESKTOP, 1688 hwnd); 1689 return 0; 1690 1691 case WM_SETFOCUS: 1692 if (!mp2 && !lbup) 1693 { 1694 1695 PID pid; 1696 TID tid; 1697 1698 if (WinQueryWindowUShort((HWND) mp1, QWS_ID) == COMMAND_BUTTON) 1699 break; 1700 if (!WinQueryWindowProcess((HWND) mp1, &pid, &tid) || 1701 pid == mypid) 1702 WinDestroyWindow(hwnd); 1703 } 1704 break; 1705 1706 case UM_RESCAN: 1707 { 1708 CHAR cl[1024]; 1709 1710 *cl = 0; 1711 lbup = TRUE; 1712 if (WinDlgBox(HWND_DESKTOP, 1713 hwnd, 1714 CmdLine2DlgProc, 1715 FM3ModHandle, 1716 EXEC2_FRAME, 1717 MPFROMP(cl))) 1718 { 1719 lstrip(cl); 1720 WinSetWindowText(hwnd, cl); 1721 } 1722 PostMsg(hwnd, 1723 UM_FOCUSME, 1724 MPVOID, 1725 MPVOID); 1726 PostMsg(hwnd, 1727 UM_SETUP, 1728 MPVOID, 1729 MPVOID); 1730 } 1731 return 0; 1732 1733 case UM_SETUP: 1734 lbup = FALSE; 1735 return 0; 1736 1737 case WM_BUTTON1DBLCLK: 1738 PostMsg(hwnd, 1739 UM_OPENWINDOWFORME, 1740 MPVOID, 1741 MPVOID); 1742 return 0; 1743 1744 case WM_COMMAND: 1745 switch (SHORT1FROMMP(mp1)) 1746 { 1747 case COMMAND_BUTTON: 1748 if (!lbup) 1749 PostMsg(hwnd, 1750 UM_RESCAN, 1751 MPVOID, 1752 MPVOID); 1753 break; 1754 } 1755 return 0; 1756 1757 case UM_OPENWINDOWFORME: 1758 { 1759 static char directory[CCHMAXPATH], cl[1000]; 1760 char **list = NULL; 1761 ULONG len; 1762 HWND hwndCnr; 1763 1764 *directory = *cl = 0; 1765 strcpy(cl, GetCmdSpec(FALSE)); 1766 strcat(cl, " /C "); 1767 len = strlen(cl); 1768 WinQueryWindowText(hwnd, 1000 - len, cl + len); 1769 bstrip(cl + len); 1770 if (strlen(cl) > len) 1771 { 1772 WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), 1773 UM_SETUP, 1774 MPFROMP(cl + len), 1775 MPVOID); 1776 WinQueryWindowText(hwndStatus, 1777 CCHMAXPATH, 1778 directory); 1779 bstrip(directory); 1780 if (*directory && (IsRoot(directory) || !IsFile(directory))) 1781 { 1782 if (!FM2Command(directory, cl + len)) 1783 { 1784 hwndCnr = TopWindow(hwndMain, (HWND) 0); 1785 if (hwndCnr) 1786 { 1787 hwndCnr = WinWindowFromID(hwndCnr, FID_CLIENT); 1788 if (hwndCnr) 1789 { 1790 hwndCnr = WinWindowFromID(hwndCnr, DIR_CNR); 1791 if (hwndCnr) 1792 list = BuildList(hwndCnr); 1793 } 1794 } 1795 WinSetActiveWindow(HWND_DESKTOP, hwndCnr); 1796 if (add_cmdline(cl + len, FALSE) && fSaveMiniCmds) 1797 save_cmdlines(FALSE); 1798 ExecOnList(hwndCnr, 1799 cl, 1800 WINDOWED | ((fKeepCmdLine) ? 1801 SEPARATEKEEP : SEPARATE), 1802 directory, 1803 list, 1804 NULL); 1805 if (list) 1806 free(list); 1807 WinDestroyWindow(hwnd); 1808 break; 1809 } 1534 1810 } 1535 WinCreateWindow(hwndT, 1536 WC_BUTTON, 1537 "#6010", 1538 BS_NOPOINTERFOCUS | 1539 BS_BITMAP | BS_PUSHBUTTON, 1540 1, 1541 19, 1542 14, 1543 13, 1544 hwndT, 1545 HWND_TOP, 1546 IDM_TOOLLEFT, 1547 NULL, 1548 NULL); 1549 WinCreateWindow(hwndT, 1550 WC_BUTTON, 1551 "#6011", 1552 BS_NOPOINTERFOCUS | 1553 BS_BITMAP | BS_PUSHBUTTON, 1554 1, 1555 4, 1556 14, 1557 13, 1558 hwndT, 1559 HWND_TOP, 1560 IDM_TOOLRIGHT, 1561 NULL, 1562 NULL); 1563 if(resize) 1564 ResizeTools(hwndT); 1811 } 1812 WinSendMsg(hwnd, EM_SETSEL, MPFROM2SHORT(0, 1024), MPVOID); 1813 } 1814 return 0; 1815 1816 case WM_CHAR: 1817 if (!lbup && !(SHORT1FROMMP(mp1) & KC_KEYUP)) 1818 { 1819 if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) 1820 { 1821 if ((SHORT1FROMMP(mp2) & 255) == '\r') 1822 PostMsg(hwnd, UM_OPENWINDOWFORME, MPVOID, MPVOID); 1823 else if ((SHORT1FROMMP(mp2) & 0xff) == 0x1b) 1824 WinDestroyWindow(hwnd); 1825 else if (SHORT2FROMMP(mp2) == VK_UP || 1826 SHORT2FROMMP(mp2) == VK_DOWN) 1827 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID); 1828 } 1829 } 1830 else if ((SHORT1FROMMP(mp1) & KC_VIRTUALKEY) && 1831 ((SHORT2FROMMP(mp2) == VK_UP || 1832 SHORT2FROMMP(mp2) == VK_DOWN) || 1833 (SHORT1FROMMP(mp2) == '\x1b') || 1834 (SHORT1FROMMP(mp2) == '\r'))) 1835 return 0; 1836 break; 1837 1838 case WM_DESTROY: 1839 PostMsg(WinQueryWindow(hwnd, QW_PARENT), 1840 UM_RESCAN, 1841 MPVOID, 1842 MPVOID); 1843 lbup = FALSE; 1844 break; 1845 } 1846 return oldproc(hwnd, msg, mp1, mp2); 1565 1847 } 1566 1848 1567 1568 MRESULT EXPENTRY CommandLineProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) { 1569 1570 PFNWP oldproc = (PFNWP)WinQueryWindowPtr(hwnd,QWL_USER); 1571 static BOOL lbup = FALSE; 1572 1573 switch(msg) { 1574 case UM_FOCUSME: 1575 WinSetFocus(HWND_DESKTOP, 1576 hwnd); 1577 return 0; 1578 1579 case WM_SETFOCUS: 1580 if(!mp2 && !lbup) { 1581 1582 PID pid; 1583 TID tid; 1584 1585 if(WinQueryWindowUShort((HWND)mp1,QWS_ID) == COMMAND_BUTTON) 1586 break; 1587 if(!WinQueryWindowProcess((HWND)mp1,&pid,&tid) || 1588 pid == mypid) 1589 WinDestroyWindow(hwnd); 1590 } 1591 break; 1592 1593 case UM_RESCAN: 1594 { 1595 CHAR cl[1024]; 1596 1597 *cl = 0; 1598 lbup = TRUE; 1599 if(WinDlgBox(HWND_DESKTOP, 1600 hwnd, 1601 CmdLine2DlgProc, 1602 FM3ModHandle, 1603 EXEC2_FRAME, 1604 MPFROMP(cl))) { 1605 lstrip(cl); 1606 WinSetWindowText(hwnd,cl); 1607 } 1608 PostMsg(hwnd, 1609 UM_FOCUSME, 1610 MPVOID, 1611 MPVOID); 1612 PostMsg(hwnd, 1613 UM_SETUP, 1614 MPVOID, 1615 MPVOID); 1616 } 1617 return 0; 1618 1619 case UM_SETUP: 1620 lbup = FALSE; 1621 return 0; 1622 1623 case WM_BUTTON1DBLCLK: 1624 PostMsg(hwnd, 1625 UM_OPENWINDOWFORME, 1626 MPVOID, 1627 MPVOID); 1628 return 0; 1629 1630 case WM_COMMAND: 1631 switch(SHORT1FROMMP(mp1)) { 1632 case COMMAND_BUTTON: 1633 if(!lbup) 1634 PostMsg(hwnd, 1635 UM_RESCAN, 1636 MPVOID, 1637 MPVOID); 1638 break; 1639 } 1640 return 0; 1641 1642 case UM_OPENWINDOWFORME: 1643 { 1644 static char directory[CCHMAXPATH],cl[1000]; 1645 char **list = NULL; 1646 ULONG len; 1647 HWND hwndCnr; 1648 1649 *directory = *cl = 0; 1650 strcpy(cl,GetCmdSpec(FALSE)); 1651 strcat(cl," /C "); 1652 len = strlen(cl); 1653 WinQueryWindowText(hwnd,1000 - len,cl + len); 1654 bstrip(cl + len); 1655 if(strlen(cl) > len) { 1656 WinSendMsg(WinQueryWindow(hwnd,QW_PARENT), 1657 UM_SETUP, 1658 MPFROMP(cl + len), 1659 MPVOID); 1660 WinQueryWindowText(hwndStatus, 1661 CCHMAXPATH, 1662 directory); 1663 bstrip(directory); 1664 if(*directory && (IsRoot(directory) || !IsFile(directory))) { 1665 if(!FM2Command(directory,cl + len)) { 1666 hwndCnr = TopWindow(hwndMain,(HWND)0); 1667 if(hwndCnr) { 1668 hwndCnr = WinWindowFromID(hwndCnr,FID_CLIENT); 1669 if(hwndCnr) { 1670 hwndCnr = WinWindowFromID(hwndCnr,DIR_CNR); 1671 if(hwndCnr) 1672 list = BuildList(hwndCnr); 1673 } 1674 } 1675 WinSetActiveWindow(HWND_DESKTOP,hwndCnr); 1676 if(add_cmdline(cl + len,FALSE) && fSaveMiniCmds) 1677 save_cmdlines(FALSE); 1678 ExecOnList(hwndCnr, 1679 cl, 1680 WINDOWED | ((fKeepCmdLine) ? 1681 SEPARATEKEEP : SEPARATE), 1682 directory, 1683 list, 1684 NULL); 1685 if(list) 1686 free(list); 1687 WinDestroyWindow(hwnd); 1688 break; 1689 } 1690 } 1691 } 1692 WinSendMsg(hwnd,EM_SETSEL,MPFROM2SHORT(0,1024),MPVOID); 1693 } 1694 return 0; 1695 1696 case WM_CHAR: 1697 if(!lbup && !(SHORT1FROMMP(mp1) & KC_KEYUP)) { 1698 if(SHORT1FROMMP(mp1) & KC_VIRTUALKEY) { 1699 if((SHORT1FROMMP(mp2) & 255) == '\r') 1700 PostMsg(hwnd,UM_OPENWINDOWFORME,MPVOID,MPVOID); 1701 else if((SHORT1FROMMP(mp2) & 0xff) == 0x1b) 1702 WinDestroyWindow(hwnd); 1703 else if(SHORT2FROMMP(mp2) == VK_UP || 1704 SHORT2FROMMP(mp2) == VK_DOWN) 1705 PostMsg(hwnd,UM_RESCAN,MPVOID,MPVOID); 1706 } 1707 } 1708 else if((SHORT1FROMMP(mp1) & KC_VIRTUALKEY) && 1709 ((SHORT2FROMMP(mp2) == VK_UP || 1710 SHORT2FROMMP(mp2) == VK_DOWN) || 1711 (SHORT1FROMMP(mp2) == '\x1b') || 1712 (SHORT1FROMMP(mp2) == '\r'))) 1713 return 0; 1714 break; 1715 1716 case WM_DESTROY: 1717 PostMsg(WinQueryWindow(hwnd,QW_PARENT), 1718 UM_RESCAN, 1719 MPVOID, 1720 MPVOID); 1721 lbup = FALSE; 1722 break; 1849 MRESULT EXPENTRY DriveBackProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 1850 { 1851 1852 switch (msg) 1853 { 1854 case WM_CREATE: 1855 PostMsg(hwnd, 1856 UM_SETUP, 1857 MPVOID, 1858 MPVOID); 1859 break; 1860 1861 case UM_SETUP: 1862 { 1863 RGB2 rgb; 1864 1865 memset(&rgb, 0, sizeof(rgb)); 1866 rgb.bRed = 128; 1867 SetPresParams(hwnd, 1868 &RGBGREY, 1869 &rgb, 1870 &RGBGREY, 1871 GetPString(IDS_8HELVTEXT)); 1872 SetTargetDir(hwnd, TRUE); 1873 } 1874 return 0; 1875 1876 case WM_SETFOCUS: 1877 case UM_FOCUSME: 1878 case WM_BUTTON1DOWN: 1879 case WM_BUTTON1UP: 1880 case WM_BUTTON2DOWN: 1881 case WM_BUTTON2UP: 1882 case WM_BUTTON3DOWN: 1883 case WM_BUTTON3UP: 1884 return CommonTextButton(hwnd, msg, mp1, mp2); 1885 1886 case WM_MOUSEMOVE: 1887 shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL)); 1888 break; 1889 1890 case UM_CLICKED: 1891 case UM_CLICKED3: 1892 PostMsg(hwndMain, 1893 WM_COMMAND, 1894 MPFROM2SHORT(IDM_SETTARGET, 0), 1895 MPVOID); 1896 return 0; 1897 1898 case WM_CHAR: 1899 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL)); 1900 break; 1901 1902 case WM_CONTROLPOINTER: 1903 if (!fNoFinger && 1904 (SHORT1FROMMP(mp1) >= IDM_DRIVEA && 1905 SHORT1FROMMP(mp1) < IDM_DRIVEA + 26)) 1906 return MRFROMLONG(hptrFinger); 1907 break; 1908 1909 case WM_COMMAND: 1910 { 1911 CHAR dv[4]; 1912 1913 *dv = 0; 1914 WinQueryWindowText(WinWindowFromID(hwnd, SHORT1FROMMP(mp1) + 50), 1915 2, 1916 dv); 1917 if (isalpha(*dv)) 1918 { 1919 1920 HWND hwndActive; 1921 1922 dv[1] = ':'; 1923 dv[2] = '\\'; 1924 dv[3] = 0; 1925 hwndActive = TopWindow(hwnd, (HWND) 0); 1926 if (hwndActive) 1927 WinSendMsg(WinWindowFromID(hwndActive, FID_CLIENT), 1928 UM_DRIVECMD, 1929 MPFROMP(dv), 1930 MPVOID); 1931 } 1932 } 1933 return 0; 1934 1935 case WM_PAINT: 1936 PaintRecessedWindow(hwnd, 1937 (HPS) 0, 1938 TRUE, 1939 FALSE); 1940 break; 1941 1942 case WM_CLOSE: 1943 WinDestroyWindow(hwnd); 1944 return 0; 1945 } 1946 return PFNWPStatic(hwnd, msg, mp1, mp2); 1947 } 1948 1949 MRESULT EXPENTRY DriveProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 1950 { 1951 1952 USHORT id; 1953 static CHAR dv[4]; 1954 static BOOL emphasized = FALSE; 1955 static HWND hwndMenu = (HWND) 0; 1956 static USHORT helpid = 0; 1957 1958 switch (msg) 1959 { 1960 case WM_MOUSEMOVE: 1961 if (fDrivebarHelp && 1962 (!hwndBubble || 1963 WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) && 1964 !WinQueryCapture(HWND_DESKTOP)) 1965 { 1966 id = WinQueryWindowUShort(hwnd, QWS_ID); 1967 if (helpid != id) 1968 { 1969 helpid = id; 1970 PostMsg(MainObjectHwnd, 1971 UM_SETUP6, 1972 MPFROMLONG((ULONG) hwnd), 1973 MPVOID); 1974 } 1975 else 1976 helpid = 0; 1977 } 1978 break; 1979 1980 case UM_SETUP6: 1981 if (helpid == WinQueryWindowUShort(hwnd, QWS_ID)) 1982 { 1983 if ((char *) mp1 && 1984 (!hwndBubble || 1985 WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) && 1986 !WinQueryCapture(HWND_DESKTOP)) 1987 { 1988 1989 RECTL rcl; 1990 POINTL ptl; 1991 1992 WinQueryPointerPos(HWND_DESKTOP, 1993 &ptl); 1994 WinMapWindowPoints(HWND_DESKTOP, 1995 hwnd, 1996 &ptl, 1997 1); 1998 WinQueryWindowRect(hwnd, &rcl); 1999 if (WinPtInRect(WinQueryAnchorBlock(hwnd), 2000 &rcl, 2001 &ptl)) 2002 BubbleHelp(hwnd, 2003 FALSE, 2004 TRUE, 2005 FALSE, 2006 (char *) mp1); 2007 } 2008 } 2009 return 0; 2010 2011 case WM_MENUEND: 2012 if (hwndMenu == (HWND) mp2) 2013 { 2014 WinDestroyWindow(hwndMenu); 2015 hwndMenu = (HWND) 0; 2016 } 2017 break; 2018 2019 case WM_CONTEXTMENU: 2020 if (hwndMenu) 2021 WinDestroyWindow(hwndMenu); 2022 hwndMenu = (HWND) 0; 2023 id = WinQueryWindowUShort(hwnd, QWS_ID); 2024 *dv = 0; 2025 WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), 2026 id + 50), 2027 sizeof(dv), 2028 dv); 2029 if (isalpha(*dv)) 2030 { 2031 hwndMenu = WinLoadMenu(HWND_DESKTOP, 2032 FM3ModHandle, 2033 MAIN_DRIVES); 2034 if (hwndMenu) 2035 { 2036 if (!(driveflags[toupper(*dv) - 'A'] & DRIVE_REMOTE)) 2037 WinEnableMenuItem(hwndMenu, 2038 IDM_DETACH, 2039 FALSE); 2040 if (driveflags[toupper(*dv) - 'A'] & DRIVE_NOTWRITEABLE) 2041 { 2042 WinEnableMenuItem(hwndMenu, 2043 IDM_MKDIR, 2044 FALSE); 2045 WinEnableMenuItem(hwndMenu, 2046 IDM_FORMAT, 2047 FALSE); 2048 WinEnableMenuItem(hwndMenu, 2049 IDM_OPTIMIZE, 2050 FALSE); 2051 WinEnableMenuItem(hwndMenu, 2052 IDM_UNDELETE, 2053 FALSE); 1723 2054 } 1724 return oldproc(hwnd,msg,mp1,mp2); 2055 if (!(driveflags[toupper(*dv) - 'A'] & DRIVE_REMOVABLE)) 2056 { 2057 WinEnableMenuItem(hwndMenu, 2058 IDM_EJECT, 2059 FALSE); 2060 WinEnableMenuItem(hwndMenu, 2061 IDM_LOCK, 2062 FALSE); 2063 WinEnableMenuItem(hwndMenu, 2064 IDM_UNLOCK, 2065 FALSE); 2066 } 2067 /* 2068 if(!(driveflags[toupper(*dv) - 'A'] & DRIVE_CDROM)) { 2069 WinEnableMenuItem(hwndMenu, 2070 IDM_CLOSETRAY, 2071 FALSE); 2072 } 2073 */ 2074 PopupMenu(hwnd, 2075 hwnd, 2076 hwndMenu); 2077 } 2078 } 2079 return MRFROMSHORT(TRUE); 2080 2081 case WM_BUTTON2CLICK: 2082 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); 2083 if (!(shiftstate & KC_CTRL)) 2084 break; 2085 2086 case WM_CHORD: 2087 case WM_BUTTON3CLICK: 2088 id = WinQueryWindowUShort(hwnd, QWS_ID); 2089 *dv = 0; 2090 WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), 2091 id + 50), 2092 sizeof(dv), 2093 dv); 2094 if (isalpha(*dv)) 2095 { 2096 strcat(dv, "\\"); 2097 if (!FindDirCnrByName(dv, TRUE)) 2098 OpenDirCnr((HWND) 0, 2099 hwndMain, 2100 hwndTree, 2101 FALSE, 2102 dv); 2103 } 2104 break; 2105 2106 case WM_COMMAND: 2107 PostMsg(hwnd, UM_COMMAND, mp1, mp2); 2108 return 0; 2109 2110 case UM_COMMAND: 2111 id = WinQueryWindowUShort(hwnd, QWS_ID); 2112 *dv = 0; 2113 WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), 2114 id + 50), 2115 sizeof(dv), 2116 dv); 2117 if (isalpha(*dv)) 2118 { 2119 strcat(dv, "\\"); 2120 CommonDriveCmd(hwnd, dv, SHORT1FROMMP(mp1)); 2121 } 2122 return 0; 2123 2124 case DM_DRAGOVER: 2125 id = WinQueryWindowUShort(hwnd, QWS_ID); 2126 *dv = 0; 2127 WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), 2128 id + 50), 2129 sizeof(dv), 2130 dv); 2131 if (isalpha(*dv) && 2132 !(driveflags[toupper(*dv) - 'A'] & DRIVE_NOTWRITEABLE)) 2133 { 2134 if (!emphasized) 2135 { 2136 emphasized = TRUE; 2137 DrawTargetEmphasis(hwnd, emphasized); 2138 } 2139 if (AcceptOneDrop(mp1, mp2)) 2140 return MRFROM2SHORT(DOR_DROP, 2141 DO_MOVE); 2142 return MRFROM2SHORT(DOR_NEVERDROP, 0); 2143 } 2144 break; 2145 2146 case DM_DRAGLEAVE: 2147 id = WinQueryWindowUShort(hwnd, QWS_ID); 2148 *dv = 0; 2149 WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), 2150 id + 50), 2151 sizeof(dv), 2152 dv); 2153 if (isalpha(*dv) && 2154 !(driveflags[toupper(*dv) - 'A'] & DRIVE_NOTWRITEABLE)) 2155 { 2156 if (emphasized) 2157 { 2158 emphasized = FALSE; 2159 DrawTargetEmphasis(hwnd, emphasized); 2160 } 2161 } 2162 break; 2163 2164 case DM_DROPHELP: 2165 id = WinQueryWindowUShort(hwnd, QWS_ID); 2166 *dv = 0; 2167 WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), 2168 id + 50), sizeof(dv), dv); 2169 if (isalpha(*dv) && 2170 !(driveflags[toupper(*dv) - 'A'] & DRIVE_NOTWRITEABLE)) 2171 { 2172 DropHelp(mp1, mp2, hwnd, GetPString(IDS_DRIVEDROPHELP)); 2173 return 0; 2174 } 2175 break; 2176 2177 case DM_DROP: 2178 id = WinQueryWindowUShort(hwnd, QWS_ID); 2179 *dv = 0; 2180 WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), 2181 id + 50), 2182 sizeof(dv), 2183 dv); 2184 if (isalpha(*dv) && 2185 !(driveflags[toupper(*dv) - 'A'] & DRIVE_NOTWRITEABLE)) 2186 { 2187 2188 CNRDRAGINFO cnd; 2189 LISTINFO *li; 2190 ULONG action = UM_ACTION; 2191 2192 if (emphasized) 2193 { 2194 emphasized = FALSE; 2195 DrawTargetEmphasis(hwnd, emphasized); 2196 } 2197 memset(&cnd, 0, sizeof(cnd)); 2198 cnd.pDragInfo = (PDRAGINFO) mp1; 2199 cnd.pRecord = NULL; 2200 li = DoFileDrop(hwnd, 2201 NULL, 2202 TRUE, 2203 MPFROM2SHORT(TREE_CNR, CN_DROP), 2204 MPFROMP(&cnd)); 2205 if (li) 2206 { 2207 strcpy(li -> targetpath, dv); 2208 strcat(li -> targetpath, "\\"); 2209 if (li -> list && 2210 li -> list[0] && 2211 IsRoot(li -> list[0])) 2212 li -> type = DO_LINK; 2213 else if (fDragndropDlg && 2214 (!*li -> arcname || !li -> info)) 2215 { 2216 2217 CHECKLIST cl; 2218 2219 memset(&cl, 0, sizeof(cl)); 2220 cl.size = sizeof(cl); 2221 cl.flags = li -> type; 2222 cl.list = li -> list; 2223 cl.cmd = li -> type; 2224 cl.prompt = li -> targetpath; 2225 li -> type = WinDlgBox(HWND_DESKTOP, 2226 hwndMain, 2227 DropListProc, 2228 FM3ModHandle, 2229 DND_FRAME, 2230 MPFROMP(&cl)); 2231 if (!li -> type) 2232 { 2233 FreeListInfo(li); 2234 return 0; 2235 } 2236 li -> list = cl.list; 2237 if (!li -> list || !li -> list[0]) 2238 { 2239 FreeListInfo(li); 2240 return 0; 2241 } 2242 } 2243 else 2244 { 2245 if (!WinDlgBox(HWND_DESKTOP, 2246 hwndMain, 2247 WalkDlgProc, 2248 FM3ModHandle, 2249 WALK_FRAME, 2250 MPFROMP(li -> targetpath)) || 2251 !*li -> targetpath) 2252 { 2253 FreeListInfo(li); 2254 return 0; 2255 } 2256 } 2257 switch (li -> type) 2258 { 2259 case DND_LAUNCH: 2260 strcat(li -> targetpath, " %a"); 2261 ExecOnList(hwndMain, 2262 li -> targetpath, 2263 PROMPT | WINDOWED, 2264 NULL, 2265 li -> list, 2266 NULL); 2267 FreeList(li -> list); 2268 li -> list = NULL; 2269 break; 2270 case DO_LINK: 2271 if (fLinkSetsIcon) 2272 { 2273 li -> type = IDM_SETICON; 2274 action = UM_MASSACTION; 2275 } 2276 else 2277 li -> type = IDM_COMPARE; 2278 break; 2279 case DND_EXTRACT: 2280 if (*li -> targetpath && 2281 !IsFile(li -> targetpath)) 2282 li -> type = IDM_EXTRACT; 2283 break; 2284 case DND_MOVE: 2285 li -> type = IDM_MOVE; 2286 if (*li -> targetpath && 2287 IsFile(li -> targetpath) == 1) 2288 { 2289 action = UM_MASSACTION; 2290 li -> type = IDM_ARCHIVEM; 2291 } 2292 break; 2293 case DND_WILDMOVE: 2294 li -> type = IDM_WILDMOVE; 2295 if (*li -> targetpath && 2296 IsFile(li -> targetpath) == 1) 2297 { 2298 action = UM_MASSACTION; 2299 li -> type = IDM_ARCHIVEM; 2300 } 2301 break; 2302 case DND_OBJECT: 2303 li -> type = IDM_OBJECT; 2304 action = UM_MASSACTION; 2305 break; 2306 case DND_SHADOW: 2307 li -> type = IDM_SHADOW; 2308 action = UM_MASSACTION; 2309 break; 2310 case DND_COMPARE: 2311 li -> type = IDM_COMPARE; 2312 break; 2313 case DND_SETICON: 2314 action = UM_MASSACTION; 2315 li -> type = IDM_SETICON; 2316 break; 2317 case DND_COPY: 2318 li -> type = IDM_COPY; 2319 if (*li -> targetpath && 2320 IsFile(li -> targetpath) == 1) 2321 { 2322 action = UM_MASSACTION; 2323 li -> type = IDM_ARCHIVE; 2324 } 2325 break; 2326 case DND_WILDCOPY: 2327 li -> type = IDM_WILDCOPY; 2328 if (*li -> targetpath && 2329 IsFile(li -> targetpath) == 1) 2330 { 2331 action = UM_MASSACTION; 2332 li -> type = IDM_ARCHIVE; 2333 } 2334 break; 2335 default: 2336 if (*li -> arcname && li -> info) 2337 { 2338 action = UM_MASSACTION; 2339 li -> type = (li -> type == DO_MOVE) ? IDM_FAKEEXTRACTM : 2340 IDM_FAKEEXTRACT; 2341 } 2342 else if (*li -> targetpath && IsFile(li -> targetpath) == 1) 2343 { 2344 action = UM_MASSACTION; 2345 li -> type = (li -> type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE; 2346 } 2347 else 2348 li -> type = (li -> type == DO_MOVE) ? IDM_MOVE : IDM_COPY; 2349 break; 2350 } 2351 if (!li -> list || !li -> list[0]) 2352 FreeListInfo(li); 2353 else 2354 WinSendMsg(hwndTree, 2355 UM_ACTION, 2356 MPFROMP(li), 2357 MPFROMLONG(action)); 2358 } 2359 return 0; 2360 } 2361 break; 2362 2363 case WM_DESTROY: 2364 if (hwndMenu) 2365 WinDestroyWindow(hwndMenu); 2366 hwndMenu = (HWND) 0; 2367 break; 2368 } 2369 return PFNWPButton(hwnd, msg, mp1, mp2); 1725 2370 } 1726 2371 1727 1728 MRESULT EXPENTRY DriveBackProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) { 1729 1730 switch(msg) { 1731 case WM_CREATE: 1732 PostMsg(hwnd, 1733 UM_SETUP, 1734 MPVOID, 1735 MPVOID); 1736 break; 1737 1738 case UM_SETUP: 1739 { 1740 RGB2 rgb; 1741 1742 memset(&rgb,0,sizeof(rgb)); 1743 rgb.bRed = 128; 1744 SetPresParams(hwnd, 1745 &RGBGREY, 1746 &rgb, 1747 &RGBGREY, 1748 GetPString(IDS_8HELVTEXT)); 1749 SetTargetDir(hwnd,TRUE); 1750 } 1751 return 0; 1752 1753 case WM_SETFOCUS: 1754 case UM_FOCUSME: 1755 case WM_BUTTON1DOWN: 1756 case WM_BUTTON1UP: 1757 case WM_BUTTON2DOWN: 1758 case WM_BUTTON2UP: 1759 case WM_BUTTON3DOWN: 1760 case WM_BUTTON3UP: 1761 return CommonTextButton(hwnd,msg,mp1,mp2); 1762 1763 case WM_MOUSEMOVE: 1764 shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL)); 1765 break; 1766 1767 case UM_CLICKED: 1768 case UM_CLICKED3: 1769 PostMsg(hwndMain, 1770 WM_COMMAND, 1771 MPFROM2SHORT(IDM_SETTARGET,0), 1772 MPVOID); 1773 return 0; 1774 1775 case WM_CHAR: 1776 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL)); 1777 break; 1778 1779 case WM_CONTROLPOINTER: 1780 if(!fNoFinger && 1781 (SHORT1FROMMP(mp1) >= IDM_DRIVEA && 1782 SHORT1FROMMP(mp1) < IDM_DRIVEA + 26)) 1783 return MRFROMLONG(hptrFinger); 1784 break; 1785 1786 case WM_COMMAND: 1787 { 1788 CHAR dv[4]; 1789 1790 *dv = 0; 1791 WinQueryWindowText(WinWindowFromID(hwnd,SHORT1FROMMP(mp1) + 50), 1792 2, 1793 dv); 1794 if(isalpha(*dv)) { 1795 1796 HWND hwndActive; 1797 1798 dv[1] = ':'; 1799 dv[2] = '\\'; 1800 dv[3] = 0; 1801 hwndActive = TopWindow(hwnd,(HWND)0); 1802 if(hwndActive) 1803 WinSendMsg(WinWindowFromID(hwndActive,FID_CLIENT), 1804 UM_DRIVECMD, 1805 MPFROMP(dv), 1806 MPVOID); 1807 } 1808 } 1809 return 0; 1810 1811 case WM_PAINT: 1812 PaintRecessedWindow(hwnd, 1813 (HPS)0, 1814 TRUE, 1815 FALSE); 1816 break; 1817 1818 case WM_CLOSE: 1819 WinDestroyWindow(hwnd); 1820 return 0; 2372 VOID BuildDrives(HWND hwndT) 2373 { 2374 2375 register ULONG x, y = 0; 2376 ULONG ulDriveNum, ulDriveMap, iconid; 2377 CHAR s[8]; 2378 HENUM henum; 2379 HWND hwndB; 2380 2381 henum = WinBeginEnumWindows(hwndT); 2382 2383 while ((hwndB = WinGetNextWindow(henum)) != NULLHANDLE) 2384 WinDestroyWindow(hwndB); 2385 2386 WinEndEnumWindows(henum); 2387 if (fDrivebar) 2388 { 2389 DosError(FERR_DISABLEHARDERR); 2390 DosQCurDisk(&ulDriveNum, &ulDriveMap); 2391 for (x = 0; x < 26; x++) 2392 { 2393 if ((ulDriveMap & (1L << x)) && 2394 !(driveflags[x] & DRIVE_IGNORE)) 2395 { 2396 if (x > 1) 2397 { 2398 if (driveflags[x] & DRIVE_CDROM) 2399 iconid = CDROM_ICON; 2400 else 2401 iconid = (driveflags[x] & DRIVE_REMOVABLE) ? 2402 REMOVABLE_ICON : 2403 (driveflags[x] & DRIVE_REMOTE) ? 2404 REMOTE_ICON : 2405 (driveflags[x] & DRIVE_ZIPSTREAM) ? 2406 DRIVE_ICON : 2407 DRIVE_ICON; 1821 2408 } 1822 return PFNWPStatic(hwnd,msg,mp1,mp2); 2409 else 2410 iconid = FLOPPY_ICON; 2411 sprintf(s, "#%lu", iconid); 2412 hwndB = WinCreateWindow(hwndT, 2413 GetPString(IDS_WCDRIVEBUTTONS), 2414 s, 2415 BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON, 2416 0, 2417 0, 2418 28, 2419 18, 2420 hwndT, 2421 HWND_TOP, 2422 y + IDM_DRIVEA, 2423 NULL, 2424 NULL); 2425 if (hwndB) 2426 { 2427 WinSetWindowPos(hwndB, 2428 HWND_BOTTOM, 2429 0, 2430 0, 2431 0, 2432 0, 2433 SWP_ZORDER); 2434 sprintf(s, "%c:", (CHAR) x + 'A'); 2435 hwndB = WinCreateWindow(hwndT, 2436 WC_STATIC, 2437 s, 2438 SS_TEXT | DT_LEFT | DT_VCENTER, 2439 0, 2440 0, 2441 10, 2442 18, 2443 hwndT, 2444 HWND_TOP, 2445 y + IDM_DRIVEATEXT, 2446 NULL, 2447 NULL); 2448 if (hwndB) 2449 { 2450 SetPresParams(hwndB, 2451 &RGBGREY, 2452 &RGBBLACK, 2453 &RGBGREY, 2454 GetPString(IDS_6HELVTEXT)); 2455 WinSetWindowPos(hwndB, 2456 HWND_BOTTOM, 2457 0, 2458 0, 2459 0, 2460 0, 2461 SWP_ZORDER); 2462 } 2463 y++; 2464 } 2465 } 2466 } 2467 } 2468 PostMsg(WinQueryWindow(hwndT, QW_PARENT), 2469 WM_UPDATEFRAME, 2470 MPFROMLONG(FCF_SIZEBORDER), 2471 MPVOID); 1823 2472 } 1824 2473 1825 1826 MRESULT EXPENTRY DriveProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) { 1827 1828 USHORT id; 1829 static CHAR dv[4]; 1830 static BOOL emphasized = FALSE; 1831 static HWND hwndMenu = (HWND)0; 1832 static USHORT helpid = 0; 1833 1834 switch(msg) { 1835 case WM_MOUSEMOVE: 1836 if(fDrivebarHelp && 1837 (!hwndBubble || 1838 WinQueryWindowULong(hwndBubble,QWL_USER) != hwnd) && 1839 !WinQueryCapture(HWND_DESKTOP)) { 1840 id = WinQueryWindowUShort(hwnd,QWS_ID); 1841 if(helpid != id) { 1842 helpid = id; 1843 PostMsg(MainObjectHwnd, 1844 UM_SETUP6, 1845 MPFROMLONG((ULONG)hwnd), 1846 MPVOID); 1847 } 1848 else 1849 helpid = 0; 1850 } 1851 break; 1852 1853 case UM_SETUP6: 1854 if(helpid == WinQueryWindowUShort(hwnd,QWS_ID)) { 1855 if((char *)mp1 && 1856 (!hwndBubble || 1857 WinQueryWindowULong(hwndBubble,QWL_USER) != hwnd) && 1858 !WinQueryCapture(HWND_DESKTOP)) { 1859 1860 RECTL rcl; 1861 POINTL ptl; 1862 1863 WinQueryPointerPos(HWND_DESKTOP, 1864 &ptl); 1865 WinMapWindowPoints(HWND_DESKTOP, 1866 hwnd, 1867 &ptl, 1868 1); 1869 WinQueryWindowRect(hwnd,&rcl); 1870 if(WinPtInRect(WinQueryAnchorBlock(hwnd), 1871 &rcl, 1872 &ptl)) 1873 BubbleHelp(hwnd, 1874 FALSE, 1875 TRUE, 1876 FALSE, 1877 (char *)mp1); 1878 } 1879 } 1880 return 0; 1881 1882 case WM_MENUEND: 1883 if(hwndMenu == (HWND)mp2) { 1884 WinDestroyWindow(hwndMenu); 1885 hwndMenu = (HWND)0; 1886 } 1887 break; 1888 1889 case WM_CONTEXTMENU: 1890 if(hwndMenu) 1891 WinDestroyWindow(hwndMenu); 1892 hwndMenu = (HWND)0; 1893 id = WinQueryWindowUShort(hwnd,QWS_ID); 1894 *dv = 0; 1895 WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT), 1896 id + 50), 1897 sizeof(dv), 1898 dv); 1899 if(isalpha(*dv)) { 1900 hwndMenu = WinLoadMenu(HWND_DESKTOP, 1901 FM3ModHandle, 1902 MAIN_DRIVES); 1903 if(hwndMenu) { 1904 if(!(driveflags[toupper(*dv) - 'A'] & DRIVE_REMOTE)) 1905 WinEnableMenuItem(hwndMenu, 1906 IDM_DETACH, 1907 FALSE); 1908 if(driveflags[toupper(*dv) - 'A'] & DRIVE_NOTWRITEABLE) { 1909 WinEnableMenuItem(hwndMenu, 1910 IDM_MKDIR, 1911 FALSE); 1912 WinEnableMenuItem(hwndMenu, 1913 IDM_FORMAT, 1914 FALSE); 1915 WinEnableMenuItem(hwndMenu, 1916 IDM_OPTIMIZE, 1917 FALSE); 1918 WinEnableMenuItem(hwndMenu, 1919 IDM_UNDELETE, 1920 FALSE); 1921 } 1922 if(!(driveflags[toupper(*dv) - 'A'] & DRIVE_REMOVABLE)) { 1923 WinEnableMenuItem(hwndMenu, 1924 IDM_EJECT, 1925 FALSE); 1926 WinEnableMenuItem(hwndMenu, 1927 IDM_LOCK, 1928 FALSE); 1929 WinEnableMenuItem(hwndMenu, 1930 IDM_UNLOCK, 1931 FALSE); 1932 } 1933 /* 1934 if(!(driveflags[toupper(*dv) - 'A'] & DRIVE_CDROM)) { 1935 WinEnableMenuItem(hwndMenu, 1936 IDM_CLOSETRAY, 1937 FALSE); 1938 } 1939 */ 1940 PopupMenu(hwnd, 1941 hwnd, 1942 hwndMenu); 1943 } 1944 } 1945 return MRFROMSHORT(TRUE); 1946 1947 case WM_BUTTON2CLICK: 1948 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); 1949 if(!(shiftstate & KC_CTRL)) 1950 break; 1951 case WM_CHORD: 1952 case WM_BUTTON3CLICK: 1953 id = WinQueryWindowUShort(hwnd,QWS_ID); 1954 *dv = 0; 1955 WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT), 1956 id + 50), 1957 sizeof(dv), 1958 dv); 1959 if(isalpha(*dv)) { 1960 strcat(dv,"\\"); 1961 if(!FindDirCnrByName(dv,TRUE)) 1962 OpenDirCnr((HWND)0, 1963 hwndMain, 1964 hwndTree, 1965 FALSE, 1966 dv); 1967 } 1968 break; 1969 1970 case WM_COMMAND: 1971 PostMsg(hwnd,UM_COMMAND,mp1,mp2); 1972 return 0; 1973 1974 case UM_COMMAND: 1975 id = WinQueryWindowUShort(hwnd,QWS_ID); 1976 *dv = 0; 1977 WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT), 1978 id + 50), 1979 sizeof(dv), 1980 dv); 1981 if(isalpha(*dv)) { 1982 strcat(dv,"\\"); 1983 CommonDriveCmd(hwnd,dv,SHORT1FROMMP(mp1)); 1984 } 1985 return 0; 1986 1987 case DM_DRAGOVER: 1988 id = WinQueryWindowUShort(hwnd,QWS_ID); 1989 *dv = 0; 1990 WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT), 1991 id + 50), 1992 sizeof(dv), 1993 dv); 1994 if(isalpha(*dv) && 1995 !(driveflags[toupper(*dv) - 'A'] & DRIVE_NOTWRITEABLE)) { 1996 if(!emphasized) { 1997 emphasized = TRUE; 1998 DrawTargetEmphasis(hwnd,emphasized); 1999 } 2000 if(AcceptOneDrop(mp1,mp2)) 2001 return MRFROM2SHORT(DOR_DROP, 2002 DO_MOVE); 2003 return MRFROM2SHORT(DOR_NEVERDROP,0); 2004 } 2005 break; 2006 2007 case DM_DRAGLEAVE: 2008 id = WinQueryWindowUShort(hwnd,QWS_ID); 2009 *dv = 0; 2010 WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT), 2011 id + 50), 2012 sizeof(dv), 2013 dv); 2014 if(isalpha(*dv) && 2015 !(driveflags[toupper(*dv) - 'A'] & DRIVE_NOTWRITEABLE)) { 2016 if(emphasized) { 2017 emphasized = FALSE; 2018 DrawTargetEmphasis(hwnd,emphasized); 2019 } 2020 } 2021 break; 2022 2023 case DM_DROPHELP: 2024 id = WinQueryWindowUShort(hwnd,QWS_ID); 2025 *dv = 0; 2026 WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT), 2027 id + 50),sizeof(dv),dv); 2028 if(isalpha(*dv) && 2029 !(driveflags[toupper(*dv) - 'A'] & DRIVE_NOTWRITEABLE)) { 2030 DropHelp(mp1,mp2,hwnd,GetPString(IDS_DRIVEDROPHELP)); 2031 return 0; 2032 } 2033 break; 2034 2035 case DM_DROP: 2036 id = WinQueryWindowUShort(hwnd,QWS_ID); 2037 *dv = 0; 2038 WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT), 2039 id + 50), 2040 sizeof(dv), 2041 dv); 2042 if(isalpha(*dv) && 2043 !(driveflags[toupper(*dv) - 'A'] & DRIVE_NOTWRITEABLE)) { 2044 2045 CNRDRAGINFO cnd; 2046 LISTINFO *li; 2047 ULONG action = UM_ACTION; 2048 2049 2050 if(emphasized) { 2051 emphasized = FALSE; 2052 DrawTargetEmphasis(hwnd,emphasized); 2053 } 2054 memset(&cnd,0,sizeof(cnd)); 2055 cnd.pDragInfo = (PDRAGINFO)mp1; 2056 cnd.pRecord = NULL; 2057 li = DoFileDrop(hwnd, 2058 NULL, 2059 TRUE, 2060 MPFROM2SHORT(TREE_CNR,CN_DROP), 2061 MPFROMP(&cnd)); 2062 if(li) { 2063 strcpy(li->targetpath,dv); 2064 strcat(li->targetpath,"\\"); 2065 if(li->list && 2066 li->list[0] && 2067 IsRoot(li->list[0])) 2068 li->type = DO_LINK; 2069 else if(fDragndropDlg && 2070 (!*li->arcname || !li->info)) { 2071 2072 CHECKLIST cl; 2073 2074 memset(&cl,0,sizeof(cl)); 2075 cl.size = sizeof(cl); 2076 cl.flags = li->type; 2077 cl.list = li->list; 2078 cl.cmd = li->type; 2079 cl.prompt = li->targetpath; 2080 li->type = WinDlgBox(HWND_DESKTOP, 2081 hwndMain, 2082 DropListProc, 2083 FM3ModHandle, 2084 DND_FRAME, 2085 MPFROMP(&cl)); 2086 if(!li->type) { 2087 FreeListInfo(li); 2088 return 0; 2089 } 2090 li->list = cl.list; 2091 if(!li->list || !li->list[0]) { 2092 FreeListInfo(li); 2093 return 0; 2094 } 2095 } 2096 else { 2097 if(!WinDlgBox(HWND_DESKTOP, 2098 hwndMain, 2099 WalkDlgProc, 2100 FM3ModHandle, 2101 WALK_FRAME, 2102 MPFROMP(li->targetpath)) || 2103 !*li->targetpath) { 2104 FreeListInfo(li); 2105 return 0; 2106 } 2107 } 2108 switch(li->type) { 2109 case DND_LAUNCH: 2110 strcat(li->targetpath," %a"); 2111 ExecOnList(hwndMain, 2112 li->targetpath, 2113 PROMPT | WINDOWED, 2114 NULL, 2115 li->list, 2116 NULL); 2117 FreeList(li->list); 2118 li->list = NULL; 2119 break; 2120 case DO_LINK: 2121 if(fLinkSetsIcon) { 2122 li->type = IDM_SETICON; 2123 action = UM_MASSACTION; 2124 } 2125 else 2126 li->type = IDM_COMPARE; 2127 break; 2128 case DND_EXTRACT: 2129 if(*li->targetpath && 2130 !IsFile(li->targetpath)) 2131 li->type = IDM_EXTRACT; 2132 break; 2133 case DND_MOVE: 2134 li->type = IDM_MOVE; 2135 if(*li->targetpath && 2136 IsFile(li->targetpath) == 1) { 2137 action = UM_MASSACTION; 2138 li->type = IDM_ARCHIVEM; 2139 } 2140 break; 2141 case DND_WILDMOVE: 2142 li->type = IDM_WILDMOVE; 2143 if(*li->targetpath && 2144 IsFile(li->targetpath) == 1) { 2145 action = UM_MASSACTION; 2146 li->type = IDM_ARCHIVEM; 2147 } 2148 break; 2149 case DND_OBJECT: 2150 li->type = IDM_OBJECT; 2151 action = UM_MASSACTION; 2152 break; 2153 case DND_SHADOW: 2154 li->type = IDM_SHADOW; 2155 action = UM_MASSACTION; 2156 break; 2157 case DND_COMPARE: 2158 li->type = IDM_COMPARE; 2159 break; 2160 case DND_SETICON: 2161 action = UM_MASSACTION; 2162 li->type = IDM_SETICON; 2163 break; 2164 case DND_COPY: 2165 li->type = IDM_COPY; 2166 if(*li->targetpath && 2167 IsFile(li->targetpath) == 1) { 2168 action = UM_MASSACTION; 2169 li->type = IDM_ARCHIVE; 2170 } 2171 break; 2172 case DND_WILDCOPY: 2173 li->type = IDM_WILDCOPY; 2174 if(*li->targetpath && 2175 IsFile(li->targetpath) == 1) { 2176 action = UM_MASSACTION; 2177 li->type = IDM_ARCHIVE; 2178 } 2179 break; 2180 default: 2181 if(*li->arcname && li->info) { 2182 action = UM_MASSACTION; 2183 li->type = (li->type == DO_MOVE) ? IDM_FAKEEXTRACTM : 2184 IDM_FAKEEXTRACT; 2185 } 2186 else if(*li->targetpath && IsFile(li->targetpath) == 1) { 2187 action = UM_MASSACTION; 2188 li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE; 2189 } 2190 else 2191 li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY; 2192 break; 2193 } 2194 if(!li->list || !li->list[0]) 2195 FreeListInfo(li); 2196 else 2197 WinSendMsg(hwndTree, 2198 UM_ACTION, 2199 MPFROMP(li), 2200 MPFROMLONG(action)); 2201 } 2202 return 0; 2203 } 2204 break; 2205 2206 case WM_DESTROY: 2207 if(hwndMenu) 2208 WinDestroyWindow(hwndMenu); 2209 hwndMenu = (HWND)0; 2210 break; 2211 } 2212 return PFNWPButton(hwnd,msg,mp1,mp2); 2213 } 2214 2215 2216 VOID BuildDrives (HWND hwndT) { 2217 2218 register ULONG x,y = 0; 2219 ULONG ulDriveNum,ulDriveMap,iconid; 2220 CHAR s[8]; 2221 HENUM henum; 2222 HWND hwndB; 2223 2224 henum = WinBeginEnumWindows(hwndT); 2225 while((hwndB = WinGetNextWindow(henum)) != NULLHANDLE) 2226 WinDestroyWindow(hwndB); 2227 WinEndEnumWindows(henum); 2228 if(fDrivebar) { 2229 DosError(FERR_DISABLEHARDERR); 2230 DosQCurDisk(&ulDriveNum,&ulDriveMap); 2231 for(x = 0;x < 26;x++) { 2232 if((ulDriveMap & (1L << x)) && 2233 !(driveflags[x] & DRIVE_IGNORE)) { 2234 if(x > 1) { 2235 if(driveflags[x] & DRIVE_CDROM) 2236 iconid = CDROM_ICON; 2237 else 2238 iconid = (driveflags[x] & DRIVE_REMOVABLE) ? 2239 REMOVABLE_ICON : 2240 (driveflags[x] & DRIVE_REMOTE) ? 2241 REMOTE_ICON : 2242 (driveflags[x] & DRIVE_ZIPSTREAM) ? 2243 DRIVE_ICON : 2244 DRIVE_ICON; 2245 } 2246 else 2247 iconid = FLOPPY_ICON; 2248 sprintf(s,"#%lu",iconid); 2249 hwndB = WinCreateWindow(hwndT, 2250 GetPString(IDS_WCDRIVEBUTTONS), 2251 s, 2252 BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON, 2253 0, 2254 0, 2255 28, 2256 18, 2257 hwndT, 2258 HWND_TOP, 2259 y + IDM_DRIVEA, 2260 NULL, 2261 NULL); 2262 if(hwndB) { 2263 WinSetWindowPos(hwndB, 2264 HWND_BOTTOM, 2265 0, 2266 0, 2267 0, 2268 0, 2269 SWP_ZORDER); 2270 sprintf(s,"%c:",(CHAR)x + 'A'); 2271 hwndB = WinCreateWindow(hwndT, 2272 WC_STATIC, 2273 s, 2274 SS_TEXT | DT_LEFT | DT_VCENTER, 2275 0, 2276 0, 2277 10, 2278 18, 2279 hwndT, 2280 HWND_TOP, 2281 y + IDM_DRIVEATEXT, 2282 NULL, 2283 NULL); 2284 if(hwndB) { 2285 SetPresParams(hwndB, 2286 &RGBGREY, 2287 &RGBBLACK, 2288 &RGBGREY, 2289 GetPString(IDS_6HELVTEXT)); 2290 WinSetWindowPos(hwndB, 2291 HWND_BOTTOM, 2292 0, 2293 0, 2294 0, 2295 0, 2296 SWP_ZORDER); 2297 } 2298 y++; 2299 } 2300 } 2301 } 2302 } 2303 PostMsg(WinQueryWindow(hwndT,QW_PARENT), 2304 WM_UPDATEFRAME, 2305 MPFROMLONG(FCF_SIZEBORDER), 2306 MPVOID); 2307 } 2308 2309 2310 VOID ResizeDrives (HWND hwndT,long xwidth) { 2311 2312 register ULONG ctrlxpos = 2,ctrlypos = 0,ctrlxsize; 2313 HENUM henum; 2314 HWND hwndB; 2315 RECTL rcl; 2474 VOID ResizeDrives(HWND hwndT, long xwidth) 2475 { 2476 2477 register ULONG ctrlxpos = 2, ctrlypos = 0, ctrlxsize; 2478 HENUM henum; 2479 HWND hwndB; 2480 RECTL rcl; 2316 2481 2317 2482 DriveLines = 0; 2318 if (!fDrivebar)2483 if (!fDrivebar) 2319 2484 return; 2320 if(!xwidth) { 2321 WinQueryWindowRect(hwndT,&rcl); 2485 if (!xwidth) 2486 { 2487 WinQueryWindowRect(hwndT, &rcl); 2322 2488 xwidth = rcl.xRight - ((WinQuerySysValue(HWND_DESKTOP, 2323 2489 SV_CYSIZEBORDER) * 2) + 2); 2324 2490 } 2325 henum = WinBeginEnumWindows(hwndT); 2326 while((hwndB = WinGetNextWindow(henum)) != NULLHANDLE) { 2327 if(WinQueryWindowUShort(hwndB,QWS_ID) > IDM_DRIVEA + 27) 2491 henum = WinBeginEnumWindows(hwndT); 2492 while ((hwndB = WinGetNextWindow(henum)) != NULLHANDLE) 2493 { 2494 if (WinQueryWindowUShort(hwndB, QWS_ID) > IDM_DRIVEA + 27) 2328 2495 ctrlxsize = 10; 2329 2496 else 2330 2497 ctrlxsize = 28; 2331 2498 WinSetWindowPos(hwndB, 2332 2333 2334 2335 2336 2337 2499 HWND_TOP, 2500 ctrlxpos, 2501 ctrlypos, 2502 ctrlxsize, 2503 18, 2504 SWP_MOVE | SWP_SHOW); 2338 2505 ctrlxpos += (ctrlxsize + 2); 2339 if(ctrlxsize == 10) { 2340 if(ctrlxpos + (42 + ((fShowTarget && DriveLines == 0) ? 2341 256 : 2342 0)) > xwidth) { 2343 ctrlxpos = 2; 2344 ctrlypos += 18; 2345 DriveLines++; 2506 if (ctrlxsize == 10) 2507 { 2508 if (ctrlxpos + (42 + ((fShowTarget && DriveLines == 0) ? 2509 256 : 2510 0)) > xwidth) 2511 { 2512 ctrlxpos = 2; 2513 ctrlypos += 18; 2514 DriveLines++; 2346 2515 } 2347 2516 } 2348 2517 } 2349 if (ctrlxpos == 2 && DriveLines)2518 if (ctrlxpos == 2 && DriveLines) 2350 2519 DriveLines--; 2351 2520 } 2352 2521 2353 2354 MRESULT EXPENTRY StatusProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2){2355 2356 static HWND hwndE = (HWND)0,hwndB = (HWND)0;2522 MRESULT EXPENTRY StatusProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 2523 { 2524 2525 static HWND hwndE = (HWND) 0, hwndB = (HWND) 0; 2357 2526 static CHAR lastcmd[1024] = ""; 2358 2527 2359 switch(msg) { 2360 case WM_CREATE: 2361 { 2362 MRESULT mr = PFNWPStatic(hwnd,msg,mp1,mp2); 2363 2364 SetPresParams(hwnd, 2365 &RGBGREY, 2366 &RGBBLACK, 2367 &RGBGREY, 2368 GetPString(IDS_8HELVBOLDTEXT)); 2369 return mr; 2370 } 2371 2372 case WM_PRESPARAMCHANGED: 2373 if(fRunning) { 2374 2375 ULONG AttrFound,AttrValue[64],cbRetLen; 2376 2377 cbRetLen = WinQueryPresParam(hwnd, 2378 (ULONG)mp1, 2379 0, 2380 &AttrFound, 2381 (ULONG)sizeof(AttrValue), 2382 &AttrValue,0); 2383 if(cbRetLen) { 2384 switch(AttrFound) { 2385 case PP_FONTNAMESIZE: 2386 PostMsg(WinQueryWindow(hwnd,QW_PARENT), 2387 WM_UPDATEFRAME, 2388 MPFROMLONG(FCF_SIZEBORDER), 2389 MPVOID); 2390 break; 2391 } 2392 } 2393 } 2394 break; 2395 2396 case WM_CONTEXTMENU: 2397 PostMsg(hwndMain, 2398 UM_CONTEXTMENU, 2399 MPVOID, 2400 MPVOID); 2401 return MRFROMSHORT(TRUE); 2402 2403 case WM_BEGINDRAG: 2404 if(hwndTree) { 2405 2406 SWP swp; 2407 ULONG fl = SWP_ACTIVATE | SWP_SHOW | SWP_ZORDER; 2408 2409 WinQueryWindowPos(hwndTree,&swp); 2410 if(!(swp.fl & SWP_MAXIMIZE)) 2411 fl |= SWP_RESTORE; 2412 WinSetWindowPos(hwndTree,HWND_TOP,0,0,0,0,fl); 2413 } 2414 break; 2415 2416 case UM_SETUP: 2417 if(mp1) 2418 strcpy(lastcmd,(CHAR *)mp1); 2419 return 0; 2420 2421 case UM_RESCAN: 2422 if(hwndE && 2423 WinIsWindow(WinQueryAnchorBlock(hwnd),hwndE)) 2424 WinDestroyWindow(hwndE); 2425 if(hwndB && 2426 WinIsWindow(WinQueryAnchorBlock(hwnd),hwndB)) 2427 WinDestroyWindow(hwndB); 2428 hwndE = hwndB = (HWND)0; 2429 return 0; 2430 2431 case WM_COMMAND: 2432 switch(SHORT1FROMMP(mp1)) { 2433 case COMMAND_BUTTON: 2434 PostMsg(hwndE,msg,mp1,mp2); 2435 break; 2436 } 2437 return 0; 2438 2439 case WM_MOUSEMOVE: 2440 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); 2441 { 2442 USHORT id = WinQueryWindowUShort(hwnd,QWS_ID); 2443 char *s = NULL; 2444 2445 if(fOtherHelp) { 2446 if((!hwndBubble || WinQueryWindowULong(hwndBubble,QWL_USER) != hwnd) && 2447 !WinQueryCapture(HWND_DESKTOP)) { 2448 switch(id) { 2449 case IDM_ATTRS: 2450 if(WinQueryWindowTextLength(hwnd)) 2451 s = GetPString(IDS_ATTRSBUTTONHELP); 2452 break; 2453 case IDM_INFO: 2454 if(WinQueryWindowTextLength(hwnd)) 2455 s = GetPString(IDS_INFOBUTTONHELP); 2456 break; 2457 case IDM_RENAME: 2458 if(WinQueryWindowTextLength(hwnd)) 2459 s = GetPString(IDS_NAMEBUTTONHELP); 2460 break; 2461 case MAIN_STATUS2: 2462 if(!hwndE) 2463 s = GetPString(IDS_STATUS2HELP); 2464 break; 2465 default: 2466 break; 2467 } 2468 if(s) 2469 MakeBubble(hwnd,FALSE,s); 2470 else if(hwndBubble) 2471 WinDestroyWindow(hwndBubble); 2472 } 2473 } 2474 switch(id) { 2475 case IDM_ATTRS: 2476 case IDM_INFO: 2477 case IDM_RENAME: 2478 case MAIN_STATUS2: 2479 return CommonTextProc(hwnd,msg,mp1,mp2); 2480 default: 2481 break; 2482 } 2483 } 2484 break; 2485 2486 case WM_BUTTON2DOWN: 2487 case WM_BUTTON2UP: 2488 case UM_FOCUSME: 2489 return CommonTextButton(hwnd,msg,mp1,mp2); 2490 2491 case WM_BUTTON1DOWN: 2492 case WM_BUTTON1UP: 2493 case WM_BUTTON3DOWN: 2494 case WM_BUTTON3UP: 2495 { 2496 USHORT id; 2497 2498 id = WinQueryWindowUShort(hwnd,QWS_ID); 2499 switch(id) { 2500 case IDM_ATTRS: 2501 case IDM_INFO: 2502 case IDM_RENAME: 2503 case MAIN_STATUS2: 2504 return CommonTextButton(hwnd,msg,mp1,mp2); 2505 default: 2506 PostMsg(hwnd, 2507 UM_FOCUSME, 2508 MPVOID, 2509 MPVOID); 2510 break; 2511 } 2512 } 2513 break; 2514 2515 case WM_SETFOCUS: 2516 if(mp2) { 2517 2518 USHORT id; 2519 2520 id = WinQueryWindowUShort(hwnd,QWS_ID); 2521 if(id == MAIN_STATUS2 && 2522 hwndE) 2523 WinSendMsg(hwnd, 2524 UM_RESCAN, 2525 MPVOID, 2526 MPVOID); 2527 else 2528 return CommonTextButton(hwnd,msg,mp1,mp2); 2529 } 2530 break; 2531 2532 case WM_BUTTON1CLICK: 2533 { 2534 USHORT id; 2535 2536 id = WinQueryWindowUShort(hwnd,QWS_ID); 2537 if(id == MAIN_STATUS) { 2538 if(SHORT2FROMMP(mp2) & KC_CTRL) 2539 PostMsg(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT), 2540 FID_CLIENT), 2541 WM_COMMAND, 2542 MPFROM2SHORT(IDM_WINDOWDLG,0), 2543 MPVOID); 2544 else if(hwndTree) 2545 PostMsg(hwndTree, 2546 UM_TIMER, 2547 MPVOID, 2548 MPVOID); 2549 } 2550 } 2551 break; 2552 2553 case UM_CLICKED: 2554 case UM_CLICKED3: 2555 { 2556 USHORT id; 2557 2558 id = WinQueryWindowUShort(hwnd,QWS_ID); 2559 if(id == MAIN_STATUS2 && 2560 !hwndE) { 2561 2562 SWP swp; 2563 CHAR directory[CCHMAXPATH]; 2564 PFNWP oldproce; 2565 2566 *directory = 0; 2567 TopWindowName(hwndMain,(HWND)0,directory); 2568 WinQueryWindowPos(hwnd,&swp); 2569 hwndB = WinCreateWindow(hwnd, 2570 WC_BUTTON, 2571 "+", 2572 WS_VISIBLE | BS_PUSHBUTTON | 2573 BS_NOPOINTERFOCUS, 2574 swp.cx - swp.cy, 2575 0, 2576 swp.cy, 2577 swp.cy, 2578 hwnd, 2579 HWND_TOP, 2580 COMMAND_BUTTON, 2581 NULL, 2582 NULL); 2583 hwndE = WinCreateWindow(hwnd, 2584 WC_ENTRYFIELD, 2585 NULL, 2586 WS_VISIBLE | ES_AUTOSCROLL, 2587 0, 2588 0, 2589 swp.cx - swp.cy, 2590 swp.cy, 2591 hwnd, 2592 HWND_TOP, 2593 COMMAND_LINE, 2594 NULL, 2595 NULL); 2596 if(!hwndE || !hwndB) { 2597 PostMsg(hwnd, 2598 UM_RESCAN, 2599 MPVOID, 2600 MPVOID); 2601 return 0; 2602 } 2603 WinSendMsg(hwndE, 2604 EM_SETTEXTLIMIT, 2605 MPFROM2SHORT(1024,0), 2606 MPVOID); 2607 WinSetWindowText(hwndStatus, 2608 directory); 2609 if(*lastcmd) 2610 WinSetWindowText(hwndE, 2611 lastcmd); 2612 else 2613 WinSetWindowText(hwndE, 2614 GetPString(IDS_HELPCMDTEXT)); 2615 oldproce = WinSubclassWindow(hwndE, 2616 (PFNWP)CommandLineProc); 2617 if(oldproce) 2618 WinSetWindowPtr(hwndE, 2619 0, 2620 (PVOID)oldproce); 2621 PostMsg(hwndE, 2622 UM_FOCUSME, 2623 MPVOID, 2624 MPVOID); 2625 PostMsg(hwndE, 2626 EM_SETSEL, 2627 MPFROM2SHORT(0,1024), 2628 MPVOID); 2629 return 0; 2630 } 2631 if(msg == UM_CLICKED3 || 2632 (SHORT2FROMMP(mp2) & KC_CTRL)) { 2633 switch(id) { 2634 case IDM_ATTRS: 2635 id = IDM_SORTSIZE; 2636 break; 2637 case IDM_INFO: 2638 id = IDM_SORTLWDATE; 2639 break; 2640 case IDM_RENAME: 2641 id = IDM_SORTFILENAME; 2642 break; 2643 } 2644 } 2645 PostMsg(WinQueryWindow(hwnd,QW_PARENT), 2646 WM_COMMAND, 2647 MPFROM2SHORT(id,0), 2648 MPVOID); 2649 } 2650 return 0; 2651 2652 case WM_PAINT: 2653 { 2654 USHORT id; 2655 2656 id = WinQueryWindowUShort(hwnd,QWS_ID); 2657 switch(id) { 2658 case IDM_ATTRS: 2659 case IDM_INFO: 2660 case IDM_RENAME: 2661 case MAIN_STATUS2: 2662 PaintRecessedWindow(hwnd,(HPS)0,TRUE,FALSE); 2663 break; 2664 default: 2665 PaintRecessedWindow(hwnd,(HPS)0,FALSE,TRUE); 2666 break; 2667 } 2668 if(id == IDM_RENAME) { 2669 2670 HPS hps; 2671 2672 hps = WinBeginPaint(hwnd,(HPS)0,NULL); 2673 if(hps) { 2674 PaintSTextWindow(hwnd,hps); 2675 WinEndPaint(hps); 2676 } 2677 return 0; 2678 } 2679 } 2680 break; 2681 2528 switch (msg) 2529 { 2530 case WM_CREATE: 2531 { 2532 MRESULT mr = PFNWPStatic(hwnd, msg, mp1, mp2); 2533 2534 SetPresParams(hwnd, 2535 &RGBGREY, 2536 &RGBBLACK, 2537 &RGBGREY, 2538 GetPString(IDS_8HELVBOLDTEXT)); 2539 return mr; 2540 } 2541 2542 case WM_PRESPARAMCHANGED: 2543 if (fRunning) 2544 { 2545 2546 ULONG AttrFound, AttrValue[64], cbRetLen; 2547 2548 cbRetLen = WinQueryPresParam(hwnd, 2549 (ULONG) mp1, 2550 0, 2551 &AttrFound, 2552 (ULONG) sizeof(AttrValue), 2553 &AttrValue, 0); 2554 if (cbRetLen) 2555 { 2556 switch (AttrFound) 2557 { 2558 case PP_FONTNAMESIZE: 2559 PostMsg(WinQueryWindow(hwnd, QW_PARENT), 2560 WM_UPDATEFRAME, 2561 MPFROMLONG(FCF_SIZEBORDER), 2562 MPVOID); 2563 break; 2682 2564 } 2683 return PFNWPStatic(hwnd,msg,mp1,mp2); 2565 } 2566 } 2567 break; 2568 2569 case WM_CONTEXTMENU: 2570 PostMsg(hwndMain, 2571 UM_CONTEXTMENU, 2572 MPVOID, 2573 MPVOID); 2574 return MRFROMSHORT(TRUE); 2575 2576 case WM_BEGINDRAG: 2577 if (hwndTree) 2578 { 2579 2580 SWP swp; 2581 ULONG fl = SWP_ACTIVATE | SWP_SHOW | SWP_ZORDER; 2582 2583 WinQueryWindowPos(hwndTree, &swp); 2584 if (!(swp.fl & SWP_MAXIMIZE)) 2585 fl |= SWP_RESTORE; 2586 WinSetWindowPos(hwndTree, HWND_TOP, 0, 0, 0, 0, fl); 2587 } 2588 break; 2589 2590 case UM_SETUP: 2591 if (mp1) 2592 strcpy(lastcmd, (CHAR *) mp1); 2593 return 0; 2594 2595 case UM_RESCAN: 2596 if (hwndE && 2597 WinIsWindow(WinQueryAnchorBlock(hwnd), hwndE)) 2598 WinDestroyWindow(hwndE); 2599 if (hwndB && 2600 WinIsWindow(WinQueryAnchorBlock(hwnd), hwndB)) 2601 WinDestroyWindow(hwndB); 2602 hwndE = hwndB = (HWND) 0; 2603 return 0; 2604 2605 case WM_COMMAND: 2606 switch (SHORT1FROMMP(mp1)) 2607 { 2608 case COMMAND_BUTTON: 2609 PostMsg(hwndE, msg, mp1, mp2); 2610 break; 2611 } 2612 return 0; 2613 2614 case WM_MOUSEMOVE: 2615 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); 2616 { 2617 USHORT id = WinQueryWindowUShort(hwnd, QWS_ID); 2618 char *s = NULL; 2619 2620 if (fOtherHelp) 2621 { 2622 if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) && 2623 !WinQueryCapture(HWND_DESKTOP)) 2624 { 2625 switch (id) 2626 { 2627 case IDM_ATTRS: 2628 if (WinQueryWindowTextLength(hwnd)) 2629 s = GetPString(IDS_ATTRSBUTTONHELP); 2630 break; 2631 case IDM_INFO: 2632 if (WinQueryWindowTextLength(hwnd)) 2633 s = GetPString(IDS_INFOBUTTONHELP); 2634 break; 2635 case IDM_RENAME: 2636 if (WinQueryWindowTextLength(hwnd)) 2637 s = GetPString(IDS_NAMEBUTTONHELP); 2638 break; 2639 case MAIN_STATUS2: 2640 if (!hwndE) 2641 s = GetPString(IDS_STATUS2HELP); 2642 break; 2643 default: 2644 break; 2645 } 2646 if (s) 2647 MakeBubble(hwnd, FALSE, s); 2648 else if (hwndBubble) 2649 WinDestroyWindow(hwndBubble); 2650 } 2651 } 2652 switch (id) 2653 { 2654 case IDM_ATTRS: 2655 case IDM_INFO: 2656 case IDM_RENAME: 2657 case MAIN_STATUS2: 2658 return CommonTextProc(hwnd, msg, mp1, mp2); 2659 default: 2660 break; 2661 } 2662 } 2663 break; 2664 2665 case WM_BUTTON2DOWN: 2666 case WM_BUTTON2UP: 2667 case UM_FOCUSME: 2668 return CommonTextButton(hwnd, msg, mp1, mp2); 2669 2670 case WM_BUTTON1DOWN: 2671 case WM_BUTTON1UP: 2672 case WM_BUTTON3DOWN: 2673 case WM_BUTTON3UP: 2674 { 2675 USHORT id; 2676 2677 id = WinQueryWindowUShort(hwnd, QWS_ID); 2678 switch (id) 2679 { 2680 case IDM_ATTRS: 2681 case IDM_INFO: 2682 case IDM_RENAME: 2683 case MAIN_STATUS2: 2684 return CommonTextButton(hwnd, msg, mp1, mp2); 2685 default: 2686 PostMsg(hwnd, 2687 UM_FOCUSME, 2688 MPVOID, 2689 MPVOID); 2690 break; 2691 } 2692 } 2693 break; 2694 2695 case WM_SETFOCUS: 2696 if (mp2) 2697 { 2698 2699 USHORT id; 2700 2701 id = WinQueryWindowUShort(hwnd, QWS_ID); 2702 if (id == MAIN_STATUS2 && 2703 hwndE) 2704 WinSendMsg(hwnd, 2705 UM_RESCAN, 2706 MPVOID, 2707 MPVOID); 2708 else 2709 return CommonTextButton(hwnd, msg, mp1, mp2); 2710 } 2711 break; 2712 2713 case WM_BUTTON1CLICK: 2714 { 2715 USHORT id; 2716 2717 id = WinQueryWindowUShort(hwnd, QWS_ID); 2718 if (id == MAIN_STATUS) 2719 { 2720 if (SHORT2FROMMP(mp2) & KC_CTRL) 2721 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), 2722 FID_CLIENT), 2723 WM_COMMAND, 2724 MPFROM2SHORT(IDM_WINDOWDLG, 0), 2725 MPVOID); 2726 else if (hwndTree) 2727 PostMsg(hwndTree, 2728 UM_TIMER, 2729 MPVOID, 2730 MPVOID); 2731 } 2732 } 2733 break; 2734 2735 case UM_CLICKED: 2736 case UM_CLICKED3: 2737 { 2738 USHORT id; 2739 2740 id = WinQueryWindowUShort(hwnd, QWS_ID); 2741 if (id == MAIN_STATUS2 && 2742 !hwndE) 2743 { 2744 2745 SWP swp; 2746 CHAR directory[CCHMAXPATH]; 2747 PFNWP oldproce; 2748 2749 *directory = 0; 2750 TopWindowName(hwndMain, (HWND) 0, directory); 2751 WinQueryWindowPos(hwnd, &swp); 2752 hwndB = WinCreateWindow(hwnd, 2753 WC_BUTTON, 2754 "+", 2755 WS_VISIBLE | BS_PUSHBUTTON | 2756 BS_NOPOINTERFOCUS, 2757 swp.cx - swp.cy, 2758 0, 2759 swp.cy, 2760 swp.cy, 2761 hwnd, 2762 HWND_TOP, 2763 COMMAND_BUTTON, 2764 NULL, 2765 NULL); 2766 hwndE = WinCreateWindow(hwnd, 2767 WC_ENTRYFIELD, 2768 NULL, 2769 WS_VISIBLE | ES_AUTOSCROLL, 2770 0, 2771 0, 2772 swp.cx - swp.cy, 2773 swp.cy, 2774 hwnd, 2775 HWND_TOP, 2776 COMMAND_LINE, 2777 NULL, 2778 NULL); 2779 if (!hwndE || !hwndB) 2780 { 2781 PostMsg(hwnd, 2782 UM_RESCAN, 2783 MPVOID, 2784 MPVOID); 2785 return 0; 2786 } 2787 WinSendMsg(hwndE, 2788 EM_SETTEXTLIMIT, 2789 MPFROM2SHORT(1024, 0), 2790 MPVOID); 2791 WinSetWindowText(hwndStatus, 2792 directory); 2793 if (*lastcmd) 2794 WinSetWindowText(hwndE, 2795 lastcmd); 2796 else 2797 WinSetWindowText(hwndE, 2798 GetPString(IDS_HELPCMDTEXT)); 2799 oldproce = WinSubclassWindow(hwndE, 2800 (PFNWP) CommandLineProc); 2801 if (oldproce) 2802 WinSetWindowPtr(hwndE, 2803 0, 2804 (PVOID) oldproce); 2805 PostMsg(hwndE, 2806 UM_FOCUSME, 2807 MPVOID, 2808 MPVOID); 2809 PostMsg(hwndE, 2810 EM_SETSEL, 2811 MPFROM2SHORT(0, 1024), 2812 MPVOID); 2813 return 0; 2814 } 2815 if (msg == UM_CLICKED3 || 2816 (SHORT2FROMMP(mp2) & KC_CTRL)) 2817 { 2818 switch (id) 2819 { 2820 case IDM_ATTRS: 2821 id = IDM_SORTSIZE; 2822 break; 2823 case IDM_INFO: 2824 id = IDM_SORTLWDATE; 2825 break; 2826 case IDM_RENAME: 2827 id = IDM_SORTFILENAME; 2828 break; 2829 } 2830 } 2831 PostMsg(WinQueryWindow(hwnd, QW_PARENT), 2832 WM_COMMAND, 2833 MPFROM2SHORT(id, 0), 2834 MPVOID); 2835 } 2836 return 0; 2837 2838 case WM_PAINT: 2839 { 2840 USHORT id; 2841 2842 id = WinQueryWindowUShort(hwnd, QWS_ID); 2843 switch (id) 2844 { 2845 case IDM_ATTRS: 2846 case IDM_INFO: 2847 case IDM_RENAME: 2848 case MAIN_STATUS2: 2849 PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE); 2850 break; 2851 default: 2852 PaintRecessedWindow(hwnd, (HPS) 0, FALSE, TRUE); 2853 break; 2854 } 2855 if (id == IDM_RENAME) 2856 { 2857 2858 HPS hps; 2859 2860 hps = WinBeginPaint(hwnd, (HPS) 0, NULL); 2861 if (hps) 2862 { 2863 PaintSTextWindow(hwnd, hps); 2864 WinEndPaint(hps); 2865 } 2866 return 0; 2867 } 2868 } 2869 break; 2870 2871 } 2872 return PFNWPStatic(hwnd, msg, mp1, mp2); 2684 2873 } 2685 2874 2686 2687 MRESULT EXPENTRY ToolBackProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) { 2688 2689 switch(msg) { 2690 case WM_CREATE: 2691 hwndToolback = hwnd; 2692 SetPresParams(hwnd, 2693 &RGBGREY, 2694 &RGBBLACK, 2695 &RGBGREY, 2696 GetPString(IDS_8HELVTEXT)); 2697 break; 2698 2699 case WM_MOUSEMOVE: 2700 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); 2701 break; 2702 2703 case WM_CONTROLPOINTER: 2704 if(!fNoFinger && 2705 SHORT1FROMMP(mp1) < 25000) 2706 return MRFROMLONG(hptrFinger); 2707 break; 2708 2709 case WM_CHAR: 2710 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL)); 2711 break; 2712 2713 case WM_COMMAND: 2714 case UM_COMMAND: 2715 return WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT), 2716 FID_CLIENT), 2717 msg, 2718 mp1, 2719 mp2); 2720 2721 case WM_PAINT: 2722 { 2723 HPS hps; 2724 RECTL rcl; 2725 2726 hps = WinBeginPaint(hwnd,(HPS)0,NULL); 2727 if(hps) { 2728 WinQueryWindowRect(hwnd,&rcl); 2729 WinFillRect(hps,&rcl,CLR_PALEGRAY); 2730 WinEndPaint(hps); 2731 } 2732 PaintRecessedWindow(hwnd, 2733 (HPS)0, 2734 TRUE, 2735 FALSE); 2736 } 2737 break; 2738 2739 case UM_SETUP: 2740 { 2741 USHORT id; 2742 TOOL *tool; 2743 2744 id = SHORT1FROMMP(mp1); 2745 tool = find_tool(id); 2746 if(tool) { 2747 del_tool(tool); 2748 WinShowWindow(WinWindowFromID(hwnd,id),FALSE); 2749 if(fToolTitles) 2750 WinShowWindow(WinWindowFromID(hwnd,id + 25000),FALSE); 2751 ResizeTools(hwnd); 2752 } 2753 } 2754 return 0; 2755 2756 case WM_CHORD: 2757 { 2758 USHORT id; 2759 2760 id = (USHORT)WinDlgBox(HWND_DESKTOP, 2761 hwnd, 2762 AddToolProc, 2763 FM3ModHandle, 2764 ADDBTN_FRAME, 2765 MPVOID); 2766 if(id && id != (USHORT)-1) 2767 WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT), 2768 FID_CLIENT), 2769 WM_COMMAND, 2770 MPFROM2SHORT(IDM_CREATETOOL,0), 2771 MPFROM2SHORT(id,0)); 2772 } 2773 break; 2774 2775 case WM_CONTEXTMENU: 2776 if(WinDlgBox(HWND_DESKTOP, 2777 hwnd, 2778 ToolIODlgProc, 2779 FM3ModHandle, 2780 SVBTN_FRAME, 2781 MPVOID)) 2782 BuildTools(hwnd,TRUE); 2783 return MRFROMSHORT(TRUE); 2784 2785 case WM_CLOSE: 2786 WinDestroyWindow(hwnd); 2787 return 0; 2788 2789 case WM_DESTROY: 2790 break; 2875 MRESULT EXPENTRY ToolBackProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 2876 { 2877 2878 switch (msg) 2879 { 2880 case WM_CREATE: 2881 hwndToolback = hwnd; 2882 SetPresParams(hwnd, 2883 &RGBGREY, 2884 &RGBBLACK, 2885 &RGBGREY, 2886 GetPString(IDS_8HELVTEXT)); 2887 break; 2888 2889 case WM_MOUSEMOVE: 2890 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); 2891 break; 2892 2893 case WM_CONTROLPOINTER: 2894 if (!fNoFinger && 2895 SHORT1FROMMP(mp1) < 25000) 2896 return MRFROMLONG(hptrFinger); 2897 break; 2898 2899 case WM_CHAR: 2900 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL)); 2901 break; 2902 2903 case WM_COMMAND: 2904 case UM_COMMAND: 2905 return WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), 2906 FID_CLIENT), 2907 msg, 2908 mp1, 2909 mp2); 2910 2911 case WM_PAINT: 2912 { 2913 HPS hps; 2914 RECTL rcl; 2915 2916 hps = WinBeginPaint(hwnd, (HPS) 0, NULL); 2917 if (hps) 2918 { 2919 WinQueryWindowRect(hwnd, &rcl); 2920 WinFillRect(hps, &rcl, CLR_PALEGRAY); 2921 WinEndPaint(hps); 2922 } 2923 PaintRecessedWindow(hwnd, 2924 (HPS) 0, 2925 TRUE, 2926 FALSE); 2927 } 2928 break; 2929 2930 case UM_SETUP: 2931 { 2932 USHORT id; 2933 TOOL *tool; 2934 2935 id = SHORT1FROMMP(mp1); 2936 tool = find_tool(id); 2937 if (tool) 2938 { 2939 del_tool(tool); 2940 WinShowWindow(WinWindowFromID(hwnd, id), FALSE); 2941 if (fToolTitles) 2942 WinShowWindow(WinWindowFromID(hwnd, id + 25000), FALSE); 2943 ResizeTools(hwnd); 2944 } 2945 } 2946 return 0; 2947 2948 case WM_CHORD: 2949 { 2950 USHORT id; 2951 2952 id = (USHORT) WinDlgBox(HWND_DESKTOP, 2953 hwnd, 2954 AddToolProc, 2955 FM3ModHandle, 2956 ADDBTN_FRAME, 2957 MPVOID); 2958 if (id && id != (USHORT) - 1) 2959 WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), 2960 FID_CLIENT), 2961 WM_COMMAND, 2962 MPFROM2SHORT(IDM_CREATETOOL, 0), 2963 MPFROM2SHORT(id, 0)); 2964 } 2965 break; 2966 2967 case WM_CONTEXTMENU: 2968 if (WinDlgBox(HWND_DESKTOP, 2969 hwnd, 2970 ToolIODlgProc, 2971 FM3ModHandle, 2972 SVBTN_FRAME, 2973 MPVOID)) 2974 BuildTools(hwnd, TRUE); 2975 return MRFROMSHORT(TRUE); 2976 2977 case WM_CLOSE: 2978 WinDestroyWindow(hwnd); 2979 return 0; 2980 2981 case WM_DESTROY: 2982 break; 2983 } 2984 return WinDefWindowProc(hwnd, msg, mp1, mp2); 2985 } 2986 2987 VOID AdjustSizeOfClient(PSWP pswp, PRECTL prectl) 2988 { 2989 2990 SWP swp; 2991 RECTL rectl; 2992 2993 if (fFreeTree) 2994 return; 2995 if (pswp) 2996 { 2997 if (WinQueryWindowPos(hwndTree, &swp) && 2998 !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE))) 2999 { 3000 pswp -> x = swp.cx; 3001 pswp -> cx -= swp.cx; 3002 } 3003 } 3004 if (prectl) 3005 { 3006 if (WinQueryWindowPos(hwndTree, &swp) && 3007 !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE)) && 3008 WinQueryWindowRect(hwndTree, &rectl)) 3009 { 3010 prectl -> xLeft = rectl.xRight; 3011 prectl -> xRight -= rectl.xRight; 3012 } 3013 } 3014 } 3015 3016 VOID FillClient(HWND hwndClient, PSWP pswp, PRECTL prectl, BOOL avoidtree) 3017 { 3018 3019 ULONG adjust; 3020 3021 adjust = WinQuerySysValue(HWND_DESKTOP, SV_CYICON); 3022 if (pswp) 3023 WinQueryWindowPos(hwndClient, pswp); 3024 if (prectl) 3025 WinQueryWindowRect(hwndClient, prectl); 3026 if (avoidtree && !fFreeTree) 3027 AdjustSizeOfClient(pswp, prectl); 3028 if (prectl) 3029 prectl -> yBottom += adjust; 3030 if (pswp) 3031 { 3032 if (!avoidtree || fFreeTree) 3033 pswp -> x = 0; 3034 pswp -> y = adjust; 3035 if (pswp -> cy >= adjust) 3036 pswp -> cy -= adjust; 3037 else 3038 pswp -> cy = 0; 3039 } 3040 } 3041 3042 VOID MoveChildrenAwayFromTree(HWND hwndClient) 3043 { 3044 3045 SWP swpC, swpT, swp; 3046 USHORT id; 3047 HWND hwndChild; 3048 HENUM henum; 3049 3050 if (fFreeTree) 3051 return; 3052 WinQueryWindowPos(hwndClient, &swpC); 3053 if (swpC.fl & (SWP_MINIMIZE | SWP_HIDE)) 3054 return; 3055 WinQueryWindowPos(hwndTree, &swpT); 3056 henum = WinBeginEnumWindows(hwndClient); 3057 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) 3058 { 3059 id = WinQueryWindowUShort(hwndChild, QWS_ID); 3060 if (!id || id == TREE_FRAME) 3061 continue; 3062 WinQueryWindowPos(hwndChild, &swp); 3063 if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) 3064 { 3065 if (swp.x < swpT.cx) 3066 { 3067 swp.x = swpT.cx; 3068 if (swp.x + swp.cx > swpC.cx) 3069 swp.cx = swpC.cx - swp.x; 3070 if (swp.cx > 24) 3071 WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy, 3072 SWP_SIZE | SWP_MOVE | SWP_SHOW); 3073 } 3074 } 3075 } 3076 WinEndEnumWindows(henum); 3077 } 3078 3079 VOID ArrangeIcons(HWND hwndClient) 3080 { 3081 3082 HENUM henum; 3083 HWND hwndChild; 3084 SWP swp; 3085 3086 henum = WinBeginEnumWindows(hwndClient); 3087 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) 3088 { 3089 WinQueryWindowPos(hwndChild, &swp); 3090 if (swp.fl & (SWP_MINIMIZE | SWP_HIDE)) 3091 { 3092 WinSetWindowUShort(hwndChild, QWS_XMINIMIZE, (USHORT) - 1); 3093 WinSetWindowUShort(hwndChild, QWS_YMINIMIZE, (USHORT) - 1); 3094 WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0, 3095 SWP_MOVE | SWP_SHOW | SWP_FOCUSDEACTIVATE); 3096 } 3097 } 3098 WinEndEnumWindows(henum); 3099 } 3100 3101 VOID NextChild(HWND hwndClient, BOOL previous) 3102 { 3103 3104 HENUM henum; 3105 HWND hwndActive, hwndNext, hwndPrev = (HWND) 0; 3106 BOOL next = FALSE, once = FALSE; 3107 3108 previous = !previous; 3109 3110 hwndActive = WinQueryActiveWindow(hwndClient); 3111 if (!hwndActive) 3112 next = TRUE; 3113 henum = WinBeginEnumWindows(hwndClient); 3114 for (;;) 3115 { 3116 hwndNext = WinGetNextWindow(henum); 3117 if (hwndNext) 3118 { 3119 if (!WinQueryWindowUShort(hwndNext, QWS_ID)) 3120 continue; 3121 if (next) 3122 break; 3123 if (hwndNext == hwndActive) 3124 { 3125 if (!previous && hwndPrev) 3126 { 3127 hwndNext = hwndPrev; 3128 break; 2791 3129 } 2792 return WinDefWindowProc(hwnd,msg,mp1,mp2); 3130 else if (previous) 3131 next = TRUE; 3132 } 3133 hwndPrev = hwndNext; 3134 } 3135 else 3136 { 3137 if ((!next && previous) || once) 3138 break; 3139 else if (!previous) 3140 { 3141 hwndNext = hwndPrev; 3142 break; 3143 } 3144 else 3145 once = next = TRUE; 3146 } 3147 } 3148 WinEndEnumWindows(henum); 3149 3150 if (hwndNext && hwndNext != hwndActive) 3151 { 3152 WinSetWindowPos(hwndNext, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER | SWP_ACTIVATE); 3153 WinSetWindowPos(hwndActive, ((previous) ? HWND_BOTTOM : hwndNext), 3154 0, 0, 0, 0, SWP_ZORDER); 3155 } 2793 3156 } 2794 3157 2795 2796 VOID AdjustSizeOfClient (PSWP pswp,PRECTL prectl) { 2797 2798 SWP swp; 2799 RECTL rectl; 2800 2801 if(fFreeTree) 2802 return; 2803 if(pswp) { 2804 if(WinQueryWindowPos(hwndTree,&swp) && 2805 !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE))) { 2806 pswp->x = swp.cx; 2807 pswp->cx -= swp.cx; 3158 BOOL CloseChildren(HWND hwndClient) 3159 { 3160 3161 HENUM henum; 3162 HWND hwndChild; 3163 BOOL ret = FALSE; 3164 3165 fNoTileUpdate = TRUE; 3166 henum = WinBeginEnumWindows(hwndClient); 3167 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) 3168 { 3169 if (hwndChild != hwndTree) 3170 { 3171 WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT), 3172 WM_SAVEAPPLICATION, 3173 MPVOID, 3174 MPVOID); 3175 if (WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT), 3176 WM_CLOSE, 3177 MPVOID, 3178 MPVOID)) 3179 { 3180 ret = TRUE; 3181 break; 3182 } 3183 } 3184 } 3185 WinEndEnumWindows(henum); 3186 fNoTileUpdate = FALSE; 3187 return ret; 3188 } 3189 3190 BOOL CloseDirCnrChildren(HWND hwndClient) 3191 { 3192 3193 /* returns TRUE if a directory container window was told to close */ 3194 3195 HENUM henum; 3196 HWND hwndChild, hwndDir, hwndTemp; 3197 BOOL ret = FALSE; 3198 3199 fNoTileUpdate = TRUE; 3200 henum = WinBeginEnumWindows(hwndClient); 3201 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) 3202 { 3203 if (hwndChild != hwndTree) 3204 { 3205 hwndTemp = WinWindowFromID(hwndChild, FID_CLIENT); 3206 if (hwndTemp) 3207 { 3208 hwndDir = WinWindowFromID(hwndTemp, DIR_CNR); 3209 if (hwndDir) 3210 { 3211 WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT), 3212 WM_CLOSE, 3213 MPVOID, 3214 MPVOID); 3215 ret = TRUE; 3216 } 3217 } 3218 } 3219 } 3220 WinEndEnumWindows(henum); 3221 fNoTileUpdate = FALSE; 3222 return ret; 3223 } 3224 3225 BOOL SaveDirCnrState(HWND hwndClient, CHAR * name) 3226 { 3227 3228 /* returns TRUE if any directory container windows existed */ 3229 3230 HENUM henum; 3231 HWND hwndChild, hwndDir, hwndC; 3232 ULONG numsaves = 0, flWindowAttr; 3233 CHAR s[120], directory[CCHMAXPATH]; 3234 SWP swp; 3235 BOOL ret = FALSE; 3236 DIRCNRDATA *dcd; 3237 3238 henum = WinBeginEnumWindows(hwndClient); 3239 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) 3240 { 3241 if (hwndChild != hwndTree) 3242 { 3243 hwndC = WinWindowFromID(hwndChild, FID_CLIENT); 3244 if (hwndC) 3245 { 3246 hwndDir = WinWindowFromID(hwndC, DIR_CNR); 3247 if (hwndDir) 3248 { 3249 WinQueryWindowPos(hwndChild, &swp); 3250 *directory = 0; 3251 WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(directory), MPVOID); 3252 if (*directory) 3253 { 3254 sprintf(s, "%s%sDirCnrPos.%lu", (name) ? name : NullStr, (name) ? "." : NullStr, 3255 numsaves); 3256 PrfWriteProfileData(fmprof, 3257 FM3Str, 3258 s, 3259 (PVOID) & swp, 3260 sizeof(SWP)); 3261 dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER); 3262 if (dcd) 3263 { 3264 sprintf(s, "%s%sDirCnrSort.%lu", (name) ? name : NullStr, (name) ? "." : NullStr, 3265 numsaves); 3266 PrfWriteProfileData(fmprof, FM3Str, s, (PVOID) & dcd -> sortFlags, 3267 sizeof(INT)); 3268 sprintf(s, "%s%sDirCnrFilter.%lu", (name) ? name : NullStr, (name) ? "." : NullStr, 3269 numsaves); 3270 PrfWriteProfileData(fmprof, FM3Str, s, (PVOID) & dcd -> mask, 3271 sizeof(MASK)); 3272 sprintf(s, "%s%sDirCnrView.%lu", (name) ? name : NullStr, (name) ? "." : NullStr, 3273 numsaves); 3274 flWindowAttr = dcd -> flWindowAttr; 3275 if (!fLeaveTree && (flWindowAttr & CV_TREE)) 3276 { 3277 flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT)); 3278 if (dcd -> lastattr) 3279 { 3280 if (dcd -> lastattr & CV_TEXT) 3281 flWindowAttr |= CV_TEXT; 3282 else if (dcd -> lastattr & CV_DETAIL) 3283 flWindowAttr |= CV_DETAIL; 3284 else if (dcd -> lastattr & CV_ICON) 3285 flWindowAttr |= CV_ICON; 3286 else 3287 flWindowAttr |= CV_NAME; 2808 3288 } 3289 else 3290 flWindowAttr |= CV_NAME; 3291 } 3292 PrfWriteProfileData(fmprof, FM3Str, s, (PVOID) & flWindowAttr, 3293 sizeof(ULONG)); 3294 } 3295 sprintf(s, "%s%sDirCnrDir.%lu", (name) ? name : NullStr, (name) ? "." : NullStr, 3296 numsaves++); 3297 PrfWriteProfileString(fmprof, FM3Str, s, directory); 3298 ret = TRUE; 3299 } 2809 3300 } 2810 if(prectl) { 2811 if(WinQueryWindowPos(hwndTree,&swp) && 2812 !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE)) && 2813 WinQueryWindowRect(hwndTree,&rectl)) { 2814 prectl->xLeft = rectl.xRight; 2815 prectl->xRight -= rectl.xRight; 3301 } 3302 } 3303 } 3304 WinEndEnumWindows(henum); 3305 if (ret) 3306 { 3307 if (WinQueryWindowPos(hwndTree, &swp)) 3308 { 3309 sprintf(s, "%s%sLastTreePos", (name) ? name : NullStr, (name) ? "." : NullStr); 3310 PrfWriteProfileData(fmprof, FM3Str, s, (PVOID) & swp, sizeof(SWP)); 3311 } 3312 sprintf(s, "%s%sNumDirsLastTime", (name) ? name : NullStr, (name) ? "." : NullStr); 3313 PrfWriteProfileData(fmprof, FM3Str, s, (PVOID) & numsaves, sizeof(ULONG)); 3314 WinQueryWindowPos(WinQueryWindow(hwndClient, QW_PARENT), &swp); 3315 sprintf(s, "%s%sMySizeLastTime", (name) ? name : NullStr, (name) ? "." : NullStr); 3316 PrfWriteProfileData(fmprof, FM3Str, s, (PVOID) & swp, sizeof(SWP)); 3317 } 3318 return ret; 3319 } 3320 3321 VOID TransformSwp(PSWP pswp, double xtrans, double ytrans) 3322 { 3323 3324 SWP swp; 3325 HWND hwnd; 3326 3327 if ((LONG) pswp -> x < 0L) 3328 { 3329 pswp -> cx -= abs(pswp -> x); 3330 pswp -> x = 0; 3331 } 3332 if ((LONG) pswp -> y < 0L) 3333 { 3334 pswp -> cy -= abs(pswp -> y); 3335 pswp -> y = 0; 3336 } 3337 pswp -> x = (LONG) (((double) pswp -> x * 100.0) / xtrans); 3338 pswp -> cx = (LONG) (((double) pswp -> cx * 100.0) / xtrans); 3339 pswp -> y = (LONG) (((double) pswp -> y * 100.0) / ytrans); 3340 pswp -> cy = (LONG) (((double) pswp -> cy * 100.0) / ytrans); 3341 if (pswp -> hwnd) 3342 { 3343 hwnd = WinQueryWindow(pswp -> hwnd, QW_PARENT); 3344 if (hwnd) 3345 { 3346 if (WinQueryWindowPos(hwnd, &swp)) 3347 { 3348 if (pswp -> x > swp.cx) 3349 pswp -> x = (swp.cx > 24) ? swp.cx - 24 : swp.cx; 3350 if (pswp -> y > swp.cy) 3351 pswp -> y = (swp.cy > 24) ? swp.cy - 24 : swp.cy; 3352 if (pswp -> x + pswp -> cx > swp.cx) 3353 pswp -> cx = swp.cx - pswp -> x; 3354 if (pswp -> y + pswp -> cy > swp.cy) 3355 pswp -> cy = swp.cy - pswp -> y; 3356 } 3357 } 3358 } 3359 } 3360 3361 BOOL RestoreDirCnrState(HWND hwndClient, CHAR * name, BOOL noview) 3362 { 3363 3364 /* returns TRUE if a directory container was opened */ 3365 3366 CHAR s[120], tdir[CCHMAXPATH]; 3367 HWND hwndDir, hwndC; 3368 SWP swp, swpO, swpN; 3369 ULONG size, numsaves = 0L, x; 3370 double xtrans, ytrans; 3371 BOOL ret = FALSE; 3372 DIRCNRDATA *dcd; 3373 3374 size = sizeof(SWP); 3375 sprintf(s, 3376 "%s%sMySizeLastTime", 3377 (name) ? name : NullStr, 3378 (name) ? "." : NullStr); 3379 if (!PrfQueryProfileData(fmprof, 3380 FM3Str, 3381 s, 3382 (PVOID) & swpO, 3383 &size) || 3384 size != sizeof(SWP) || !swp.cx || !swp.cy) 3385 WinQueryWindowPos(WinQueryWindow(hwndClient, QW_PARENT), &swpO); 3386 if (!name || 3387 !strcmp(name, GetPString(IDS_FM2TEMPTEXT))) 3388 PrfWriteProfileData(fmprof, 3389 FM3Str, 3390 s, 3391 NULL, 3392 0L); 3393 WinQueryWindowPos(WinQueryWindow(hwndClient, QW_PARENT), &swpN); 3394 if (swpN.fl & (SWP_MINIMIZE | SWP_HIDE)) 3395 swpN = swpO; 3396 xtrans = ((double) swpO.cx * 100.0) / (double) swpN.cx; 3397 ytrans = ((double) swpO.cy * 100.0) / (double) swpN.cy; 3398 size = sizeof(SWP); 3399 sprintf(s, 3400 "%s%sLastTreePos", 3401 (name) ? (name) : NullStr, 3402 (name) ? "." : NullStr); 3403 if (PrfQueryProfileData(fmprof, 3404 FM3Str, 3405 s, 3406 (PVOID) & swp, 3407 &size)) 3408 { 3409 if (!name || 3410 !strcmp(name, GetPString(IDS_FM2TEMPTEXT))) 3411 PrfWriteProfileData(fmprof, 3412 FM3Str, 3413 s, 3414 NULL, 3415 0L); 3416 swp.hwnd = hwndTree; 3417 TransformSwp(&swp, 3418 xtrans, 3419 ytrans); 3420 if (!fFreeTree) 3421 { 3422 WinQueryWindowPos(hwndClient, &swpN); 3423 swp.x = 0; 3424 swp.y = (swpN.cy - swp.cy); 3425 } 3426 if (!(swp.fl & (SWP_MINIMIZE | SWP_HIDE))) 3427 { 3428 swp.fl &= (~SWP_ACTIVATE); 3429 WinSetWindowPos(hwndTree, 3430 HWND_TOP, 3431 swp.x, 3432 swp.y, 3433 swp.cx, 3434 swp.cy, 3435 swp.fl | SWP_MOVE | 3436 SWP_SIZE | SWP_SHOW | SWP_ZORDER); 3437 } 3438 else 3439 { 3440 WinSetWindowPos(hwndTree, 3441 HWND_TOP, 3442 0, 3443 0, 3444 0, 3445 0, 3446 SWP_MINIMIZE | SWP_SHOW); 3447 WinSetWindowUShort(hwndTree, 3448 QWS_XRESTORE, 3449 (USHORT) swp.x); 3450 WinSetWindowUShort(hwndTree, 3451 QWS_CXRESTORE, 3452 (USHORT) swp.cx); 3453 WinSetWindowUShort(hwndTree, 3454 QWS_YRESTORE, 3455 (USHORT) swp.y); 3456 WinSetWindowUShort(hwndTree, 3457 QWS_CYRESTORE, 3458 (USHORT) swp.cy); 3459 } 3460 } 3461 size = sizeof(ULONG); 3462 sprintf(s, 3463 "%s%sNumDirsLastTime", 3464 (name) ? name : NullStr, 3465 (name) ? "." : NullStr); 3466 if (PrfQueryProfileData(fmprof, 3467 FM3Str, 3468 s, 3469 (PVOID) & numsaves, 3470 &size) && 3471 numsaves) 3472 { 3473 if (!name || 3474 !strcmp(name, GetPString(IDS_FM2TEMPTEXT))) 3475 PrfWriteProfileData(fmprof, 3476 FM3Str, 3477 s, 3478 NULL, 3479 0L); 3480 for (x = 0; x < numsaves; x++) 3481 { 3482 sprintf(s, 3483 "%s%sDirCnrPos.%lu", 3484 (name) ? name : NullStr, 3485 (name) ? "." : NullStr, 3486 x); 3487 size = sizeof(SWP); 3488 if (PrfQueryProfileData(fmprof, 3489 FM3Str, 3490 s, 3491 (PVOID) & swp, 3492 &size)) 3493 { 3494 if (!name || 3495 !strcmp(name, GetPString(IDS_FM2TEMPTEXT))) 3496 PrfWriteProfileData(fmprof, 3497 FM3Str, 3498 s, 3499 NULL, 3500 0L); 3501 sprintf(s, 3502 "%s%sDirCnrDir.%lu", 3503 (name) ? name : NullStr, 3504 (name) ? "." : NullStr, 3505 x); 3506 size = sizeof(tdir); 3507 if (PrfQueryProfileData(fmprof, 3508 FM3Str, 3509 s, 3510 (PVOID) tdir, 3511 &size)) 3512 { 3513 if (!name || 3514 !strcmp(name, GetPString(IDS_FM2TEMPTEXT))) 3515 PrfWriteProfileData(fmprof, 3516 FM3Str, 3517 s, 3518 NULL, 3519 0L); 3520 hwndDir = (HWND) WinSendMsg(hwndClient, 3521 UM_SETDIR, 3522 MPFROMP(tdir), 3523 MPFROMLONG(1L)); 3524 if (hwndDir) 3525 { 3526 hwndC = WinWindowFromID(hwndDir, 3527 FID_CLIENT); 3528 if (hwndC) 3529 { 3530 dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), 3531 0); 3532 if (dcd) 3533 { 3534 size = sizeof(INT); 3535 sprintf(s, 3536 "%s%sDirCnrSort.%lu", 3537 (name) ? name : NullStr, 3538 (name) ? "." : NullStr, 3539 x); 3540 if (PrfQueryProfileData(fmprof, 3541 FM3Str, 3542 s, 3543 (PVOID) & dcd -> sortFlags, 3544 &size) && 3545 size == sizeof(INT)) 3546 { 3547 if (!dcd -> sortFlags) 3548 dcd -> sortFlags = SORT_PATHNAME; 2816 3549 } 3550 if (!name || 3551 !strcmp(name, GetPString(IDS_FM2TEMPTEXT))) 3552 PrfWriteProfileData(fmprof, 3553 FM3Str, 3554 s, 3555 NULL, 3556 0L); 3557 size = sizeof(MASK); 3558 sprintf(s, 3559 "%s%sDirCnrFilter.%lu", 3560 (name) ? name : NullStr, 3561 (name) ? "." : NullStr, 3562 x); 3563 if (PrfQueryProfileData(fmprof, 3564 FM3Str, 3565 s, 3566 (PVOID) & dcd -> mask, 3567 &size) && 3568 size) 3569 { 3570 if (*dcd -> mask.szMask) 3571 WinSendMsg(WinWindowFromID(hwndC, DIR_CNR), 3572 UM_FILTER, 3573 MPFROMP(dcd -> mask.szMask), 3574 MPVOID); 3575 } 3576 *(dcd -> mask.prompt) = 0; 3577 if (!name || 3578 !strcmp(name, GetPString(IDS_FM2TEMPTEXT))) 3579 PrfWriteProfileData(fmprof, 3580 FM3Str, 3581 s, 3582 NULL, 3583 0L); 3584 size = sizeof(ULONG); 3585 sprintf(s, 3586 "%s%sDirCnrView.%lu", 3587 (name) ? name : NullStr, 3588 (name) ? "." : NullStr, 3589 x); 3590 if (!noview) 3591 { 3592 if (PrfQueryProfileData(fmprof, 3593 FM3Str, 3594 s, 3595 (PVOID) & dcd -> flWindowAttr, 3596 &size) && 3597 size == sizeof(ULONG)) 3598 { 3599 3600 CNRINFO cnri; 3601 3602 memset(&cnri, 0, sizeof(CNRINFO)); 3603 cnri.cb = sizeof(CNRINFO); 3604 if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR), 3605 CM_QUERYCNRINFO, 3606 MPFROMP(&cnri), 3607 MPFROMLONG(sizeof(CNRINFO)))) 3608 { 3609 cnri.flWindowAttr = dcd -> flWindowAttr; 3610 WinSendMsg(WinWindowFromID(hwndC, DIR_CNR), 3611 CM_SETCNRINFO, 3612 MPFROMP(&cnri), 3613 MPFROMLONG(CMA_FLWINDOWATTR)); 3614 } 3615 } 3616 } 3617 if (!name || 3618 !strcmp(name, GetPString(IDS_FM2TEMPTEXT))) 3619 PrfWriteProfileData(fmprof, 3620 FM3Str, 3621 s, 3622 NULL, 3623 0L); 3624 } 3625 } 3626 ret = TRUE; 3627 swp.hwnd = hwndDir; 3628 TransformSwp(&swp, 3629 xtrans, 3630 ytrans); 3631 if (!fAutoTile && 3632 !(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) 3633 WinSetWindowPos(hwndDir, 3634 HWND_TOP, 3635 swp.x, 3636 swp.y, 3637 swp.cx, 3638 swp.cy, 3639 swp.fl | SWP_MOVE | 3640 SWP_SIZE | SWP_SHOW | SWP_ZORDER | SWP_ACTIVATE); 3641 else if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) 3642 { 3643 WinSetWindowPos(hwndDir, 3644 HWND_TOP, 3645 0, 3646 0, 3647 0, 3648 0, 3649 SWP_MINIMIZE | SWP_SHOW); 3650 WinSetWindowUShort(hwndDir, 3651 QWS_XRESTORE, 3652 (USHORT) swp.x); 3653 WinSetWindowUShort(hwndDir, 3654 QWS_CXRESTORE, 3655 (USHORT) swp.cx); 3656 WinSetWindowUShort(hwndDir, 3657 QWS_YRESTORE, 3658 (USHORT) swp.y); 3659 WinSetWindowUShort(hwndDir, 3660 QWS_CYRESTORE, 3661 (USHORT) swp.cy); 3662 } 3663 else 3664 WinSetWindowPos(hwndDir, 3665 HWND_TOP, 3666 0, 3667 0, 3668 0, 3669 0, 3670 SWP_ZORDER | SWP_ACTIVATE); 3671 } 2817 3672 } 3673 } 3674 } 3675 } 3676 return ret; 2818 3677 } 2819 3678 2820 2821 VOID FillClient (HWND hwndClient,PSWP pswp,PRECTL prectl,BOOL avoidtree) { 2822 2823 ULONG adjust; 2824 2825 adjust = WinQuerySysValue(HWND_DESKTOP,SV_CYICON); 2826 if(pswp) 2827 WinQueryWindowPos(hwndClient,pswp); 2828 if(prectl) 2829 WinQueryWindowRect(hwndClient,prectl); 2830 if(avoidtree && !fFreeTree) 2831 AdjustSizeOfClient(pswp,prectl); 2832 if(prectl) 2833 prectl->yBottom += adjust; 2834 if(pswp) { 2835 if(!avoidtree || fFreeTree) 2836 pswp->x = 0; 2837 pswp->y = adjust; 2838 if(pswp->cy >= adjust) 2839 pswp->cy -= adjust; 2840 else 2841 pswp->cy = 0; 3679 ULONG CountChildren(HWND hwndClient, ULONG * ulNumMinChildren) 3680 { 3681 3682 HENUM henum; 3683 HWND hwndChild; 3684 SWP swp; 3685 register ULONG ulCnt = 0L; 3686 USHORT id; 3687 3688 if (ulNumMinChildren) 3689 *ulNumMinChildren = 0L; 3690 henum = WinBeginEnumWindows(hwndClient); 3691 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) 3692 { 3693 id = WinQueryWindowUShort(hwndChild, QWS_ID); 3694 if (!id || (!fFreeTree && id == TREE_FRAME)) 3695 continue; 3696 ulCnt++; 3697 if (ulNumMinChildren) 3698 { 3699 if (WinQueryWindowPos(hwndChild, &swp) && 3700 (swp.fl & SWP_MINIMIZE)) 3701 (*ulNumMinChildren)++; 3702 } 3703 } 3704 WinEndEnumWindows(henum); 3705 return ulCnt; 3706 } 3707 3708 VOID GetNextWindowPos(HWND hwndClient, PSWP pswp, ULONG * ulCntR, 3709 ULONG * ulNumMinChildrenR) 3710 { 3711 3712 register ULONG ulCnt; 3713 ULONG ulNumMinChildren; 3714 RECTL Rectl; 3715 register ULONG ulXDiff, ulYDiff, ulWindowsPerStack; 3716 3717 if (!ulCntR || !ulNumMinChildrenR) 3718 ulCnt = CountChildren(hwndClient, &ulNumMinChildren); 3719 else 3720 { 3721 ulCnt = *ulCntR; 3722 ulNumMinChildren = *ulNumMinChildrenR; 3723 if (ulCnt == (ULONG) - 1L) 3724 { 3725 ulCnt = CountChildren(hwndClient, &ulNumMinChildren); 3726 /* return these values to the caller for later use */ 3727 *ulCntR = ulCnt; 3728 *ulNumMinChildrenR = ulNumMinChildren; 3729 } 3730 } 3731 WinQueryWindowRect(hwndClient, &Rectl); 3732 AdjustSizeOfClient(NULL, &Rectl); 3733 if (!fFreeTree) 3734 { 3735 3736 SWP swp; 3737 3738 WinQueryWindowPos(hwndTree, &swp); 3739 if (ulNumMinChildren || (swp.fl & (SWP_HIDE | SWP_MINIMIZE))) 3740 Rectl.yBottom += WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2; 3741 } 3742 else if (ulNumMinChildren) 3743 Rectl.yBottom += WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2; 3744 3745 ulXDiff = WinQuerySysValue(HWND_DESKTOP, SV_CXSIZEBORDER) + 3746 WinQuerySysValue(HWND_DESKTOP, SV_CXMINMAXBUTTON) / 2; 3747 ulYDiff = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER) + 3748 WinQuerySysValue(HWND_DESKTOP, SV_CYMINMAXBUTTON); 3749 ulWindowsPerStack = (Rectl.yTop - Rectl.yBottom) / (3 * ulYDiff); 3750 pswp -> cx = Rectl.xRight - (ulWindowsPerStack * ulXDiff); 3751 pswp -> cy = (Rectl.yTop - Rectl.yBottom) - (ulWindowsPerStack * ulYDiff); 3752 ulWindowsPerStack++; 3753 pswp -> x = Rectl.xLeft + ((ulCnt % ulWindowsPerStack) * ulXDiff); 3754 pswp -> y = (Rectl.yTop - pswp -> cy - ((ulCnt % ulWindowsPerStack) * ulYDiff)); 3755 } 3756 3757 VOID CascadeChildren(HWND hwndClient) 3758 { 3759 3760 ULONG ulCnt = 0L, ulNumMinChildren; 3761 HWND hwndChild; 3762 HENUM henum; 3763 SWP swp; 3764 USHORT id; 3765 RECTL Rectl; 3766 3767 WinQueryWindowPos(hwndClient, &swp); 3768 if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) 3769 return; 3770 3771 CountChildren(hwndClient, &ulNumMinChildren); 3772 if (!fFreeTree) 3773 { 3774 WinQueryWindowRect(hwndClient, &Rectl); 3775 AdjustSizeOfClient(NULL, &Rectl); 3776 WinQueryWindowPos(hwndTree, &swp); 3777 if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) 3778 { 3779 if (swp.y + swp.cy < Rectl.yTop - Rectl.yBottom) 3780 swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y; 3781 if (swp.x != 0) 3782 swp.x = 0; 3783 if (swp.y < 0) 3784 swp.y = 0; 3785 if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft) 3786 swp.cx = Rectl.xRight - Rectl.xLeft; 3787 WinSetWindowPos(hwndTree, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy, 3788 SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE); 3789 } 3790 } 3791 henum = WinBeginEnumWindows(hwndClient); 3792 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) 3793 { 3794 id = WinQueryWindowUShort(hwndChild, QWS_ID); 3795 if (!id || (!fFreeTree && id == TREE_FRAME)) 3796 continue; 3797 WinQueryWindowPos(hwndChild, &swp); 3798 if (!(swp.fl & (SWP_MINIMIZE | SWP_HIDE))) 3799 { 3800 GetNextWindowPos(hwndClient, &swp, &ulCnt, &ulNumMinChildren); 3801 WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy, 3802 SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_RESTORE | 3803 SWP_ZORDER | SWP_ACTIVATE); 3804 ulCnt++; 3805 } 3806 } 3807 WinEndEnumWindows(henum); 3808 } 3809 3810 VOID TileChildren(HWND hwndClient, BOOL absolute) 3811 { 3812 3813 register ULONG ulChildCnt, ulSquare, ulNumRows, ulNumCols, ulExtraCols, 3814 ulWidth, ulHeight; 3815 ULONG ulNumMinChildren; 3816 RECTL Rectl; 3817 HWND hwndChild; 3818 3819 if (fNoTileUpdate || hwndClient == HWND_DESKTOP) 3820 return; 3821 { 3822 SWP swp; 3823 3824 WinQueryWindowPos(hwndClient, &swp); 3825 if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) 3826 return; 3827 } 3828 ulChildCnt = CountChildren(hwndClient, 3829 &ulNumMinChildren); 3830 ulChildCnt -= ulNumMinChildren; 3831 if (!ulChildCnt) 3832 return; 3833 3834 fNoTileUpdate = TRUE; 3835 3836 for (ulSquare = 2; 3837 ulSquare * ulSquare <= ulChildCnt; 3838 ulSquare++) 3839 ; 3840 if (!fTileBackwards) 3841 { 3842 ulNumCols = ulSquare - 1L; 3843 ulNumRows = ulChildCnt / ulNumCols; 3844 } 3845 else 3846 { 3847 ulNumRows = ulSquare - 1L; 3848 ulNumCols = ulChildCnt / ulNumRows; 3849 } 3850 ulExtraCols = ulChildCnt % ulNumCols; 3851 3852 WinQueryWindowRect(hwndClient, 3853 &Rectl); 3854 3855 if (!fFreeTree) 3856 { 3857 3858 SWP swp; 3859 3860 WinQueryWindowPos(hwndTree, &swp); 3861 if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) 3862 { 3863 if (swp.y < 0) 3864 swp.y = 0; 3865 if (swp.y + swp.cy < Rectl.yTop - Rectl.yBottom) 3866 swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y; 3867 if (swp.x != 0) 3868 swp.x = 0; 3869 if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft) 3870 swp.cx = Rectl.xRight - Rectl.xLeft; 3871 WinSetWindowPos(hwndTree, 3872 HWND_TOP, 3873 swp.x, 3874 swp.y, 3875 swp.cx, 3876 swp.cy, 3877 SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE); 3878 WinQueryWindowPos(hwndTree, &swp); 3879 } 3880 if (ulNumMinChildren || 3881 (swp.fl & (SWP_HIDE | SWP_MINIMIZE))) 3882 Rectl.yBottom += WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2; 3883 } 3884 else if (ulNumMinChildren) 3885 Rectl.yBottom += WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2; 3886 3887 AdjustSizeOfClient(NULL, 3888 &Rectl); 3889 3890 if (Rectl.xRight > 0L && 3891 (Rectl.yBottom < Rectl.yTop)) 3892 { 3893 3894 HENUM henum; 3895 3896 henum = WinBeginEnumWindows(hwndClient); 3897 if ((hwndChild = WinGetNextWindow(henum)) != (HWND) 0) 3898 { 3899 3900 ULONG ulCurRow, ulCurCol; 3901 SWP swp; 3902 USHORT id; 3903 3904 ulHeight = (Rectl.yTop - Rectl.yBottom) / ulNumRows; 3905 3906 for (ulCurRow = 0; 3907 ulCurRow < ulNumRows; 3908 ulCurRow++) 3909 { 3910 if ((ulNumRows - ulCurRow) <= ulExtraCols) 3911 ulNumCols++; 3912 for (ulCurCol = 0; 3913 ulCurCol < ulNumCols; 3914 ulCurCol++) 3915 { 3916 ulWidth = Rectl.xRight / ulNumCols; 3917 3918 while (hwndChild) 3919 { 3920 id = WinQueryWindowUShort(hwndChild, QWS_ID); 3921 if (id && 3922 (id != TREE_FRAME || fFreeTree)) 3923 { 3924 WinQueryWindowPos(hwndChild, &swp); 3925 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) 3926 break; 3927 } 3928 hwndChild = WinGetNextWindow(henum); 3929 } 3930 3931 if (hwndChild) 3932 { 3933 if (!absolute && 3934 (swp.fl & SWP_MAXIMIZE)) 3935 { 3936 WinGetMaxPosition(hwndChild, &swp); 3937 WinSetWindowPos(hwndChild, 3938 HWND_TOP, 3939 swp.x, 3940 swp.y, 3941 swp.cx, 3942 swp.cy, 3943 SWP_MOVE | SWP_SIZE | SWP_SHOW); 3944 WinSetWindowUShort(hwndChild, 3945 QWS_XRESTORE, 3946 (USHORT) (ulWidth * ulCurCol) + Rectl.xLeft); 3947 WinSetWindowUShort(hwndChild, 3948 QWS_YRESTORE, 3949 (USHORT) (Rectl.yTop - 3950 (ulHeight * (ulCurRow + 1L)))); 3951 WinSetWindowUShort(hwndChild, 3952 QWS_CXRESTORE, 3953 (USHORT) ulWidth); 3954 WinSetWindowUShort(hwndChild, 3955 QWS_CYRESTORE, 3956 (USHORT) ulHeight); 3957 } 3958 else 3959 WinSetWindowPos(hwndChild, 3960 HWND_TOP, 3961 (ulWidth * ulCurCol) + Rectl.xLeft, 3962 Rectl.yTop - (ulHeight * (ulCurRow + 1L)), 3963 ulWidth, 3964 ulHeight, 3965 SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE); 3966 hwndChild = WinGetNextWindow(henum); 3967 } 2842 3968 } 3969 if ((ulNumRows - ulCurRow) <= ulExtraCols) 3970 { 3971 ulNumCols--; 3972 ulExtraCols--; 3973 } 3974 } 3975 } 3976 WinEndEnumWindows(henum); 3977 } 3978 3979 fNoTileUpdate = FALSE; 2843 3980 } 2844 3981 2845 2846 VOID MoveChildrenAwayFromTree (HWND hwndClient) { 2847 2848 SWP swpC,swpT,swp; 2849 USHORT id; 2850 HWND hwndChild; 2851 HENUM henum; 2852 2853 if(fFreeTree) 2854 return; 2855 WinQueryWindowPos(hwndClient,&swpC); 2856 if(swpC.fl & (SWP_MINIMIZE | SWP_HIDE)) 2857 return; 2858 WinQueryWindowPos(hwndTree,&swpT); 2859 henum = WinBeginEnumWindows(hwndClient); 2860 while((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) { 2861 id = WinQueryWindowUShort(hwndChild,QWS_ID); 2862 if(!id || id == TREE_FRAME) 2863 continue; 2864 WinQueryWindowPos(hwndChild,&swp); 2865 if(!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) { 2866 if(swp.x < swpT.cx) { 2867 swp.x = swpT.cx; 2868 if(swp.x + swp.cx > swpC.cx) 2869 swp.cx = swpC.cx - swp.x; 2870 if(swp.cx > 24) 2871 WinSetWindowPos(hwndChild,HWND_TOP,swp.x,swp.y,swp.cx,swp.cy, 2872 SWP_SIZE | SWP_MOVE | SWP_SHOW); 2873 } 2874 } 3982 VOID ResizeChildren(HWND hwndClient, SHORT oldcx, SHORT oldcy, SHORT newcx, 3983 SHORT newcy) 3984 { 3985 /* 3986 * resize all children of the client to maintain their proportional 3987 * sizes and positions 3988 */ 3989 3990 if (!newcx || 3991 !newcy || 3992 !oldcx || 3993 !oldcy) 3994 return; 3995 { 3996 HENUM henum; 3997 HWND hwndChild; 3998 register LONG x, y, cx, cy, ucx, ucy, ux, uy; 3999 SWP swp; 4000 4001 henum = WinBeginEnumWindows(hwndClient); 4002 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) 4003 { 4004 if (!WinQueryWindowUShort(hwndChild, QWS_ID)) 4005 continue; 4006 if (WinQueryWindowPos(hwndChild, &swp)) 4007 { 4008 if (swp.fl & (SWP_MINIMIZE | SWP_HIDE)) 4009 { 4010 swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE); 4011 swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE); 4012 swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE); 4013 swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE); 2875 4014 } 2876 WinEndEnumWindows(henum); 4015 else if (swp.fl & SWP_MAXIMIZE) 4016 { 4017 swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE); 4018 swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE); 4019 swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE); 4020 swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE); 4021 } 4022 cx = (swp.cx) ? (LONG) (((double) oldcx * 100.0) / (double) swp.cx) : 0; 4023 cy = (swp.cy) ? (LONG) (((double) oldcy * 100.0) / (double) swp.cy) : 0; 4024 x = (swp.x) ? (LONG) (((double) oldcx * 100.0) / (double) swp.x) : 0; 4025 y = (swp.y) ? (LONG) (((double) oldcy * 100.0) / (double) swp.y) : 0; 4026 if (x < 0) 4027 x = 0; 4028 if (y < 0) 4029 y = 0; 4030 ux = (x) ? (LONG) (((double) newcx * 100.0) / (double) x) : 0; 4031 uy = (y) ? (LONG) (((double) newcy * 100.0) / (double) y) : 0; 4032 ucx = (cx) ? (LONG) (((double) newcx * 100.0) / (double) cx) : 0; 4033 ucy = (cy) ? (LONG) (((double) newcy * 100.0) / (double) cy) : 0; 4034 if (ux + ucx > newcx) 4035 ucx = newcx - ux; 4036 if (uy + ucy > newcy) 4037 ucy = newcy - uy; 4038 4039 if (!(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE))) 4040 WinSetWindowPos(hwndChild, HWND_TOP, ux, uy, ucx, ucy, 4041 SWP_MOVE | SWP_SIZE | SWP_SHOW); 4042 else if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) 4043 { 4044 WinSetWindowUShort(hwndChild, QWS_XMINIMIZE, (USHORT) - 1); 4045 WinSetWindowUShort(hwndChild, QWS_YMINIMIZE, (USHORT) - 1); 4046 WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0, 4047 SWP_SIZE | SWP_MOVE | SWP_FOCUSDEACTIVATE); 4048 WinSetWindowUShort(hwndChild, QWS_XRESTORE, ux); 4049 WinSetWindowUShort(hwndChild, QWS_YRESTORE, uy); 4050 WinSetWindowUShort(hwndChild, QWS_CXRESTORE, ucx); 4051 WinSetWindowUShort(hwndChild, QWS_CYRESTORE, ucy); 4052 } 4053 else 4054 { 4055 WinGetMaxPosition(hwndChild, &swp); 4056 WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy, 4057 SWP_MOVE | SWP_SIZE | SWP_SHOW); 4058 WinSetWindowUShort(hwndChild, QWS_XRESTORE, ux); 4059 WinSetWindowUShort(hwndChild, QWS_YRESTORE, uy); 4060 WinSetWindowUShort(hwndChild, QWS_CXRESTORE, ucx); 4061 WinSetWindowUShort(hwndChild, QWS_CYRESTORE, ucy); 4062 } 4063 } 4064 } 4065 WinEndEnumWindows(henum); 4066 } 4067 if (!fFreeTree) 4068 { 4069 4070 RECTL Rectl; 4071 SWP swp; 4072 4073 WinQueryWindowRect(hwndClient, &Rectl); 4074 AdjustSizeOfClient(NULL, &Rectl); 4075 WinQueryWindowPos(hwndTree, &swp); 4076 if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) 4077 { 4078 if (swp.y + swp.cy < Rectl.yTop - Rectl.yBottom) 4079 swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y; 4080 if (swp.x != 0) 4081 swp.x = 0; 4082 if (swp.y < 0) 4083 swp.y = 0; 4084 if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft) 4085 swp.cx = Rectl.xRight - Rectl.xLeft; 4086 WinSetWindowPos(hwndTree, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy, 4087 SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE); 4088 } 4089 } 2877 4090 } 2878 4091 2879 2880 VOID ArrangeIcons (HWND hwndClient) { 2881 2882 HENUM henum; 2883 HWND hwndChild; 2884 SWP swp; 2885 2886 henum = WinBeginEnumWindows(hwndClient); 2887 while((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) { 2888 WinQueryWindowPos(hwndChild,&swp); 2889 if(swp.fl & (SWP_MINIMIZE | SWP_HIDE)) { 2890 WinSetWindowUShort(hwndChild,QWS_XMINIMIZE,(USHORT)-1); 2891 WinSetWindowUShort(hwndChild,QWS_YMINIMIZE,(USHORT)-1); 2892 WinSetWindowPos(hwndChild,HWND_TOP,0,0,0,0, 2893 SWP_MOVE | SWP_SHOW | SWP_FOCUSDEACTIVATE); 2894 } 4092 VOID MinResChildren(HWND hwndClient, ULONG cmd) 4093 { 4094 4095 HENUM henum; 4096 HWND hwndChild; 4097 4098 { 4099 SWP swp; 4100 4101 WinQueryWindowPos(hwndClient, &swp); 4102 if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) 4103 return; 4104 } 4105 henum = WinBeginEnumWindows(hwndClient); 4106 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) 4107 { 4108 if (!WinQueryWindowUShort(hwndChild, QWS_ID)) 4109 continue; 4110 WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0, cmd); 4111 } 4112 } 4113 4114 MRESULT EXPENTRY ChildFrameButtonProc(HWND hwnd, ULONG msg, MPARAM mp1, 4115 MPARAM mp2) 4116 { 4117 4118 USHORT id; 4119 static BOOL emphasized = FALSE; 4120 4121 switch (msg) 4122 { 4123 case WM_BUTTON1CLICK: 4124 case WM_CHORD: 4125 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); 4126 break; 4127 4128 case WM_MOUSEMOVE: 4129 if (fOtherHelp) 4130 { 4131 if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) && 4132 !WinQueryCapture(HWND_DESKTOP)) 4133 { 4134 id = WinQueryWindowUShort(hwnd, QWS_ID); 4135 switch (id) 4136 { 4137 case IDM_OPENWALK: 4138 MakeBubble(hwnd, 4139 FALSE, 4140 GetPString(IDS_WALKBUTTONHELP)); 4141 break; 4142 case IDM_USERLIST: 4143 MakeBubble(hwnd, 4144 FALSE, 4145 GetPString(IDS_QUICKBUTTONHELP)); 4146 break; 2895 4147 } 2896 WinEndEnumWindows(henum); 4148 } 4149 } 4150 break; 4151 4152 case WM_BUTTON3CLICK: 4153 case WM_BUTTON2CLICK: 4154 { 4155 USHORT cmd = 0; 4156 4157 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); 4158 id = WinQueryWindowUShort(hwnd, QWS_ID); 4159 switch (id) 4160 { 4161 case IDM_OPENWALK: 4162 switch (msg) 4163 { 4164 case WM_BUTTON2CLICK: 4165 if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) == 4166 (KC_ALT | KC_SHIFT | KC_CTRL)) 4167 cmd = IDM_GREP; 4168 else if ((shiftstate & (KC_ALT | KC_CTRL)) == 4169 (KC_ALT | KC_CTRL)) 4170 CascadeChildren(hwndMain); 4171 4172 #ifdef NEVER 4173 else if ((shiftstate & (KC_ALT | KC_SHIFT)) == 4174 (KC_ALT | KC_SHIFT)) 4175 cmd = IDM_SYSINFO; 4176 #endif 4177 4178 else if (shiftstate & KC_SHIFT) 4179 cmd = IDM_WINDOWDLG; 4180 else if (shiftstate & KC_CTRL) 4181 cmd = IDM_SEEALL; 4182 else if (shiftstate & KC_ALT) 4183 TileChildren(hwndMain, TRUE); 4184 else 4185 cmd = IDM_WALKDIR; 4186 break; 4187 case WM_BUTTON3CLICK: 4188 TileChildren(hwndMain, TRUE); 4189 break; 4190 } 4191 break; 4192 case IDM_USERLIST: 4193 switch (msg) 4194 { 4195 case WM_BUTTON2CLICK: 4196 if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) == 4197 (KC_ALT | KC_SHIFT | KC_CTRL)) 4198 cmd = IDM_COLORPALETTE; 4199 else if ((shiftstate & (KC_ALT | KC_CTRL)) == 4200 (KC_ALT | KC_CTRL)) 4201 cmd = IDM_HIDEMENU; 4202 else if ((shiftstate & (KC_ALT | KC_SHIFT)) == 4203 (KC_ALT | KC_SHIFT)) 4204 cmd = IDM_NOTEBOOK; 4205 else if (shiftstate & KC_SHIFT) 4206 cmd = IDM_TOOLTITLES; 4207 else if (shiftstate & KC_CTRL) 4208 cmd = IDM_TEXTTOOLS; 4209 else if (shiftstate & KC_ALT) 4210 cmd = IDM_FONTPALETTE; 4211 else 4212 cmd = IDM_TOOLBAR; 4213 break; 4214 case WM_BUTTON3CLICK: 4215 cmd = IDM_DRIVEBAR; 4216 break; 4217 } 4218 break; 4219 } 4220 if (cmd) 4221 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_CLIENT), 4222 WM_COMMAND, 4223 MPFROM2SHORT(cmd, 0), 4224 MPVOID); 4225 } 4226 break; 4227 4228 case DM_DRAGOVER: 4229 id = WinQueryWindowUShort(hwnd, QWS_ID); 4230 if (id == IDM_OPENWALK) 4231 { 4232 if (!emphasized) 4233 { 4234 emphasized = TRUE; 4235 DrawTargetEmphasis(hwnd, emphasized); 4236 } 4237 if (AcceptOneDrop(mp1, mp2)) 4238 return MRFROM2SHORT(DOR_DROP, 4239 DO_MOVE); 4240 } 4241 return MRFROM2SHORT(DOR_NEVERDROP, 0); 4242 4243 case DM_DRAGLEAVE: 4244 if (emphasized) 4245 { 4246 emphasized = FALSE; 4247 DrawTargetEmphasis(hwnd, emphasized); 4248 } 4249 break; 4250 4251 case DM_DROPHELP: 4252 DropHelp(mp1, mp2, hwnd, GetPString(IDS_OPENDROPHELP)); 4253 return 0; 4254 4255 case DM_DROP: 4256 { 4257 char szFrom[CCHMAXPATH + 2]; 4258 4259 if (emphasized) 4260 { 4261 emphasized = FALSE; 4262 DrawTargetEmphasis(hwnd, 4263 emphasized); 4264 } 4265 if (GetOneDrop(mp1, 4266 mp2, 4267 szFrom, 4268 sizeof(szFrom))) 4269 { 4270 if (MakeValidDir(szFrom) && 4271 !FindDirCnrByName(szFrom, TRUE)) 4272 { 4273 OpenDirCnr((HWND) 0, 4274 hwndMain, 4275 hwndTree, 4276 FALSE, 4277 szFrom); 4278 } 4279 } 4280 } 4281 return 0; 4282 4283 case WM_CLOSE: 4284 WinDestroyWindow(hwnd); 4285 return 0; 4286 } 4287 return PFNWPButton(hwnd, msg, mp1, mp2); 2897 4288 } 2898 4289 2899 2900 VOID NextChild (HWND hwndClient,BOOL previous) { 2901 2902 HENUM henum; 2903 HWND hwndActive,hwndNext,hwndPrev = (HWND)0; 2904 BOOL next = FALSE,once = FALSE; 2905 2906 previous = !previous; 2907 2908 hwndActive = WinQueryActiveWindow(hwndClient); 2909 if(!hwndActive) 2910 next = TRUE; 2911 henum = WinBeginEnumWindows(hwndClient); 2912 for(;;) { 2913 hwndNext = WinGetNextWindow(henum); 2914 if(hwndNext) { 2915 if(!WinQueryWindowUShort(hwndNext,QWS_ID)) 2916 continue; 2917 if(next) 2918 break; 2919 if(hwndNext == hwndActive) { 2920 if(!previous && hwndPrev) { 2921 hwndNext = hwndPrev; 2922 break; 2923 } 2924 else if(previous) 2925 next = TRUE; 2926 } 2927 hwndPrev = hwndNext; 2928 } 2929 else { 2930 if((!next && previous) || once) 2931 break; 2932 else if(!previous) { 2933 hwndNext = hwndPrev; 2934 break; 2935 } 2936 else 2937 once = next = TRUE; 2938 } 4290 MRESULT EXPENTRY MainFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 4291 { 4292 4293 PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER); 4294 static ULONG aheight = 0L; 4295 4296 switch (msg) 4297 { 4298 case WM_ADJUSTWINDOWPOS: 4299 { 4300 SWP *pswp; 4301 4302 pswp = (SWP *) mp1; 4303 if (fDataMin && !fAmClosing) 4304 { 4305 if (pswp -> fl & (SWP_HIDE | SWP_MINIMIZE)) 4306 { 4307 4308 SWP swp; 4309 4310 WinQueryWindowPos(hwnd, &swp); 4311 PostMsg(hwnd, 4312 UM_FOCUSME, 4313 MPFROMLONG(swp.fl), 4314 MPVOID); 4315 HideNote(); 2939 4316 } 2940 WinEndEnumWindows(henum); 2941 2942 if(hwndNext && hwndNext != hwndActive) { 2943 WinSetWindowPos(hwndNext,HWND_TOP,0,0,0,0,SWP_ZORDER | SWP_ACTIVATE); 2944 WinSetWindowPos(hwndActive,((previous) ? HWND_BOTTOM : hwndNext), 2945 0,0,0,0,SWP_ZORDER); 4317 else if (pswp -> fl & (SWP_SHOW | SWP_RESTORE)) 4318 { 4319 if (DataHwnd) 4320 PostMsg(DataHwnd, 4321 WM_CLOSE, 4322 MPVOID, 4323 MPVOID); 2946 4324 } 4325 } 4326 if (!fAmClosing) 4327 { 4328 if (pswp -> fl & (SWP_HIDE | SWP_MINIMIZE)) 4329 HideNote(); 4330 } 4331 } 4332 break; 4333 4334 case UM_FOCUSME: 4335 CreateDataBar(HWND_DESKTOP, (ULONG) mp1); 4336 return 0; 4337 4338 case WM_BUTTON1UP: 4339 case WM_BUTTON2UP: 4340 case WM_BUTTON3UP: 4341 case WM_MOUSEMOVE: 4342 case WM_CHORD: 4343 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); 4344 break; 4345 4346 case WM_CHAR: 4347 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL)); 4348 break; 4349 4350 case WM_CONTROL: 4351 return WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), UM_CONTROL, mp1, mp2); 4352 4353 case WM_COMMAND: 4354 return WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), msg, mp1, mp2); 4355 4356 case WM_CALCFRAMERECT: 4357 { 4358 MRESULT mr; 4359 PRECTL prectl; 4360 LONG sheight = 20, bheight = 20; 4361 4362 mr = oldproc(hwnd, msg, mp1, mp2); 4363 4364 /* 4365 * Calculate the position of the client rectangle. 4366 * Otherwise, we'll see a lot of redraw when we move the 4367 * client during WM_FORMATFRAME. 4368 */ 4369 4370 if (mr && mp2) 4371 { 4372 prectl = (PRECTL) mp1; 4373 if (prectl -> yBottom != prectl -> yTop) 4374 { 4375 { 4376 HPS hps; 4377 POINTL aptl[TXTBOX_COUNT]; 4378 4379 hps = WinGetPS(hwndStatus); 4380 if (hps) 4381 { 4382 GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl); 4383 bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6; 4384 WinReleasePS(hps); 4385 } 4386 } 4387 prectl -> yBottom += (sheight + 4); 4388 prectl -> yTop -= (sheight + 4); 4389 if (fMoreButtons) 4390 { 4391 4392 HPS hps; 4393 POINTL aptl[TXTBOX_COUNT]; 4394 4395 hps = WinGetPS(hwndName); 4396 if (hps) 4397 { 4398 GpiQueryTextBox(hps, 4399 6, 4400 "$`WjgT", 4401 TXTBOX_COUNT, 4402 aptl); 4403 bheight = aptl[TXTBOX_TOPLEFT].y + 6; 4404 WinReleasePS(hps); 4405 } 4406 prectl -> yBottom += (bheight + 4); 4407 prectl -> yTop -= (bheight + 4); 4408 } 4409 if (fToolbar) 4410 { 4411 if (!fTextTools) 4412 prectl -> yTop -= ((fToolTitles) ? 50 : 40); 4413 else 4414 prectl -> yTop -= 32; 4415 } 4416 if (fDrivebar) 4417 { 4418 ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES), 4419 ((prectl -> xRight - 4420 (WinQuerySysValue(HWND_DESKTOP, 4421 SV_CYSIZEBORDER) * 2)) - 4)); 4422 prectl -> yTop -= (16 * (DriveLines * 18)); 4423 } 4424 if (fUserComboBox) 4425 { 4426 if (!aheight) 4427 { 4428 4429 SWP swpTemp; 4430 4431 WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT), 4432 &swpTemp); 4433 aheight = swpTemp.cy; 4434 } 4435 prectl -> yTop -= (aheight + 6L); 4436 } 4437 if (fAutoView) 4438 { 4439 AutoviewHeight = min(AutoviewHeight, 4440 (prectl -> yTop - prectl -> yBottom) - 116); 4441 AutoviewHeight = max(AutoviewHeight, 36); 4442 prectl -> yBottom += (AutoviewHeight + 6); 4443 } 4444 } 4445 } 4446 return mr; 4447 } 4448 4449 case WM_FORMATFRAME: 4450 { 4451 SHORT sCount, soldCount; 4452 PSWP pswp, pswpClient, pswpNew; 4453 SWP swpClient; 4454 LONG theight = 48L, dheight = 20L, width, sheight = 20, bheight = 20; 4455 4456 sCount = (SHORT) oldproc(hwnd, msg, mp1, mp2); 4457 soldCount = sCount; 4458 4459 /* 4460 * Reformat the frame to "squeeze" the client 4461 * and make room for status window sibling beneath 4462 * and toolbar above (if toolbar's on) and userlists 4463 * (if userlists are on). 4464 */ 4465 4466 pswp = (PSWP) mp1; 4467 { 4468 SHORT x; 4469 4470 for (x = 0; x < soldCount; x++) 4471 { 4472 if (WinQueryWindowUShort(pswp -> hwnd, QWS_ID) == FID_CLIENT) 4473 { 4474 pswpClient = pswp; 4475 break; 4476 } 4477 pswp++; 4478 } 4479 } 4480 4481 { 4482 HPS hps; 4483 POINTL aptl[TXTBOX_COUNT]; 4484 4485 hps = WinGetPS(hwndStatus); 4486 if (hps) 4487 { 4488 GpiQueryTextBox(hps, 4489 6, 4490 "$`WjgT", 4491 TXTBOX_COUNT, 4492 aptl); 4493 bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6; 4494 WinReleasePS(hps); 4495 } 4496 if (fMoreButtons) 4497 { 4498 hps = WinGetPS(hwndName); 4499 if (hps) 4500 { 4501 GpiQueryTextBox(hps, 4502 6, 4503 "$`WjgT", 4504 TXTBOX_COUNT, 4505 aptl); 4506 bheight = aptl[TXTBOX_TOPLEFT].y + 6; 4507 WinReleasePS(hps); 4508 } 4509 } 4510 } 4511 pswpNew = (PSWP) mp1 + soldCount; 4512 *pswpNew = *pswpClient; 4513 swpClient = *pswpClient; 4514 pswpNew -> hwnd = hwndStatus; 4515 pswpNew -> hwndInsertBehind = HWND_BOTTOM; 4516 pswpNew -> x = swpClient.x + 3; 4517 pswpNew -> y = swpClient.y + 2; 4518 if (!fSplitStatus) 4519 width = swpClient.cx - (16 + (sheight * 2) + 4); 4520 else 4521 width = (swpClient.cx - (16 + (sheight * 2) + 4)) / 2; 4522 width = max(width, 10); 4523 if (fSplitStatus) 4524 pswpNew -> cx = width - 6; 4525 else 4526 pswpNew -> cx = width - 8; 4527 pswpNew -> cy = sheight; 4528 pswpClient -> y = pswpNew -> y + pswpNew -> cy + 3; 4529 pswpClient -> cy = (swpClient.cy - pswpNew -> cy) - 3; 4530 sCount++; 4531 4532 if (fSplitStatus) 4533 { 4534 pswpNew = (PSWP) mp1 + (soldCount + 1); 4535 *pswpNew = *pswpClient; 4536 pswpNew -> hwnd = hwndStatus2; 4537 pswpNew -> hwndInsertBehind = HWND_BOTTOM; 4538 pswpNew -> x = width + 8; 4539 pswpNew -> y = swpClient.y + 2; 4540 pswpNew -> cx = width - 6; 4541 pswpNew -> cy = sheight; 4542 sCount++; 4543 } 4544 else 4545 { 4546 WinShowWindow(hwndStatus2, FALSE); 4547 WinSetWindowText(hwndStatus2, 4548 NullStr); 4549 } 4550 4551 if (fToolbar) 4552 { 4553 if (fTextTools) 4554 theight = 32L; 4555 else if (!fToolTitles) 4556 theight = 40L; 4557 pswpNew = (PSWP) mp1 + (soldCount + 1 + 4558 (fSplitStatus != FALSE)); 4559 *pswpNew = *pswpClient; 4560 pswpNew -> hwnd = WinWindowFromID(hwnd, MAIN_TOOLS); 4561 pswpNew -> hwndInsertBehind = HWND_BOTTOM; 4562 pswpNew -> x = swpClient.x + 2; 4563 pswpNew -> y = (swpClient.y + swpClient.cy) - (theight - 2); 4564 pswpNew -> cx = swpClient.cx - 4; 4565 pswpNew -> cy = theight - 4; 4566 pswpClient -> cy -= theight; 4567 sCount++; 4568 } 4569 else 4570 WinShowWindow(WinWindowFromID(hwnd, MAIN_TOOLS), FALSE); 4571 4572 if (fDrivebar) 4573 { 4574 ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES), 4575 pswpClient -> cx - 4); 4576 pswpNew = (PSWP) mp1 + (soldCount + 1 + 4577 (fSplitStatus != FALSE) + 4578 (fToolbar != FALSE)); 4579 *pswpNew = *pswpClient; 4580 pswpNew -> hwnd = WinWindowFromID(hwnd, MAIN_DRIVES); 4581 pswpNew -> hwndInsertBehind = HWND_BOTTOM; 4582 pswpNew -> x = swpClient.x + 2; 4583 dheight += ((dheight - 2) * DriveLines); 4584 pswpNew -> y = (swpClient.y + swpClient.cy) - (dheight - 2); 4585 if (fToolbar) 4586 pswpNew -> y -= theight; 4587 pswpNew -> cx = swpClient.cx - 4; 4588 pswpNew -> cy = dheight - 4; 4589 pswpClient -> cy -= dheight; 4590 sCount++; 4591 } 4592 else 4593 WinShowWindow(WinWindowFromID(hwnd, MAIN_DRIVES), FALSE); 4594 4595 if (fAutoView) 4596 { 4597 pswpNew = (PSWP) mp1 + (soldCount + 1 + 4598 (fToolbar != FALSE) + 4599 (fDrivebar != FALSE) + 4600 (fSplitStatus != FALSE)); 4601 *pswpNew = *pswpClient; 4602 pswpNew -> hwnd = (fComments) ? hwndAutoMLE : hwndAutoview; 4603 pswpNew -> x = pswpClient -> x + 3; 4604 pswpNew -> y = pswpClient -> y + 3; 4605 if (fMoreButtons) 4606 pswpNew -> y += (bheight + 4); 4607 pswpNew -> cx = pswpClient -> cx - 6; 4608 AutoviewHeight = min(AutoviewHeight, 4609 pswpClient -> cy - 116); 4610 AutoviewHeight = max(AutoviewHeight, 36); 4611 pswpNew -> cy = AutoviewHeight; 4612 pswpClient -> y += (AutoviewHeight + 6); 4613 pswpClient -> cy -= (AutoviewHeight + 6); 4614 sCount++; 4615 WinShowWindow((fComments) ? hwndAutoview : hwndAutoMLE, FALSE); 4616 } 4617 else 4618 { 4619 WinShowWindow(hwndAutoview, FALSE); 4620 WinShowWindow(hwndAutoMLE, FALSE); 4621 } 4622 4623 pswpNew = (PSWP) mp1 + (soldCount + 1 + 4624 (fToolbar != FALSE) + 4625 (fDrivebar != FALSE) + 4626 (fSplitStatus != FALSE) + 4627 (fAutoView != FALSE)); 4628 *pswpNew = *pswpClient; 4629 pswpNew -> hwnd = WinWindowFromID(hwnd, IDM_OPENWALK); 4630 pswpNew -> x = swpClient.cx - ((sheight * 2) + 4); 4631 pswpNew -> y = swpClient.y; 4632 pswpNew -> cx = sheight + 4; 4633 pswpNew -> cy = sheight + 4; 4634 sCount++; 4635 pswpNew = (PSWP) mp1 + (soldCount + 2 + 4636 (fToolbar != FALSE) + 4637 (fDrivebar != FALSE) + 4638 (fSplitStatus != FALSE) + 4639 (fAutoView != FALSE)); 4640 *pswpNew = *pswpClient; 4641 pswpNew -> hwnd = WinWindowFromID(hwnd, IDM_USERLIST); 4642 pswpNew -> x = swpClient.cx - (sheight + 2); 4643 pswpNew -> y = swpClient.y; 4644 pswpNew -> cx = sheight + 4; 4645 pswpNew -> cy = sheight + 4; 4646 sCount++; 4647 pswpNew = (PSWP) mp1 + (soldCount + 3 + 4648 (fToolbar != FALSE) + 4649 (fDrivebar != FALSE) + 4650 (fSplitStatus != FALSE) + 4651 (fAutoView != FALSE)); 4652 *pswpNew = *pswpClient; 4653 pswpNew -> hwnd = WinWindowFromID(hwnd, MAIN_LED); 4654 pswpNew -> x = swpClient.cx - ((sheight * 2) + 16); 4655 pswpNew -> y = swpClient.y; 4656 pswpNew -> cx = 12; 4657 pswpNew -> cy = 12; 4658 sCount++; 4659 pswpNew = (PSWP) mp1 + (soldCount + 4 + 4660 (fToolbar != FALSE) + 4661 (fDrivebar != FALSE) + 4662 (fSplitStatus != FALSE) + 4663 (fAutoView != FALSE)); 4664 *pswpNew = *pswpClient; 4665 pswpNew -> hwnd = WinWindowFromID(hwnd, MAIN_LEDHDR); 4666 pswpNew -> x = swpClient.cx - ((sheight * 2) + 16); 4667 pswpNew -> y = swpClient.y + 12; 4668 pswpNew -> cx = 12; 4669 pswpNew -> cy = sheight - 8; 4670 sCount++; 4671 if (fUserComboBox) 4672 { 4673 if (!aheight) 4674 { 4675 4676 SWP swpTemp; 4677 4678 WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT), 4679 &swpTemp); 4680 aheight = swpTemp.cy; 4681 } 4682 pswpNew = (PSWP) mp1 + (soldCount + 5 + 4683 (fToolbar != FALSE) + 4684 (fSplitStatus != FALSE) + 4685 (fDrivebar != FALSE) + 4686 (fAutoView != FALSE)); 4687 *pswpNew = *pswpClient; 4688 pswpNew -> hwnd = hwndDrivelist; 4689 pswpNew -> x = swpClient.x; 4690 pswpNew -> cx = 48; 4691 pswpClient -> cy -= (aheight + 6L); 4692 pswpNew -> y = pswpClient -> y; 4693 pswpNew -> cy = pswpClient -> cy + (aheight + 5L); 4694 sCount++; 4695 pswpNew = (PSWP) mp1 + (soldCount + 6 + 4696 (fToolbar != FALSE) + 4697 (fDrivebar != FALSE) + 4698 (fSplitStatus != FALSE) + 4699 (fAutoView != FALSE)); 4700 *pswpNew = *pswpClient; 4701 pswpNew -> hwnd = hwndStatelist; 4702 pswpNew -> x = swpClient.x + 48; 4703 pswpNew -> cx = (swpClient.cx - 48) / 7; 4704 pswpNew -> y = pswpClient -> y; 4705 pswpNew -> cy = pswpClient -> cy + (aheight + 5L); 4706 sCount++; 4707 pswpNew = (PSWP) mp1 + (soldCount + 7 + 4708 (fToolbar != FALSE) + 4709 (fDrivebar != FALSE) + 4710 (fSplitStatus != FALSE) + 4711 (fAutoView != FALSE)); 4712 *pswpNew = *pswpClient; 4713 pswpNew -> hwnd = hwndCmdlist; 4714 pswpNew -> x = swpClient.x + 48 + ((swpClient.cx - 48) / 7); 4715 pswpNew -> cx = (swpClient.cx - 48) / 5 + 4716 ((swpClient.cx - 48) / 5) - ((swpClient.cx - 48) / 7); 4717 pswpNew -> y = pswpClient -> y; 4718 pswpNew -> cy = pswpClient -> cy + (aheight + 5L); 4719 sCount++; 4720 pswpNew = (PSWP) mp1 + (soldCount + 8 + 4721 (fToolbar != FALSE) + 4722 (fDrivebar != FALSE) + 4723 (fSplitStatus != FALSE) + 4724 (fAutoView != FALSE)); 4725 *pswpNew = *pswpClient; 4726 pswpNew -> hwnd = hwndUserlist; 4727 pswpNew -> x = swpClient.x + 48 + (((swpClient.cx - 48) / 5) * 2); 4728 pswpNew -> cx = ((swpClient.x + swpClient.cx) - pswpNew -> x) - 4729 ((fToolbar) ? 4730 ((swpClient.cx - 48) / 7) : 0); 4731 pswpNew -> y = pswpClient -> y; 4732 pswpNew -> cy = pswpClient -> cy + (aheight + 5L); 4733 sCount++; 4734 if (fToolbar) 4735 { 4736 pswpNew = (PSWP) mp1 + (soldCount + 9 + 4737 (fToolbar != FALSE) + 4738 (fDrivebar != FALSE) + 4739 (fSplitStatus != FALSE) + 4740 (fAutoView != FALSE)); 4741 *pswpNew = *pswpClient; 4742 pswpNew -> hwnd = hwndButtonlist; 4743 pswpNew -> x = swpClient.cx - ((swpClient.cx - 48) / 7) + 4; 4744 pswpNew -> cx = (swpClient.x + swpClient.cx) - pswpNew -> x; 4745 pswpNew -> y = pswpClient -> y; 4746 pswpNew -> cy = pswpClient -> cy + (aheight + 5L); 4747 sCount++; 4748 } 4749 else 4750 WinShowWindow(hwndButtonlist, FALSE); 4751 } 4752 else 4753 { 4754 WinShowWindow(hwndUserlist, FALSE); 4755 WinShowWindow(hwndDrivelist, FALSE); 4756 WinShowWindow(hwndStatelist, FALSE); 4757 WinShowWindow(hwndButtonlist, FALSE); 4758 WinShowWindow(hwndCmdlist, FALSE); 4759 } 4760 { 4761 PSWP pswpTitlebar = (PSWP) 0, pswpMinbutton = (PSWP) 0; 4762 SHORT x; 4763 4764 pswpNew = (PSWP) mp1 + (soldCount + 5 + 4765 (fToolbar != FALSE) + 4766 (fDrivebar != FALSE) + 4767 (fSplitStatus != FALSE) + 4768 (fAutoView != FALSE) + 4769 ((fUserComboBox != FALSE) * 4) + 4770 (fUserComboBox != FALSE && 4771 fToolbar != FALSE)); 4772 pswp = (PSWP) mp1; 4773 for (x = 0; x < soldCount; x++) 4774 { 4775 if (!pswpTitlebar && 4776 WinQueryWindowUShort(pswp -> hwnd, QWS_ID) == FID_TITLEBAR) 4777 pswpTitlebar = pswp; 4778 else if (!pswpMinbutton && 4779 WinQueryWindowUShort(pswp -> hwnd, QWS_ID) == FID_MINMAX) 4780 pswpMinbutton = pswp; 4781 if (pswpTitlebar && 4782 pswpMinbutton) 4783 break; 4784 pswp++; 4785 } 4786 if (pswpMinbutton && 4787 pswpTitlebar) 4788 { 4789 *pswpNew = *pswpMinbutton; 4790 pswpNew -> hwnd = WinWindowFromID(hwnd, IDM_IDEALSIZE); 4791 pswpNew -> cy = pswpMinbutton -> cy + 3; 4792 pswpNew -> cx = min(pswpNew -> cy, (pswpMinbutton -> cx / 2) + 3); 4793 pswpTitlebar -> cx -= (pswpNew -> cx - 1); 4794 pswpNew -> x = pswpTitlebar -> x + (pswpTitlebar -> cx); 4795 pswpNew -> y = pswpMinbutton -> y - 1; 4796 sCount++; 4797 } 4798 else 4799 WinShowWindow(WinWindowFromID(hwnd, IDM_IDEALSIZE), FALSE); 4800 } 4801 4802 if (fMoreButtons) 4803 { 4804 4805 LONG lastx; 4806 4807 pswpNew = (PSWP) mp1 + (soldCount + 6 + 4808 (fToolbar != FALSE) + 4809 (fDrivebar != FALSE) + 4810 (fSplitStatus != FALSE) + 4811 (fAutoView != FALSE) + 4812 ((fUserComboBox != FALSE) * 4) + 4813 (fUserComboBox != FALSE && 4814 fToolbar != FALSE)); 4815 *pswpNew = *pswpClient; 4816 pswpNew -> hwnd = hwndName; 4817 pswpNew -> x = swpClient.x + 3; 4818 pswpNew -> y = swpClient.y + (sheight + 6); 4819 pswpNew -> cx = ((swpClient.cx / 2) + (swpClient.cx / 5)) - 3; 4820 lastx = pswpNew -> x + pswpNew -> cx; 4821 pswpNew -> cy = bheight; 4822 pswpClient -> y += (bheight + 4); 4823 pswpClient -> cy -= (bheight + 4); 4824 sCount++; 4825 pswpNew = (PSWP) mp1 + (soldCount + 7 + 4826 (fToolbar != FALSE) + 4827 (fDrivebar != FALSE) + 4828 (fSplitStatus != FALSE) + 4829 (fAutoView != FALSE) + 4830 ((fUserComboBox != FALSE) * 4) + 4831 (fUserComboBox != FALSE && 4832 fToolbar != FALSE)); 4833 *pswpNew = *pswpClient; 4834 pswpNew -> hwnd = hwndDate; 4835 pswpNew -> x = lastx + 3; 4836 pswpNew -> y = swpClient.y + (sheight + 6); 4837 pswpNew -> cx = (swpClient.cx / 6) + (swpClient.cx / 16) - 3; 4838 lastx = pswpNew -> x + pswpNew -> cx; 4839 pswpNew -> cy = bheight; 4840 sCount++; 4841 pswpNew = (PSWP) mp1 + (soldCount + 8 + 4842 (fToolbar != FALSE) + 4843 (fDrivebar != FALSE) + 4844 (fSplitStatus != FALSE) + 4845 (fAutoView != FALSE) + 4846 ((fUserComboBox != FALSE) * 4) + 4847 (fUserComboBox != FALSE && 4848 fToolbar != FALSE)); 4849 *pswpNew = *pswpClient; 4850 pswpNew -> hwnd = hwndAttr; 4851 pswpNew -> x = lastx + 3; 4852 pswpNew -> y = swpClient.y + (sheight + 6); 4853 pswpNew -> cx = (swpClient.cx - pswpNew -> x) - 1; 4854 pswpNew -> cy = bheight; 4855 sCount++; 4856 } 4857 else 4858 { 4859 WinShowWindow(hwndAttr, FALSE); 4860 WinShowWindow(hwndName, FALSE); 4861 WinShowWindow(hwndDate, FALSE); 4862 } 4863 return MRFROMSHORT(sCount); 4864 } 4865 4866 case WM_QUERYFRAMECTLCOUNT: 4867 { 4868 SHORT sCount; 4869 4870 sCount = (SHORT) oldproc(hwnd, msg, mp1, mp2); 4871 4872 sCount += 6; 4873 if (fSplitStatus) 4874 sCount++; 4875 if (fToolbar) 4876 sCount++; 4877 if (fUserComboBox) 4878 { 4879 sCount += 4; 4880 if (fToolbar) 4881 sCount++; 4882 } 4883 if (fDrivebar) 4884 sCount++; 4885 if (fAutoView) 4886 sCount++; 4887 if (fMoreButtons) 4888 sCount += 3; 4889 return MRFROMSHORT(sCount); 4890 } 4891 4892 case WM_CLOSE: 4893 WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), msg, mp1, mp2); 4894 return 0; 4895 } 4896 return oldproc(hwnd, msg, mp1, mp2); 2947 4897 } 2948 4898 2949 2950 BOOL CloseChildren (HWND hwndClient) { 2951 2952 HENUM henum; 2953 HWND hwndChild; 2954 BOOL ret = FALSE; 2955 2956 fNoTileUpdate = TRUE; 2957 henum = WinBeginEnumWindows(hwndClient); 2958 while((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) { 2959 if(hwndChild != hwndTree) { 2960 WinSendMsg(WinWindowFromID(hwndChild,FID_CLIENT), 2961 WM_SAVEAPPLICATION, 2962 MPVOID, 2963 MPVOID); 2964 if(WinSendMsg(WinWindowFromID(hwndChild,FID_CLIENT), 2965 WM_CLOSE, 2966 MPVOID, 2967 MPVOID)) { 2968 ret = TRUE; 2969 break; 2970 } 2971 } 2972 } 2973 WinEndEnumWindows(henum); 2974 fNoTileUpdate = FALSE; 2975 return ret; 2976 } 2977 2978 2979 BOOL CloseDirCnrChildren (HWND hwndClient) { 2980 2981 /* returns TRUE if a directory container window was told to close */ 2982 2983 HENUM henum; 2984 HWND hwndChild,hwndDir,hwndTemp; 2985 BOOL ret = FALSE; 2986 2987 fNoTileUpdate = TRUE; 2988 henum = WinBeginEnumWindows(hwndClient); 2989 while((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) { 2990 if(hwndChild != hwndTree) { 2991 hwndTemp = WinWindowFromID(hwndChild,FID_CLIENT); 2992 if(hwndTemp) { 2993 hwndDir = WinWindowFromID(hwndTemp,DIR_CNR); 2994 if(hwndDir) { 2995 WinSendMsg(WinWindowFromID(hwndChild,FID_CLIENT), 2996 WM_CLOSE, 2997 MPVOID, 2998 MPVOID); 2999 ret = TRUE; 3000 } 3001 } 3002 } 3003 } 3004 WinEndEnumWindows(henum); 3005 fNoTileUpdate = FALSE; 3006 return ret; 3007 } 3008 3009 3010 BOOL SaveDirCnrState (HWND hwndClient,CHAR *name) { 3011 3012 /* returns TRUE if any directory container windows existed */ 3013 3014 HENUM henum; 3015 HWND hwndChild,hwndDir,hwndC; 3016 ULONG numsaves = 0,flWindowAttr; 3017 CHAR s[120],directory[CCHMAXPATH]; 3018 SWP swp; 3019 BOOL ret = FALSE; 3020 DIRCNRDATA *dcd; 3021 3022 henum = WinBeginEnumWindows(hwndClient); 3023 while((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) { 3024 if(hwndChild != hwndTree) { 3025 hwndC = WinWindowFromID(hwndChild,FID_CLIENT); 3026 if(hwndC) { 3027 hwndDir = WinWindowFromID(hwndC,DIR_CNR); 3028 if(hwndDir) { 3029 WinQueryWindowPos(hwndChild,&swp); 3030 *directory = 0; 3031 WinSendMsg(hwndC,UM_CONTAINERDIR,MPFROMP(directory),MPVOID); 3032 if(*directory) { 3033 sprintf(s,"%s%sDirCnrPos.%lu",(name) ? name : NullStr,(name) ? "." : NullStr, 3034 numsaves); 3035 PrfWriteProfileData(fmprof, 3036 FM3Str, 3037 s, 3038 (PVOID)&swp, 3039 sizeof(SWP)); 3040 dcd = WinQueryWindowPtr(WinWindowFromID(hwndC,DIR_CNR),QWL_USER); 3041 if(dcd) { 3042 sprintf(s,"%s%sDirCnrSort.%lu",(name) ? name : NullStr,(name) ? "." : NullStr, 3043 numsaves); 3044 PrfWriteProfileData(fmprof,FM3Str,s,(PVOID)&dcd->sortFlags, 3045 sizeof(INT)); 3046 sprintf(s,"%s%sDirCnrFilter.%lu",(name) ? name : NullStr,(name) ? "." : NullStr, 3047 numsaves); 3048 PrfWriteProfileData(fmprof,FM3Str,s,(PVOID)&dcd->mask, 3049 sizeof(MASK)); 3050 sprintf(s,"%s%sDirCnrView.%lu",(name) ? name : NullStr,(name) ? "." : NullStr, 3051 numsaves); 3052 flWindowAttr = dcd->flWindowAttr; 3053 if(!fLeaveTree && (flWindowAttr & CV_TREE)) { 3054 flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT)); 3055 if(dcd->lastattr) { 3056 if(dcd->lastattr & CV_TEXT) 3057 flWindowAttr |= CV_TEXT; 3058 else if(dcd->lastattr & CV_DETAIL) 3059 flWindowAttr |= CV_DETAIL; 3060 else if(dcd->lastattr & CV_ICON) 3061 flWindowAttr |= CV_ICON; 3062 else 3063 flWindowAttr |= CV_NAME; 3064 } 3065 else 3066 flWindowAttr |= CV_NAME; 3067 } 3068 PrfWriteProfileData(fmprof,FM3Str,s,(PVOID)&flWindowAttr, 3069 sizeof(ULONG)); 3070 } 3071 sprintf(s,"%s%sDirCnrDir.%lu",(name) ? name : NullStr,(name) ? "." : NullStr, 3072 numsaves++); 3073 PrfWriteProfileString(fmprof,FM3Str,s,directory); 3074 ret = TRUE; 3075 } 3076 } 3077 } 3078 } 3079 } 3080 WinEndEnumWindows(henum); 3081 if(ret) { 3082 if(WinQueryWindowPos(hwndTree,&swp)) { 3083 sprintf(s,"%s%sLastTreePos",(name) ? name : NullStr,(name) ? "." : NullStr); 3084 PrfWriteProfileData(fmprof,FM3Str,s,(PVOID)&swp,sizeof(SWP)); 3085 } 3086 sprintf(s,"%s%sNumDirsLastTime",(name) ? name : NullStr,(name) ? "." : NullStr); 3087 PrfWriteProfileData(fmprof,FM3Str,s,(PVOID)&numsaves,sizeof(ULONG)); 3088 WinQueryWindowPos(WinQueryWindow(hwndClient,QW_PARENT),&swp); 3089 sprintf(s,"%s%sMySizeLastTime",(name) ? name : NullStr,(name) ? "." : NullStr); 3090 PrfWriteProfileData(fmprof,FM3Str,s,(PVOID)&swp,sizeof(SWP)); 3091 } 3092 return ret; 3093 } 3094 3095 3096 VOID TransformSwp (PSWP pswp,double xtrans,double ytrans) { 3097 3098 SWP swp; 3099 HWND hwnd; 3100 3101 if((LONG)pswp->x < 0L) { 3102 pswp->cx -= abs(pswp->x); 3103 pswp->x = 0; 3104 } 3105 if((LONG)pswp->y < 0L) { 3106 pswp->cy -= abs(pswp->y); 3107 pswp->y = 0; 3108 } 3109 pswp->x = (LONG)(((double)pswp->x * 100.0) / xtrans); 3110 pswp->cx = (LONG)(((double)pswp->cx * 100.0) / xtrans); 3111 pswp->y = (LONG)(((double)pswp->y * 100.0) / ytrans); 3112 pswp->cy = (LONG)(((double)pswp->cy * 100.0) / ytrans); 3113 if(pswp->hwnd) { 3114 hwnd = WinQueryWindow(pswp->hwnd,QW_PARENT); 3115 if(hwnd) { 3116 if(WinQueryWindowPos(hwnd,&swp)) { 3117 if(pswp->x > swp.cx) 3118 pswp->x = (swp.cx > 24) ? swp.cx - 24 : swp.cx; 3119 if(pswp->y > swp.cy) 3120 pswp->y = (swp.cy > 24) ? swp.cy - 24 : swp.cy; 3121 if(pswp->x + pswp->cx > swp.cx) 3122 pswp->cx = swp.cx - pswp->x; 3123 if(pswp->y + pswp->cy > swp.cy) 3124 pswp->cy = swp.cy - pswp->y; 3125 } 3126 } 3127 } 3128 } 3129 3130 3131 BOOL RestoreDirCnrState (HWND hwndClient,CHAR *name,BOOL noview) { 3132 3133 /* returns TRUE if a directory container was opened */ 3134 3135 CHAR s[120],tdir[CCHMAXPATH]; 3136 HWND hwndDir,hwndC; 3137 SWP swp,swpO,swpN; 3138 ULONG size,numsaves = 0L,x; 3139 double xtrans,ytrans; 3140 BOOL ret = FALSE; 3141 DIRCNRDATA *dcd; 3142 3143 size = sizeof(SWP); 3144 sprintf(s, 3145 "%s%sMySizeLastTime", 3146 (name) ? name : NullStr, 3147 (name) ? "." : NullStr); 3148 if(!PrfQueryProfileData(fmprof, 3149 FM3Str, 3150 s, 3151 (PVOID)&swpO, 3152 &size) || 3153 size != sizeof(SWP) || !swp.cx || !swp.cy) 3154 WinQueryWindowPos(WinQueryWindow(hwndClient,QW_PARENT),&swpO); 3155 if(!name || 3156 !strcmp(name,GetPString(IDS_FM2TEMPTEXT))) 3157 PrfWriteProfileData(fmprof, 3158 FM3Str, 3159 s, 3160 NULL, 3161 0L); 3162 WinQueryWindowPos(WinQueryWindow(hwndClient,QW_PARENT),&swpN); 3163 if(swpN.fl & (SWP_MINIMIZE | SWP_HIDE)) 3164 swpN = swpO; 3165 xtrans = ((double)swpO.cx * 100.0) / (double)swpN.cx; 3166 ytrans = ((double)swpO.cy * 100.0) / (double)swpN.cy; 3167 size = sizeof(SWP); 3168 sprintf(s, 3169 "%s%sLastTreePos", 3170 (name) ? (name) : NullStr, 3171 (name) ? "." : NullStr); 3172 if(PrfQueryProfileData(fmprof, 3173 FM3Str, 3174 s, 3175 (PVOID)&swp, 3176 &size)) { 3177 if(!name || 3178 !strcmp(name,GetPString(IDS_FM2TEMPTEXT))) 3179 PrfWriteProfileData(fmprof, 3180 FM3Str, 3181 s, 3182 NULL, 3183 0L); 3184 swp.hwnd = hwndTree; 3185 TransformSwp(&swp, 3186 xtrans, 3187 ytrans); 3188 if(!fFreeTree) { 3189 WinQueryWindowPos(hwndClient,&swpN); 3190 swp.x = 0; 3191 swp.y = (swpN.cy - swp.cy); 3192 } 3193 if(!(swp.fl & (SWP_MINIMIZE | SWP_HIDE))) { 3194 swp.fl &= (~SWP_ACTIVATE); 3195 WinSetWindowPos(hwndTree, 3196 HWND_TOP, 3197 swp.x, 3198 swp.y, 3199 swp.cx, 3200 swp.cy, 3201 swp.fl | SWP_MOVE | 3202 SWP_SIZE | SWP_SHOW | SWP_ZORDER); 3203 } 3204 else { 3205 WinSetWindowPos(hwndTree, 3206 HWND_TOP, 3207 0, 3208 0, 3209 0, 3210 0, 3211 SWP_MINIMIZE | SWP_SHOW); 3212 WinSetWindowUShort(hwndTree, 3213 QWS_XRESTORE, 3214 (USHORT)swp.x); 3215 WinSetWindowUShort(hwndTree, 3216 QWS_CXRESTORE, 3217 (USHORT)swp.cx); 3218 WinSetWindowUShort(hwndTree, 3219 QWS_YRESTORE, 3220 (USHORT)swp.y); 3221 WinSetWindowUShort(hwndTree, 3222 QWS_CYRESTORE, 3223 (USHORT)swp.cy); 3224 } 3225 } 3226 size = sizeof(ULONG); 3227 sprintf(s, 3228 "%s%sNumDirsLastTime", 3229 (name) ? name : NullStr, 3230 (name) ? "." : NullStr); 3231 if(PrfQueryProfileData(fmprof, 3232 FM3Str, 3233 s, 3234 (PVOID)&numsaves, 3235 &size) && 3236 numsaves) { 3237 if(!name || 3238 !strcmp(name,GetPString(IDS_FM2TEMPTEXT))) 3239 PrfWriteProfileData(fmprof, 3240 FM3Str, 3241 s, 3242 NULL, 3243 0L); 3244 for(x = 0;x < numsaves;x++) { 3245 sprintf(s, 3246 "%s%sDirCnrPos.%lu", 3247 (name) ? name : NullStr, 3248 (name) ? "." : NullStr, 3249 x); 3250 size = sizeof(SWP); 3251 if(PrfQueryProfileData(fmprof, 3252 FM3Str, 3253 s, 3254 (PVOID)&swp, 3255 &size)) { 3256 if(!name || 3257 !strcmp(name,GetPString(IDS_FM2TEMPTEXT))) 3258 PrfWriteProfileData(fmprof, 3259 FM3Str, 3260 s, 3261 NULL, 3262 0L); 3263 sprintf(s, 3264 "%s%sDirCnrDir.%lu", 3265 (name) ? name : NullStr, 3266 (name) ? "." : NullStr, 3267 x); 3268 size = sizeof(tdir); 3269 if(PrfQueryProfileData(fmprof, 3270 FM3Str, 3271 s, 3272 (PVOID)tdir, 3273 &size)) { 3274 if(!name || 3275 !strcmp(name,GetPString(IDS_FM2TEMPTEXT))) 3276 PrfWriteProfileData(fmprof, 3277 FM3Str, 3278 s, 3279 NULL, 3280 0L); 3281 hwndDir = (HWND)WinSendMsg(hwndClient, 3282 UM_SETDIR, 3283 MPFROMP(tdir), 3284 MPFROMLONG(1L)); 3285 if(hwndDir) { 3286 hwndC = WinWindowFromID(hwndDir, 3287 FID_CLIENT); 3288 if(hwndC) { 3289 dcd = WinQueryWindowPtr(WinWindowFromID(hwndC,DIR_CNR), 3290 0); 3291 if(dcd) { 3292 size = sizeof(INT); 3293 sprintf(s, 3294 "%s%sDirCnrSort.%lu", 3295 (name) ? name : NullStr, 3296 (name) ? "." : NullStr, 3297 x); 3298 if(PrfQueryProfileData(fmprof, 3299 FM3Str, 3300 s, 3301 (PVOID)&dcd->sortFlags, 3302 &size) && 3303 size == sizeof(INT)) { 3304 if(!dcd->sortFlags) 3305 dcd->sortFlags = SORT_PATHNAME; 3306 } 3307 if(!name || 3308 !strcmp(name,GetPString(IDS_FM2TEMPTEXT))) 3309 PrfWriteProfileData(fmprof, 3310 FM3Str, 3311 s, 3312 NULL, 3313 0L); 3314 size = sizeof(MASK); 3315 sprintf(s, 3316 "%s%sDirCnrFilter.%lu", 3317 (name) ? name : NullStr, 3318 (name) ? "." : NullStr, 3319 x); 3320 if(PrfQueryProfileData(fmprof, 3321 FM3Str, 3322 s, 3323 (PVOID)&dcd->mask, 3324 &size) && 3325 size) { 3326 if(*dcd->mask.szMask) 3327 WinSendMsg(WinWindowFromID(hwndC,DIR_CNR), 3328 UM_FILTER, 3329 MPFROMP(dcd->mask.szMask), 3330 MPVOID); 3331 } 3332 *(dcd->mask.prompt) = 0; 3333 if(!name || 3334 !strcmp(name,GetPString(IDS_FM2TEMPTEXT))) 3335 PrfWriteProfileData(fmprof, 3336 FM3Str, 3337 s, 3338 NULL, 3339 0L); 3340 size = sizeof(ULONG); 3341 sprintf(s, 3342 "%s%sDirCnrView.%lu", 3343 (name) ? name : NullStr, 3344 (name) ? "." : NullStr, 3345 x); 3346 if(!noview) { 3347 if(PrfQueryProfileData(fmprof, 3348 FM3Str, 3349 s, 3350 (PVOID)&dcd->flWindowAttr, 3351 &size) && 3352 size == sizeof(ULONG)) { 3353 3354 CNRINFO cnri; 3355 3356 memset(&cnri,0,sizeof(CNRINFO)); 3357 cnri.cb = sizeof(CNRINFO); 3358 if(WinSendMsg(WinWindowFromID(hwndC,DIR_CNR), 3359 CM_QUERYCNRINFO, 3360 MPFROMP(&cnri), 3361 MPFROMLONG(sizeof(CNRINFO)))) { 3362 cnri.flWindowAttr = dcd->flWindowAttr; 3363 WinSendMsg(WinWindowFromID(hwndC,DIR_CNR), 3364 CM_SETCNRINFO, 3365 MPFROMP(&cnri), 3366 MPFROMLONG(CMA_FLWINDOWATTR)); 3367 } 3368 } 3369 } 3370 if(!name || 3371 !strcmp(name,GetPString(IDS_FM2TEMPTEXT))) 3372 PrfWriteProfileData(fmprof, 3373 FM3Str, 3374 s, 3375 NULL, 3376 0L); 3377 } 3378 } 3379 ret = TRUE; 3380 swp.hwnd = hwndDir; 3381 TransformSwp(&swp, 3382 xtrans, 3383 ytrans); 3384 if(!fAutoTile && 3385 !(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) 3386 WinSetWindowPos(hwndDir, 3387 HWND_TOP, 3388 swp.x, 3389 swp.y, 3390 swp.cx, 3391 swp.cy, 3392 swp.fl | SWP_MOVE | 3393 SWP_SIZE | SWP_SHOW | SWP_ZORDER | SWP_ACTIVATE); 3394 else if(swp.fl & (SWP_HIDE | SWP_MINIMIZE)) { 3395 WinSetWindowPos(hwndDir, 3396 HWND_TOP, 3397 0, 3398 0, 3399 0, 3400 0, 3401 SWP_MINIMIZE | SWP_SHOW); 3402 WinSetWindowUShort(hwndDir, 3403 QWS_XRESTORE, 3404 (USHORT)swp.x); 3405 WinSetWindowUShort(hwndDir, 3406 QWS_CXRESTORE, 3407 (USHORT)swp.cx); 3408 WinSetWindowUShort(hwndDir, 3409 QWS_YRESTORE, 3410 (USHORT)swp.y); 3411 WinSetWindowUShort(hwndDir, 3412 QWS_CYRESTORE, 3413 (USHORT)swp.cy); 3414 } 3415 else 3416 WinSetWindowPos(hwndDir, 3417 HWND_TOP, 3418 0, 3419 0, 3420 0, 3421 0, 3422 SWP_ZORDER | SWP_ACTIVATE); 3423 } 3424 } 3425 } 3426 } 3427 } 3428 return ret; 3429 } 3430 3431 3432 ULONG CountChildren (HWND hwndClient,ULONG *ulNumMinChildren) { 3433 3434 HENUM henum; 3435 HWND hwndChild; 3436 SWP swp; 3437 register ULONG ulCnt = 0L; 3438 USHORT id; 3439 3440 if(ulNumMinChildren) 3441 *ulNumMinChildren = 0L; 3442 henum = WinBeginEnumWindows(hwndClient); 3443 while((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) { 3444 id = WinQueryWindowUShort(hwndChild,QWS_ID); 3445 if(!id || (!fFreeTree && id == TREE_FRAME)) 3446 continue; 3447 ulCnt++; 3448 if(ulNumMinChildren) { 3449 if(WinQueryWindowPos(hwndChild,&swp) && 3450 (swp.fl & SWP_MINIMIZE)) 3451 (*ulNumMinChildren)++; 3452 } 3453 } 3454 WinEndEnumWindows(henum); 3455 return ulCnt; 3456 } 3457 3458 3459 VOID GetNextWindowPos (HWND hwndClient,PSWP pswp,ULONG *ulCntR, 3460 ULONG *ulNumMinChildrenR) { 3461 3462 register ULONG ulCnt; 3463 ULONG ulNumMinChildren; 3464 RECTL Rectl; 3465 register ULONG ulXDiff,ulYDiff,ulWindowsPerStack; 3466 3467 if(!ulCntR || !ulNumMinChildrenR) 3468 ulCnt = CountChildren(hwndClient,&ulNumMinChildren); 3469 else { 3470 ulCnt = *ulCntR; 3471 ulNumMinChildren = *ulNumMinChildrenR; 3472 if(ulCnt == (ULONG)-1L) { 3473 ulCnt = CountChildren(hwndClient,&ulNumMinChildren); 3474 /* return these values to the caller for later use */ 3475 *ulCntR = ulCnt; 3476 *ulNumMinChildrenR = ulNumMinChildren; 3477 } 3478 } 3479 WinQueryWindowRect(hwndClient,&Rectl); 3480 AdjustSizeOfClient(NULL,&Rectl); 3481 if(!fFreeTree) { 3482 3483 SWP swp; 3484 3485 WinQueryWindowPos(hwndTree,&swp); 3486 if(ulNumMinChildren || (swp.fl & (SWP_HIDE | SWP_MINIMIZE))) 3487 Rectl.yBottom += WinQuerySysValue(HWND_DESKTOP,SV_CYICON) * 2; 3488 } 3489 else if(ulNumMinChildren) 3490 Rectl.yBottom += WinQuerySysValue(HWND_DESKTOP,SV_CYICON) * 2; 3491 3492 ulXDiff = WinQuerySysValue(HWND_DESKTOP,SV_CXSIZEBORDER) + 3493 WinQuerySysValue(HWND_DESKTOP,SV_CXMINMAXBUTTON) / 2; 3494 ulYDiff = WinQuerySysValue(HWND_DESKTOP,SV_CYSIZEBORDER) + 3495 WinQuerySysValue(HWND_DESKTOP,SV_CYMINMAXBUTTON); 3496 ulWindowsPerStack = (Rectl.yTop - Rectl.yBottom) / (3 * ulYDiff); 3497 pswp->cx = Rectl.xRight - (ulWindowsPerStack * ulXDiff); 3498 pswp->cy = (Rectl.yTop - Rectl.yBottom) - (ulWindowsPerStack * ulYDiff); 3499 ulWindowsPerStack++; 3500 pswp->x = Rectl.xLeft + ((ulCnt % ulWindowsPerStack) * ulXDiff); 3501 pswp->y = (Rectl.yTop - pswp->cy - ((ulCnt % ulWindowsPerStack) * ulYDiff)); 3502 } 3503 3504 3505 VOID CascadeChildren (HWND hwndClient) { 3506 3507 ULONG ulCnt = 0L,ulNumMinChildren; 3508 HWND hwndChild; 3509 HENUM henum; 3510 SWP swp; 3511 USHORT id; 3512 RECTL Rectl; 3513 3514 WinQueryWindowPos(hwndClient,&swp); 3515 if(swp.fl & (SWP_HIDE | SWP_MINIMIZE)) 3516 return; 3517 3518 CountChildren(hwndClient,&ulNumMinChildren); 3519 if(!fFreeTree) { 3520 WinQueryWindowRect(hwndClient,&Rectl); 3521 AdjustSizeOfClient(NULL,&Rectl); 3522 WinQueryWindowPos(hwndTree,&swp); 3523 if(!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) { 3524 if(swp.y + swp.cy < Rectl.yTop - Rectl.yBottom) 3525 swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y; 3526 if(swp.x != 0) 3527 swp.x = 0; 3528 if(swp.y < 0) 3529 swp.y = 0; 3530 if(swp.x + swp.cx > Rectl.xRight - Rectl.xLeft) 3531 swp.cx = Rectl.xRight - Rectl.xLeft; 3532 WinSetWindowPos(hwndTree,HWND_TOP,swp.x,swp.y,swp.cx,swp.cy, 3533 SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE); 3534 } 3535 } 3536 henum = WinBeginEnumWindows(hwndClient); 3537 while((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) { 3538 id = WinQueryWindowUShort(hwndChild,QWS_ID); 3539 if(!id || (!fFreeTree && id == TREE_FRAME)) 3540 continue; 3541 WinQueryWindowPos(hwndChild,&swp); 3542 if(!(swp.fl & (SWP_MINIMIZE | SWP_HIDE))) { 3543 GetNextWindowPos(hwndClient,&swp,&ulCnt,&ulNumMinChildren); 3544 WinSetWindowPos(hwndChild,HWND_TOP,swp.x,swp.y,swp.cx,swp.cy, 3545 SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_RESTORE | 3546 SWP_ZORDER | SWP_ACTIVATE); 3547 ulCnt++; 3548 } 3549 } 3550 WinEndEnumWindows(henum); 3551 } 3552 3553 3554 VOID TileChildren (HWND hwndClient,BOOL absolute) { 3555 3556 register ULONG ulChildCnt,ulSquare,ulNumRows,ulNumCols, 3557 ulExtraCols,ulWidth,ulHeight; 3558 ULONG ulNumMinChildren; 3559 RECTL Rectl; 3560 HWND hwndChild; 3561 3562 if(fNoTileUpdate || hwndClient == HWND_DESKTOP) 3563 return; 3564 { 3565 SWP swp; 3566 3567 WinQueryWindowPos(hwndClient,&swp); 3568 if(swp.fl & (SWP_HIDE | SWP_MINIMIZE)) 3569 return; 3570 } 3571 ulChildCnt = CountChildren(hwndClient, 3572 &ulNumMinChildren); 3573 ulChildCnt -= ulNumMinChildren; 3574 if(!ulChildCnt) 3575 return; 3576 3577 fNoTileUpdate = TRUE; 3578 3579 for(ulSquare = 2; 3580 ulSquare * ulSquare <= ulChildCnt; 3581 ulSquare++) 3582 ; 3583 if(!fTileBackwards) { 3584 ulNumCols = ulSquare - 1L; 3585 ulNumRows = ulChildCnt / ulNumCols; 3586 } 3587 else { 3588 ulNumRows = ulSquare - 1L; 3589 ulNumCols = ulChildCnt / ulNumRows; 3590 } 3591 ulExtraCols = ulChildCnt % ulNumCols; 3592 3593 WinQueryWindowRect(hwndClient, 3594 &Rectl); 3595 3596 if(!fFreeTree) { 3597 3598 SWP swp; 3599 3600 WinQueryWindowPos(hwndTree,&swp); 3601 if(!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) { 3602 if(swp.y < 0) 3603 swp.y = 0; 3604 if(swp.y + swp.cy < Rectl.yTop - Rectl.yBottom) 3605 swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y; 3606 if(swp.x != 0) 3607 swp.x = 0; 3608 if(swp.x + swp.cx > Rectl.xRight - Rectl.xLeft) 3609 swp.cx = Rectl.xRight - Rectl.xLeft; 3610 WinSetWindowPos(hwndTree, 3611 HWND_TOP, 3612 swp.x, 3613 swp.y, 3614 swp.cx, 3615 swp.cy, 3616 SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE); 3617 WinQueryWindowPos(hwndTree,&swp); 3618 } 3619 if(ulNumMinChildren || 3620 (swp.fl & (SWP_HIDE | SWP_MINIMIZE))) 3621 Rectl.yBottom += WinQuerySysValue(HWND_DESKTOP,SV_CYICON) * 2; 3622 } 3623 else if(ulNumMinChildren) 3624 Rectl.yBottom += WinQuerySysValue(HWND_DESKTOP,SV_CYICON) * 2; 3625 3626 AdjustSizeOfClient(NULL, 3627 &Rectl); 3628 3629 if(Rectl.xRight > 0L && 3630 (Rectl.yBottom < Rectl.yTop)) { 3631 3632 HENUM henum; 3633 3634 henum = WinBeginEnumWindows(hwndClient); 3635 if((hwndChild = WinGetNextWindow(henum)) != (HWND)0) { 3636 3637 ULONG ulCurRow,ulCurCol; 3638 SWP swp; 3639 USHORT id; 3640 3641 ulHeight = (Rectl.yTop - Rectl.yBottom) / ulNumRows; 3642 3643 for(ulCurRow = 0; 3644 ulCurRow < ulNumRows; 3645 ulCurRow++) { 3646 if((ulNumRows - ulCurRow) <= ulExtraCols) 3647 ulNumCols++; 3648 for(ulCurCol = 0; 3649 ulCurCol < ulNumCols; 3650 ulCurCol++) { 3651 ulWidth = Rectl.xRight / ulNumCols; 3652 3653 while(hwndChild) { 3654 id = WinQueryWindowUShort(hwndChild,QWS_ID); 3655 if(id && 3656 (id != TREE_FRAME || fFreeTree)) { 3657 WinQueryWindowPos(hwndChild,&swp); 3658 if(!(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) 3659 break; 3660 } 3661 hwndChild = WinGetNextWindow(henum); 3662 } 3663 3664 if(hwndChild) { 3665 if(!absolute && 3666 (swp.fl & SWP_MAXIMIZE)) { 3667 WinGetMaxPosition(hwndChild,&swp); 3668 WinSetWindowPos(hwndChild, 3669 HWND_TOP, 3670 swp.x, 3671 swp.y, 3672 swp.cx, 3673 swp.cy, 3674 SWP_MOVE | SWP_SIZE | SWP_SHOW); 3675 WinSetWindowUShort(hwndChild, 3676 QWS_XRESTORE, 3677 (USHORT)(ulWidth * ulCurCol) + Rectl.xLeft); 3678 WinSetWindowUShort(hwndChild, 3679 QWS_YRESTORE, 3680 (USHORT)(Rectl.yTop - 3681 (ulHeight * (ulCurRow + 1L)))); 3682 WinSetWindowUShort(hwndChild, 3683 QWS_CXRESTORE, 3684 (USHORT)ulWidth); 3685 WinSetWindowUShort(hwndChild, 3686 QWS_CYRESTORE, 3687 (USHORT)ulHeight); 3688 } 3689 else 3690 WinSetWindowPos(hwndChild, 3691 HWND_TOP, 3692 (ulWidth * ulCurCol) + Rectl.xLeft, 3693 Rectl.yTop - (ulHeight * (ulCurRow + 1L)), 3694 ulWidth, 3695 ulHeight, 3696 SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE); 3697 hwndChild = WinGetNextWindow(henum); 3698 } 3699 } 3700 if((ulNumRows - ulCurRow) <= ulExtraCols) { 3701 ulNumCols--; 3702 ulExtraCols--; 3703 } 3704 } 3705 } 3706 WinEndEnumWindows(henum); 3707 } 3708 3709 fNoTileUpdate = FALSE; 3710 } 3711 3712 3713 VOID ResizeChildren (HWND hwndClient,SHORT oldcx,SHORT oldcy,SHORT newcx, 3714 SHORT newcy) { 3715 /* 3716 * resize all children of the client to maintain their proportional 3717 * sizes and positions 3718 */ 3719 3720 if(!newcx || 3721 !newcy || 3722 !oldcx || 3723 !oldcy) 3724 return; 3725 { 3726 HENUM henum; 3727 HWND hwndChild; 3728 register LONG x,y,cx,cy,ucx,ucy,ux,uy; 3729 SWP swp; 3730 3731 henum = WinBeginEnumWindows(hwndClient); 3732 while((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) { 3733 if(!WinQueryWindowUShort(hwndChild,QWS_ID)) 3734 continue; 3735 if(WinQueryWindowPos(hwndChild,&swp)) { 3736 if(swp.fl & (SWP_MINIMIZE | SWP_HIDE)) { 3737 swp.x = WinQueryWindowUShort(hwndChild,QWS_XRESTORE); 3738 swp.y = WinQueryWindowUShort(hwndChild,QWS_YRESTORE); 3739 swp.cx = WinQueryWindowUShort(hwndChild,QWS_CXRESTORE); 3740 swp.cy = WinQueryWindowUShort(hwndChild,QWS_CYRESTORE); 3741 } 3742 else if(swp.fl & SWP_MAXIMIZE) { 3743 swp.x = WinQueryWindowUShort(hwndChild,QWS_XRESTORE); 3744 swp.y = WinQueryWindowUShort(hwndChild,QWS_YRESTORE); 3745 swp.cx = WinQueryWindowUShort(hwndChild,QWS_CXRESTORE); 3746 swp.cy = WinQueryWindowUShort(hwndChild,QWS_CYRESTORE); 3747 } 3748 cx = (swp.cx) ? (LONG)(((double)oldcx * 100.0) / (double)swp.cx) : 0; 3749 cy = (swp.cy) ? (LONG)(((double)oldcy * 100.0) / (double)swp.cy) : 0; 3750 x = (swp.x) ? (LONG)(((double)oldcx * 100.0) / (double)swp.x) : 0; 3751 y = (swp.y) ? (LONG)(((double)oldcy * 100.0) / (double)swp.y) : 0; 3752 if(x < 0) 3753 x = 0; 3754 if(y < 0) 3755 y = 0; 3756 ux = (x) ? (LONG)(((double)newcx * 100.0) / (double)x) : 0; 3757 uy = (y) ? (LONG)(((double)newcy * 100.0) / (double)y) : 0; 3758 ucx = (cx) ? (LONG)(((double)newcx * 100.0) / (double)cx) : 0; 3759 ucy = (cy) ? (LONG)(((double)newcy * 100.0) / (double)cy) : 0; 3760 if(ux + ucx > newcx) 3761 ucx = newcx - ux; 3762 if(uy + ucy > newcy) 3763 ucy = newcy - uy; 3764 3765 if(!(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE))) 3766 WinSetWindowPos(hwndChild,HWND_TOP,ux,uy,ucx,ucy, 3767 SWP_MOVE | SWP_SIZE | SWP_SHOW); 3768 else if(swp.fl & (SWP_HIDE | SWP_MINIMIZE)) { 3769 WinSetWindowUShort(hwndChild,QWS_XMINIMIZE,(USHORT)-1); 3770 WinSetWindowUShort(hwndChild,QWS_YMINIMIZE,(USHORT)-1); 3771 WinSetWindowPos(hwndChild,HWND_TOP,0,0,0,0, 3772 SWP_SIZE | SWP_MOVE | SWP_FOCUSDEACTIVATE); 3773 WinSetWindowUShort(hwndChild,QWS_XRESTORE,ux); 3774 WinSetWindowUShort(hwndChild,QWS_YRESTORE,uy); 3775 WinSetWindowUShort(hwndChild,QWS_CXRESTORE,ucx); 3776 WinSetWindowUShort(hwndChild,QWS_CYRESTORE,ucy); 3777 } 3778 else { 3779 WinGetMaxPosition(hwndChild,&swp); 3780 WinSetWindowPos(hwndChild,HWND_TOP,swp.x,swp.y,swp.cx,swp.cy, 3781 SWP_MOVE | SWP_SIZE | SWP_SHOW); 3782 WinSetWindowUShort(hwndChild,QWS_XRESTORE,ux); 3783 WinSetWindowUShort(hwndChild,QWS_YRESTORE,uy); 3784 WinSetWindowUShort(hwndChild,QWS_CXRESTORE,ucx); 3785 WinSetWindowUShort(hwndChild,QWS_CYRESTORE,ucy); 3786 } 3787 } 3788 } 3789 WinEndEnumWindows(henum); 3790 } 3791 if(!fFreeTree) { 3792 3793 RECTL Rectl; 3794 SWP swp; 3795 3796 WinQueryWindowRect(hwndClient,&Rectl); 3797 AdjustSizeOfClient(NULL,&Rectl); 3798 WinQueryWindowPos(hwndTree,&swp); 3799 if(!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) { 3800 if(swp.y + swp.cy < Rectl.yTop - Rectl.yBottom) 3801 swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y; 3802 if(swp.x != 0) 3803 swp.x = 0; 3804 if(swp.y < 0) 3805 swp.y = 0; 3806 if(swp.x + swp.cx > Rectl.xRight - Rectl.xLeft) 3807 swp.cx = Rectl.xRight - Rectl.xLeft; 3808 WinSetWindowPos(hwndTree,HWND_TOP,swp.x,swp.y,swp.cx,swp.cy, 3809 SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE); 3810 } 3811 } 3812 } 3813 3814 3815 VOID MinResChildren (HWND hwndClient,ULONG cmd) { 3816 3817 HENUM henum; 3818 HWND hwndChild; 3819 3820 { 3821 SWP swp; 3822 3823 WinQueryWindowPos(hwndClient,&swp); 3824 if(swp.fl & (SWP_HIDE | SWP_MINIMIZE)) 3825 return; 3826 } 3827 henum = WinBeginEnumWindows(hwndClient); 3828 while((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) { 3829 if(!WinQueryWindowUShort(hwndChild,QWS_ID)) 3830 continue; 3831 WinSetWindowPos(hwndChild,HWND_TOP,0,0,0,0,cmd); 3832 } 3833 } 3834 3835 3836 MRESULT EXPENTRY ChildFrameButtonProc (HWND hwnd,ULONG msg,MPARAM mp1, 3837 MPARAM mp2) { 3838 3839 USHORT id; 3840 static BOOL emphasized = FALSE; 3841 3842 switch(msg) { 3843 case WM_BUTTON1CLICK: 3844 case WM_CHORD: 3845 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); 3846 break; 3847 3848 case WM_MOUSEMOVE: 3849 if(fOtherHelp) { 3850 if((!hwndBubble || WinQueryWindowULong(hwndBubble,QWL_USER) != hwnd) && 3851 !WinQueryCapture(HWND_DESKTOP)) { 3852 id = WinQueryWindowUShort(hwnd,QWS_ID); 3853 switch(id) { 3854 case IDM_OPENWALK: 3855 MakeBubble(hwnd, 3856 FALSE, 3857 GetPString(IDS_WALKBUTTONHELP)); 3858 break; 3859 case IDM_USERLIST: 3860 MakeBubble(hwnd, 3861 FALSE, 3862 GetPString(IDS_QUICKBUTTONHELP)); 3863 break; 3864 } 3865 } 3866 } 3867 break; 3868 3869 case WM_BUTTON3CLICK: 3870 case WM_BUTTON2CLICK: 3871 { 3872 USHORT cmd = 0; 3873 3874 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); 3875 id = WinQueryWindowUShort(hwnd,QWS_ID); 3876 switch(id) { 3877 case IDM_OPENWALK: 3878 switch(msg) { 3879 case WM_BUTTON2CLICK: 3880 if((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) == 3881 (KC_ALT | KC_SHIFT | KC_CTRL)) 3882 cmd = IDM_GREP; 3883 else if((shiftstate & (KC_ALT | KC_CTRL)) == 3884 (KC_ALT | KC_CTRL)) 3885 CascadeChildren(hwndMain); 3886 #ifdef NEVER 3887 else if((shiftstate & (KC_ALT | KC_SHIFT)) == 3888 (KC_ALT | KC_SHIFT)) 3889 cmd = IDM_SYSINFO; 3890 #endif 3891 else if(shiftstate & KC_SHIFT) 3892 cmd = IDM_WINDOWDLG; 3893 else if(shiftstate & KC_CTRL) 3894 cmd = IDM_SEEALL; 3895 else if(shiftstate & KC_ALT) 3896 TileChildren(hwndMain,TRUE); 3897 else 3898 cmd = IDM_WALKDIR; 3899 break; 3900 case WM_BUTTON3CLICK: 3901 TileChildren(hwndMain,TRUE); 3902 break; 3903 } 3904 break; 3905 case IDM_USERLIST: 3906 switch(msg) { 3907 case WM_BUTTON2CLICK: 3908 if((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) == 3909 (KC_ALT | KC_SHIFT | KC_CTRL)) 3910 cmd = IDM_COLORPALETTE; 3911 else if((shiftstate & (KC_ALT | KC_CTRL)) == 3912 (KC_ALT | KC_CTRL)) 3913 cmd = IDM_HIDEMENU; 3914 else if((shiftstate & (KC_ALT | KC_SHIFT)) == 3915 (KC_ALT | KC_SHIFT)) 3916 cmd = IDM_NOTEBOOK; 3917 else if(shiftstate & KC_SHIFT) 3918 cmd = IDM_TOOLTITLES; 3919 else if(shiftstate & KC_CTRL) 3920 cmd = IDM_TEXTTOOLS; 3921 else if(shiftstate & KC_ALT) 3922 cmd = IDM_FONTPALETTE; 3923 else 3924 cmd = IDM_TOOLBAR; 3925 break; 3926 case WM_BUTTON3CLICK: 3927 cmd = IDM_DRIVEBAR; 3928 break; 3929 } 3930 break; 3931 } 3932 if(cmd) 3933 PostMsg(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),FID_CLIENT), 3934 WM_COMMAND, 3935 MPFROM2SHORT(cmd,0), 3936 MPVOID); 3937 } 3938 break; 3939 3940 case DM_DRAGOVER: 3941 id = WinQueryWindowUShort(hwnd,QWS_ID); 3942 if(id == IDM_OPENWALK) { 3943 if(!emphasized) { 3944 emphasized = TRUE; 3945 DrawTargetEmphasis(hwnd,emphasized); 3946 } 3947 if(AcceptOneDrop(mp1,mp2)) 3948 return MRFROM2SHORT(DOR_DROP, 3949 DO_MOVE); 3950 } 3951 return MRFROM2SHORT(DOR_NEVERDROP,0); 3952 3953 case DM_DRAGLEAVE: 3954 if(emphasized) { 3955 emphasized = FALSE; 3956 DrawTargetEmphasis(hwnd,emphasized); 3957 } 3958 break; 3959 3960 case DM_DROPHELP: 3961 DropHelp(mp1,mp2,hwnd,GetPString(IDS_OPENDROPHELP)); 3962 return 0; 3963 3964 case DM_DROP: 3965 { 3966 char szFrom[CCHMAXPATH + 2]; 3967 3968 if(emphasized) { 3969 emphasized = FALSE; 3970 DrawTargetEmphasis(hwnd, 3971 emphasized); 3972 } 3973 if(GetOneDrop(mp1, 3974 mp2, 3975 szFrom, 3976 sizeof(szFrom))) { 3977 if(MakeValidDir(szFrom) && 3978 !FindDirCnrByName(szFrom,TRUE)) { 3979 OpenDirCnr((HWND)0, 3980 hwndMain, 3981 hwndTree, 3982 FALSE, 3983 szFrom); 3984 } 3985 } 3986 } 3987 return 0; 3988 3989 case WM_CLOSE: 3990 WinDestroyWindow(hwnd); 3991 return 0; 3992 } 3993 return PFNWPButton(hwnd,msg,mp1,mp2); 3994 } 3995 3996 3997 MRESULT EXPENTRY MainFrameWndProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) { 3998 3999 PFNWP oldproc = (PFNWP)WinQueryWindowPtr(hwnd,QWL_USER); 4000 static ULONG aheight = 0L; 4001 4002 switch(msg) { 4003 case WM_ADJUSTWINDOWPOS: 4004 { 4005 SWP *pswp; 4006 4007 pswp = (SWP *)mp1; 4008 if(fDataMin && !fAmClosing) { 4009 if(pswp->fl & (SWP_HIDE | SWP_MINIMIZE)) { 4010 4011 SWP swp; 4012 4013 WinQueryWindowPos(hwnd,&swp); 4014 PostMsg(hwnd, 4015 UM_FOCUSME, 4016 MPFROMLONG(swp.fl), 4017 MPVOID); 4018 HideNote(); 4019 } 4020 else if(pswp->fl & (SWP_SHOW | SWP_RESTORE)) { 4021 if(DataHwnd) 4022 PostMsg(DataHwnd, 4023 WM_CLOSE, 4024 MPVOID, 4025 MPVOID); 4026 } 4027 } 4028 if(!fAmClosing) { 4029 if(pswp->fl & (SWP_HIDE | SWP_MINIMIZE)) 4030 HideNote(); 4031 } 4032 } 4033 break; 4034 4035 case UM_FOCUSME: 4036 CreateDataBar(HWND_DESKTOP,(ULONG)mp1); 4037 return 0; 4038 4039 case WM_BUTTON1UP: 4040 case WM_BUTTON2UP: 4041 case WM_BUTTON3UP: 4042 case WM_MOUSEMOVE: 4043 case WM_CHORD: 4044 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); 4045 break; 4046 4047 case WM_CHAR: 4048 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL)); 4049 break; 4050 4051 case WM_CONTROL: 4052 return WinSendMsg(WinWindowFromID(hwnd,FID_CLIENT),UM_CONTROL,mp1,mp2); 4053 4054 case WM_COMMAND: 4055 return WinSendMsg(WinWindowFromID(hwnd,FID_CLIENT),msg,mp1,mp2); 4056 4057 case WM_CALCFRAMERECT: 4058 { 4059 MRESULT mr; 4060 PRECTL prectl; 4061 LONG sheight = 20,bheight = 20; 4062 4063 mr = oldproc(hwnd,msg,mp1,mp2); 4064 4065 /* 4066 * Calculate the position of the client rectangle. 4067 * Otherwise, we'll see a lot of redraw when we move the 4068 * client during WM_FORMATFRAME. 4069 */ 4070 4071 if(mr && mp2) { 4072 prectl = (PRECTL)mp1; 4073 if(prectl->yBottom != prectl->yTop) { 4074 { 4075 HPS hps; 4076 POINTL aptl[TXTBOX_COUNT]; 4077 4078 hps = WinGetPS(hwndStatus); 4079 if(hps) { 4080 GpiQueryTextBox(hps,6,"$`WjgT",TXTBOX_COUNT,aptl); 4081 bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6; 4082 WinReleasePS(hps); 4083 } 4084 } 4085 prectl->yBottom += (sheight + 4); 4086 prectl->yTop -= (sheight + 4); 4087 if(fMoreButtons) { 4088 4089 HPS hps; 4090 POINTL aptl[TXTBOX_COUNT]; 4091 4092 hps = WinGetPS(hwndName); 4093 if(hps) { 4094 GpiQueryTextBox(hps, 4095 6, 4096 "$`WjgT", 4097 TXTBOX_COUNT, 4098 aptl); 4099 bheight = aptl[TXTBOX_TOPLEFT].y + 6; 4100 WinReleasePS(hps); 4101 } 4102 prectl->yBottom += (bheight + 4); 4103 prectl->yTop -= (bheight + 4); 4104 } 4105 if(fToolbar) { 4106 if(!fTextTools) 4107 prectl->yTop -= ((fToolTitles) ? 50 : 40); 4108 else 4109 prectl->yTop -= 32; 4110 } 4111 if(fDrivebar) { 4112 ResizeDrives(WinWindowFromID(hwnd,MAIN_DRIVES), 4113 ((prectl->xRight - 4114 (WinQuerySysValue(HWND_DESKTOP, 4115 SV_CYSIZEBORDER) * 2)) - 4)); 4116 prectl->yTop -= (16 * (DriveLines * 18)); 4117 } 4118 if(fUserComboBox) { 4119 if(!aheight) { 4120 4121 SWP swpTemp; 4122 4123 WinQueryWindowPos(WinWindowFromID(hwndDrivelist,CBID_EDIT), 4124 &swpTemp); 4125 aheight = swpTemp.cy; 4126 } 4127 prectl->yTop -= (aheight + 6L); 4128 } 4129 if(fAutoView) { 4130 AutoviewHeight = min(AutoviewHeight, 4131 (prectl->yTop - prectl->yBottom) - 116); 4132 AutoviewHeight = max(AutoviewHeight,36); 4133 prectl->yBottom += (AutoviewHeight + 6); 4134 } 4135 } 4136 } 4137 return mr; 4138 } 4139 4140 case WM_FORMATFRAME: 4141 { 4142 SHORT sCount,soldCount; 4143 PSWP pswp,pswpClient,pswpNew; 4144 SWP swpClient; 4145 LONG theight = 48L,dheight = 20L,width,sheight = 20,bheight = 20; 4146 4147 sCount = (SHORT)oldproc(hwnd,msg,mp1,mp2); 4148 soldCount = sCount; 4149 4150 /* 4151 * Reformat the frame to "squeeze" the client 4152 * and make room for status window sibling beneath 4153 * and toolbar above (if toolbar's on) and userlists 4154 * (if userlists are on). 4155 */ 4156 4157 pswp = (PSWP)mp1; 4158 { 4159 SHORT x; 4160 4161 for(x = 0;x < soldCount;x++) { 4162 if(WinQueryWindowUShort(pswp->hwnd,QWS_ID) == FID_CLIENT) { 4163 pswpClient = pswp; 4164 break; 4165 } 4166 pswp++; 4167 } 4168 } 4169 4170 { 4171 HPS hps; 4172 POINTL aptl[TXTBOX_COUNT]; 4173 4174 hps = WinGetPS(hwndStatus); 4175 if(hps) { 4176 GpiQueryTextBox(hps, 4177 6, 4178 "$`WjgT", 4179 TXTBOX_COUNT, 4180 aptl); 4181 bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6; 4182 WinReleasePS(hps); 4183 } 4184 if(fMoreButtons) { 4185 hps = WinGetPS(hwndName); 4186 if(hps) { 4187 GpiQueryTextBox(hps, 4188 6, 4189 "$`WjgT", 4190 TXTBOX_COUNT, 4191 aptl); 4192 bheight = aptl[TXTBOX_TOPLEFT].y + 6; 4193 WinReleasePS(hps); 4194 } 4195 } 4196 } 4197 pswpNew = (PSWP)mp1 + soldCount; 4198 *pswpNew = *pswpClient; 4199 swpClient = *pswpClient; 4200 pswpNew->hwnd = hwndStatus; 4201 pswpNew->hwndInsertBehind = HWND_BOTTOM; 4202 pswpNew->x = swpClient.x + 3; 4203 pswpNew->y = swpClient.y + 2; 4204 if(!fSplitStatus) 4205 width = swpClient.cx - (16 + (sheight * 2) + 4); 4206 else 4207 width = (swpClient.cx - (16 + (sheight * 2) + 4)) / 2; 4208 width = max(width,10); 4209 if(fSplitStatus) 4210 pswpNew->cx = width - 6; 4211 else 4212 pswpNew->cx = width - 8; 4213 pswpNew->cy = sheight; 4214 pswpClient->y = pswpNew->y + pswpNew->cy + 3; 4215 pswpClient->cy = (swpClient.cy - pswpNew->cy) - 3; 4216 sCount++; 4217 4218 if(fSplitStatus) { 4219 pswpNew = (PSWP)mp1 + (soldCount + 1); 4220 *pswpNew = *pswpClient; 4221 pswpNew->hwnd = hwndStatus2; 4222 pswpNew->hwndInsertBehind = HWND_BOTTOM; 4223 pswpNew->x = width + 8; 4224 pswpNew->y = swpClient.y + 2; 4225 pswpNew->cx = width - 6; 4226 pswpNew->cy = sheight; 4227 sCount++; 4228 } 4229 else { 4230 WinShowWindow(hwndStatus2,FALSE); 4231 WinSetWindowText(hwndStatus2, 4232 NullStr); 4233 } 4234 4235 if(fToolbar) { 4236 if(fTextTools) 4237 theight = 32L; 4238 else if(!fToolTitles) 4239 theight = 40L; 4240 pswpNew = (PSWP)mp1 + (soldCount + 1 + 4241 (fSplitStatus != FALSE)); 4242 *pswpNew = *pswpClient; 4243 pswpNew->hwnd = WinWindowFromID(hwnd,MAIN_TOOLS); 4244 pswpNew->hwndInsertBehind = HWND_BOTTOM; 4245 pswpNew->x = swpClient.x + 2; 4246 pswpNew->y = (swpClient.y + swpClient.cy) - (theight - 2); 4247 pswpNew->cx = swpClient.cx - 4; 4248 pswpNew->cy = theight - 4; 4249 pswpClient->cy -= theight; 4250 sCount++; 4251 } 4252 else 4253 WinShowWindow(WinWindowFromID(hwnd,MAIN_TOOLS),FALSE); 4254 4255 if(fDrivebar) { 4256 ResizeDrives(WinWindowFromID(hwnd,MAIN_DRIVES), 4257 pswpClient->cx - 4); 4258 pswpNew = (PSWP)mp1 + (soldCount + 1 + 4259 (fSplitStatus != FALSE) + 4260 (fToolbar != FALSE)); 4261 *pswpNew = *pswpClient; 4262 pswpNew->hwnd = WinWindowFromID(hwnd,MAIN_DRIVES); 4263 pswpNew->hwndInsertBehind = HWND_BOTTOM; 4264 pswpNew->x = swpClient.x + 2; 4265 dheight += ((dheight - 2) * DriveLines); 4266 pswpNew->y = (swpClient.y + swpClient.cy) - (dheight - 2); 4267 if(fToolbar) 4268 pswpNew->y -= theight; 4269 pswpNew->cx = swpClient.cx - 4; 4270 pswpNew->cy = dheight - 4; 4271 pswpClient->cy -= dheight; 4272 sCount++; 4273 } 4274 else 4275 WinShowWindow(WinWindowFromID(hwnd,MAIN_DRIVES),FALSE); 4276 4277 if(fAutoView) { 4278 pswpNew = (PSWP)mp1 + (soldCount + 1 + 4279 (fToolbar != FALSE) + 4280 (fDrivebar != FALSE) + 4281 (fSplitStatus != FALSE)); 4282 *pswpNew = *pswpClient; 4283 pswpNew->hwnd = (fComments) ? hwndAutoMLE : hwndAutoview; 4284 pswpNew->x = pswpClient->x + 3; 4285 pswpNew->y = pswpClient->y + 3; 4286 if(fMoreButtons) 4287 pswpNew->y += (bheight + 4); 4288 pswpNew->cx = pswpClient->cx - 6; 4289 AutoviewHeight = min(AutoviewHeight, 4290 pswpClient->cy - 116); 4291 AutoviewHeight = max(AutoviewHeight,36); 4292 pswpNew->cy = AutoviewHeight; 4293 pswpClient->y += (AutoviewHeight + 6); 4294 pswpClient->cy -= (AutoviewHeight + 6); 4295 sCount++; 4296 WinShowWindow((fComments) ? hwndAutoview : hwndAutoMLE,FALSE); 4297 } 4298 else { 4299 WinShowWindow(hwndAutoview,FALSE); 4300 WinShowWindow(hwndAutoMLE,FALSE); 4301 } 4302 4303 pswpNew = (PSWP)mp1 + (soldCount + 1 + 4304 (fToolbar != FALSE) + 4305 (fDrivebar != FALSE) + 4306 (fSplitStatus != FALSE) + 4307 (fAutoView != FALSE)); 4308 *pswpNew = *pswpClient; 4309 pswpNew->hwnd = WinWindowFromID(hwnd,IDM_OPENWALK); 4310 pswpNew->x = swpClient.cx - ((sheight * 2) + 4); 4311 pswpNew->y = swpClient.y; 4312 pswpNew->cx = sheight + 4; 4313 pswpNew->cy = sheight + 4; 4314 sCount++; 4315 pswpNew = (PSWP)mp1 + (soldCount + 2 + 4316 (fToolbar != FALSE) + 4317 (fDrivebar != FALSE) + 4318 (fSplitStatus != FALSE) + 4319 (fAutoView != FALSE)); 4320 *pswpNew = *pswpClient; 4321 pswpNew->hwnd = WinWindowFromID(hwnd,IDM_USERLIST); 4322 pswpNew->x = swpClient.cx - (sheight + 2); 4323 pswpNew->y = swpClient.y; 4324 pswpNew->cx = sheight + 4; 4325 pswpNew->cy = sheight + 4; 4326 sCount++; 4327 pswpNew = (PSWP)mp1 + (soldCount + 3 + 4328 (fToolbar != FALSE) + 4329 (fDrivebar != FALSE) + 4330 (fSplitStatus != FALSE) + 4331 (fAutoView != FALSE)); 4332 *pswpNew = *pswpClient; 4333 pswpNew->hwnd = WinWindowFromID(hwnd,MAIN_LED); 4334 pswpNew->x = swpClient.cx - ((sheight * 2) + 16); 4335 pswpNew->y = swpClient.y; 4336 pswpNew->cx = 12; 4337 pswpNew->cy = 12; 4338 sCount++; 4339 pswpNew = (PSWP)mp1 + (soldCount + 4 + 4340 (fToolbar != FALSE) + 4341 (fDrivebar != FALSE) + 4342 (fSplitStatus != FALSE) + 4343 (fAutoView != FALSE)); 4344 *pswpNew = *pswpClient; 4345 pswpNew->hwnd = WinWindowFromID(hwnd,MAIN_LEDHDR); 4346 pswpNew->x = swpClient.cx - ((sheight * 2) + 16); 4347 pswpNew->y = swpClient.y + 12; 4348 pswpNew->cx = 12; 4349 pswpNew->cy = sheight - 8; 4350 sCount++; 4351 if(fUserComboBox) { 4352 if(!aheight) { 4353 4354 SWP swpTemp; 4355 4356 WinQueryWindowPos(WinWindowFromID(hwndDrivelist,CBID_EDIT), 4357 &swpTemp); 4358 aheight = swpTemp.cy; 4359 } 4360 pswpNew = (PSWP)mp1 + (soldCount + 5 + 4361 (fToolbar != FALSE) + 4362 (fSplitStatus != FALSE) + 4363 (fDrivebar != FALSE) + 4364 (fAutoView != FALSE)); 4365 *pswpNew = *pswpClient; 4366 pswpNew->hwnd = hwndDrivelist; 4367 pswpNew->x = swpClient.x; 4368 pswpNew->cx = 48; 4369 pswpClient->cy -= (aheight + 6L); 4370 pswpNew->y = pswpClient->y; 4371 pswpNew->cy = pswpClient->cy + (aheight + 5L); 4372 sCount++; 4373 pswpNew = (PSWP)mp1 + (soldCount + 6 + 4374 (fToolbar != FALSE) + 4375 (fDrivebar != FALSE) + 4376 (fSplitStatus != FALSE) + 4377 (fAutoView != FALSE)); 4378 *pswpNew = *pswpClient; 4379 pswpNew->hwnd = hwndStatelist; 4380 pswpNew->x = swpClient.x + 48; 4381 pswpNew->cx = (swpClient.cx - 48) / 7; 4382 pswpNew->y = pswpClient->y; 4383 pswpNew->cy = pswpClient->cy + (aheight + 5L); 4384 sCount++; 4385 pswpNew = (PSWP)mp1 + (soldCount + 7 + 4386 (fToolbar != FALSE) + 4387 (fDrivebar != FALSE) + 4388 (fSplitStatus != FALSE) + 4389 (fAutoView != FALSE)); 4390 *pswpNew = *pswpClient; 4391 pswpNew->hwnd = hwndCmdlist; 4392 pswpNew->x = swpClient.x + 48 + ((swpClient.cx - 48) / 7); 4393 pswpNew->cx = (swpClient.cx - 48) / 5 + 4394 ((swpClient.cx - 48) / 5) - ((swpClient.cx - 48) / 7); 4395 pswpNew->y = pswpClient->y; 4396 pswpNew->cy = pswpClient->cy + (aheight + 5L); 4397 sCount++; 4398 pswpNew = (PSWP)mp1 + (soldCount + 8 + 4399 (fToolbar != FALSE) + 4400 (fDrivebar != FALSE) + 4401 (fSplitStatus != FALSE) + 4402 (fAutoView != FALSE)); 4403 *pswpNew = *pswpClient; 4404 pswpNew->hwnd = hwndUserlist; 4405 pswpNew->x = swpClient.x + 48 + (((swpClient.cx - 48) / 5) * 2); 4406 pswpNew->cx = ((swpClient.x + swpClient.cx) - pswpNew->x) - 4407 ((fToolbar) ? 4408 ((swpClient.cx - 48) / 7) : 0); 4409 pswpNew->y = pswpClient->y; 4410 pswpNew->cy = pswpClient->cy + (aheight + 5L); 4411 sCount++; 4412 if(fToolbar) { 4413 pswpNew = (PSWP)mp1 + (soldCount + 9 + 4414 (fToolbar != FALSE) + 4415 (fDrivebar != FALSE) + 4416 (fSplitStatus != FALSE) + 4417 (fAutoView != FALSE)); 4418 *pswpNew = *pswpClient; 4419 pswpNew->hwnd = hwndButtonlist; 4420 pswpNew->x = swpClient.cx - ((swpClient.cx - 48) / 7) + 4; 4421 pswpNew->cx = (swpClient.x + swpClient.cx) - pswpNew->x; 4422 pswpNew->y = pswpClient->y; 4423 pswpNew->cy = pswpClient->cy + (aheight + 5L); 4424 sCount++; 4425 } 4426 else 4427 WinShowWindow(hwndButtonlist,FALSE); 4428 } 4429 else { 4430 WinShowWindow(hwndUserlist,FALSE); 4431 WinShowWindow(hwndDrivelist,FALSE); 4432 WinShowWindow(hwndStatelist,FALSE); 4433 WinShowWindow(hwndButtonlist,FALSE); 4434 WinShowWindow(hwndCmdlist,FALSE); 4435 } 4436 { 4437 PSWP pswpTitlebar = (PSWP)0,pswpMinbutton = (PSWP)0; 4438 SHORT x; 4439 4440 pswpNew = (PSWP)mp1 + (soldCount + 5 + 4441 (fToolbar != FALSE) + 4442 (fDrivebar != FALSE) + 4443 (fSplitStatus != FALSE) + 4444 (fAutoView != FALSE) + 4445 ((fUserComboBox != FALSE) * 4) + 4446 (fUserComboBox != FALSE && 4447 fToolbar != FALSE)); 4448 pswp = (PSWP)mp1; 4449 for(x = 0;x < soldCount;x++) { 4450 if(!pswpTitlebar && 4451 WinQueryWindowUShort(pswp->hwnd,QWS_ID) == FID_TITLEBAR) 4452 pswpTitlebar = pswp; 4453 else if(!pswpMinbutton && 4454 WinQueryWindowUShort(pswp->hwnd,QWS_ID) == FID_MINMAX) 4455 pswpMinbutton = pswp; 4456 if(pswpTitlebar && 4457 pswpMinbutton) 4458 break; 4459 pswp++; 4460 } 4461 if(pswpMinbutton && 4462 pswpTitlebar) { 4463 *pswpNew = *pswpMinbutton; 4464 pswpNew->hwnd = WinWindowFromID(hwnd,IDM_IDEALSIZE); 4465 pswpNew->cy = pswpMinbutton->cy + 3; 4466 pswpNew->cx = min(pswpNew->cy,(pswpMinbutton->cx / 2) + 3); 4467 pswpTitlebar->cx -= (pswpNew->cx - 1); 4468 pswpNew->x = pswpTitlebar->x + (pswpTitlebar->cx); 4469 pswpNew->y = pswpMinbutton->y - 1; 4470 sCount++; 4471 } 4472 else 4473 WinShowWindow(WinWindowFromID(hwnd,IDM_IDEALSIZE),FALSE); 4474 } 4475 4476 if(fMoreButtons) { 4477 4478 LONG lastx; 4479 4480 pswpNew = (PSWP)mp1 + (soldCount + 6 + 4481 (fToolbar != FALSE) + 4482 (fDrivebar != FALSE) + 4483 (fSplitStatus != FALSE) + 4484 (fAutoView != FALSE) + 4485 ((fUserComboBox != FALSE) * 4) + 4486 (fUserComboBox != FALSE && 4487 fToolbar != FALSE)); 4488 *pswpNew = *pswpClient; 4489 pswpNew->hwnd = hwndName; 4490 pswpNew->x = swpClient.x + 3; 4491 pswpNew->y = swpClient.y + (sheight + 6); 4492 pswpNew->cx = ((swpClient.cx / 2) + (swpClient.cx / 5)) - 3; 4493 lastx = pswpNew->x + pswpNew->cx; 4494 pswpNew->cy = bheight; 4495 pswpClient->y += (bheight + 4); 4496 pswpClient->cy -= (bheight + 4); 4497 sCount++; 4498 pswpNew = (PSWP)mp1 + (soldCount + 7 + 4499 (fToolbar != FALSE) + 4500 (fDrivebar != FALSE) + 4501 (fSplitStatus != FALSE) + 4502 (fAutoView != FALSE) + 4503 ((fUserComboBox != FALSE) * 4) + 4504 (fUserComboBox != FALSE && 4505 fToolbar != FALSE)); 4506 *pswpNew = *pswpClient; 4507 pswpNew->hwnd = hwndDate; 4508 pswpNew->x = lastx + 3; 4509 pswpNew->y = swpClient.y + (sheight + 6); 4510 pswpNew->cx = (swpClient.cx / 6) + (swpClient.cx / 16) - 3; 4511 lastx = pswpNew->x + pswpNew->cx; 4512 pswpNew->cy = bheight; 4513 sCount++; 4514 pswpNew = (PSWP)mp1 + (soldCount + 8 + 4515 (fToolbar != FALSE) + 4516 (fDrivebar != FALSE) + 4517 (fSplitStatus != FALSE) + 4518 (fAutoView != FALSE) + 4519 ((fUserComboBox != FALSE) * 4) + 4520 (fUserComboBox != FALSE && 4521 fToolbar != FALSE)); 4522 *pswpNew = *pswpClient; 4523 pswpNew->hwnd = hwndAttr; 4524 pswpNew->x = lastx + 3; 4525 pswpNew->y = swpClient.y + (sheight + 6); 4526 pswpNew->cx = (swpClient.cx - pswpNew->x) - 1; 4527 pswpNew->cy = bheight; 4528 sCount++; 4529 } 4530 else { 4531 WinShowWindow(hwndAttr,FALSE); 4532 WinShowWindow(hwndName,FALSE); 4533 WinShowWindow(hwndDate,FALSE); 4534 } 4535 return MRFROMSHORT(sCount); 4536 } 4537 4538 case WM_QUERYFRAMECTLCOUNT: 4539 { 4540 SHORT sCount; 4541 4542 sCount = (SHORT)oldproc(hwnd,msg,mp1,mp2); 4543 4544 sCount += 6; 4545 if(fSplitStatus) 4546 sCount++; 4547 if(fToolbar) 4548 sCount++; 4549 if(fUserComboBox) { 4550 sCount += 4; 4551 if(fToolbar) 4552 sCount++; 4553 } 4554 if(fDrivebar) 4555 sCount++; 4556 if(fAutoView) 4557 sCount++; 4558 if(fMoreButtons) 4559 sCount += 3; 4560 return MRFROMSHORT(sCount); 4561 } 4562 4563 case WM_CLOSE: 4564 WinSendMsg(WinWindowFromID(hwnd,FID_CLIENT),msg,mp1,mp2); 4565 return 0; 4566 } 4567 return oldproc(hwnd,msg,mp1,mp2); 4568 } 4569 4570 4571 MRESULT EXPENTRY MainWMCommand (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) 4899 MRESULT EXPENTRY MainWMCommand(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 4572 4900 { 4573 4901 SetShiftState(); 4574 switch(SHORT1FROMMP(mp1)) { 4575 case IDM_SETTARGET: 4576 SetTargetDir(hwnd,FALSE); 4577 break; 4578 4579 case IDM_TOAUTOMLE: 4580 if(fComments && fAutoView) 4581 WinSetFocus(HWND_DESKTOP, 4582 hwndAutoMLE); 4583 break; 4584 4585 case IDM_HIDENOTEWND: 4586 HideNote(); 4587 break; 4588 case IDM_SHOWNOTEWND: 4589 ShowNote(); 4590 break; 4591 4592 case IDM_COMPARE: 4593 { 4594 WALK2 wa; 4595 PCNRITEM pci; 4596 4597 memset(&wa,0,sizeof(wa)); 4598 wa.size = sizeof(wa); 4599 pci = (PCNRITEM)WinSendMsg(WinWindowFromID(WinWindowFromID( 4600 hwndTree,FID_CLIENT),TREE_CNR), 4601 CM_QUERYRECORDEMPHASIS, 4602 MPFROMLONG(CMA_FIRST), 4603 MPFROMSHORT(CRA_CURSORED)); 4604 if(pci && (INT)pci != -1) { 4605 strcpy(wa.szCurrentPath1,pci->szFileName); 4606 MakeValidDir(wa.szCurrentPath1); 4607 } 4608 else 4609 save_dir2(wa.szCurrentPath1); 4610 TopWindowName(hwndMain,(HWND)0,wa.szCurrentPath2); 4611 if(!*wa.szCurrentPath2) 4612 strcpy(wa.szCurrentPath2,wa.szCurrentPath1); 4613 MakeValidDir(wa.szCurrentPath2); 4614 if(WinDlgBox(HWND_DESKTOP, 4615 hwnd, 4616 WalkTwoCmpDlgProc, 4617 FM3ModHandle, 4618 WALK2_FRAME, 4619 MPFROMP(&wa)) && 4620 !IsFile(wa.szCurrentPath1) && 4621 !IsFile(wa.szCurrentPath2)) { 4622 if(!*dircompare) { 4623 4624 COMPARE *cmp; 4625 4626 cmp = malloc(sizeof(COMPARE)); 4627 if(cmp) { 4628 memset(cmp,0,sizeof(COMPARE)); 4629 cmp->size = sizeof(COMPARE); 4630 strcpy(cmp->leftdir,wa.szCurrentPath1); 4631 strcpy(cmp->rightdir,wa.szCurrentPath2); 4632 cmp->hwndParent = hwnd; 4633 cmp->dcd.hwndParent = hwnd; 4634 WinDlgBox(HWND_DESKTOP, 4635 HWND_DESKTOP, 4636 CompareDlgProc, 4637 FM3ModHandle, 4638 COMP_FRAME, 4639 MPFROMP(cmp)); 4640 } 4641 } 4642 else { 4643 4644 CHAR *d1 = "\"",*d2 = "\""; 4645 4646 if(!needs_quoting(wa.szCurrentPath1)) 4647 *d1 = 0; 4648 if(!needs_quoting(wa.szCurrentPath2)) 4649 *d2 = 0; 4650 runemf2(SEPARATE, 4651 HWND_DESKTOP, 4652 NULL, 4653 NULL, 4654 "%s %s%s%s %s%s%s", 4655 dircompare, 4656 d1, 4657 wa.szCurrentPath1, 4658 d1, 4659 d2, 4660 wa.szCurrentPath2, 4661 d2); 4662 } 4663 } 4664 } 4665 break; 4666 4667 case IDM_EXIT: 4668 case IDM_KILLME: 4669 PostMsg(hwnd, 4670 WM_CLOSE, 4671 MPVOID, 4672 MPVOID); 4673 break; 4674 4675 case IDM_CLI: 4676 if(fSplitStatus && 4677 hwndStatus2 && 4678 !WinIsWindow(WinQueryAnchorBlock(hwnd), 4679 WinWindowFromID(hwndStatus2,COMMAND_LINE))) 4680 PostMsg(hwndStatus2, 4681 UM_CLICKED, 4682 MPVOID, 4683 MPVOID); 4684 break; 4685 4686 case IDM_ADDTOUSERLIST: 4687 case IDM_DELETEFROMUSERLIST: 4688 { 4689 CHAR temp[CCHMAXPATH],path[CCHMAXPATH]; 4690 4691 *temp = 0; 4692 WinQueryWindowText(hwndUserlist, 4693 CCHMAXPATH, 4694 temp); 4695 bstrip(temp); 4696 if(*temp && 4697 !DosQueryPathInfo(temp, 4698 FIL_QUERYFULLNAME, 4699 path, 4700 sizeof(path))) { 4701 if(SHORT1FROMMP(mp1) == IDM_ADDTOUSERLIST) { 4702 if(add_udir(TRUE,path)) { 4703 if(fUdirsChanged) 4704 save_udirs(); 4705 WinSendMsg(hwnd, 4706 UM_FILLUSERLIST, 4707 MPVOID, 4708 MPVOID); 4709 } 4710 else 4711 DosBeep(50,50); 4712 } 4713 else { 4714 if(remove_udir(path)) { 4715 if(fUdirsChanged) 4716 save_udirs(); 4717 WinSendMsg(hwnd,UM_FILLUSERLIST,MPVOID,MPVOID); 4718 } 4719 else 4720 DosBeep(50,50); 4721 } 4722 } 4723 } 4724 break; 4725 4726 case IDM_SAVEDIRCNRSTATE: 4727 case IDM_DELETEDIRCNRSTATE: 4728 { 4729 CHAR name[14]; 4730 4731 *name = 0; 4732 WinQueryWindowText(hwndStatelist,13,name); 4733 bstrip(name); 4734 if(*name) { 4735 if(SHORT1FROMMP(mp1) == IDM_SAVEDIRCNRSTATE) { 4736 if(SaveDirCnrState(hwnd,name)) { 4737 if(add_setup(name)) { 4738 WinSendMsg(hwndStatelist,LM_INSERTITEM, 4739 MPFROM2SHORT(LIT_SORTASCENDING,0), 4740 MPFROMP(name)); 4741 save_setups(); 4742 } 4743 } 4744 WinSetWindowText(hwndStatelist, 4745 GetPString(IDS_STATETEXT)); 4746 } 4747 else { 4748 4749 ULONG numsaves = 0,size,x; 4750 CHAR s[120]; 4751 4752 if(remove_setup(name)) 4753 save_setups(); 4754 sprintf(s,"%s.NumDirsLastTime",name); 4755 size = sizeof(ULONG); 4756 if(PrfQueryProfileData(fmprof,FM3Str,s,(PVOID)&numsaves, 4757 &size) && size) { 4758 PrfWriteProfileData(fmprof,FM3Str,s,NULL,0L); 4759 for(x = 0;x < numsaves;x++) { 4760 sprintf(s,"%s.DirCnrPos.%lu",name,x); 4761 PrfWriteProfileData(fmprof,FM3Str,s,NULL,0); 4762 sprintf(s,"%s.DirCnrDir.%lu",name,x); 4763 PrfWriteProfileData(fmprof,FM3Str,s,NULL,0); 4764 sprintf(s,"%s.DirCnrSort.%lu",name,x); 4765 PrfWriteProfileData(fmprof,FM3Str,s,NULL,0); 4766 sprintf(s,"%s.DirCnrFilter.%lu",name,x); 4767 PrfWriteProfileData(fmprof,FM3Str,s,NULL,0); 4768 sprintf(s,"%s.DirCnrView.%lu",name,x); 4769 PrfWriteProfileData(fmprof,FM3Str,s,NULL,0); 4770 } 4771 sprintf(s,"%s.LastTreePos",name); 4772 PrfWriteProfileData(fmprof,FM3Str,s,NULL,0); 4773 sprintf(s,"%s.MySizeLastTime",name); 4774 PrfWriteProfileData(fmprof,FM3Str,s,NULL,0); 4775 } 4776 else 4777 DosBeep(50,100); 4778 PostMsg(hwnd,UM_FILLSETUPLIST,MPVOID,MPVOID); 4779 } 4780 } 4781 } 4782 break; 4783 4784 case IDM_IDEALSIZE: 4785 { 4786 SWP swp,swpD; 4787 ULONG icz = WinQuerySysValue(HWND_DESKTOP,SV_CYICON) * 2L; 4788 ULONG bsz = WinQuerySysValue(HWND_DESKTOP,SV_CYSIZEBORDER); 4789 4790 WinQueryWindowPos(WinQueryWindow(hwnd,QW_PARENT),&swp); 4791 if(swp.fl & SWP_MAXIMIZE) { 4792 WinSendMsg(WinQueryWindow(hwnd,QW_PARENT),WM_SYSCOMMAND, 4793 MPFROM2SHORT(SC_RESTORE,0),MPVOID); 4794 WinQueryWindowPos(WinQueryWindow(hwnd,QW_PARENT),&swp); 4795 } 4796 WinGetMaxPosition(WinQueryWindow(hwnd,QW_PARENT),&swpD); 4797 swpD.x += bsz; 4798 swpD.cx -= (bsz * 2); 4799 swpD.y += icz; 4800 swpD.cy -= (icz + bsz); 4801 if(swp.x == swpD.x && swp.y == swpD.y && 4802 swp.cx == swpD.cx && 4803 swp.cy == swpD.cy && 4804 WinQueryWindowUShort(hwnd,10) && 4805 WinQueryWindowUShort(hwnd,14)) { 4806 swpD.x = WinQueryWindowUShort(hwnd,8); 4807 swpD.cx = WinQueryWindowUShort(hwnd,10); 4808 swpD.y = WinQueryWindowUShort(hwnd,12); 4809 swpD.cy = WinQueryWindowUShort(hwnd,14); 4810 } 4811 else { 4812 WinSetWindowUShort(hwnd,8,(USHORT)swp.x); 4813 WinSetWindowUShort(hwnd,10,(USHORT)swp.cx); 4814 WinSetWindowUShort(hwnd,12,(USHORT)swp.y); 4815 WinSetWindowUShort(hwnd,14,(USHORT)swp.cy); 4816 } 4817 WinSetWindowPos(WinQueryWindow(hwnd,QW_PARENT),HWND_TOP, 4818 swpD.x,swpD.y,swpD.cx, 4819 swpD.cy,SWP_MOVE | SWP_SIZE); 4820 } 4821 break; 4822 4823 case IDM_BLINK: 4824 WinSetWindowPos(WinQueryWindow(hwnd,QW_PARENT),HWND_TOP,0,0,0,0, 4825 SWP_MINIMIZE); 4826 WinSetWindowPos(WinQueryWindow(hwnd,QW_PARENT),HWND_TOP,0,0,0,0, 4827 SWP_RESTORE | SWP_ZORDER); 4828 break; 4829 4830 4831 case DID_CANCEL: 4832 { 4833 HWND hwndTop = TopWindow(hwndMain,(HWND)0); 4834 4835 if(hwndTop) 4836 WinSetFocus(HWND_DESKTOP, 4837 hwndTop); 4838 } 4839 break; 4840 4841 case IDM_NOTEBOOK: 4842 WinDlgBox(HWND_DESKTOP, 4843 hwnd, 4844 CfgDlgProc, 4845 FM3ModHandle, 4846 CFG_FRAME, 4847 MPVOID); 4848 break; 4849 4850 case IDM_VIEWHELPS: 4851 case IDM_VIEWINFS: 4852 WinDlgBox(HWND_DESKTOP, 4853 HWND_DESKTOP, 4854 ViewInfProc, 4855 FM3ModHandle, 4856 VINF_FRAME, 4857 ((SHORT1FROMMP(mp1) == IDM_VIEWHELPS) ? 4858 MPFROMP(NullStr) : 4859 MPVOID)); 4860 break; 4861 4862 case IDM_OPENWALK: 4863 { 4864 char newpath[CCHMAXPATH]; 4865 4866 *newpath = 0; 4867 TopWindowName(hwnd,(HWND)0,newpath); 4868 if(WinDlgBox(HWND_DESKTOP, 4869 hwnd, 4870 WalkAllDlgProc, 4871 FM3ModHandle, 4872 WALK_FRAME, 4873 MPFROMP(newpath)) && 4874 *newpath) 4875 OpenDirCnr((HWND)0, 4876 hwndMain, 4877 hwndTree, 4878 FALSE, 4879 newpath); 4880 } 4881 break; 4882 4883 case IDM_WINDOWDLG: 4884 WindowList(hwnd); 4885 break; 4886 4887 case IDM_HELPMOUSE: 4888 case IDM_HELPCONTEXT: 4889 case IDM_HELPHINTS: 4890 case IDM_HELPPIX: 4891 case IDM_HELPTUTOR: 4892 case IDM_HELPUSERLIST: 4893 case IDM_HELP: 4894 case IDM_HELPCONTENTS: 4895 case IDM_HELPKEYS: 4896 case IDM_HELPGENERAL: 4897 if(hwndHelp) { 4898 if(SHORT1FROMMP(mp2) == CMDSRC_MENU) { 4899 4900 RECTL rcl; 4901 ULONG icz = WinQuerySysValue(HWND_DESKTOP,SV_CYICON) * 2L; 4902 4903 WinQueryWindowRect(HWND_DESKTOP,&rcl); 4904 rcl.yBottom += icz; 4905 rcl.yTop -= icz; 4906 rcl.xLeft += icz; 4907 rcl.xRight -= icz; 4908 WinSendMsg(hwndHelp,HM_SET_COVERPAGE_SIZE, 4909 MPFROMP(&rcl),MPVOID); 4910 } 4911 else { 4912 4913 RECTL rcl; 4914 4915 WinQueryWindowRect(HWND_DESKTOP,&rcl); 4916 rcl.yBottom += 8; 4917 rcl.yTop = (rcl.yTop / 2) + (rcl.yTop / 7); 4918 rcl.xLeft = (rcl.xRight / 2) - (rcl.xRight / 7); 4919 rcl.xRight -= 8; 4920 WinSendMsg(hwndHelp,HM_SET_COVERPAGE_SIZE, 4921 MPFROMP(&rcl),MPVOID); 4922 } 4923 switch(SHORT1FROMMP(mp1)) { 4924 case IDM_HELPCONTEXT: 4925 WinSendMsg(hwndHelp,HM_DISPLAY_HELP, 4926 MPFROM2SHORT(HELP_CONTEXT,0), 4927 MPFROMSHORT(HM_RESOURCEID)); 4928 break; 4929 4930 case IDM_HELPMOUSE: 4931 if(hwndHelp) 4932 WinSendMsg(hwndHelp,HM_DISPLAY_HELP, 4933 MPFROM2SHORT(HELP_MOUSE,0), 4934 MPFROMSHORT(HM_RESOURCEID)); 4935 break; 4936 4937 case IDM_HELPPIX: 4938 WinSendMsg(hwndHelp,HM_DISPLAY_HELP, 4939 MPFROM2SHORT(HELP_BITMAP1,0), 4940 MPFROMSHORT(HM_RESOURCEID)); 4941 break; 4942 4943 case IDM_HELPTUTOR: 4944 WinSendMsg(hwndHelp,HM_DISPLAY_HELP, 4945 MPFROM2SHORT(HELP_TUTORIAL,0), 4946 MPFROMSHORT(HM_RESOURCEID)); 4947 break; 4948 4949 case IDM_HELPHINTS: 4950 WinSendMsg(hwndHelp,HM_DISPLAY_HELP, 4951 MPFROM2SHORT(HELP_HINTS,0), 4952 MPFROMSHORT(HM_RESOURCEID)); 4953 break; 4954 4955 case IDM_HELPGENERAL: 4956 WinSendMsg(hwndHelp,HM_DISPLAY_HELP, 4957 MPFROM2SHORT(HELP_MAIN,0), 4958 MPFROMSHORT(HM_RESOURCEID)); 4959 break; 4960 case IDM_HELPKEYS: 4961 WinSendMsg(hwndHelp,HM_DISPLAY_HELP, 4962 MPFROM2SHORT(HELP_KEYS,0), 4963 MPFROMSHORT(HM_RESOURCEID)); 4964 break; 4965 4966 case IDM_HELP: 4967 case IDM_HELPCONTENTS: 4968 WinSendMsg(hwndHelp,HM_HELP_CONTENTS,MPVOID,MPVOID); 4969 break; 4970 4971 case IDM_HELPUSERLIST: 4972 WinSendMsg(hwndHelp,HM_DISPLAY_HELP, 4973 MPFROM2SHORT(HELP_USERLISTS,0), 4974 MPFROMSHORT(HM_RESOURCEID)); 4975 break; 4976 } 4977 } 4978 break; 4979 4980 case IDM_EDITANYARCHIVER: 4981 { 4982 DIRCNRDATA arc; 4983 4984 memset(&arc,0,sizeof(DIRCNRDATA)); 4985 EditArchiverData(hwnd,&arc); 4986 } 4987 break; 4988 4989 case IDM_ABOUT: 4990 WinDlgBox(HWND_DESKTOP,hwnd,AboutDlgProc,FM3ModHandle, 4991 ABT_FRAME,MPVOID); 4992 break; 4993 4994 case IDM_FONTPALETTE: 4995 OpenObject("<WP_FNTPAL>",Default,hwnd); 4996 break; 4997 4998 case IDM_HICOLORPALETTE: 4999 case IDM_COLORPALETTE: 5000 { 5001 CHAR *palette = "<WP_CLRPAL>"; 5002 ULONG version[2]; 5003 5004 if(!DosQuerySysInfo(QSV_VERSION_MAJOR,QSV_VERSION_MINOR, 5005 (PVOID)&version,(ULONG)sizeof(version))) { 5006 if(version[0] > 20L || (version[0] == 20L && version[1] > 29L)) { 5007 if(SHORT1FROMMP(mp1) == IDM_HICOLORPALETTE) 5008 palette = "<WP_HIRESCLRPAL>"; 5009 else 5010 palette = "<WP_LORESCLRPAL>"; 5011 } 5012 } 5013 OpenObject(palette,Default,hwnd); 5014 } 5015 break; 5016 5017 case IDM_SYSTEMSETUP: 5018 OpenObject("<WP_CONFIG>",Default,hwnd); 5019 break; 5020 5021 5022 case IDM_SCHEMEPALETTE: 5023 { 5024 HOBJECT hWPSObject; 5025 5026 hWPSObject = WinQueryObject("<WP_SCHPAL>"); 5027 if(hWPSObject != NULLHANDLE) 5028 WinSetObjectData(hWPSObject,"SCHEMES=Winter:PM_Winter," 5029 "Spring:PM_Spring,Summer:PM_Summer," 5030 "System:PM_System,Windows:PM_Windows;" 5031 "OPEN=DEFAULT"); 5032 } 5033 break; 5034 5035 5036 case IDM_SYSTEMCLOCK: 5037 OpenObject("<WP_CLOCK>",Default,hwnd); 5038 break; 4902 switch (SHORT1FROMMP(mp1)) 4903 { 4904 case IDM_SETTARGET: 4905 SetTargetDir(hwnd, FALSE); 4906 break; 4907 4908 case IDM_TOAUTOMLE: 4909 if (fComments && fAutoView) 4910 WinSetFocus(HWND_DESKTOP, 4911 hwndAutoMLE); 4912 break; 4913 4914 case IDM_HIDENOTEWND: 4915 HideNote(); 4916 break; 4917 case IDM_SHOWNOTEWND: 4918 ShowNote(); 4919 break; 4920 4921 case IDM_COMPARE: 4922 { 4923 WALK2 wa; 4924 PCNRITEM pci; 4925 4926 memset(&wa, 0, sizeof(wa)); 4927 wa.size = sizeof(wa); 4928 pci = (PCNRITEM) WinSendMsg(WinWindowFromID(WinWindowFromID( 4929 hwndTree, FID_CLIENT), TREE_CNR), 4930 CM_QUERYRECORDEMPHASIS, 4931 MPFROMLONG(CMA_FIRST), 4932 MPFROMSHORT(CRA_CURSORED)); 4933 if (pci && (INT) pci != -1) 4934 { 4935 strcpy(wa.szCurrentPath1, pci -> szFileName); 4936 MakeValidDir(wa.szCurrentPath1); 4937 } 4938 else 4939 save_dir2(wa.szCurrentPath1); 4940 TopWindowName(hwndMain, (HWND) 0, wa.szCurrentPath2); 4941 if (!*wa.szCurrentPath2) 4942 strcpy(wa.szCurrentPath2, wa.szCurrentPath1); 4943 MakeValidDir(wa.szCurrentPath2); 4944 if (WinDlgBox(HWND_DESKTOP, 4945 hwnd, 4946 WalkTwoCmpDlgProc, 4947 FM3ModHandle, 4948 WALK2_FRAME, 4949 MPFROMP(&wa)) && 4950 !IsFile(wa.szCurrentPath1) && 4951 !IsFile(wa.szCurrentPath2)) 4952 { 4953 if (!*dircompare) 4954 { 4955 4956 COMPARE *cmp; 4957 4958 cmp = malloc(sizeof(COMPARE)); 4959 if (cmp) 4960 { 4961 memset(cmp, 0, sizeof(COMPARE)); 4962 cmp -> size = sizeof(COMPARE); 4963 strcpy(cmp -> leftdir, wa.szCurrentPath1); 4964 strcpy(cmp -> rightdir, wa.szCurrentPath2); 4965 cmp -> hwndParent = hwnd; 4966 cmp -> dcd.hwndParent = hwnd; 4967 WinDlgBox(HWND_DESKTOP, 4968 HWND_DESKTOP, 4969 CompareDlgProc, 4970 FM3ModHandle, 4971 COMP_FRAME, 4972 MPFROMP(cmp)); 4973 } 4974 } 4975 else 4976 { 4977 4978 CHAR *d1 = "\"", *d2 = "\""; 4979 4980 if (!needs_quoting(wa.szCurrentPath1)) 4981 *d1 = 0; 4982 if (!needs_quoting(wa.szCurrentPath2)) 4983 *d2 = 0; 4984 runemf2(SEPARATE, 4985 HWND_DESKTOP, 4986 NULL, 4987 NULL, 4988 "%s %s%s%s %s%s%s", 4989 dircompare, 4990 d1, 4991 wa.szCurrentPath1, 4992 d1, 4993 d2, 4994 wa.szCurrentPath2, 4995 d2); 4996 } 4997 } 4998 } 4999 break; 5000 5001 case IDM_EXIT: 5002 case IDM_KILLME: 5003 PostMsg(hwnd, 5004 WM_CLOSE, 5005 MPVOID, 5006 MPVOID); 5007 break; 5008 5009 case IDM_CLI: 5010 if (fSplitStatus && 5011 hwndStatus2 && 5012 !WinIsWindow(WinQueryAnchorBlock(hwnd), 5013 WinWindowFromID(hwndStatus2, COMMAND_LINE))) 5014 PostMsg(hwndStatus2, 5015 UM_CLICKED, 5016 MPVOID, 5017 MPVOID); 5018 break; 5019 5020 case IDM_ADDTOUSERLIST: 5021 case IDM_DELETEFROMUSERLIST: 5022 { 5023 CHAR temp[CCHMAXPATH], path[CCHMAXPATH]; 5024 5025 *temp = 0; 5026 WinQueryWindowText(hwndUserlist, 5027 CCHMAXPATH, 5028 temp); 5029 bstrip(temp); 5030 if (*temp && 5031 !DosQueryPathInfo(temp, 5032 FIL_QUERYFULLNAME, 5033 path, 5034 sizeof(path))) 5035 { 5036 if (SHORT1FROMMP(mp1) == IDM_ADDTOUSERLIST) 5037 { 5038 if (add_udir(TRUE, path)) 5039 { 5040 if (fUdirsChanged) 5041 save_udirs(); 5042 WinSendMsg(hwnd, 5043 UM_FILLUSERLIST, 5044 MPVOID, 5045 MPVOID); 5046 } 5047 else 5048 DosBeep(50, 50); 5049 } 5050 else 5051 { 5052 if (remove_udir(path)) 5053 { 5054 if (fUdirsChanged) 5055 save_udirs(); 5056 WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID); 5057 } 5058 else 5059 DosBeep(50, 50); 5060 } 5061 } 5062 } 5063 break; 5064 5065 case IDM_SAVEDIRCNRSTATE: 5066 case IDM_DELETEDIRCNRSTATE: 5067 { 5068 CHAR name[14]; 5069 5070 *name = 0; 5071 WinQueryWindowText(hwndStatelist, 13, name); 5072 bstrip(name); 5073 if (*name) 5074 { 5075 if (SHORT1FROMMP(mp1) == IDM_SAVEDIRCNRSTATE) 5076 { 5077 if (SaveDirCnrState(hwnd, name)) 5078 { 5079 if (add_setup(name)) 5080 { 5081 WinSendMsg(hwndStatelist, LM_INSERTITEM, 5082 MPFROM2SHORT(LIT_SORTASCENDING, 0), 5083 MPFROMP(name)); 5084 save_setups(); 5085 } 5086 } 5087 WinSetWindowText(hwndStatelist, 5088 GetPString(IDS_STATETEXT)); 5089 } 5090 else 5091 { 5092 5093 ULONG numsaves = 0, size, x; 5094 CHAR s[120]; 5095 5096 if (remove_setup(name)) 5097 save_setups(); 5098 sprintf(s, "%s.NumDirsLastTime", name); 5099 size = sizeof(ULONG); 5100 if (PrfQueryProfileData(fmprof, FM3Str, s, (PVOID) & numsaves, 5101 &size) && size) 5102 { 5103 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0L); 5104 for (x = 0; x < numsaves; x++) 5105 { 5106 sprintf(s, "%s.DirCnrPos.%lu", name, x); 5107 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0); 5108 sprintf(s, "%s.DirCnrDir.%lu", name, x); 5109 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0); 5110 sprintf(s, "%s.DirCnrSort.%lu", name, x); 5111 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0); 5112 sprintf(s, "%s.DirCnrFilter.%lu", name, x); 5113 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0); 5114 sprintf(s, "%s.DirCnrView.%lu", name, x); 5115 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0); 5116 } 5117 sprintf(s, "%s.LastTreePos", name); 5118 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0); 5119 sprintf(s, "%s.MySizeLastTime", name); 5120 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0); 5121 } 5122 else 5123 DosBeep(50, 100); 5124 PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID); 5125 } 5126 } 5127 } 5128 break; 5129 5130 case IDM_IDEALSIZE: 5131 { 5132 SWP swp, swpD; 5133 ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2L; 5134 ULONG bsz = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER); 5135 5136 WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp); 5137 if (swp.fl & SWP_MAXIMIZE) 5138 { 5139 WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_SYSCOMMAND, 5140 MPFROM2SHORT(SC_RESTORE, 0), MPVOID); 5141 WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp); 5142 } 5143 WinGetMaxPosition(WinQueryWindow(hwnd, QW_PARENT), &swpD); 5144 swpD.x += bsz; 5145 swpD.cx -= (bsz * 2); 5146 swpD.y += icz; 5147 swpD.cy -= (icz + bsz); 5148 if (swp.x == swpD.x && swp.y == swpD.y && 5149 swp.cx == swpD.cx && 5150 swp.cy == swpD.cy && 5151 WinQueryWindowUShort(hwnd, QWL_USER + 10) && 5152 WinQueryWindowUShort(hwnd, QWL_USER + 14)) 5153 { 5154 swpD.x = WinQueryWindowUShort(hwnd, QWL_USER + 8); 5155 swpD.cx = WinQueryWindowUShort(hwnd, QWL_USER + 10); 5156 swpD.y = WinQueryWindowUShort(hwnd, QWL_USER + 12); 5157 swpD.cy = WinQueryWindowUShort(hwnd, QWL_USER + 14); 5158 } 5159 else 5160 { 5161 WinSetWindowUShort(hwnd, QWL_USER + 8, (USHORT) swp.x); 5162 WinSetWindowUShort(hwnd, QWL_USER + 10, (USHORT) swp.cx); 5163 WinSetWindowUShort(hwnd, QWL_USER + 12, (USHORT) swp.y); 5164 WinSetWindowUShort(hwnd, QWL_USER + 14, (USHORT) swp.cy); 5165 } 5166 WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 5167 swpD.x, swpD.y, swpD.cx, 5168 swpD.cy, SWP_MOVE | SWP_SIZE); 5169 } 5170 break; 5171 5172 case IDM_BLINK: 5173 WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0, 5174 SWP_MINIMIZE); 5175 WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0, 5176 SWP_RESTORE | SWP_ZORDER); 5177 break; 5178 5179 case DID_CANCEL: 5180 { 5181 HWND hwndTop = TopWindow(hwndMain, (HWND) 0); 5182 5183 if (hwndTop) 5184 WinSetFocus(HWND_DESKTOP, 5185 hwndTop); 5186 } 5187 break; 5188 5189 case IDM_NOTEBOOK: 5190 WinDlgBox(HWND_DESKTOP, 5191 hwnd, 5192 CfgDlgProc, 5193 FM3ModHandle, 5194 CFG_FRAME, 5195 MPVOID); 5196 break; 5197 5198 case IDM_VIEWHELPS: 5199 case IDM_VIEWINFS: 5200 WinDlgBox(HWND_DESKTOP, 5201 HWND_DESKTOP, 5202 ViewInfProc, 5203 FM3ModHandle, 5204 VINF_FRAME, 5205 ((SHORT1FROMMP(mp1) == IDM_VIEWHELPS) ? 5206 MPFROMP(NullStr) : 5207 MPVOID)); 5208 break; 5209 5210 case IDM_OPENWALK: 5211 { 5212 char newpath[CCHMAXPATH]; 5213 5214 *newpath = 0; 5215 TopWindowName(hwnd, (HWND) 0, newpath); 5216 if (WinDlgBox(HWND_DESKTOP, 5217 hwnd, 5218 WalkAllDlgProc, 5219 FM3ModHandle, 5220 WALK_FRAME, 5221 MPFROMP(newpath)) && 5222 *newpath) 5223 OpenDirCnr((HWND) 0, 5224 hwndMain, 5225 hwndTree, 5226 FALSE, 5227 newpath); 5228 } 5229 break; 5230 5231 case IDM_WINDOWDLG: 5232 WindowList(hwnd); 5233 break; 5234 5235 case IDM_HELPMOUSE: 5236 case IDM_HELPCONTEXT: 5237 case IDM_HELPHINTS: 5238 case IDM_HELPPIX: 5239 case IDM_HELPTUTOR: 5240 case IDM_HELPUSERLIST: 5241 case IDM_HELP: 5242 case IDM_HELPCONTENTS: 5243 case IDM_HELPKEYS: 5244 case IDM_HELPGENERAL: 5245 if (hwndHelp) 5246 { 5247 if (SHORT1FROMMP(mp2) == CMDSRC_MENU) 5248 { 5249 5250 RECTL rcl; 5251 ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2L; 5252 5253 WinQueryWindowRect(HWND_DESKTOP, &rcl); 5254 rcl.yBottom += icz; 5255 rcl.yTop -= icz; 5256 rcl.xLeft += icz; 5257 rcl.xRight -= icz; 5258 WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, 5259 MPFROMP(&rcl), MPVOID); 5260 } 5261 else 5262 { 5263 5264 RECTL rcl; 5265 5266 WinQueryWindowRect(HWND_DESKTOP, &rcl); 5267 rcl.yBottom += 8; 5268 rcl.yTop = (rcl.yTop / 2) + (rcl.yTop / 7); 5269 rcl.xLeft = (rcl.xRight / 2) - (rcl.xRight / 7); 5270 rcl.xRight -= 8; 5271 WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, 5272 MPFROMP(&rcl), MPVOID); 5273 } 5274 switch (SHORT1FROMMP(mp1)) 5275 { 5276 case IDM_HELPCONTEXT: 5277 WinSendMsg(hwndHelp, HM_DISPLAY_HELP, 5278 MPFROM2SHORT(HELP_CONTEXT, 0), 5279 MPFROMSHORT(HM_RESOURCEID)); 5280 break; 5281 5282 case IDM_HELPMOUSE: 5283 if (hwndHelp) 5284 WinSendMsg(hwndHelp, HM_DISPLAY_HELP, 5285 MPFROM2SHORT(HELP_MOUSE, 0), 5286 MPFROMSHORT(HM_RESOURCEID)); 5287 break; 5288 5289 case IDM_HELPPIX: 5290 WinSendMsg(hwndHelp, HM_DISPLAY_HELP, 5291 MPFROM2SHORT(HELP_BITMAP1, 0), 5292 MPFROMSHORT(HM_RESOURCEID)); 5293 break; 5294 5295 case IDM_HELPTUTOR: 5296 WinSendMsg(hwndHelp, HM_DISPLAY_HELP, 5297 MPFROM2SHORT(HELP_TUTORIAL, 0), 5298 MPFROMSHORT(HM_RESOURCEID)); 5299 break; 5300 5301 case IDM_HELPHINTS: 5302 WinSendMsg(hwndHelp, HM_DISPLAY_HELP, 5303 MPFROM2SHORT(HELP_HINTS, 0), 5304 MPFROMSHORT(HM_RESOURCEID)); 5305 break; 5306 5307 case IDM_HELPGENERAL: 5308 WinSendMsg(hwndHelp, HM_DISPLAY_HELP, 5309 MPFROM2SHORT(HELP_MAIN, 0), 5310 MPFROMSHORT(HM_RESOURCEID)); 5311 break; 5312 case IDM_HELPKEYS: 5313 WinSendMsg(hwndHelp, HM_DISPLAY_HELP, 5314 MPFROM2SHORT(HELP_KEYS, 0), 5315 MPFROMSHORT(HM_RESOURCEID)); 5316 break; 5317 5318 case IDM_HELP: 5319 case IDM_HELPCONTENTS: 5320 WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID); 5321 break; 5322 5323 case IDM_HELPUSERLIST: 5324 WinSendMsg(hwndHelp, HM_DISPLAY_HELP, 5325 MPFROM2SHORT(HELP_USERLISTS, 0), 5326 MPFROMSHORT(HM_RESOURCEID)); 5327 break; 5328 } 5329 } 5330 break; 5331 5332 case IDM_EDITANYARCHIVER: 5333 { 5334 DIRCNRDATA arc; 5335 5336 memset(&arc, 0, sizeof(DIRCNRDATA)); 5337 EditArchiverData(hwnd, &arc); 5338 } 5339 break; 5340 5341 case IDM_ABOUT: 5342 WinDlgBox(HWND_DESKTOP, hwnd, AboutDlgProc, FM3ModHandle, 5343 ABT_FRAME, MPVOID); 5344 break; 5345 5346 case IDM_FONTPALETTE: 5347 OpenObject("<WP_FNTPAL>", Default, hwnd); 5348 break; 5349 5350 case IDM_HICOLORPALETTE: 5351 case IDM_COLORPALETTE: 5352 { 5353 CHAR *palette = "<WP_CLRPAL>"; 5354 ULONG version[2]; 5355 5356 if (!DosQuerySysInfo(QSV_VERSION_MAJOR, QSV_VERSION_MINOR, 5357 (PVOID) & version, (ULONG) sizeof(version))) 5358 { 5359 if (version[0] > 20L || (version[0] == 20L && version[1] > 29L)) 5360 { 5361 if (SHORT1FROMMP(mp1) == IDM_HICOLORPALETTE) 5362 palette = "<WP_HIRESCLRPAL>"; 5363 else 5364 palette = "<WP_LORESCLRPAL>"; 5365 } 5366 } 5367 OpenObject(palette, Default, hwnd); 5368 } 5369 break; 5370 5371 case IDM_SYSTEMSETUP: 5372 OpenObject("<WP_CONFIG>", Default, hwnd); 5373 break; 5374 5375 case IDM_SCHEMEPALETTE: 5376 { 5377 HOBJECT hWPSObject; 5378 5379 hWPSObject = WinQueryObject("<WP_SCHPAL>"); 5380 if (hWPSObject != NULLHANDLE) 5381 WinSetObjectData(hWPSObject, "SCHEMES=Winter:PM_Winter," 5382 "Spring:PM_Spring,Summer:PM_Summer," 5383 "System:PM_System,Windows:PM_Windows;" 5384 "OPEN=DEFAULT"); 5385 } 5386 break; 5387 5388 case IDM_SYSTEMCLOCK: 5389 OpenObject("<WP_CLOCK>", Default, hwnd); 5390 break; 5039 5391 5040 5392 #ifdef NEVER 5041 5042 WinDlgBox(HWND_DESKTOP,HWND_DESKTOP,SysInfoDlgProc,FM3ModHandle,5043 SYS_FRAME,NULL);5044 5393 case IDM_SYSINFO: 5394 WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, SysInfoDlgProc, FM3ModHandle, 5395 SYS_FRAME, NULL); 5396 break; 5045 5397 #endif 5046 5398 5047 case IDM_INSTANT: 5048 { 5049 CHAR path[CCHMAXPATH]; 5050 PCNRITEM pci = (PCNRITEM)0; 5051 5052 if(hwndTree) 5053 pci = (PCNRITEM)WinSendMsg(hwndTree,CM_QUERYRECORDEMPHASIS, 5054 MPFROMLONG(CMA_FIRST), 5055 MPFROMSHORT(CRA_CURSORED)); 5056 if(pci && (INT)pci != -1) { 5057 strcpy(path,pci->szFileName); 5058 MakeValidDir(path); 5059 } 5060 else 5061 save_dir2(path); 5062 WinDlgBox(HWND_DESKTOP,hwnd,InstantDlgProc,FM3ModHandle, 5063 BAT_FRAME,MPFROMP(path)); 5064 } 5065 break; 5066 5067 case IDM_WINFULLSCREEN: 5068 case IDM_DOSCOMMANDLINE: 5069 case IDM_COMMANDLINE: 5070 { 5071 CHAR *env = GetCmdSpec(FALSE),path[CCHMAXPATH]; 5072 INT type = SEPARATE | WINDOWED; 5073 5074 *path = 0; 5075 TopWindowName(hwnd,(HWND)0,path); 5076 if(SHORT1FROMMP(mp1) == IDM_DOSCOMMANDLINE) 5077 env = GetCmdSpec(TRUE); 5078 else if(SHORT1FROMMP(mp1) != IDM_COMMANDLINE) { 5079 env = "WINOS2.COM"; 5080 type = SEPARATE | FULLSCREEN; 5081 } 5082 runemf2(type,hwnd,path,NULL,"%s",env); 5083 } 5084 break; 5085 5086 case IDM_KILLPROC: 5087 WinDlgBox(HWND_DESKTOP,hwnd,KillDlgProc,FM3ModHandle, 5088 KILL_FRAME,NULL); 5089 break; 5090 5091 case IDM_AUTOVIEWCOMMENTS: 5092 case IDM_AUTOVIEWFILE: 5093 if(SHORT1FROMMP(mp1) == IDM_AUTOVIEWFILE) 5094 fComments = FALSE; 5399 case IDM_INSTANT: 5400 { 5401 CHAR path[CCHMAXPATH]; 5402 PCNRITEM pci = (PCNRITEM) 0; 5403 5404 if (hwndTree) 5405 pci = (PCNRITEM) WinSendMsg(hwndTree, CM_QUERYRECORDEMPHASIS, 5406 MPFROMLONG(CMA_FIRST), 5407 MPFROMSHORT(CRA_CURSORED)); 5408 if (pci && (INT) pci != -1) 5409 { 5410 strcpy(path, pci -> szFileName); 5411 MakeValidDir(path); 5412 } 5095 5413 else 5096 fComments = TRUE; 5097 PrfWriteProfileData(fmprof,FM3Str,"Comments",&fComments, 5098 sizeof(BOOL)); 5099 WinSetWindowText((fComments) ? hwndAutoview : hwndAutoMLE,NullStr); 5100 goto AutoChange; 5101 5102 case IDM_AUTOVIEW: 5103 SetMenuCheck(WinQueryWindowULong(hwnd,QWL_USER),SHORT1FROMMP(mp1), 5104 &fAutoView,TRUE,"AutoView"); 5105 AutoChange: 5106 PostMsg(WinQueryWindow(hwnd,QW_PARENT),WM_UPDATEFRAME, 5107 MPFROMLONG(FCF_SIZEBORDER),MPVOID); 5108 if(fAutoView) { 5109 5110 CHAR s[CCHMAXPATH]; 5111 HWND hwndDir; 5112 PCNRITEM pci; 5113 5114 hwndDir = TopWindowName(hwnd,(HWND)0,s); 5115 if(hwndDir) { 5116 hwndDir = WinWindowFromID(hwndDir,FID_CLIENT); 5117 if(hwndDir) { 5118 hwndDir = WinWindowFromID(hwndDir,DIR_CNR); 5119 if(hwndDir) { 5120 pci = (PCNRITEM)WinSendMsg(hwndDir,CM_QUERYRECORDEMPHASIS, 5121 MPFROMLONG(CMA_FIRST), 5122 MPFROMSHORT(CRA_CURSORED)); 5123 if(pci && (INT)pci != -1 && 5124 (!(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_SLOW))) 5125 WinSendMsg(hwnd, 5126 UM_LOADFILE, 5127 MPFROMP(pci->szFileName), 5128 (SHORT1FROMMP(mp1) == IDM_AUTOVIEW) ? 5129 MPVOID : 5130 MPFROMLONG(1L)); 5131 } 5132 } 5133 } 5134 } 5135 break; 5136 5137 case IDM_TEXTTOOLS: 5138 SetMenuCheck(WinQueryWindowULong(hwnd,QWL_USER),SHORT1FROMMP(mp1), 5139 &fTextTools,TRUE,"TextTools"); 5140 BuildTools(hwndToolback,TRUE); 5141 PostMsg(WinQueryWindow(hwnd,QW_PARENT),WM_UPDATEFRAME, 5142 MPFROMLONG(FCF_SIZEBORDER),MPVOID); 5143 break; 5144 5145 case IDM_TOOLTITLES: 5146 SetMenuCheck(WinQueryWindowULong(hwnd,QWL_USER),SHORT1FROMMP(mp1), 5147 &fToolTitles,TRUE,"ToolTitles"); 5148 BuildTools(hwndToolback,TRUE); 5149 PostMsg(WinQueryWindow(hwnd,QW_PARENT),WM_UPDATEFRAME, 5150 MPFROMLONG(FCF_SIZEBORDER),MPVOID); 5151 break; 5152 5153 case IDM_HIDEMENU: 5154 { 5155 HWND hwndMenu; 5156 5157 hwndMenu = WinQueryWindowULong(hwnd,QWL_USER); 5158 MenuInvisible = (MenuInvisible) ? FALSE : TRUE; 5159 if(MenuInvisible) { 5160 WinSetParent(hwndMenu,HWND_OBJECT,FALSE); 5161 WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT), 5162 FID_SYSMENU),IDM_HIDEMENU, 5163 GetPString(IDS_UNHIDEMENUTEXT)); 5164 } 5165 else { 5166 WinSetParent(hwndMenu,WinQueryWindow(hwnd,QW_PARENT),FALSE); 5167 WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT), 5168 FID_SYSMENU),IDM_HIDEMENU, 5169 GetPString(IDS_HIDEMENUTEXT)); 5170 } 5171 PostMsg(WinQueryWindow(hwnd,QW_PARENT),WM_UPDATEFRAME, 5172 MPFROMLONG(FCF_MENU),MPVOID); 5173 PrfWriteProfileData(fmprof,FM3Str,"MenuInvisible", 5174 &MenuInvisible,sizeof(BOOL)); 5175 } 5176 break; 5177 5178 case IDM_SEEALL: 5179 case IDM_GREP: 5180 case IDM_COLLECTOR: 5181 { 5182 HWND hwndC; 5183 SWP swp; 5184 BOOL already = FALSE; 5185 5186 if(Collector) 5187 already = TRUE; 5188 if(!already && !fAutoTile && !fExternalCollector) 5189 GetNextWindowPos(hwnd,&swp,NULL,NULL); 5190 hwndC = StartCollector((fExternalCollector) ? HWND_DESKTOP : 5191 hwnd,4); 5192 if(hwndC) { 5193 if(!already && !fAutoTile && !fExternalCollector) 5194 WinSetWindowPos(hwndC,HWND_TOP,swp.x,swp.y, 5195 swp.cx,swp.cy,SWP_MOVE | SWP_SIZE | 5196 SWP_SHOW | SWP_ZORDER); 5197 else if(fAutoTile && !already) 5198 TileChildren(hwnd,TRUE); 5199 WinSetWindowPos(hwndC,HWND_TOP,0,0,0,0,SWP_SHOW | SWP_RESTORE | 5200 SWP_ACTIVATE); 5201 if(SHORT1FROMMP(mp1) == IDM_GREP) 5202 PostMsg(WinWindowFromID(hwndC,FID_CLIENT),WM_COMMAND, 5203 MPFROM2SHORT(IDM_GREP,0),MPVOID); 5204 if(SHORT1FROMMP(mp1) == IDM_SEEALL) 5205 PostMsg(WinWindowFromID(hwndC,FID_CLIENT),WM_COMMAND, 5206 MPFROM2SHORT(IDM_SEEALL,0),MPVOID); 5207 } 5208 } 5209 break; 5210 5211 case IDM_TOOLLEFT: 5212 case IDM_TOOLRIGHT: 5213 { 5214 TOOL *tool; 5215 5216 if(!toolhead || !toolhead->next) { 5217 firsttool = (toolhead) ? toolhead->id : 0; 5218 break; 5219 } 5220 tool = find_tool(firsttool); 5221 if(!tool) 5222 tool = toolhead; 5223 if(SHORT1FROMMP(mp1) == IDM_TOOLRIGHT) { 5224 tool = prev_tool(tool,TRUE); 5225 firsttool = tool->id; 5226 } 5227 else { 5228 tool = next_tool(tool,TRUE); 5229 firsttool = tool->id; 5230 } 5231 ResizeTools(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT), 5232 MAIN_TOOLS)); 5233 } 5234 break; 5235 5236 case IDM_CREATETOOL: 5237 BuildTools(hwndToolback, 5238 TRUE); 5239 break; 5240 5241 case IDM_TOOLBAR: 5242 SetMenuCheck(WinQueryWindowULong(hwnd,QWL_USER), 5243 IDM_TOOLSUBMENU, 5244 &fToolbar, 5245 TRUE, 5246 "Toolbar"); 5247 BuildTools(hwndToolback, 5248 TRUE); 5249 WinShowWindow(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT), 5250 MAIN_TOOLS), 5251 fToolbar); 5252 WinSendMsg(WinQueryWindow(hwnd,QW_PARENT), 5253 WM_UPDATEFRAME, 5254 MPFROMLONG(FCF_SIZEBORDER), 5255 MPVOID); 5256 if(fDrivebar) 5257 WinInvalidateRect(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT), 5258 MAIN_DRIVES), 5259 NULL, 5260 TRUE); 5261 break; 5262 5263 case IDM_DRIVEBAR: 5264 SetMenuCheck(WinQueryWindowULong(hwnd,QWL_USER), 5265 IDM_DRIVEBAR, 5266 &fDrivebar, 5267 TRUE, 5268 "Drivebar"); 5269 WinShowWindow(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT), 5270 MAIN_DRIVES), 5271 fDrivebar); 5272 PostMsg(WinQueryWindow(hwnd,QW_PARENT), 5273 WM_UPDATEFRAME, 5274 MPFROMLONG(FCF_SIZEBORDER), 5275 MPVOID); 5276 PostMsg(hwnd, 5277 UM_BUILDDRIVES, 5278 MPVOID, 5279 MPVOID); 5280 break; 5281 5282 case IDM_USERLIST: 5283 SetMenuCheck(WinQueryWindowULong(hwnd,QWL_USER), 5284 SHORT1FROMMP(mp1), 5285 &fUserComboBox, 5286 TRUE, 5287 "UserComboBox"); 5288 WinShowWindow(hwndUserlist,fUserComboBox); 5289 PostMsg(WinQueryWindow(hwnd,QW_PARENT), 5290 WM_UPDATEFRAME, 5291 MPFROMLONG(FCF_SIZEBORDER), 5292 MPVOID); 5293 PostMsg(hwnd, 5294 UM_FILLUSERLIST, 5295 MPVOID, 5296 MPVOID); 5297 PostMsg(hwnd, 5298 UM_FILLSETUPLIST, 5299 MPVOID, 5300 MPVOID); 5301 PostMsg(hwnd, 5302 UM_FILLCMDLIST, 5303 MPVOID, 5304 MPVOID); 5305 PostMsg(hwnd, 5306 UM_FILLBUTTONLIST, 5307 MPVOID, 5308 MPVOID); 5309 break; 5310 5311 case IDM_MOREBUTTONS: 5312 WinSetWindowText(hwndName,NullStr); 5313 WinSetWindowText(hwndDate,NullStr); 5314 WinSetWindowText(hwndAttr,NullStr); 5315 SetMenuCheck(WinQueryWindowULong(hwnd,QWL_USER), 5316 SHORT1FROMMP(mp1), 5317 &fMoreButtons, 5318 TRUE, 5319 "MoreButtons"); 5320 if(fMoreButtons) { 5321 5322 HWND hwndTemp; 5323 5324 hwndTemp = TopWindow(hwnd,(HWND)0); 5325 5326 if(hwndTemp) { 5327 WinSetFocus(HWND_DESKTOP, 5328 hwnd); 5329 WinSetFocus(HWND_DESKTOP, 5330 hwndTemp); 5331 } 5332 } 5333 PostMsg(WinQueryWindow(hwnd,QW_PARENT), 5334 WM_UPDATEFRAME, 5335 MPFROMLONG(FCF_SIZEBORDER), 5336 MPVOID); 5337 break; 5338 5339 case IDM_FREETREE: 5340 if(fFreeTree) { 5341 5342 SWP swp,swpT; 5343 5344 WinQueryWindowPos(hwndTree,&swpT); 5345 WinQueryWindowPos(hwnd,&swp); 5346 WinSetWindowPos(hwndTree,HWND_TOP,0,swp.cy - swpT.cy,0,0,SWP_MOVE); 5347 } 5348 SetMenuCheck(WinQueryWindowULong(hwnd,QWL_USER),SHORT1FROMMP(mp1), 5349 &fFreeTree,TRUE,"FreeTree"); 5350 if(fAutoTile) 5351 TileChildren(hwnd,TRUE); 5352 break; 5353 5354 case IDM_AUTOTILE: 5355 SetMenuCheck(WinQueryWindowULong(hwnd,QWL_USER), 5356 SHORT1FROMMP(mp1), 5357 &fAutoTile, 5358 TRUE, 5359 "AutoTile"); 5360 if(fAutoTile) 5361 TileChildren(hwnd,TRUE); 5362 break; 5363 5364 case IDM_TILEBACKWARDS: 5365 SetMenuCheck(WinQueryWindowULong(hwnd,QWL_USER), 5366 SHORT1FROMMP(mp1), 5367 &fTileBackwards, 5368 TRUE, 5369 "TileBackwards"); 5370 if(fAutoTile) 5371 TileChildren(hwnd,TRUE); 5372 break; 5373 5374 case IDM_NEXTWINDOW: 5375 case IDM_PREVWINDOW: 5376 NextChild(hwnd, 5377 (SHORT1FROMMP(mp1) == IDM_PREVWINDOW)); 5378 break; 5379 5380 case IDM_CASCADE: 5381 CascadeChildren(hwnd); 5382 break; 5383 5384 case IDM_TILE: 5385 TileChildren(hwnd,TRUE); 5386 break; 5387 5388 case IDM_RESTORE: 5389 MinResChildren(hwnd, 5390 SWP_RESTORE); 5391 break; 5392 5393 case IDM_MINIMIZE: 5394 MinResChildren(hwnd, 5395 SWP_MINIMIZE); 5396 break; 5397 5398 case IDM_ARRANGEICONS: 5399 ArrangeIcons(hwnd); 5400 break; 5401 5402 case IDM_INIVIEWER: 5403 StartIniEditor(hwnd,NULL,4); 5404 break; 5405 5406 case IDM_EDITASSOC: 5407 EditAssociations(hwnd); 5408 break; 5409 5410 case IDM_EDITCOMMANDS: 5411 EditCommands(hwnd); 5412 PostMsg(hwnd, 5413 UM_FILLCMDLIST, 5414 MPVOID, 5415 MPVOID); 5416 break; 5417 5418 default: 5419 if(!SwitchCommand((HWND)WinQueryWindowULong(hwnd,QWL_USER), 5420 SHORT1FROMMP(mp1))) { 5421 if(SHORT1FROMMP(mp1) >= IDM_COMMANDSTART && 5422 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) { 5423 5424 INT x; 5425 HWND hwndCnr; 5426 5427 if(!cmdloaded) 5428 load_commands(); 5429 hwndCnr = TopWindow(hwnd,(HWND)0); 5430 hwndCnr = (HWND)WinSendMsg(WinWindowFromID(hwndCnr,FID_CLIENT), 5431 UM_CONTAINERHWND, 5432 MPVOID, 5433 MPVOID); 5434 if(!hwndCnr) { 5435 DosBeep(50,100); 5436 break; 5437 } 5438 x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART; 5439 if(x >= 0) { 5440 x++; 5441 RunCommand(hwndCnr,x); 5442 if(fUnHilite) { 5443 5444 PCNRITEM pci; 5445 DIRCNRDATA *dcd = NULL; 5446 5447 if(WinQueryWindowUShort(hwndCnr,QWS_ID) != TREE_CNR) 5448 dcd = INSTDATA(hwndCnr); 5449 pci = (PCNRITEM)WinSendMsg(hwndCnr, 5450 CM_QUERYRECORDEMPHASIS, 5451 MPFROMLONG(CMA_FIRST), 5452 MPFROMSHORT(CRA_CURSORED)); 5453 if(pci && (INT)pci != -1 && 5454 (pci->rc.flRecordAttr & CRA_SELECTED)) 5455 UnHilite(hwnd, 5456 TRUE, 5457 ((dcd) ? &dcd->lastselection : NULL)); 5458 } 5459 } 5460 } 5461 else if(SHORT1FROMMP(mp1) >= IDM_QUICKTOOLSTART && 5462 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART + 50) { 5463 if(!qtloaded) 5464 load_quicktools(); 5465 if(quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]) { 5466 if(fToolsChanged) 5467 save_tools(NULL); 5468 if(!load_tools(quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART])) 5469 load_tools(NULL); 5470 else { 5471 strcpy(lasttoolbox, 5472 quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]); 5473 PrfWriteProfileString(fmprof, 5474 FM3Str, 5475 "LastToolBox", 5476 lasttoolbox); 5477 } 5478 BuildTools(hwndToolback, 5479 TRUE); 5480 } 5481 } 5482 else { 5483 5484 HWND hwndActive; 5485 5486 hwndActive = TopWindow(hwnd, 5487 (HWND)0); 5488 if(hwndActive) 5489 PostMsg(WinWindowFromID(hwndActive,FID_CLIENT), 5490 WM_COMMAND, 5491 mp1, 5492 mp2); 5493 } 5494 } 5495 break; 5414 save_dir2(path); 5415 WinDlgBox(HWND_DESKTOP, hwnd, InstantDlgProc, FM3ModHandle, 5416 BAT_FRAME, MPFROMP(path)); 5417 } 5418 break; 5419 5420 case IDM_WINFULLSCREEN: 5421 case IDM_DOSCOMMANDLINE: 5422 case IDM_COMMANDLINE: 5423 { 5424 CHAR *env = GetCmdSpec(FALSE), path[CCHMAXPATH]; 5425 INT type = SEPARATE | WINDOWED; 5426 5427 *path = 0; 5428 TopWindowName(hwnd, (HWND) 0, path); 5429 if (SHORT1FROMMP(mp1) == IDM_DOSCOMMANDLINE) 5430 env = GetCmdSpec(TRUE); 5431 else if (SHORT1FROMMP(mp1) != IDM_COMMANDLINE) 5432 { 5433 env = "WINOS2.COM"; 5434 type = SEPARATE | FULLSCREEN; 5435 } 5436 runemf2(type, hwnd, path, NULL, "%s", env); 5437 } 5438 break; 5439 5440 case IDM_KILLPROC: 5441 WinDlgBox(HWND_DESKTOP, hwnd, KillDlgProc, FM3ModHandle, 5442 KILL_FRAME, NULL); 5443 break; 5444 5445 case IDM_AUTOVIEWCOMMENTS: 5446 case IDM_AUTOVIEWFILE: 5447 if (SHORT1FROMMP(mp1) == IDM_AUTOVIEWFILE) 5448 fComments = FALSE; 5449 else 5450 fComments = TRUE; 5451 PrfWriteProfileData(fmprof, FM3Str, "Comments", &fComments, 5452 sizeof(BOOL)); 5453 WinSetWindowText((fComments) ? hwndAutoview : hwndAutoMLE, NullStr); 5454 goto AutoChange; 5455 5456 case IDM_AUTOVIEW: 5457 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1), 5458 &fAutoView, TRUE, "AutoView"); 5459 AutoChange: 5460 PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME, 5461 MPFROMLONG(FCF_SIZEBORDER), MPVOID); 5462 if (fAutoView) 5463 { 5464 5465 CHAR s[CCHMAXPATH]; 5466 HWND hwndDir; 5467 PCNRITEM pci; 5468 5469 hwndDir = TopWindowName(hwnd, (HWND) 0, s); 5470 if (hwndDir) 5471 { 5472 hwndDir = WinWindowFromID(hwndDir, FID_CLIENT); 5473 if (hwndDir) 5474 { 5475 hwndDir = WinWindowFromID(hwndDir, DIR_CNR); 5476 if (hwndDir) 5477 { 5478 pci = (PCNRITEM) WinSendMsg(hwndDir, CM_QUERYRECORDEMPHASIS, 5479 MPFROMLONG(CMA_FIRST), 5480 MPFROMSHORT(CRA_CURSORED)); 5481 if (pci && (INT) pci != -1 && 5482 (!(driveflags[toupper(*pci -> szFileName) - 'A'] & DRIVE_SLOW))) 5483 WinSendMsg(hwnd, 5484 UM_LOADFILE, 5485 MPFROMP(pci -> szFileName), 5486 (SHORT1FROMMP(mp1) == IDM_AUTOVIEW) ? 5487 MPVOID : 5488 MPFROMLONG(1L)); 5489 } 5490 } 5491 } 5492 } 5493 break; 5494 5495 case IDM_TEXTTOOLS: 5496 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1), 5497 &fTextTools, TRUE, "TextTools"); 5498 BuildTools(hwndToolback, TRUE); 5499 PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME, 5500 MPFROMLONG(FCF_SIZEBORDER), MPVOID); 5501 break; 5502 5503 case IDM_TOOLTITLES: 5504 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1), 5505 &fToolTitles, TRUE, "ToolTitles"); 5506 BuildTools(hwndToolback, TRUE); 5507 PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME, 5508 MPFROMLONG(FCF_SIZEBORDER), MPVOID); 5509 break; 5510 5511 case IDM_HIDEMENU: 5512 { 5513 HWND hwndMenu; 5514 5515 hwndMenu = WinQueryWindowULong(hwnd, QWL_USER); 5516 MenuInvisible = (MenuInvisible) ? FALSE : TRUE; 5517 if (MenuInvisible) 5518 { 5519 WinSetParent(hwndMenu, HWND_OBJECT, FALSE); 5520 WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), 5521 FID_SYSMENU), IDM_HIDEMENU, 5522 GetPString(IDS_UNHIDEMENUTEXT)); 5523 } 5524 else 5525 { 5526 WinSetParent(hwndMenu, WinQueryWindow(hwnd, QW_PARENT), FALSE); 5527 WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), 5528 FID_SYSMENU), IDM_HIDEMENU, 5529 GetPString(IDS_HIDEMENUTEXT)); 5530 } 5531 PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME, 5532 MPFROMLONG(FCF_MENU), MPVOID); 5533 PrfWriteProfileData(fmprof, FM3Str, "MenuInvisible", 5534 &MenuInvisible, sizeof(BOOL)); 5535 } 5536 break; 5537 5538 case IDM_SEEALL: 5539 case IDM_GREP: 5540 case IDM_COLLECTOR: 5541 { 5542 HWND hwndC; 5543 SWP swp; 5544 BOOL already = FALSE; 5545 5546 if (Collector) 5547 already = TRUE; 5548 if (!already && !fAutoTile && !fExternalCollector) 5549 GetNextWindowPos(hwnd, &swp, NULL, NULL); 5550 hwndC = StartCollector((fExternalCollector) ? HWND_DESKTOP : 5551 hwnd, 4); 5552 if (hwndC) 5553 { 5554 if (!already && !fAutoTile && !fExternalCollector) 5555 WinSetWindowPos(hwndC, HWND_TOP, swp.x, swp.y, 5556 swp.cx, swp.cy, SWP_MOVE | SWP_SIZE | 5557 SWP_SHOW | SWP_ZORDER); 5558 else if (fAutoTile && !already) 5559 TileChildren(hwnd, TRUE); 5560 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE | 5561 SWP_ACTIVATE); 5562 if (SHORT1FROMMP(mp1) == IDM_GREP) 5563 PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND, 5564 MPFROM2SHORT(IDM_GREP, 0), MPVOID); 5565 if (SHORT1FROMMP(mp1) == IDM_SEEALL) 5566 PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND, 5567 MPFROM2SHORT(IDM_SEEALL, 0), MPVOID); 5568 } 5569 } 5570 break; 5571 5572 case IDM_TOOLLEFT: 5573 case IDM_TOOLRIGHT: 5574 { 5575 TOOL *tool; 5576 5577 if (!toolhead || !toolhead -> next) 5578 { 5579 firsttool = (toolhead) ? toolhead -> id : 0; 5580 break; 5581 } 5582 tool = find_tool(firsttool); 5583 if (!tool) 5584 tool = toolhead; 5585 if (SHORT1FROMMP(mp1) == IDM_TOOLRIGHT) 5586 { 5587 tool = prev_tool(tool, TRUE); 5588 firsttool = tool -> id; 5589 } 5590 else 5591 { 5592 tool = next_tool(tool, TRUE); 5593 firsttool = tool -> id; 5594 } 5595 ResizeTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), 5596 MAIN_TOOLS)); 5597 } 5598 break; 5599 5600 case IDM_CREATETOOL: 5601 BuildTools(hwndToolback, 5602 TRUE); 5603 break; 5604 5605 case IDM_TOOLBAR: 5606 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), 5607 IDM_TOOLSUBMENU, 5608 &fToolbar, 5609 TRUE, 5610 "Toolbar"); 5611 BuildTools(hwndToolback, 5612 TRUE); 5613 WinShowWindow(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), 5614 MAIN_TOOLS), 5615 fToolbar); 5616 WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), 5617 WM_UPDATEFRAME, 5618 MPFROMLONG(FCF_SIZEBORDER), 5619 MPVOID); 5620 if (fDrivebar) 5621 WinInvalidateRect(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), 5622 MAIN_DRIVES), 5623 NULL, 5624 TRUE); 5625 break; 5626 5627 case IDM_DRIVEBAR: 5628 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), 5629 IDM_DRIVEBAR, 5630 &fDrivebar, 5631 TRUE, 5632 "Drivebar"); 5633 WinShowWindow(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), 5634 MAIN_DRIVES), 5635 fDrivebar); 5636 PostMsg(WinQueryWindow(hwnd, QW_PARENT), 5637 WM_UPDATEFRAME, 5638 MPFROMLONG(FCF_SIZEBORDER), 5639 MPVOID); 5640 PostMsg(hwnd, 5641 UM_BUILDDRIVES, 5642 MPVOID, 5643 MPVOID); 5644 break; 5645 5646 case IDM_USERLIST: 5647 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), 5648 SHORT1FROMMP(mp1), 5649 &fUserComboBox, 5650 TRUE, 5651 "UserComboBox"); 5652 WinShowWindow(hwndUserlist, fUserComboBox); 5653 PostMsg(WinQueryWindow(hwnd, QW_PARENT), 5654 WM_UPDATEFRAME, 5655 MPFROMLONG(FCF_SIZEBORDER), 5656 MPVOID); 5657 PostMsg(hwnd, 5658 UM_FILLUSERLIST, 5659 MPVOID, 5660 MPVOID); 5661 PostMsg(hwnd, 5662 UM_FILLSETUPLIST, 5663 MPVOID, 5664 MPVOID); 5665 PostMsg(hwnd, 5666 UM_FILLCMDLIST, 5667 MPVOID, 5668 MPVOID); 5669 PostMsg(hwnd, 5670 UM_FILLBUTTONLIST, 5671 MPVOID, 5672 MPVOID); 5673 break; 5674 5675 case IDM_MOREBUTTONS: 5676 WinSetWindowText(hwndName, NullStr); 5677 WinSetWindowText(hwndDate, NullStr); 5678 WinSetWindowText(hwndAttr, NullStr); 5679 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), 5680 SHORT1FROMMP(mp1), 5681 &fMoreButtons, 5682 TRUE, 5683 "MoreButtons"); 5684 if (fMoreButtons) 5685 { 5686 5687 HWND hwndTemp; 5688 5689 hwndTemp = TopWindow(hwnd, (HWND) 0); 5690 5691 if (hwndTemp) 5692 { 5693 WinSetFocus(HWND_DESKTOP, 5694 hwnd); 5695 WinSetFocus(HWND_DESKTOP, 5696 hwndTemp); 5697 } 5698 } 5699 PostMsg(WinQueryWindow(hwnd, QW_PARENT), 5700 WM_UPDATEFRAME, 5701 MPFROMLONG(FCF_SIZEBORDER), 5702 MPVOID); 5703 break; 5704 5705 case IDM_FREETREE: 5706 if (fFreeTree) 5707 { 5708 5709 SWP swp, swpT; 5710 5711 WinQueryWindowPos(hwndTree, &swpT); 5712 WinQueryWindowPos(hwnd, &swp); 5713 WinSetWindowPos(hwndTree, HWND_TOP, 0, swp.cy - swpT.cy, 0, 0, SWP_MOVE); 5714 } 5715 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1), 5716 &fFreeTree, TRUE, "FreeTree"); 5717 if (fAutoTile) 5718 TileChildren(hwnd, TRUE); 5719 break; 5720 5721 case IDM_AUTOTILE: 5722 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), 5723 SHORT1FROMMP(mp1), 5724 &fAutoTile, 5725 TRUE, 5726 "AutoTile"); 5727 if (fAutoTile) 5728 TileChildren(hwnd, TRUE); 5729 break; 5730 5731 case IDM_TILEBACKWARDS: 5732 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), 5733 SHORT1FROMMP(mp1), 5734 &fTileBackwards, 5735 TRUE, 5736 "TileBackwards"); 5737 if (fAutoTile) 5738 TileChildren(hwnd, TRUE); 5739 break; 5740 5741 case IDM_NEXTWINDOW: 5742 case IDM_PREVWINDOW: 5743 NextChild(hwnd, 5744 (SHORT1FROMMP(mp1) == IDM_PREVWINDOW)); 5745 break; 5746 5747 case IDM_CASCADE: 5748 CascadeChildren(hwnd); 5749 break; 5750 5751 case IDM_TILE: 5752 TileChildren(hwnd, TRUE); 5753 break; 5754 5755 case IDM_RESTORE: 5756 MinResChildren(hwnd, 5757 SWP_RESTORE); 5758 break; 5759 5760 case IDM_MINIMIZE: 5761 MinResChildren(hwnd, 5762 SWP_MINIMIZE); 5763 break; 5764 5765 case IDM_ARRANGEICONS: 5766 ArrangeIcons(hwnd); 5767 break; 5768 5769 case IDM_INIVIEWER: 5770 StartIniEditor(hwnd, NULL, 4); 5771 break; 5772 5773 case IDM_EDITASSOC: 5774 EditAssociations(hwnd); 5775 break; 5776 5777 case IDM_EDITCOMMANDS: 5778 EditCommands(hwnd); 5779 PostMsg(hwnd, 5780 UM_FILLCMDLIST, 5781 MPVOID, 5782 MPVOID); 5783 break; 5784 5785 default: 5786 if (!SwitchCommand((HWND) WinQueryWindowULong(hwnd, QWL_USER), 5787 SHORT1FROMMP(mp1))) 5788 { 5789 if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART && 5790 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) 5791 { 5792 5793 INT x; 5794 HWND hwndCnr; 5795 5796 if (!cmdloaded) 5797 load_commands(); 5798 hwndCnr = TopWindow(hwnd, (HWND) 0); 5799 hwndCnr = (HWND) WinSendMsg(WinWindowFromID(hwndCnr, FID_CLIENT), 5800 UM_CONTAINERHWND, 5801 MPVOID, 5802 MPVOID); 5803 if (!hwndCnr) 5804 { 5805 DosBeep(50, 100); 5806 break; 5807 } 5808 x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART; 5809 if (x >= 0) 5810 { 5811 x++; 5812 RunCommand(hwndCnr, x); 5813 if (fUnHilite) 5814 { 5815 5816 PCNRITEM pci; 5817 DIRCNRDATA *dcd = NULL; 5818 5819 if (WinQueryWindowUShort(hwndCnr, QWS_ID) != TREE_CNR) 5820 dcd = INSTDATA(hwndCnr); 5821 pci = (PCNRITEM) WinSendMsg(hwndCnr, 5822 CM_QUERYRECORDEMPHASIS, 5823 MPFROMLONG(CMA_FIRST), 5824 MPFROMSHORT(CRA_CURSORED)); 5825 if (pci && (INT) pci != -1 && 5826 (pci -> rc.flRecordAttr & CRA_SELECTED)) 5827 UnHilite(hwnd, 5828 TRUE, 5829 ((dcd) ? &dcd -> lastselection : NULL)); 5830 } 5831 } 5832 } 5833 else if (SHORT1FROMMP(mp1) >= IDM_QUICKTOOLSTART && 5834 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART + 50) 5835 { 5836 if (!qtloaded) 5837 load_quicktools(); 5838 if (quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]) 5839 { 5840 if (fToolsChanged) 5841 save_tools(NULL); 5842 if (!load_tools(quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART])) 5843 load_tools(NULL); 5844 else 5845 { 5846 strcpy(lasttoolbox, 5847 quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]); 5848 PrfWriteProfileString(fmprof, 5849 FM3Str, 5850 "LastToolBox", 5851 lasttoolbox); 5852 } 5853 BuildTools(hwndToolback, 5854 TRUE); 5855 } 5856 } 5857 else 5858 { 5859 5860 HWND hwndActive; 5861 5862 hwndActive = TopWindow(hwnd, 5863 (HWND) 0); 5864 if (hwndActive) 5865 PostMsg(WinWindowFromID(hwndActive, FID_CLIENT), 5866 WM_COMMAND, 5867 mp1, 5868 mp2); 5869 } 5870 } 5871 break; 5496 5872 } 5497 5873 return 0; 5498 5874 } 5499 5875 5500 5501 MRESULT EXPENTRY MainWMOnce (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) { 5502 5503 switch(msg) { 5504 case WM_CREATE: 5505 { 5506 TID tid; 5507 5508 WinQueryWindowProcess(hwnd, 5509 &mypid, 5510 &tid); 5511 } 5512 hwndMain = hwnd; 5513 WinSetWindowUShort(hwnd,8,0); 5514 WinSetWindowUShort(hwnd,10,0); 5515 WinSetWindowUShort(hwnd,12,0); 5516 WinSetWindowUShort(hwnd,16,0); 5517 if(_beginthread(MakeMainObjWin, 5518 NULL, 5519 245760, 5520 MPVOID) == -1) { 5521 PostMsg(hwnd, 5522 WM_CLOSE, 5523 MPVOID, 5524 MPVOID); 5525 return 0; 5526 } 5876 MRESULT EXPENTRY MainWMOnce(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 5877 { 5878 5879 switch (msg) 5880 { 5881 case WM_CREATE: 5882 { 5883 TID tid; 5884 5885 WinQueryWindowProcess(hwnd, 5886 &mypid, 5887 &tid); 5888 } 5889 hwndMain = hwnd; 5890 WinSetWindowUShort(hwnd, QWL_USER + 8, 0); 5891 WinSetWindowUShort(hwnd, QWL_USER + 10, 0); 5892 WinSetWindowUShort(hwnd, QWL_USER + 12, 0); 5893 WinSetWindowUShort(hwnd, QWL_USER + 16, 0); 5894 if (_beginthread(MakeMainObjWin, 5895 NULL, 5896 245760, 5897 MPVOID) == -1) 5898 { 5899 PostMsg(hwnd, 5900 WM_CLOSE, 5901 MPVOID, 5902 MPVOID); 5903 return 0; 5904 } 5905 else 5906 DosSleep(64); 5907 { 5908 SWP swp; 5909 PFNWP oldproc; 5910 5911 /* 5912 * create frame children (not client children, frame children) 5913 */ 5914 DosSleep(1L); 5915 WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp); 5916 oldproc = WinSubclassWindow(WinQueryWindow(hwnd, QW_PARENT), 5917 (PFNWP) MainFrameWndProc); 5918 if (oldproc) 5919 WinSetWindowPtr(WinQueryWindow(hwnd, QW_PARENT), 5920 0, 5921 (PVOID) oldproc); 5922 CommonCreateMainChildren(hwnd, &swp); 5923 5924 if (WinCreateWindow(WinQueryWindow(hwnd, QW_PARENT), 5925 WC_BUTTON, 5926 "I", 5927 WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS, 5928 ((swp.cx - 5929 WinQuerySysValue(HWND_DESKTOP, 5930 SV_CXMINMAXBUTTON)) - 5931 WinQuerySysValue(HWND_DESKTOP, 5932 SV_CXMINMAXBUTTON) / 2) - 5933 WinQuerySysValue(HWND_DESKTOP, 5934 SV_CXSIZEBORDER), 5935 (swp.cy - WinQuerySysValue(HWND_DESKTOP, 5936 SV_CYMINMAXBUTTON)) - 5937 WinQuerySysValue(HWND_DESKTOP, 5938 SV_CYSIZEBORDER), 5939 WinQuerySysValue(HWND_DESKTOP, 5940 SV_CXMINMAXBUTTON) / 2, 5941 WinQuerySysValue(HWND_DESKTOP, 5942 SV_CYMINMAXBUTTON), 5943 hwnd, 5944 HWND_TOP, 5945 IDM_IDEALSIZE, 5946 NULL, 5947 NULL)) 5948 { 5949 WinSubclassWindow(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), 5950 IDM_IDEALSIZE), 5951 (PFNWP) IdealButtonProc); 5952 SetPresParams(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), 5953 IDM_IDEALSIZE), 5954 NULL, 5955 NULL, 5956 NULL, 5957 GetPString(IDS_10SYSTEMVIOTEXT)); 5958 } 5959 5960 WinCreateWindow(WinQueryWindow(hwnd, QW_PARENT), 5961 WC_BUTTON, 5962 "#1019", 5963 WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS | 5964 BS_BITMAP, 5965 swp.cx - 46, 5966 swp.y + 2, 5967 24, 5968 22, 5969 hwnd, 5970 HWND_TOP, 5971 IDM_OPENWALK, 5972 NULL, 5973 NULL); 5974 WinCreateWindow(WinQueryWindow(hwnd, QW_PARENT), 5975 WC_BUTTON, 5976 "#3062", 5977 WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS | 5978 BS_BITMAP, 5979 swp.cx - 22, 5980 swp.y + 2, 5981 24, 5982 22, 5983 hwnd, 5984 HWND_TOP, 5985 IDM_USERLIST, 5986 NULL, 5987 NULL); 5988 5989 hwndUserlist = WinCreateWindow(WinQueryWindow(hwnd, QW_PARENT), 5990 WC_COMBOBOX, 5991 (PSZ) NULL, 5992 WS_VISIBLE | CBS_DROPDOWN | 5993 LS_HORZSCROLL, 5994 (swp.x + 5995 WinQuerySysValue(HWND_DESKTOP, 5996 SV_CXSIZEBORDER) + 48L), 5997 (swp.cy - 5998 WinQuerySysValue(HWND_DESKTOP, 5999 SV_CYSIZEBORDER)) - 60, 6000 ((swp.cx - 6001 (WinQuerySysValue(HWND_DESKTOP, 6002 SV_CXSIZEBORDER) * 2)) - 64L), 6003 60L, 6004 WinQueryWindow(hwnd, QW_PARENT), 6005 HWND_TOP, 6006 MAIN_USERLIST, 6007 NULL, 6008 NULL); 6009 hwndCmdlist = WinCreateWindow(WinQueryWindow(hwnd, QW_PARENT), 6010 WC_COMBOBOX, 6011 (PSZ) NULL, 6012 WS_VISIBLE | CBS_DROPDOWN | 6013 LS_HORZSCROLL, 6014 (swp.x + 6015 WinQuerySysValue(HWND_DESKTOP, 6016 SV_CXSIZEBORDER) + 48L), 6017 (swp.cy - 6018 WinQuerySysValue(HWND_DESKTOP, 6019 SV_CYSIZEBORDER)) - 60, 6020 ((swp.cx - 6021 (WinQuerySysValue(HWND_DESKTOP, 6022 SV_CXSIZEBORDER) * 2)) - 64L), 6023 60L, 6024 WinQueryWindow(hwnd, QW_PARENT), 6025 HWND_TOP, 6026 MAIN_CMDLIST, 6027 NULL, 6028 NULL); 6029 WinSetWindowText(hwndCmdlist, 6030 GetPString(IDS_COMMANDSTEXT)); 6031 hwndStatelist = WinCreateWindow(WinQueryWindow(hwnd, QW_PARENT), 6032 WC_COMBOBOX, 6033 (PSZ) NULL, 6034 WS_VISIBLE | CBS_DROPDOWN | 6035 LS_HORZSCROLL, 6036 (swp.x + 6037 WinQuerySysValue(HWND_DESKTOP, 6038 SV_CXSIZEBORDER) + 48L), 6039 (swp.cy - 6040 WinQuerySysValue(HWND_DESKTOP, 6041 SV_CYSIZEBORDER)) - 60, 6042 ((swp.cx - 6043 (WinQuerySysValue(HWND_DESKTOP, 6044 SV_CXSIZEBORDER) * 2)) - 64L), 6045 60L, 6046 WinQueryWindow(hwnd, QW_PARENT), 6047 HWND_TOP, 6048 MAIN_SETUPLIST, 6049 NULL, 6050 NULL); 6051 hwndDrivelist = WinCreateWindow(WinQueryWindow(hwnd, QW_PARENT), 6052 WC_COMBOBOX, 6053 (PSZ) NULL, 6054 WS_VISIBLE | CBS_DROPDOWN, 6055 (swp.x + 6056 WinQuerySysValue(HWND_DESKTOP, 6057 SV_CXSIZEBORDER)), 6058 (swp.cy - 6059 WinQuerySysValue(HWND_DESKTOP, 6060 SV_CYSIZEBORDER)) - 60, 6061 48L, 6062 60L, 6063 WinQueryWindow(hwnd, QW_PARENT), 6064 HWND_TOP, 6065 MAIN_DRIVELIST, 6066 NULL, 6067 NULL); 6068 SetPresParams(hwndDrivelist, 6069 NULL, 6070 NULL, 6071 NULL, 6072 GetPString(IDS_10SYSTEMMONOTEXT)); 6073 hwndButtonlist = WinCreateWindow(WinQueryWindow(hwnd, QW_PARENT), 6074 WC_COMBOBOX, 6075 (PSZ) NULL, 6076 WS_VISIBLE | CBS_DROPDOWN | 6077 LS_HORZSCROLL, 6078 (swp.cx - 6079 WinQuerySysValue(HWND_DESKTOP, 6080 SV_CXSIZEBORDER)) - 164L, 6081 (swp.cy - 6082 WinQuerySysValue(HWND_DESKTOP, 6083 SV_CYSIZEBORDER)) - 60, 6084 164L, 6085 60L, 6086 WinQueryWindow(hwnd, QW_PARENT), 6087 HWND_TOP, 6088 MAIN_BUTTONLIST, 6089 NULL, 6090 NULL); 6091 WinSendMsg(WinWindowFromID(hwndUserlist, CBID_EDIT), 6092 EM_SETTEXTLIMIT, 6093 MPFROM2SHORT(CCHMAXPATH, 0), 6094 MPVOID); 6095 WinSendMsg(WinWindowFromID(hwndStatelist, CBID_EDIT), 6096 EM_SETTEXTLIMIT, 6097 MPFROM2SHORT(13, 0), 6098 MPVOID); 6099 WinSendMsg(WinWindowFromID(hwndDrivelist, CBID_EDIT), 6100 EM_SETREADONLY, 6101 MPFROM2SHORT(TRUE, 0), 6102 MPVOID); 6103 WinSendMsg(WinWindowFromID(hwndButtonlist, CBID_EDIT), 6104 EM_SETREADONLY, 6105 MPFROM2SHORT(TRUE, 0), 6106 MPVOID); 6107 WinSendMsg(WinWindowFromID(hwndCmdlist, CBID_EDIT), 6108 EM_SETREADONLY, 6109 MPFROM2SHORT(TRUE, 0), 6110 MPVOID); 6111 oldproc = WinSubclassWindow(WinWindowFromID(hwndUserlist, CBID_EDIT), 6112 (PFNWP) DropDownListProc); 6113 if (oldproc) 6114 WinSetWindowPtr(WinWindowFromID(hwndUserlist, CBID_EDIT), 6115 0, 6116 (PVOID) oldproc); 6117 oldproc = WinSubclassWindow(WinWindowFromID(hwndCmdlist, CBID_EDIT), 6118 (PFNWP) DropDownListProc); 6119 if (oldproc) 6120 WinSetWindowPtr(WinWindowFromID(hwndCmdlist, CBID_EDIT), 6121 0, 6122 (PVOID) oldproc); 6123 oldproc = WinSubclassWindow(WinWindowFromID(hwndButtonlist, CBID_EDIT), 6124 (PFNWP) DropDownListProc); 6125 if (oldproc) 6126 WinSetWindowPtr(WinWindowFromID(hwndButtonlist, CBID_EDIT), 6127 0, 6128 (PVOID) oldproc); 6129 oldproc = WinSubclassWindow(WinWindowFromID(hwndStatelist, CBID_EDIT), 6130 (PFNWP) DropDownListProc); 6131 if (oldproc) 6132 WinSetWindowPtr(WinWindowFromID(hwndStatelist, CBID_EDIT), 6133 0, 6134 (PVOID) oldproc); 6135 oldproc = WinSubclassWindow(WinWindowFromID(hwndDrivelist, CBID_EDIT), 6136 (PFNWP) DropDownListProc); 6137 if (oldproc) 6138 WinSetWindowPtr(WinWindowFromID(hwndDrivelist, CBID_EDIT), 6139 0, 6140 (PVOID) oldproc); 6141 oldproc = WinSubclassWindow(hwndUserlist, 6142 (PFNWP) DropDownListProc); 6143 if (oldproc) 6144 WinSetWindowPtr(hwndUserlist, 6145 0, 6146 (PVOID) oldproc); 6147 oldproc = WinSubclassWindow(hwndCmdlist, 6148 (PFNWP) DropDownListProc); 6149 if (oldproc) 6150 WinSetWindowPtr(hwndCmdlist, 6151 0, 6152 (PVOID) oldproc); 6153 oldproc = WinSubclassWindow(hwndStatelist, 6154 (PFNWP) DropDownListProc); 6155 if (oldproc) 6156 WinSetWindowPtr(hwndStatelist, 6157 0, 6158 (PVOID) oldproc); 6159 oldproc = WinSubclassWindow(hwndDrivelist, 6160 (PFNWP) DropDownListProc); 6161 if (oldproc) 6162 WinSetWindowPtr(hwndDrivelist, QWL_USER, (PVOID) oldproc); 6163 oldproc = WinSubclassWindow(hwndButtonlist, 6164 (PFNWP) DropDownListProc); 6165 if (oldproc) 6166 WinSetWindowPtr(hwndButtonlist, 6167 0, 6168 (PVOID) oldproc); 6169 oldproc = WinSubclassWindow(WinWindowFromID(WinQueryWindow(hwnd, 6170 QW_PARENT), 6171 IDM_USERLIST), 6172 (PFNWP) ChildFrameButtonProc); 6173 if (oldproc) 6174 WinSetWindowPtr(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), 6175 IDM_USERLIST), 6176 0, 6177 (PVOID) oldproc); 6178 oldproc = WinSubclassWindow(WinWindowFromID(WinQueryWindow(hwnd, 6179 QW_PARENT), 6180 IDM_OPENWALK), 6181 (PFNWP) ChildFrameButtonProc); 6182 if (oldproc) 6183 WinSetWindowPtr(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), 6184 IDM_OPENWALK), 6185 0, 6186 (PVOID) oldproc); 6187 { 6188 HWND hwndSysMenu, hwndSysSubMenu, hwndMenu; 6189 USHORT idSysMenu; 6190 MENUITEM mi, mit; 6191 6192 hwndMenu = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), 6193 FID_MENU); 6194 WinSendMsg(hwnd, 6195 UM_ADDTOMENU, 6196 MPVOID, 6197 MPVOID); 6198 SetToggleChecks(hwndMenu); 6199 SetConditionalCascade(hwndMenu, 6200 IDM_TOOLSUBMENU, 6201 IDM_TOOLBAR); 6202 SetConditionalCascade(hwndMenu, 6203 IDM_AUTOVIEWSUBMENU, 6204 IDM_AUTOVIEW); 6205 SetConditionalCascade(hwndMenu, 6206 IDM_TILEMENU, 6207 IDM_TILE); 6208 WinSetWindowULong(hwnd, 6209 0, 6210 (ULONG) hwndMenu); 6211 memset(&mi, 0, sizeof(mi)); 6212 memset(&mit, 0, sizeof(mit)); 6213 hwndSysMenu = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), 6214 FID_SYSMENU); 6215 idSysMenu = SHORT1FROMMR(WinSendMsg(hwndSysMenu, 6216 MM_ITEMIDFROMPOSITION, 6217 MPVOID, 6218 MPVOID)); 6219 WinSendMsg(hwndSysMenu, 6220 MM_QUERYITEM, 6221 MPFROM2SHORT(idSysMenu, 0), 6222 MPFROMP(&mit)); 6223 hwndSysSubMenu = mit.hwndSubMenu; 6224 mi.iPosition = MIT_END; 6225 mi.afStyle = MIS_SEPARATOR; 6226 mi.id = -1; 6227 WinSendMsg(hwndSysSubMenu, 6228 MM_INSERTITEM, 6229 MPFROMP(&mi), 6230 MPFROMP(NULL)); 6231 mi.afStyle = MIS_TEXT; 6232 mi.id = IDM_IDEALSIZE; 6233 WinSendMsg(hwndSysSubMenu, 6234 MM_INSERTITEM, 6235 MPFROMP(&mi), 6236 MPFROMP(GetPString(IDS_IDEALMENUTEXT))); 6237 mi.afStyle = MIS_TEXT; 6238 mi.id = IDM_HIDEMENU; 6239 WinSendMsg(hwndSysSubMenu, 6240 MM_INSERTITEM, 6241 MPFROMP(&mi), 6242 MPFROMP(GetPString(IDS_HIDEMENUTEXT))); 6243 SetSysMenu(hwndSysMenu); 6244 } 6245 } 6246 { 6247 ULONG size; 6248 BOOL temp = FALSE; 6249 6250 size = sizeof(BOOL); 6251 if (PrfQueryProfileData(fmprof, 6252 FM3Str, 6253 "MenuInvisible", 6254 (PVOID) & temp, 6255 &size) && 6256 size && 6257 temp) 6258 WinSendMsg(hwnd, 6259 WM_COMMAND, 6260 MPFROM2SHORT(IDM_HIDEMENU, 0), 6261 MPVOID); 6262 size = sizeof(BOOL); 6263 if (PrfQueryProfileData(fmprof, 6264 FM3Str, 6265 "FreeTree", 6266 (PVOID) & temp, 6267 &size) && 6268 size && 6269 temp) 6270 WinSendMsg(hwnd, 6271 WM_COMMAND, 6272 MPFROM2SHORT(IDM_FREETREE, 0), 6273 MPVOID); 6274 size = sizeof(BOOL); 6275 if (PrfQueryProfileData(fmprof, 6276 FM3Str, 6277 "AutoTile", 6278 (PVOID) & temp, 6279 &size) && 6280 size && 6281 !temp) 6282 WinSendMsg(hwnd, 6283 WM_COMMAND, 6284 MPFROM2SHORT(IDM_AUTOTILE, 0), 6285 MPVOID); 6286 size = sizeof(BOOL); 6287 if (PrfQueryProfileData(fmprof, 6288 FM3Str, 6289 "Toolbar", 6290 &temp, 6291 &size) && 6292 size && 6293 !temp) 6294 WinSendMsg(hwnd, 6295 WM_COMMAND, 6296 MPFROM2SHORT(IDM_TOOLBAR, 0), 6297 MPVOID); 6298 } 6299 WinSetWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), 6300 FID_TITLEBAR), 6301 "FM/2"); 6302 FixSwitchList(WinQueryWindow(hwnd, QW_PARENT), 6303 NULL); 6304 break; 6305 6306 case UM_SETUP: 6307 /* 6308 * start up some initial children 6309 */ 6310 load_tools(NULL); 6311 BuildTools(hwndToolback, 6312 TRUE); 6313 WinShowWindow(WinQueryWindow(hwnd, QW_PARENT), 6314 TRUE); 6315 PostMsg(MainObjectHwnd, 6316 UM_SETUP2, 6317 mp1, 6318 mp2); 6319 return 0; 6320 6321 case UM_SETUP2: 6322 { 6323 SWP swp; 6324 ULONG size = sizeof(SWP); 6325 6326 WinQueryWindowPos(hwnd, &swp); 6327 hwndTree = StartTreeCnr(hwnd, 0); 6328 if (!hwndTree) 6329 WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT)); 5527 6330 else 5528 DosSleep(64); 5529 { 5530 SWP swp; 5531 PFNWP oldproc; 5532 5533 /* 5534 * create frame children (not client children, frame children) 5535 */ 5536 DosSleep(1L); 5537 WinQueryWindowPos(WinQueryWindow(hwnd,QW_PARENT),&swp); 5538 oldproc = WinSubclassWindow(WinQueryWindow(hwnd,QW_PARENT), 5539 (PFNWP)MainFrameWndProc); 5540 if(oldproc) 5541 WinSetWindowPtr(WinQueryWindow(hwnd,QW_PARENT), 5542 0, 5543 (PVOID)oldproc); 5544 CommonCreateMainChildren(hwnd,&swp); 5545 5546 if(WinCreateWindow(WinQueryWindow(hwnd,QW_PARENT), 5547 WC_BUTTON, 5548 "I", 5549 WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS, 5550 ((swp.cx - 5551 WinQuerySysValue(HWND_DESKTOP, 5552 SV_CXMINMAXBUTTON)) - 5553 WinQuerySysValue(HWND_DESKTOP, 5554 SV_CXMINMAXBUTTON) / 2) - 5555 WinQuerySysValue(HWND_DESKTOP, 5556 SV_CXSIZEBORDER), 5557 (swp.cy - WinQuerySysValue(HWND_DESKTOP, 5558 SV_CYMINMAXBUTTON)) - 5559 WinQuerySysValue(HWND_DESKTOP, 5560 SV_CYSIZEBORDER), 5561 WinQuerySysValue(HWND_DESKTOP, 5562 SV_CXMINMAXBUTTON) / 2, 5563 WinQuerySysValue(HWND_DESKTOP, 5564 SV_CYMINMAXBUTTON), 5565 hwnd, 5566 HWND_TOP, 5567 IDM_IDEALSIZE, 5568 NULL, 5569 NULL)) { 5570 WinSubclassWindow(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT), 5571 IDM_IDEALSIZE), 5572 (PFNWP)IdealButtonProc); 5573 SetPresParams(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT), 5574 IDM_IDEALSIZE), 5575 NULL, 5576 NULL, 5577 NULL, 5578 GetPString(IDS_10SYSTEMVIOTEXT)); 5579 } 5580 5581 5582 WinCreateWindow(WinQueryWindow(hwnd,QW_PARENT), 5583 WC_BUTTON, 5584 "#1019", 5585 WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS | 5586 BS_BITMAP, 5587 swp.cx - 46, 5588 swp.y + 2, 5589 24, 5590 22, 5591 hwnd, 5592 HWND_TOP, 5593 IDM_OPENWALK, 5594 NULL, 5595 NULL); 5596 WinCreateWindow(WinQueryWindow(hwnd,QW_PARENT), 5597 WC_BUTTON, 5598 "#3062", 5599 WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS | 5600 BS_BITMAP, 5601 swp.cx - 22, 5602 swp.y + 2, 5603 24, 5604 22, 5605 hwnd, 5606 HWND_TOP, 5607 IDM_USERLIST, 5608 NULL, 5609 NULL); 5610 5611 hwndUserlist = WinCreateWindow(WinQueryWindow(hwnd,QW_PARENT), 5612 WC_COMBOBOX, 5613 (PSZ)NULL, 5614 WS_VISIBLE | CBS_DROPDOWN | 5615 LS_HORZSCROLL, 5616 (swp.x + 5617 WinQuerySysValue(HWND_DESKTOP, 5618 SV_CXSIZEBORDER) + 48L), 5619 (swp.cy - 5620 WinQuerySysValue(HWND_DESKTOP, 5621 SV_CYSIZEBORDER)) - 60, 5622 ((swp.cx - 5623 (WinQuerySysValue(HWND_DESKTOP, 5624 SV_CXSIZEBORDER) * 2)) - 64L), 5625 60L, 5626 WinQueryWindow(hwnd,QW_PARENT), 5627 HWND_TOP, 5628 MAIN_USERLIST, 5629 NULL, 5630 NULL); 5631 hwndCmdlist = WinCreateWindow(WinQueryWindow(hwnd,QW_PARENT), 5632 WC_COMBOBOX, 5633 (PSZ)NULL, 5634 WS_VISIBLE | CBS_DROPDOWN | 5635 LS_HORZSCROLL, 5636 (swp.x + 5637 WinQuerySysValue(HWND_DESKTOP, 5638 SV_CXSIZEBORDER) + 48L), 5639 (swp.cy - 5640 WinQuerySysValue(HWND_DESKTOP, 5641 SV_CYSIZEBORDER)) - 60, 5642 ((swp.cx - 5643 (WinQuerySysValue(HWND_DESKTOP, 5644 SV_CXSIZEBORDER) * 2)) - 64L), 5645 60L, 5646 WinQueryWindow(hwnd,QW_PARENT), 5647 HWND_TOP, 5648 MAIN_CMDLIST, 5649 NULL, 5650 NULL); 5651 WinSetWindowText(hwndCmdlist, 5652 GetPString(IDS_COMMANDSTEXT)); 5653 hwndStatelist = WinCreateWindow(WinQueryWindow(hwnd,QW_PARENT), 5654 WC_COMBOBOX, 5655 (PSZ)NULL, 5656 WS_VISIBLE | CBS_DROPDOWN | 5657 LS_HORZSCROLL, 5658 (swp.x + 5659 WinQuerySysValue(HWND_DESKTOP, 5660 SV_CXSIZEBORDER) + 48L), 5661 (swp.cy - 5662 WinQuerySysValue(HWND_DESKTOP, 5663 SV_CYSIZEBORDER)) - 60, 5664 ((swp.cx - 5665 (WinQuerySysValue(HWND_DESKTOP, 5666 SV_CXSIZEBORDER) * 2)) - 64L), 5667 60L, 5668 WinQueryWindow(hwnd,QW_PARENT), 5669 HWND_TOP, 5670 MAIN_SETUPLIST, 5671 NULL, 5672 NULL); 5673 hwndDrivelist = WinCreateWindow(WinQueryWindow(hwnd,QW_PARENT), 5674 WC_COMBOBOX, 5675 (PSZ)NULL, 5676 WS_VISIBLE | CBS_DROPDOWN, 5677 (swp.x + 5678 WinQuerySysValue(HWND_DESKTOP, 5679 SV_CXSIZEBORDER)), 5680 (swp.cy - 5681 WinQuerySysValue(HWND_DESKTOP, 5682 SV_CYSIZEBORDER)) - 60, 5683 48L, 5684 60L, 5685 WinQueryWindow(hwnd,QW_PARENT), 5686 HWND_TOP, 5687 MAIN_DRIVELIST, 5688 NULL, 5689 NULL); 5690 SetPresParams(hwndDrivelist, 5691 NULL, 5692 NULL, 5693 NULL, 5694 GetPString(IDS_10SYSTEMMONOTEXT)); 5695 hwndButtonlist = WinCreateWindow(WinQueryWindow(hwnd,QW_PARENT), 5696 WC_COMBOBOX, 5697 (PSZ)NULL, 5698 WS_VISIBLE | CBS_DROPDOWN | 5699 LS_HORZSCROLL, 5700 (swp.cx - 5701 WinQuerySysValue(HWND_DESKTOP, 5702 SV_CXSIZEBORDER)) - 164L, 5703 (swp.cy - 5704 WinQuerySysValue(HWND_DESKTOP, 5705 SV_CYSIZEBORDER)) - 60, 5706 164L, 5707 60L, 5708 WinQueryWindow(hwnd,QW_PARENT), 5709 HWND_TOP, 5710 MAIN_BUTTONLIST, 5711 NULL, 5712 NULL); 5713 WinSendMsg(WinWindowFromID(hwndUserlist,CBID_EDIT), 5714 EM_SETTEXTLIMIT, 5715 MPFROM2SHORT(CCHMAXPATH,0), 5716 MPVOID); 5717 WinSendMsg(WinWindowFromID(hwndStatelist,CBID_EDIT), 5718 EM_SETTEXTLIMIT, 5719 MPFROM2SHORT(13,0), 5720 MPVOID); 5721 WinSendMsg(WinWindowFromID(hwndDrivelist,CBID_EDIT), 5722 EM_SETREADONLY, 5723 MPFROM2SHORT(TRUE,0), 5724 MPVOID); 5725 WinSendMsg(WinWindowFromID(hwndButtonlist,CBID_EDIT), 5726 EM_SETREADONLY, 5727 MPFROM2SHORT(TRUE,0), 5728 MPVOID); 5729 WinSendMsg(WinWindowFromID(hwndCmdlist,CBID_EDIT), 5730 EM_SETREADONLY, 5731 MPFROM2SHORT(TRUE,0), 5732 MPVOID); 5733 oldproc = WinSubclassWindow(WinWindowFromID(hwndUserlist,CBID_EDIT), 5734 (PFNWP)DropDownListProc); 5735 if(oldproc) 5736 WinSetWindowPtr(WinWindowFromID(hwndUserlist,CBID_EDIT), 5737 0, 5738 (PVOID)oldproc); 5739 oldproc = WinSubclassWindow(WinWindowFromID(hwndCmdlist,CBID_EDIT), 5740 (PFNWP)DropDownListProc); 5741 if(oldproc) 5742 WinSetWindowPtr(WinWindowFromID(hwndCmdlist,CBID_EDIT), 5743 0, 5744 (PVOID)oldproc); 5745 oldproc = WinSubclassWindow(WinWindowFromID(hwndButtonlist,CBID_EDIT), 5746 (PFNWP)DropDownListProc); 5747 if(oldproc) 5748 WinSetWindowPtr(WinWindowFromID(hwndButtonlist,CBID_EDIT), 5749 0, 5750 (PVOID)oldproc); 5751 oldproc = WinSubclassWindow(WinWindowFromID(hwndStatelist,CBID_EDIT), 5752 (PFNWP)DropDownListProc); 5753 if(oldproc) 5754 WinSetWindowPtr(WinWindowFromID(hwndStatelist,CBID_EDIT), 5755 0, 5756 (PVOID)oldproc); 5757 oldproc = WinSubclassWindow(WinWindowFromID(hwndDrivelist,CBID_EDIT), 5758 (PFNWP)DropDownListProc); 5759 if(oldproc) 5760 WinSetWindowPtr(WinWindowFromID(hwndDrivelist,CBID_EDIT), 5761 0, 5762 (PVOID)oldproc); 5763 oldproc = WinSubclassWindow(hwndUserlist, 5764 (PFNWP)DropDownListProc); 5765 if(oldproc) 5766 WinSetWindowPtr(hwndUserlist, 5767 0, 5768 (PVOID)oldproc); 5769 oldproc = WinSubclassWindow(hwndCmdlist, 5770 (PFNWP)DropDownListProc); 5771 if(oldproc) 5772 WinSetWindowPtr(hwndCmdlist, 5773 0, 5774 (PVOID)oldproc); 5775 oldproc = WinSubclassWindow(hwndStatelist, 5776 (PFNWP)DropDownListProc); 5777 if(oldproc) 5778 WinSetWindowPtr(hwndStatelist, 5779 0, 5780 (PVOID)oldproc); 5781 oldproc = WinSubclassWindow(hwndDrivelist, 5782 (PFNWP)DropDownListProc); 5783 if(oldproc) 5784 WinSetWindowPtr(hwndDrivelist,QWL_USER,(PVOID)oldproc); 5785 oldproc = WinSubclassWindow(hwndButtonlist, 5786 (PFNWP)DropDownListProc); 5787 if(oldproc) 5788 WinSetWindowPtr(hwndButtonlist, 5789 0, 5790 (PVOID)oldproc); 5791 oldproc = WinSubclassWindow(WinWindowFromID(WinQueryWindow(hwnd, 5792 QW_PARENT), 5793 IDM_USERLIST), 5794 (PFNWP)ChildFrameButtonProc); 5795 if(oldproc) 5796 WinSetWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT), 5797 IDM_USERLIST), 5798 0, 5799 (PVOID)oldproc); 5800 oldproc = WinSubclassWindow(WinWindowFromID(WinQueryWindow(hwnd, 5801 QW_PARENT), 5802 IDM_OPENWALK), 5803 (PFNWP)ChildFrameButtonProc); 5804 if(oldproc) 5805 WinSetWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT), 5806 IDM_OPENWALK), 5807 0, 5808 (PVOID)oldproc); 5809 { 5810 HWND hwndSysMenu,hwndSysSubMenu,hwndMenu; 5811 USHORT idSysMenu; 5812 MENUITEM mi,mit; 5813 5814 hwndMenu = WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT), 5815 FID_MENU); 5816 WinSendMsg(hwnd, 5817 UM_ADDTOMENU, 5818 MPVOID, 5819 MPVOID); 5820 SetToggleChecks(hwndMenu); 5821 SetConditionalCascade(hwndMenu, 5822 IDM_TOOLSUBMENU, 5823 IDM_TOOLBAR); 5824 SetConditionalCascade(hwndMenu, 5825 IDM_AUTOVIEWSUBMENU, 5826 IDM_AUTOVIEW); 5827 SetConditionalCascade(hwndMenu, 5828 IDM_TILEMENU, 5829 IDM_TILE); 5830 WinSetWindowULong(hwnd, 5831 0, 5832 (ULONG)hwndMenu); 5833 memset(&mi,0,sizeof(mi)); 5834 memset(&mit,0,sizeof(mit)); 5835 hwndSysMenu = WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT), 5836 FID_SYSMENU); 5837 idSysMenu = SHORT1FROMMR(WinSendMsg(hwndSysMenu, 5838 MM_ITEMIDFROMPOSITION, 5839 MPVOID, 5840 MPVOID)); 5841 WinSendMsg(hwndSysMenu, 5842 MM_QUERYITEM, 5843 MPFROM2SHORT(idSysMenu, 0), 5844 MPFROMP(&mit)); 5845 hwndSysSubMenu = mit.hwndSubMenu; 5846 mi.iPosition = MIT_END; 5847 mi.afStyle = MIS_SEPARATOR; 5848 mi.id = -1; 5849 WinSendMsg(hwndSysSubMenu, 5850 MM_INSERTITEM, 5851 MPFROMP(&mi), 5852 MPFROMP(NULL)); 5853 mi.afStyle = MIS_TEXT; 5854 mi.id = IDM_IDEALSIZE; 5855 WinSendMsg(hwndSysSubMenu, 5856 MM_INSERTITEM, 5857 MPFROMP(&mi), 5858 MPFROMP(GetPString(IDS_IDEALMENUTEXT))); 5859 mi.afStyle = MIS_TEXT; 5860 mi.id = IDM_HIDEMENU; 5861 WinSendMsg(hwndSysSubMenu, 5862 MM_INSERTITEM, 5863 MPFROMP(&mi), 5864 MPFROMP(GetPString(IDS_HIDEMENUTEXT))); 5865 SetSysMenu(hwndSysMenu); 5866 } 5867 } 5868 { 5869 ULONG size; 5870 BOOL temp = FALSE; 5871 5872 size = sizeof(BOOL); 5873 if(PrfQueryProfileData(fmprof, 5874 FM3Str, 5875 "MenuInvisible", 5876 (PVOID)&temp, 5877 &size) && 5878 size && 5879 temp) 5880 WinSendMsg(hwnd, 5881 WM_COMMAND, 5882 MPFROM2SHORT(IDM_HIDEMENU,0), 5883 MPVOID); 5884 size = sizeof(BOOL); 5885 if(PrfQueryProfileData(fmprof, 5886 FM3Str, 5887 "FreeTree", 5888 (PVOID)&temp, 5889 &size) && 5890 size && 5891 temp) 5892 WinSendMsg(hwnd, 5893 WM_COMMAND, 5894 MPFROM2SHORT(IDM_FREETREE,0), 5895 MPVOID); 5896 size = sizeof(BOOL); 5897 if(PrfQueryProfileData(fmprof, 5898 FM3Str, 5899 "AutoTile", 5900 (PVOID)&temp, 5901 &size) && 5902 size && 5903 !temp) 5904 WinSendMsg(hwnd, 5905 WM_COMMAND, 5906 MPFROM2SHORT(IDM_AUTOTILE,0), 5907 MPVOID); 5908 size = sizeof(BOOL); 5909 if(PrfQueryProfileData(fmprof, 5910 FM3Str, 5911 "Toolbar", 5912 &temp, 5913 &size) && 5914 size && 5915 !temp) 5916 WinSendMsg(hwnd, 5917 WM_COMMAND, 5918 MPFROM2SHORT(IDM_TOOLBAR,0), 5919 MPVOID); 5920 } 5921 WinSetWindowText(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT), 5922 FID_TITLEBAR), 5923 "FM/2"); 5924 FixSwitchList(WinQueryWindow(hwnd,QW_PARENT), 5925 NULL); 6331 { 6332 if (!fSaveState || 6333 !PrfQueryProfileData(fmprof, 6334 FM3Str, 6335 "LastTreePos", 6336 &swp, 6337 &size) || 6338 size != sizeof(SWP)) 6339 { 6340 6341 INT ratio, height = 0; 6342 6343 if (!fNoTreeGap) 6344 height = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2; 6345 size = sizeof(ratio); 6346 if (!PrfQueryProfileData(fmprof, 6347 FM3Str, 6348 "TreeWindowRatio", 6349 (PVOID) & ratio, 6350 &size) || 6351 size < sizeof(ratio)) 6352 ratio = 400; 6353 WinSetWindowPos(hwndTree, 6354 HWND_TOP, 6355 0, 6356 height, 6357 (swp.cx * 100) / ratio, 6358 swp.cy - height, 6359 SWP_SHOW | SWP_SIZE | SWP_MOVE | 6360 SWP_ACTIVATE | SWP_ZORDER); 6361 } 6362 else 6363 WinSetWindowPos(hwndTree, 6364 HWND_TOP, 6365 swp.x, 6366 swp.y, 6367 swp.cx, 6368 swp.cy, 6369 swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW | 6370 SWP_ZORDER | SWP_ACTIVATE); 6371 } 6372 ResizeTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), 6373 MAIN_TOOLS)); 6374 } 6375 PostMsg(MainObjectHwnd, 6376 UM_SETUP3, 6377 mp1, 6378 mp2); 6379 return 0; 6380 6381 case UM_SETUP3: 6382 /* start remaining child windows */ 6383 { 6384 if (!fNoSaveState && 6385 fSaveState) 6386 PostMsg(MainObjectHwnd, 6387 UM_RESTORE, 6388 MPVOID, 6389 MPVOID); 6390 PostMsg(MainObjectHwnd, 6391 UM_SETUP4, 6392 mp1, 6393 mp2); 6394 } 6395 return 0; 6396 6397 case UM_SETUP4: 6398 { 6399 INT argc = (INT) mp1, x; 6400 CHAR **argv = (CHAR **) mp2; 6401 6402 for (x = 1; x < argc; x++) 6403 { 6404 if (*argv[x] == '/' || *argv[x] == ';') 6405 continue; 6406 if (!IsFile(argv[x]) && 6407 !FindDirCnrByName(argv[x], FALSE)) 6408 OpenDirCnr((HWND) 0, 6409 hwndMain, 6410 hwndTree, 6411 TRUE, 6412 argv[x]); 6413 } 6414 } 6415 PostMsg(MainObjectHwnd, 6416 UM_SETUP5, 6417 MPVOID, 6418 MPVOID); 6419 return 0; 6420 6421 case UM_SETUP5: 6422 if (fAutoTile) 6423 TileChildren(hwnd, TRUE); 6424 PostMsg(hwnd, 6425 UM_FILLUSERLIST, 6426 MPVOID, 6427 MPVOID); 6428 PostMsg(hwnd, 6429 UM_FILLSETUPLIST, 6430 MPVOID, 6431 MPVOID); 6432 PostMsg(hwnd, 6433 UM_FILLCMDLIST, 6434 MPVOID, 6435 MPVOID); 6436 PostMsg(hwnd, 6437 UM_FILLBUTTONLIST, 6438 MPVOID, 6439 MPVOID); 6440 { 6441 HWND hwndActive; 6442 6443 hwndActive = TopWindow(hwnd, hwndTree); 6444 if (hwndActive) 6445 WinSetWindowPos(hwndActive, 6446 HWND_TOP, 6447 0, 6448 0, 6449 0, 6450 0, 6451 SWP_ACTIVATE); 6452 } 6453 if (fStartMinimized || 6454 fReminimize) 6455 PostMsg(hwndTree, 6456 UM_MINIMIZE, 6457 MPVOID, 6458 MPVOID); 6459 else if (fStartMaximized) 6460 PostMsg(hwndTree, 6461 UM_MAXIMIZE, 6462 MPVOID, 6463 MPVOID); 6464 fRunning = TRUE; 6465 return 0; 6466 } 6467 6468 return WinDefWindowProc(hwnd, msg, mp1, mp2); 6469 } 6470 6471 MRESULT EXPENTRY MainWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 6472 { 6473 6474 switch (msg) 6475 { 6476 case WM_CREATE: 6477 case UM_SETUP: 6478 case UM_SETUP2: 6479 case UM_SETUP3: 6480 case UM_SETUP4: 6481 case UM_SETUP5: 6482 return MainWMOnce(hwnd, msg, mp1, mp2); 6483 6484 case WM_CONTROLPOINTER: 6485 if (!fNoFinger && 6486 (SHORT1FROMMP(mp1) == IDM_OPENWALK || 6487 SHORT1FROMMP(mp1) == IDM_USERLIST)) 6488 return MRFROMLONG(hptrFinger); 6489 break; 6490 6491 case UM_LOADFILE: 6492 case UM_THREADUSE: 6493 case UM_BUILDDRIVES: 6494 return CommonMainWndProc(hwnd, msg, mp1, mp2); 6495 6496 case WM_BUTTON1UP: 6497 case WM_BUTTON2UP: 6498 case WM_BUTTON3UP: 6499 case WM_MOUSEMOVE: 6500 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); 6501 break; 6502 6503 case WM_CHAR: 6504 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL)); 6505 break; 6506 6507 case WM_MENUEND: 6508 if ((HWND) mp2 == MainPopupMenu) 6509 { 6510 WinDestroyWindow(MainPopupMenu); 6511 MainPopupMenu = (HWND) 0; 6512 } 6513 break; 6514 6515 case UM_CONTEXTMENU: 6516 case WM_CONTEXTMENU: 6517 if (CheckMenu(&MainPopupMenu, MAIN_POPUP)) 6518 { 6519 SetToggleChecks(MainPopupMenu); 6520 PopupMenu(hwnd, hwnd, MainPopupMenu); 6521 } 6522 if (msg == UM_CONTEXTMENU) 6523 return 0; 6524 return MRFROMSHORT(TRUE); 6525 6526 case UM_SETUSERLISTNAME: 6527 if (mp1) 6528 { 6529 if (fUserComboBox) 6530 WinSetWindowText(WinWindowFromID(hwndUserlist, CBID_EDIT), 6531 (CHAR *) mp1); 6532 if (add_udir(FALSE, (CHAR *) mp1)) 6533 { 6534 if (fUserComboBox) 6535 { 6536 if (fAutoAddDirs) 6537 WinSendMsg(hwndUserlist, LM_INSERTITEM, 6538 MPFROM2SHORT(LIT_SORTASCENDING, 0), 6539 MPFROMP((CHAR *) mp1)); 6540 } 6541 } 6542 } 6543 return 0; 6544 6545 case UM_ARRANGEICONS: 6546 ArrangeIcons(hwnd); 6547 return 0; 6548 6549 case WM_CHORD: 6550 PostMsg(hwnd, 6551 WM_COMMAND, 6552 MPFROM2SHORT(IDM_WINDOWDLG, 0), 6553 MPVOID); 6554 break; 6555 6556 case WM_SETFOCUS: 6557 if (mp2) 6558 PostMsg(hwnd, 6559 UM_FOCUSME, 6560 MPVOID, 6561 MPVOID); 6562 break; 6563 6564 case UM_FOCUSME: 6565 WinSetFocus(hwndTree, 6566 TRUE); 6567 return 0; 6568 6569 case UM_RESCAN: 6570 TileChildren(hwnd, TRUE); 6571 return 0; 6572 6573 case WM_SAVEAPPLICATION: 6574 { 6575 SWP swp; 6576 6577 WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp); 6578 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) 6579 { 6580 WinStoreWindowPos(FM2Str, 6581 "MainWindowPos", 6582 WinQueryWindow(hwnd, QW_PARENT)); 6583 if (!fNoSaveState && fSaveState) 6584 SaveDirCnrState(hwnd, NULL); 6585 } 6586 } 6587 break; 6588 6589 case MM_PORTHOLEINIT: 6590 switch (SHORT1FROMMP(mp1)) 6591 { 6592 case 0: 6593 case 1: 6594 { 6595 HWND hwndCurrent; 6596 ULONG wmsg; 6597 6598 wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU; 6599 hwndCurrent = TopWindow(hwnd, (HWND) 0); 6600 PortholeInit((HWND) WinSendMsg(WinWindowFromID(hwndCurrent, 6601 FID_CLIENT), wmsg, MPVOID, 6602 MPVOID), mp1, mp2); 6603 } 5926 6604 break; 5927 5928 case UM_SETUP: 6605 } 6606 break; 6607 6608 case WM_INITMENU: 6609 switch (SHORT1FROMMP(mp1)) 6610 { 6611 case IDM_CONFIGMENU: 6612 SetToggleChecks((HWND) WinQueryWindowULong(hwnd, QWL_USER)); 6613 break; 6614 6615 case IDM_WINDOWSMENU: 5929 6616 /* 5930 * start up some initial children 6617 * add child windows of client 6618 * and switchlist entries to end of pulldown menu 5931 6619 */ 5932 load_tools(NULL); 5933 BuildTools(hwndToolback, 5934 TRUE); 5935 WinShowWindow(WinQueryWindow(hwnd,QW_PARENT), 5936 TRUE); 5937 PostMsg(MainObjectHwnd, 5938 UM_SETUP2, 5939 mp1, 5940 mp2); 6620 { 6621 HWND hwndMenu, hwndSubMenu; 6622 MENUITEM mi; 6623 6624 hwndMenu = WinQueryWindowULong(hwnd, QWL_USER); 6625 memset(&mi, 0, sizeof(mi)); 6626 mi.iPosition = MIT_END; 6627 mi.afStyle = MIS_TEXT; 6628 if (!WinSendMsg(hwndMenu, MM_QUERYITEM, 6629 MPFROM2SHORT(IDM_WINDOWSMENU, TRUE), 6630 MPFROMP(&mi))) 6631 break; 6632 hwndSubMenu = mi.hwndSubMenu; 6633 SetupWinList(hwndSubMenu, 6634 hwnd, 6635 WinQueryWindow(hwnd, QW_PARENT)); 6636 } 6637 break; 6638 6639 default: 6640 { 6641 HWND hwndCurrent; 6642 6643 hwndCurrent = TopWindow(hwnd, (HWND) 0); 6644 if (hwndCurrent) 6645 WinSendMsg(hwndCurrent, UM_INITMENU, mp1, mp2); 6646 } 6647 break; 6648 } 6649 break; 6650 6651 case UM_ADDTOMENU: 6652 AddToMenu((CHAR *) mp1, WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), 6653 FID_MENU)); 6654 return 0; 6655 6656 case UM_FILLCMDLIST: 6657 WinSendMsg(hwndCmdlist, LM_DELETEALL, MPVOID, MPVOID); 6658 if (!cmdloaded) 6659 load_commands(); 6660 if (cmdhead) 6661 { 6662 6663 LINKCMDS *info; 6664 6665 info = cmdhead; 6666 while (info) 6667 { 6668 WinSendMsg(hwndCmdlist, LM_INSERTITEM, 6669 MPFROM2SHORT(LIT_END, 0), 6670 MPFROMP(info -> title)); 6671 info = info -> next; 6672 } 6673 } 6674 return 0; 6675 6676 case UM_FILLSETUPLIST: 6677 WinSendMsg(hwndStatelist, LM_DELETEALL, MPVOID, MPVOID); 6678 if (fUserComboBox) 6679 { 6680 6681 INT x; 6682 6683 if (!loadedsetups) 6684 load_setups(); 6685 for (x = 0; x < MAXNUMSETUPS; x++) 6686 { 6687 if (*lastsetups[x]) 6688 WinSendMsg(hwndStatelist, LM_INSERTITEM, 6689 MPFROM2SHORT(LIT_SORTASCENDING, 0), 6690 MPFROMP(lastsetups[x])); 6691 } 6692 WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT)); 6693 } 6694 return 0; 6695 6696 case UM_FILLBUTTONLIST: 6697 WinSendMsg(hwndButtonlist, LM_DELETEALL, MPVOID, MPVOID); 6698 if (fUserComboBox) 6699 { 6700 6701 BOOL foundit = FALSE, thisone; 6702 ULONG ulSearchCount; 6703 SHORT sSelect; 6704 FILEFINDBUF3 findbuf; 6705 HDIR hDir; 6706 CHAR *p; 6707 6708 DosError(FERR_DISABLEHARDERR); 6709 hDir = HDIR_CREATE; 6710 ulSearchCount = 1L; 6711 if (!DosFindFirst("*.TLS", &hDir, FILE_READONLY | FILE_ARCHIVED, 6712 &findbuf, sizeof(FILEFINDBUF3), 6713 &ulSearchCount, FIL_STANDARD)) 6714 { 6715 do 6716 { 6717 priority_bumped(); 6718 if (!foundit) 6719 { 6720 thisone = FALSE; 6721 p = strrchr(lasttoolbox, '\\'); 6722 if (!p) 6723 p = lasttoolbox; 6724 else 6725 p++; 6726 if (!stricmp(findbuf.achName, p)) 6727 thisone = TRUE; 6728 } 6729 p = strrchr(findbuf.achName, '.'); 6730 if (p) 6731 *p = 0; 6732 sSelect = (SHORT) WinSendMsg(hwndButtonlist, LM_INSERTITEM, 6733 MPFROM2SHORT(LIT_SORTASCENDING, 0), 6734 MPFROMP(findbuf.achName)); 6735 if (!foundit && thisone && sSelect >= 0) 6736 { 6737 WinSendMsg(hwndButtonlist, LM_SELECTITEM, MPFROM2SHORT(sSelect, 0), 6738 MPFROMLONG(TRUE)); 6739 foundit = TRUE; 6740 } 6741 } 6742 while (!DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3), 6743 &ulSearchCount)); 6744 DosFindClose(hDir); 6745 priority_bumped(); 6746 } 6747 WinSetWindowText(hwndButtonlist, GetPString(IDS_TOOLBOXTEXT)); 6748 } 6749 return 0; 6750 6751 case UM_FILLUSERLIST: 6752 WinSendMsg(hwndUserlist, LM_DELETEALL, MPVOID, MPVOID); 6753 if (fUserComboBox) 6754 { 6755 6756 ULONG ulDriveNum, ulDriveMap; 6757 ULONG ulSearchCount; 6758 FILEFINDBUF3 findbuf; 6759 HDIR hDir; 6760 APIRET rc; 6761 LINKDIRS *info, *temp; 6762 6763 if (!loadedudirs) 6764 load_udirs(); 6765 DosError(FERR_DISABLEHARDERR); 6766 DosQCurDisk(&ulDriveNum, &ulDriveMap); 6767 info = udirhead; 6768 while (info) 6769 { 6770 if (IsFullName(info -> path) && 6771 !(driveflags[toupper(*info -> path) - 'A'] & 6772 (DRIVE_IGNORE | DRIVE_INVALID))) 6773 { 6774 DosError(FERR_DISABLEHARDERR); 6775 hDir = HDIR_CREATE; 6776 ulSearchCount = 1L; 6777 if (!IsRoot(info -> path)) 6778 rc = DosFindFirst(info -> path, &hDir, FILE_DIRECTORY | 6779 MUST_HAVE_DIRECTORY | FILE_READONLY | 6780 FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN, 6781 &findbuf, sizeof(FILEFINDBUF3), 6782 &ulSearchCount, FIL_STANDARD); 6783 else 6784 { 6785 rc = 0; 6786 findbuf.attrFile = FILE_DIRECTORY; 6787 } 6788 priority_bumped(); 6789 if (!rc) 6790 { 6791 if (!IsRoot(info -> path)) 6792 DosFindClose(hDir); 6793 if (findbuf.attrFile & FILE_DIRECTORY) 6794 WinSendMsg(hwndUserlist, LM_INSERTITEM, 6795 MPFROM2SHORT(LIT_SORTASCENDING, 0), 6796 MPFROMP(info -> path)); 6797 else 6798 { 6799 temp = info -> next; 6800 remove_udir(info -> path); 6801 info = temp; 6802 continue; 6803 } 6804 } 6805 else if (!(ulDriveMap & (1L << (toupper(*info -> path) - 'A')))) 6806 { 6807 temp = info -> next; 6808 remove_udir(info -> path); 6809 info = temp; 6810 continue; 6811 } 6812 } 6813 info = info -> next; 6814 } 6815 info = ldirhead; 6816 while (info) 6817 { 6818 if (IsFullName(info -> path) && 6819 !(driveflags[toupper(*info -> path) - 'A'] & 6820 (DRIVE_IGNORE | DRIVE_INVALID))) 6821 { 6822 DosError(FERR_DISABLEHARDERR); 6823 hDir = HDIR_CREATE; 6824 ulSearchCount = 1L; 6825 if (!IsRoot(info -> path)) 6826 rc = DosFindFirst(info -> path, &hDir, FILE_DIRECTORY | 6827 MUST_HAVE_DIRECTORY | FILE_READONLY | 6828 FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN, 6829 &findbuf, sizeof(FILEFINDBUF3), 6830 &ulSearchCount, FIL_STANDARD); 6831 else 6832 { 6833 rc = 0; 6834 findbuf.attrFile = FILE_DIRECTORY; 6835 } 6836 priority_bumped(); 6837 if (!rc) 6838 { 6839 if (!IsRoot(info -> path)) 6840 DosFindClose(hDir); 6841 if (findbuf.attrFile & FILE_DIRECTORY) 6842 WinSendMsg(hwndUserlist, LM_INSERTITEM, 6843 MPFROM2SHORT(LIT_SORTASCENDING, 0), 6844 MPFROMP(info -> path)); 6845 else 6846 { 6847 temp = info -> next; 6848 remove_udir(info -> path); 6849 info = temp; 6850 continue; 6851 } 6852 } 6853 else if (!(ulDriveMap & (1L << (toupper(*info -> path) - 'A')))) 6854 { 6855 temp = info -> next; 6856 remove_udir(info -> path); 6857 info = temp; 6858 continue; 6859 } 6860 } 6861 info = info -> next; 6862 } 6863 WinSendMsg(hwndUserlist, LM_INSERTITEM, 6864 MPFROM2SHORT(0, 0), 6865 MPFROMP(GetPString(IDS_NEWDIRECTORYTEXT))); 6866 WinSetWindowText(hwndUserlist, GetPString(IDS_COMMONDIRTEXT)); 6867 } 6868 return 0; 6869 6870 case UM_SIZE: 6871 if (fAutoTile) 6872 TileChildren(hwnd, FALSE); 6873 else 6874 MoveChildrenAwayFromTree(hwnd); 6875 return 0; 6876 6877 case WM_SIZE: 6878 ResizeChildren(hwnd, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1), 6879 SHORT1FROMMP(mp2), SHORT2FROMMP(mp2)); 6880 break; 6881 6882 case WM_ERASEBACKGROUND: 6883 WinFillRect((HPS) mp1, (PRECTL) mp2, 0x00d0d0d0); 6884 return 0; 6885 6886 case WM_PAINT: 6887 { 6888 HPS hps; 6889 RECTL rcl; 6890 6891 hps = WinBeginPaint(hwnd, (HPS) 0, NULL); 6892 if (hps) 6893 { 6894 WinQueryWindowRect(hwnd, &rcl); 6895 WinFillRect(hps, &rcl, CLR_PALEGRAY); 6896 WinEndPaint(hps); 6897 } 6898 } 6899 break; 6900 6901 case UM_CONTROL: 6902 switch (SHORT1FROMMP(mp1)) 6903 { 6904 case MAIN_CMDLIST: 6905 case MAIN_SETUPLIST: 6906 case MAIN_DRIVELIST: 6907 case MAIN_USERLIST: 6908 case MAIN_BUTTONLIST: 6909 switch (SHORT2FROMMP(mp1)) 6910 { 6911 case CBN_ENTER: 6912 { 6913 HWND hwndUL = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), 6914 SHORT1FROMMP(mp1)); 6915 CHAR path[CCHMAXPATH]; 6916 6917 SetShiftState(); 6918 WinQueryWindowText(WinWindowFromID(hwndUL, CBID_EDIT), 6919 ((SHORT1FROMMP(mp1) == MAIN_USERLIST) ? 6920 CCHMAXPATH : 13), path); 6921 bstrip(path); 6922 if (*path) 6923 { 6924 if (SHORT1FROMMP(mp1) == MAIN_USERLIST) 6925 { 6926 if (!strcmp(path, GetPString(IDS_NEWDIRECTORYTEXT))) 6927 { 6928 if (!LastDir || 6929 !WinSendMsg(WinQueryWindow(LastDir, QW_PARENT), 6930 UM_CONTAINERDIR, 6931 MPFROMP(path), 6932 MPVOID)) 6933 save_dir2(path); 6934 if (!PMMkDir(hwnd, 6935 path, 6936 TRUE)) 6937 { 6938 WinSetWindowText(hwndUL, 6939 GetPString(IDS_COMMONDIRTEXT)); 6940 break; 6941 } 6942 } 6943 if (!IsFile(path) && 6944 !FindDirCnrByName(path, TRUE)) 6945 { 6946 6947 HWND hwndDir; 6948 6949 if ((fUserListSwitches && 6950 !(shiftstate & KC_SHIFT)) || 6951 (!fUserListSwitches && 6952 (shiftstate & KC_SHIFT))) 6953 { 6954 hwndDir = FindDirCnr(hwnd); 6955 if (hwndDir) 6956 { 6957 WinSendMsg(LastDir, 6958 UM_SETDIR, 6959 MPFROMP(path), 6960 MPVOID); 6961 break; 6962 } 6963 } 6964 OpenDirCnr((HWND) 0, 6965 hwndMain, 6966 hwndTree, 6967 FALSE, 6968 path); 6969 } 6970 } 6971 else if (SHORT1FROMMP(mp1) == MAIN_DRIVELIST) 6972 { 6973 ShowTreeRec(WinWindowFromID(WinWindowFromID(hwndTree, 6974 FID_CLIENT), 6975 TREE_CNR), 6976 path, 6977 FALSE, 6978 TRUE); 6979 WinSetFocus(HWND_DESKTOP, 6980 hwndTree); 6981 } 6982 else if (SHORT1FROMMP(mp1) == MAIN_BUTTONLIST) 6983 { 6984 strcat(path, ".TLS"); 6985 load_tools(path); 6986 PrfWriteProfileString(fmprof, 6987 FM3Str, 6988 "LastToolBox", 6989 lasttoolbox); 6990 BuildTools(hwndToolback, 6991 TRUE); 6992 WinSetWindowText(hwndButtonlist, 6993 GetPString(IDS_TOOLBOXTEXT)); 6994 } 6995 else if (SHORT1FROMMP(mp1) == MAIN_SETUPLIST) 6996 { 6997 6998 CHAR s[120]; 6999 ULONG size, numsaves = 0; 7000 7001 SetShiftState(); 7002 size = sizeof(ULONG); 7003 sprintf(s, 7004 "%s.NumDirsLastTime", 7005 path); 7006 if (PrfQueryProfileData(fmprof, 7007 FM3Str, 7008 s, 7009 (PVOID) & numsaves, 7010 &size) && 7011 numsaves) 7012 { 7013 if ((shiftstate & KC_SHIFT) == 0) 7014 PostMsg(MainObjectHwnd, 7015 UM_RESTORE, 7016 MPVOID, 7017 MPFROMLONG(2L)); 7018 { 7019 char *temp; 7020 7021 temp = strdup(path); 7022 if (temp) 7023 { 7024 if (!PostMsg(MainObjectHwnd, 7025 UM_RESTORE, 7026 MPFROMP(temp), 7027 MPVOID)) 7028 free(temp); 7029 } 7030 else 7031 { 7032 if ((shiftstate & KC_SHIFT) != 0 || 7033 fAutoTile) 7034 PostMsg(MainObjectHwnd, 7035 UM_RESTORE, 7036 MPVOID, 7037 MPFROMLONG(1L)); 7038 } 7039 } 7040 } 7041 else 7042 DosBeep(50, 100); 7043 WinSetWindowText(hwndStatelist, 7044 GetPString(IDS_STATETEXT)); 7045 } 7046 else if (SHORT1FROMMP(mp1) == MAIN_CMDLIST) 7047 { 7048 7049 SHORT sSelect; 7050 7051 sSelect = (SHORT) WinSendMsg(hwndCmdlist, 7052 LM_QUERYSELECTION, 7053 MPFROMSHORT(LIT_FIRST), 7054 MPVOID); 7055 if (sSelect >= 0) 7056 WinPostMsg(hwnd, 7057 WM_COMMAND, 7058 MPFROM2SHORT(IDM_COMMANDSTART + sSelect, 0), 7059 MPVOID); 7060 WinSetWindowText(hwndCmdlist, 7061 GetPString(IDS_COMMANDSTEXT)); 7062 } 7063 } 7064 } 7065 break; 7066 7067 default: 7068 break; 7069 } 7070 break; 7071 7072 default: 7073 break; 7074 } 7075 return 0; 7076 7077 case WM_HELP: 7078 WinSendMsg(hwndHelp, 7079 HM_HELP_CONTENTS, 7080 MPVOID, 7081 MPVOID); 7082 break; 7083 7084 case UM_COMMAND: 7085 case WM_COMMAND: 7086 7087 return MainWMCommand(hwnd, msg, mp1, mp2); 7088 7089 case WM_CLOSE: 7090 WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), 7091 WM_SYSCOMMAND, 7092 MPFROM2SHORT(SC_RESTORE, 0), 7093 MPVOID); 7094 WinSendMsg(hwnd, 7095 WM_SAVEAPPLICATION, 7096 MPVOID, 7097 MPVOID); 7098 fAmClosing = TRUE; 7099 WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), 7100 WM_SYSCOMMAND, 7101 MPFROM2SHORT(SC_MINIMIZE, 0), 7102 MPVOID); 7103 if (CloseChildren(hwnd)) 7104 { 7105 fAmClosing = FALSE; 7106 if (fAutoTile) 7107 PostMsg(hwnd, 7108 WM_COMMAND, 7109 MPFROM2SHORT(IDM_TILE, 0), 7110 MPVOID); 5941 7111 return 0; 5942 5943 case UM_SETUP2: 5944 { 5945 SWP swp; 5946 ULONG size = sizeof(SWP); 5947 5948 WinQueryWindowPos(hwnd,&swp); 5949 hwndTree = StartTreeCnr(hwnd,0); 5950 if(!hwndTree) 5951 WinDestroyWindow(WinQueryWindow(hwnd,QW_PARENT)); 5952 else { 5953 if(!fSaveState || 5954 !PrfQueryProfileData(fmprof, 5955 FM3Str, 5956 "LastTreePos", 5957 &swp, 5958 &size) || 5959 size != sizeof(SWP)) { 5960 5961 INT ratio,height = 0; 5962 5963 if(!fNoTreeGap) 5964 height = WinQuerySysValue(HWND_DESKTOP,SV_CYICON) * 2; 5965 size = sizeof(ratio); 5966 if(!PrfQueryProfileData(fmprof, 5967 FM3Str, 5968 "TreeWindowRatio", 5969 (PVOID)&ratio, 5970 &size) || 5971 size < sizeof(ratio)) 5972 ratio = 400; 5973 WinSetWindowPos(hwndTree, 5974 HWND_TOP, 5975 0, 5976 height, 5977 (swp.cx * 100) / ratio, 5978 swp.cy - height, 5979 SWP_SHOW | SWP_SIZE | SWP_MOVE | 5980 SWP_ACTIVATE | SWP_ZORDER); 5981 } 5982 else 5983 WinSetWindowPos(hwndTree, 5984 HWND_TOP, 5985 swp.x, 5986 swp.y, 5987 swp.cx, 5988 swp.cy, 5989 swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW | 5990 SWP_ZORDER | SWP_ACTIVATE); 5991 } 5992 ResizeTools(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT), 5993 MAIN_TOOLS)); 5994 } 5995 PostMsg(MainObjectHwnd, 5996 UM_SETUP3, 5997 mp1, 5998 mp2); 5999 return 0; 6000 6001 case UM_SETUP3: 6002 /* start remaining child windows */ 6003 { 6004 if(!fNoSaveState && 6005 fSaveState) 6006 PostMsg(MainObjectHwnd, 6007 UM_RESTORE, 6008 MPVOID, 6009 MPVOID); 6010 PostMsg(MainObjectHwnd, 6011 UM_SETUP4, 6012 mp1, 6013 mp2); 6014 } 6015 return 0; 6016 6017 case UM_SETUP4: 6018 { 6019 INT argc = (INT)mp1,x; 6020 CHAR **argv = (CHAR **)mp2; 6021 6022 for(x = 1;x < argc;x++) { 6023 if(*argv[x] == '/' || *argv[x] == ';') 6024 continue; 6025 if(!IsFile(argv[x]) && 6026 !FindDirCnrByName(argv[x],FALSE)) 6027 OpenDirCnr((HWND)0, 6028 hwndMain, 6029 hwndTree, 6030 TRUE, 6031 argv[x]); 6032 } 6033 } 6034 PostMsg(MainObjectHwnd, 6035 UM_SETUP5, 6036 MPVOID, 6037 MPVOID); 6038 return 0; 6039 6040 case UM_SETUP5: 6041 if(fAutoTile) 6042 TileChildren(hwnd,TRUE); 6043 PostMsg(hwnd, 6044 UM_FILLUSERLIST, 6045 MPVOID, 6046 MPVOID); 6047 PostMsg(hwnd, 6048 UM_FILLSETUPLIST, 6049 MPVOID, 6050 MPVOID); 6051 PostMsg(hwnd, 6052 UM_FILLCMDLIST, 6053 MPVOID, 6054 MPVOID); 6055 PostMsg(hwnd, 6056 UM_FILLBUTTONLIST, 6057 MPVOID, 6058 MPVOID); 6059 { 6060 HWND hwndActive; 6061 6062 hwndActive = TopWindow(hwnd,hwndTree); 6063 if(hwndActive) 6064 WinSetWindowPos(hwndActive, 6065 HWND_TOP, 6066 0, 6067 0, 6068 0, 6069 0, 6070 SWP_ACTIVATE); 6071 } 6072 if(fStartMinimized || 6073 fReminimize) 6074 PostMsg(hwndTree, 6075 UM_MINIMIZE, 6076 MPVOID, 6077 MPVOID); 6078 else if(fStartMaximized) 6079 PostMsg(hwndTree, 6080 UM_MAXIMIZE, 6081 MPVOID, 6082 MPVOID); 6083 fRunning = TRUE; 6084 return 0; 7112 } 7113 if (hwndTree) 7114 { 7115 if (!PostMsg(hwndTree, 7116 WM_CLOSE, 7117 MPVOID, 7118 MPVOID)) 7119 WinSendMsg(hwndTree, 7120 WM_CLOSE, 7121 MPVOID, 7122 MPVOID); 7123 } 7124 DosSleep(1L); 7125 return 0; 7126 7127 case UM_CLOSE: 7128 HideNote(); 7129 WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT)); 7130 return 0; 7131 7132 case UM_RESTORE: 7133 { 7134 char *temp; 7135 7136 temp = strdup(GetPString(IDS_FM2TEMPTEXT)); 7137 if (temp) 7138 { 7139 if (!PostMsg(MainObjectHwnd, 7140 UM_RESTORE, 7141 MPFROMP(temp), 7142 MPVOID)) 7143 free(temp); 7144 } 7145 } 7146 return 0; 7147 7148 case UM_SETDIR: 7149 if (mp1) /* mp1 == name of directory to open */ 7150 return MRFROMLONG(OpenDirCnr((HWND) 0, 7151 hwndMain, 7152 hwndTree, 7153 (BOOL) mp2, 7154 (char *) mp1)); 7155 return 0; 7156 7157 case WM_DESTROY: 7158 hwndMain = (HWND) 0; 7159 if (!PostMsg((HWND) 0, 7160 WM_QUIT, 7161 MPVOID, 7162 MPVOID)) 7163 WinSendMsg((HWND) 0, 7164 WM_QUIT, 7165 MPVOID, 7166 MPVOID); 7167 break; 6085 7168 } 6086 7169 6087 return WinDefWindowProc(hwnd, msg,mp1,mp2);7170 return WinDefWindowProc(hwnd, msg, mp1, mp2); 6088 7171 } 6089 6090 6091 MRESULT EXPENTRY MainWndProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {6092 6093 switch(msg) {6094 case WM_CREATE:6095 case UM_SETUP:6096 case UM_SETUP2:6097 case UM_SETUP3:6098 case UM_SETUP4:6099 case UM_SETUP5:6100 return MainWMOnce(hwnd,msg,mp1,mp2);6101 6102 case WM_CONTROLPOINTER:6103 if(!fNoFinger &&6104 (SHORT1FROMMP(mp1) == IDM_OPENWALK ||6105 SHORT1FROMMP(mp1) == IDM_USERLIST))6106 return MRFROMLONG(hptrFinger);6107 break;6108 6109 case UM_LOADFILE:6110 case UM_THREADUSE:6111 case UM_BUILDDRIVES:6112 return CommonMainWndProc(hwnd,msg,mp1,mp2);6113 6114 case WM_BUTTON1UP:6115 case WM_BUTTON2UP:6116 case WM_BUTTON3UP:6117 case WM_MOUSEMOVE:6118 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));6119 break;6120 6121 case WM_CHAR:6122 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));6123 break;6124 6125 case WM_MENUEND:6126 if((HWND)mp2 == MainPopupMenu) {6127 WinDestroyWindow(MainPopupMenu);6128 MainPopupMenu = (HWND)0;6129 }6130 break;6131 6132 case UM_CONTEXTMENU:6133 case WM_CONTEXTMENU:6134 if(CheckMenu(&MainPopupMenu,MAIN_POPUP)) {6135 SetToggleChecks(MainPopupMenu);6136 PopupMenu(hwnd,hwnd,MainPopupMenu);6137 }6138 if(msg == UM_CONTEXTMENU)6139 return 0;6140 return MRFROMSHORT(TRUE);6141 6142 case UM_SETUSERLISTNAME:6143 if(mp1) {6144 if(fUserComboBox)6145 WinSetWindowText(WinWindowFromID(hwndUserlist,CBID_EDIT),6146 (CHAR *)mp1);6147 if(add_udir(FALSE,(CHAR *)mp1)) {6148 if(fUserComboBox) {6149 if(fAutoAddDirs)6150 WinSendMsg(hwndUserlist,LM_INSERTITEM,6151 MPFROM2SHORT(LIT_SORTASCENDING,0),6152 MPFROMP((CHAR *)mp1));6153 }6154 }6155 }6156 return 0;6157 6158 case UM_ARRANGEICONS:6159 ArrangeIcons(hwnd);6160 return 0;6161 6162 case WM_CHORD:6163 PostMsg(hwnd,6164 WM_COMMAND,6165 MPFROM2SHORT(IDM_WINDOWDLG,0),6166 MPVOID);6167 break;6168 6169 case WM_SETFOCUS:6170 if(mp2)6171 PostMsg(hwnd,6172 UM_FOCUSME,6173 MPVOID,6174 MPVOID);6175 break;6176 6177 case UM_FOCUSME:6178 WinSetFocus(hwndTree,6179 TRUE);6180 return 0;6181 6182 case UM_RESCAN:6183 TileChildren(hwnd,TRUE);6184 return 0;6185 6186 case WM_SAVEAPPLICATION:6187 {6188 SWP swp;6189 6190 WinQueryWindowPos(WinQueryWindow(hwnd,QW_PARENT),&swp);6191 if(!(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) {6192 WinStoreWindowPos(FM2Str,6193 "MainWindowPos",6194 WinQueryWindow(hwnd,QW_PARENT));6195 if(!fNoSaveState && fSaveState)6196 SaveDirCnrState(hwnd,NULL);6197 }6198 }6199 break;6200 6201 case MM_PORTHOLEINIT:6202 switch(SHORT1FROMMP(mp1)) {6203 case 0:6204 case 1:6205 {6206 HWND hwndCurrent;6207 ULONG wmsg;6208 6209 wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;6210 hwndCurrent = TopWindow(hwnd,(HWND)0);6211 PortholeInit((HWND)WinSendMsg(WinWindowFromID(hwndCurrent,6212 FID_CLIENT),wmsg,MPVOID,6213 MPVOID),mp1,mp2);6214 }6215 break;6216 }6217 break;6218 6219 case WM_INITMENU:6220 switch(SHORT1FROMMP(mp1)) {6221 case IDM_CONFIGMENU:6222 SetToggleChecks((HWND)WinQueryWindowULong(hwnd,QWL_USER));6223 break;6224 6225 case IDM_WINDOWSMENU:6226 /*6227 * add child windows of client6228 * and switchlist entries to end of pulldown menu6229 */6230 {6231 HWND hwndMenu,hwndSubMenu;6232 MENUITEM mi;6233 6234 hwndMenu = WinQueryWindowULong(hwnd,QWL_USER);6235 memset(&mi,0,sizeof(mi));6236 mi.iPosition = MIT_END;6237 mi.afStyle = MIS_TEXT;6238 if(!WinSendMsg(hwndMenu,MM_QUERYITEM,6239 MPFROM2SHORT(IDM_WINDOWSMENU,TRUE),6240 MPFROMP(&mi)))6241 break;6242 hwndSubMenu = mi.hwndSubMenu;6243 SetupWinList(hwndSubMenu,6244 hwnd,6245 WinQueryWindow(hwnd,QW_PARENT));6246 }6247 break;6248 6249 default:6250 {6251 HWND hwndCurrent;6252 6253 hwndCurrent = TopWindow(hwnd,(HWND)0);6254 if(hwndCurrent)6255 WinSendMsg(hwndCurrent,UM_INITMENU,mp1,mp2);6256 }6257 break;6258 }6259 break;6260 6261 case UM_ADDTOMENU:6262 AddToMenu((CHAR *)mp1,WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),6263 FID_MENU));6264 return 0;6265 6266 case UM_FILLCMDLIST:6267 WinSendMsg(hwndCmdlist,LM_DELETEALL,MPVOID,MPVOID);6268 if(!cmdloaded)6269 load_commands();6270 if(cmdhead) {6271 6272 LINKCMDS *info;6273 6274 info = cmdhead;6275 while(info) {6276 WinSendMsg(hwndCmdlist,LM_INSERTITEM,6277 MPFROM2SHORT(LIT_END,0),6278 MPFROMP(info->title));6279 info = info->next;6280 }6281 }6282 return 0;6283 6284 case UM_FILLSETUPLIST:6285 WinSendMsg(hwndStatelist,LM_DELETEALL,MPVOID,MPVOID);6286 if(fUserComboBox) {6287 6288 INT x;6289 6290 if(!loadedsetups)6291 load_setups();6292 for(x = 0;x < MAXNUMSETUPS;x++) {6293 if(*lastsetups[x])6294 WinSendMsg(hwndStatelist,LM_INSERTITEM,6295 MPFROM2SHORT(LIT_SORTASCENDING,0),6296 MPFROMP(lastsetups[x]));6297 }6298 WinSetWindowText(hwndStatelist,GetPString(IDS_STATETEXT));6299 }6300 return 0;6301 6302 case UM_FILLBUTTONLIST:6303 WinSendMsg(hwndButtonlist,LM_DELETEALL,MPVOID,MPVOID);6304 if(fUserComboBox) {6305 6306 BOOL foundit = FALSE,thisone;6307 ULONG ulSearchCount;6308 SHORT sSelect;6309 FILEFINDBUF3 findbuf;6310 HDIR hDir;6311 CHAR *p;6312 6313 DosError(FERR_DISABLEHARDERR);6314 hDir = HDIR_CREATE;6315 ulSearchCount = 1L;6316 if(!DosFindFirst("*.TLS",&hDir,FILE_READONLY | FILE_ARCHIVED,6317 &findbuf,sizeof(FILEFINDBUF3),6318 &ulSearchCount, FIL_STANDARD)) {6319 do {6320 priority_bumped();6321 if(!foundit) {6322 thisone = FALSE;6323 p = strrchr(lasttoolbox,'\\');6324 if(!p)6325 p = lasttoolbox;6326 else6327 p++;6328 if(!stricmp(findbuf.achName,p))6329 thisone = TRUE;6330 }6331 p = strrchr(findbuf.achName,'.');6332 if(p)6333 *p = 0;6334 sSelect = (SHORT)WinSendMsg(hwndButtonlist,LM_INSERTITEM,6335 MPFROM2SHORT(LIT_SORTASCENDING,0),6336 MPFROMP(findbuf.achName));6337 if(!foundit && thisone && sSelect >= 0) {6338 WinSendMsg(hwndButtonlist,LM_SELECTITEM,MPFROM2SHORT(sSelect,0),6339 MPFROMLONG(TRUE));6340 foundit = TRUE;6341 }6342 } while(!DosFindNext(hDir,&findbuf,sizeof(FILEFINDBUF3),6343 &ulSearchCount));6344 DosFindClose(hDir);6345 priority_bumped();6346 }6347 WinSetWindowText(hwndButtonlist,GetPString(IDS_TOOLBOXTEXT));6348 }6349 return 0;6350 6351 case UM_FILLUSERLIST:6352 WinSendMsg(hwndUserlist,LM_DELETEALL,MPVOID,MPVOID);6353 if(fUserComboBox) {6354 6355 ULONG ulDriveNum,ulDriveMap;6356 ULONG ulSearchCount;6357 FILEFINDBUF3 findbuf;6358 HDIR hDir;6359 APIRET rc;6360 LINKDIRS *info,*temp;6361 6362 if(!loadedudirs)6363 load_udirs();6364 DosError(FERR_DISABLEHARDERR);6365 DosQCurDisk(&ulDriveNum,&ulDriveMap);6366 info = udirhead;6367 while(info) {6368 if(IsFullName(info->path) &&6369 !(driveflags[toupper(*info->path) - 'A'] &6370 (DRIVE_IGNORE | DRIVE_INVALID))) {6371 DosError(FERR_DISABLEHARDERR);6372 hDir = HDIR_CREATE;6373 ulSearchCount = 1L;6374 if(!IsRoot(info->path))6375 rc = DosFindFirst(info->path,&hDir,FILE_DIRECTORY |6376 MUST_HAVE_DIRECTORY | FILE_READONLY |6377 FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,6378 &findbuf,sizeof(FILEFINDBUF3),6379 &ulSearchCount, FIL_STANDARD);6380 else {6381 rc = 0;6382 findbuf.attrFile = FILE_DIRECTORY;6383 }6384 priority_bumped();6385 if(!rc) {6386 if(!IsRoot(info->path))6387 DosFindClose(hDir);6388 if(findbuf.attrFile & FILE_DIRECTORY)6389 WinSendMsg(hwndUserlist,LM_INSERTITEM,6390 MPFROM2SHORT(LIT_SORTASCENDING,0),6391 MPFROMP(info->path));6392 else {6393 temp = info->next;6394 remove_udir(info->path);6395 info = temp;6396 continue;6397 }6398 }6399 else if(!(ulDriveMap & (1L << (toupper(*info->path) - 'A')))) {6400 temp = info->next;6401 remove_udir(info->path);6402 info = temp;6403 continue;6404 }6405 }6406 info = info->next;6407 }6408 info = ldirhead;6409 while(info) {6410 if(IsFullName(info->path) &&6411 !(driveflags[toupper(*info->path) - 'A'] &6412 (DRIVE_IGNORE | DRIVE_INVALID))) {6413 DosError(FERR_DISABLEHARDERR);6414 hDir = HDIR_CREATE;6415 ulSearchCount = 1L;6416 if(!IsRoot(info->path))6417 rc = DosFindFirst(info->path,&hDir,FILE_DIRECTORY |6418 MUST_HAVE_DIRECTORY | FILE_READONLY |6419 FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,6420 &findbuf,sizeof(FILEFINDBUF3),6421 &ulSearchCount, FIL_STANDARD);6422 else {6423 rc = 0;6424 findbuf.attrFile = FILE_DIRECTORY;6425 }6426 priority_bumped();6427 if(!rc) {6428 if(!IsRoot(info->path))6429 DosFindClose(hDir);6430 if(findbuf.attrFile & FILE_DIRECTORY)6431 WinSendMsg(hwndUserlist,LM_INSERTITEM,6432 MPFROM2SHORT(LIT_SORTASCENDING,0),6433 MPFROMP(info->path));6434 else {6435 temp = info->next;6436 remove_udir(info->path);6437 info = temp;6438 continue;6439 }6440 }6441 else if(!(ulDriveMap & (1L << (toupper(*info->path) - 'A')))) {6442 temp = info->next;6443 remove_udir(info->path);6444 info = temp;6445 continue;6446 }6447 }6448 info = info->next;6449 }6450 WinSendMsg(hwndUserlist,LM_INSERTITEM,6451 MPFROM2SHORT(0,0),6452 MPFROMP(GetPString(IDS_NEWDIRECTORYTEXT)));6453 WinSetWindowText(hwndUserlist,GetPString(IDS_COMMONDIRTEXT));6454 }6455 return 0;6456 6457 case UM_SIZE:6458 if(fAutoTile)6459 TileChildren(hwnd,FALSE);6460 else6461 MoveChildrenAwayFromTree(hwnd);6462 return 0;6463 6464 case WM_SIZE:6465 ResizeChildren(hwnd,SHORT1FROMMP(mp1),SHORT2FROMMP(mp1),6466 SHORT1FROMMP(mp2),SHORT2FROMMP(mp2));6467 break;6468 6469 case WM_ERASEBACKGROUND:6470 WinFillRect((HPS)mp1,(PRECTL)mp2,0x00d0d0d0);6471 return 0;6472 6473 case WM_PAINT:6474 {6475 HPS hps;6476 RECTL rcl;6477 6478 hps = WinBeginPaint(hwnd,(HPS)0,NULL);6479 if(hps) {6480 WinQueryWindowRect(hwnd,&rcl);6481 WinFillRect(hps,&rcl,CLR_PALEGRAY);6482 WinEndPaint(hps);6483 }6484 }6485 break;6486 6487 case UM_CONTROL:6488 switch(SHORT1FROMMP(mp1)) {6489 case MAIN_CMDLIST:6490 case MAIN_SETUPLIST:6491 case MAIN_DRIVELIST:6492 case MAIN_USERLIST:6493 case MAIN_BUTTONLIST:6494 switch(SHORT2FROMMP(mp1)) {6495 case CBN_ENTER:6496 {6497 HWND hwndUL = WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),6498 SHORT1FROMMP(mp1));6499 CHAR path[CCHMAXPATH];6500 6501 SetShiftState();6502 WinQueryWindowText(WinWindowFromID(hwndUL,CBID_EDIT),6503 ((SHORT1FROMMP(mp1) == MAIN_USERLIST) ?6504 CCHMAXPATH : 13),path);6505 bstrip(path);6506 if(*path) {6507 if(SHORT1FROMMP(mp1) == MAIN_USERLIST) {6508 if(!strcmp(path,GetPString(IDS_NEWDIRECTORYTEXT))) {6509 if(!LastDir ||6510 !WinSendMsg(WinQueryWindow(LastDir,QW_PARENT),6511 UM_CONTAINERDIR,6512 MPFROMP(path),6513 MPVOID))6514 save_dir2(path);6515 if(!PMMkDir(hwnd,6516 path,6517 TRUE)) {6518 WinSetWindowText(hwndUL,6519 GetPString(IDS_COMMONDIRTEXT));6520 break;6521 }6522 }6523 if(!IsFile(path) &&6524 !FindDirCnrByName(path,TRUE)) {6525 6526 HWND hwndDir;6527 6528 if((fUserListSwitches &&6529 !(shiftstate & KC_SHIFT)) ||6530 (!fUserListSwitches &&6531 (shiftstate & KC_SHIFT))) {6532 hwndDir = FindDirCnr(hwnd);6533 if(hwndDir) {6534 WinSendMsg(LastDir,6535 UM_SETDIR,6536 MPFROMP(path),6537 MPVOID);6538 break;6539 }6540 }6541 OpenDirCnr((HWND)0,6542 hwndMain,6543 hwndTree,6544 FALSE,6545 path);6546 }6547 }6548 else if(SHORT1FROMMP(mp1) == MAIN_DRIVELIST) {6549 ShowTreeRec(WinWindowFromID(WinWindowFromID(hwndTree,6550 FID_CLIENT),6551 TREE_CNR),6552 path,6553 FALSE,6554 TRUE);6555 WinSetFocus(HWND_DESKTOP,6556 hwndTree);6557 }6558 else if(SHORT1FROMMP(mp1) == MAIN_BUTTONLIST) {6559 strcat(path,".TLS");6560 load_tools(path);6561 PrfWriteProfileString(fmprof,6562 FM3Str,6563 "LastToolBox",6564 lasttoolbox);6565 BuildTools(hwndToolback,6566 TRUE);6567 WinSetWindowText(hwndButtonlist,6568 GetPString(IDS_TOOLBOXTEXT));6569 }6570 else if(SHORT1FROMMP(mp1) == MAIN_SETUPLIST) {6571 6572 CHAR s[120];6573 ULONG size,numsaves = 0;6574 6575 SetShiftState();6576 size = sizeof(ULONG);6577 sprintf(s,6578 "%s.NumDirsLastTime",6579 path);6580 if(PrfQueryProfileData(fmprof,6581 FM3Str,6582 s,6583 (PVOID)&numsaves,6584 &size) &&6585 numsaves) {6586 if((shiftstate & KC_SHIFT) == 0)6587 PostMsg(MainObjectHwnd,6588 UM_RESTORE,6589 MPVOID,6590 MPFROMLONG(2L));6591 {6592 char *temp;6593 6594 temp = strdup(path);6595 if(temp) {6596 if(!PostMsg(MainObjectHwnd,6597 UM_RESTORE,6598 MPFROMP(temp),6599 MPVOID))6600 free(temp);6601 }6602 else {6603 if((shiftstate & KC_SHIFT) != 0 ||6604 fAutoTile)6605 PostMsg(MainObjectHwnd,6606 UM_RESTORE,6607 MPVOID,6608 MPFROMLONG(1L));6609 }6610 }6611 }6612 else6613 DosBeep(50,100);6614 WinSetWindowText(hwndStatelist,6615 GetPString(IDS_STATETEXT));6616 }6617 else if(SHORT1FROMMP(mp1) == MAIN_CMDLIST) {6618 6619 SHORT sSelect;6620 6621 sSelect = (SHORT)WinSendMsg(hwndCmdlist,6622 LM_QUERYSELECTION,6623 MPFROMSHORT(LIT_FIRST),6624 MPVOID);6625 if(sSelect >= 0)6626 WinPostMsg(hwnd,6627 WM_COMMAND,6628 MPFROM2SHORT(IDM_COMMANDSTART + sSelect,0),6629 MPVOID);6630 WinSetWindowText(hwndCmdlist,6631 GetPString(IDS_COMMANDSTEXT));6632 }6633 }6634 }6635 break;6636 6637 default:6638 break;6639 }6640 break;6641 6642 default:6643 break;6644 }6645 return 0;6646 6647 case WM_HELP:6648 WinSendMsg(hwndHelp,6649 HM_HELP_CONTENTS,6650 MPVOID,6651 MPVOID);6652 break;6653 6654 case UM_COMMAND:6655 case WM_COMMAND:6656 6657 return MainWMCommand(hwnd,msg,mp1,mp2);6658 6659 case WM_CLOSE:6660 WinSendMsg(WinQueryWindow(hwnd,QW_PARENT),6661 WM_SYSCOMMAND,6662 MPFROM2SHORT(SC_RESTORE,0),6663 MPVOID);6664 WinSendMsg(hwnd,6665 WM_SAVEAPPLICATION,6666 MPVOID,6667 MPVOID);6668 fAmClosing = TRUE;6669 WinSendMsg(WinQueryWindow(hwnd,QW_PARENT),6670 WM_SYSCOMMAND,6671 MPFROM2SHORT(SC_MINIMIZE,0),6672 MPVOID);6673 if(CloseChildren(hwnd)) {6674 fAmClosing = FALSE;6675 if(fAutoTile)6676 PostMsg(hwnd,6677 WM_COMMAND,6678 MPFROM2SHORT(IDM_TILE,0),6679 MPVOID);6680 return 0;6681 }6682 if(hwndTree) {6683 if(!PostMsg(hwndTree,6684 WM_CLOSE,6685 MPVOID,6686 MPVOID))6687 WinSendMsg(hwndTree,6688 WM_CLOSE,6689 MPVOID,6690 MPVOID);6691 }6692 DosSleep(1L);6693 return 0;6694 6695 case UM_CLOSE:6696 HideNote();6697 WinDestroyWindow(WinQueryWindow(hwnd,QW_PARENT));6698 return 0;6699 6700 case UM_RESTORE:6701 {6702 char *temp;6703 6704 temp = strdup(GetPString(IDS_FM2TEMPTEXT));6705 if(temp) {6706 if(!PostMsg(MainObjectHwnd,6707 UM_RESTORE,6708 MPFROMP(temp),6709 MPVOID))6710 free(temp);6711 }6712 }6713 return 0;6714 6715 case UM_SETDIR:6716 if(mp1) /* mp1 == name of directory to open */6717 return MRFROMLONG(OpenDirCnr((HWND)0,6718 hwndMain,6719 hwndTree,6720 (BOOL)mp2,6721 (char *)mp1));6722 return 0;6723 6724 case WM_DESTROY:6725 hwndMain = (HWND)0;6726 if(!PostMsg((HWND)0,6727 WM_QUIT,6728 MPVOID,6729 MPVOID))6730 WinSendMsg((HWND)0,6731 WM_QUIT,6732 MPVOID,6733 MPVOID);6734 break;6735 }6736 6737 return WinDefWindowProc(hwnd,msg,mp1,mp2);6738 }6739
Note:
See TracChangeset
for help on using the changeset viewer.