| 1 |  | 
|---|
| 2 | /*********************************************************************** | 
|---|
| 3 |  | 
|---|
| 4 | $Id: mainwnd2.c 1482 2009-12-13 19:59:47Z gyoung $ | 
|---|
| 5 |  | 
|---|
| 6 | fm/4 main window | 
|---|
| 7 |  | 
|---|
| 8 | Copyright (c) 1993-98 M. Kimes | 
|---|
| 9 | Copyright (c) 2005, 2008 Steven H. Levine | 
|---|
| 10 |  | 
|---|
| 11 | 23 May 05 SHL Use datamin.h | 
|---|
| 12 | 26 May 05 SHL Comments and localize code | 
|---|
| 13 | 06 Aug 05 SHL Renames | 
|---|
| 14 | 02 Jan 06 SHL Use QWL_USER more | 
|---|
| 15 | 02 Jan 06 SHL Map IDM_WINDOWDLG to match IBM_TWODIRS | 
|---|
| 16 | 17 Jul 06 SHL Use Runtime_Error | 
|---|
| 17 | 30 Mar 07 GKY Remove GetPString for window class names | 
|---|
| 18 | 12 May 07 SHL Pass ulItemsToUnHilite to UnHilite | 
|---|
| 19 | 06 Aug 07 GKY Reduce DosSleep times (ticket 148) | 
|---|
| 20 | 07 Aug 07 SHL Use BldQuotedFileName | 
|---|
| 21 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat | 
|---|
| 22 | 10 Jan 08 SHL Sync with CfgDlgProc mods | 
|---|
| 23 | 19 Jan 08 GKY Rework Utilities menu | 
|---|
| 24 | 14 Feb 08 SHL Rework to support settings menu conditional cascade | 
|---|
| 25 | 29 Feb 08 GKY Use xfree where appropriate | 
|---|
| 26 | 27 Aug 08 JBS Ticket 259: Support saving/restoring toolbars with states | 
|---|
| 27 | 01 Sep 08 GKY Add bmps for default toolbars | 
|---|
| 28 | 10 Dec 08 SHL Integrate exception handler support | 
|---|
| 29 | 03 Jan 09 GKY Check for system that is protectonly to gray out Dos/Win command lines and prevent | 
|---|
| 30 | Dos/Win programs from being inserted into the execute dialog with message why. | 
|---|
| 31 | 21 Jun 09 GKY Added drive letter to bitmap buttons in drive bar; Eliminate static drive | 
|---|
| 32 | letter windows; Use button ID to identify drive letter for processing. | 
|---|
| 33 | 22 Jul 09 GKY Code changes to use semaphores to serialize drive scanning | 
|---|
| 34 | 12 Sep 09 GKY Add FM3.INI User ini and system ini to submenu for view ini | 
|---|
| 35 | 13 Dec 09 GKY Fixed separate paramenters. Please note that appname should be used in | 
|---|
| 36 | profile calls for user settings that work and are setable in more than one | 
|---|
| 37 | miniapp; FM3Str should be used for setting only relavent to FM/2 or that | 
|---|
| 38 | aren't user settable; realappname should be used for setting applicable to | 
|---|
| 39 | one or more miniapp but not to FM/2 | 
|---|
| 40 |  | 
|---|
| 41 | ***********************************************************************/ | 
|---|
| 42 |  | 
|---|
| 43 | #include <stdlib.h> | 
|---|
| 44 | #include <string.h> | 
|---|
| 45 | #include <share.h> | 
|---|
| 46 | // #include <process.h>                 // _beginthread | 
|---|
| 47 |  | 
|---|
| 48 | #define INCL_DOS | 
|---|
| 49 | #define INCL_WIN | 
|---|
| 50 | #define INCL_GPI | 
|---|
| 51 | #define INCL_LONGLONG | 
|---|
| 52 |  | 
|---|
| 53 | #include "fm3dll.h" | 
|---|
| 54 | #include "fm3dll2.h"                    // #define's for UM_*, control id's, etc. | 
|---|
| 55 | #include "killproc.h"                   // Data declaration(s) | 
|---|
| 56 | #include "grep.h"                       // Data declaration(s) | 
|---|
| 57 | #include "autoview.h"                   // Data declaration(s) | 
|---|
| 58 | #include "dircnrs.h"                    // Data declaration(s) | 
|---|
| 59 | #include "worker.h"                     // Data declaration(s) | 
|---|
| 60 | #include "init.h"                       // Data declaration(s) | 
|---|
| 61 | #include "fm3dlg.h" | 
|---|
| 62 | #include "fm3str.h" | 
|---|
| 63 | #include "tools.h" | 
|---|
| 64 | #include "datamin.h" | 
|---|
| 65 | #include "comp.h"                       // COMPARE | 
|---|
| 66 | #include "pathutil.h"                   // BldQuotedFileName | 
|---|
| 67 | #include "errutil.h"                    // Dos_Error... | 
|---|
| 68 | #include "strutil.h"                    // GetPString | 
|---|
| 69 | #include "notebook.h"                   // CfgDlgProc | 
|---|
| 70 | #include "command.h"                    // RunCommand | 
|---|
| 71 | #include "misc.h"                       // BoxWindow, FixSwitchList, SetConditionalCascade | 
|---|
| 72 | // SetSysMenu | 
|---|
| 73 | #include "mainwnd.h"                    // CloseChildren, MainWMCommand, MakeMainObjWin, ResizeDrives | 
|---|
| 74 | // TopWindow | 
|---|
| 75 | #include "common.h"                     // CommonCreateMainChildren, CommonMainWndProc | 
|---|
| 76 | #include "notify.h"                     // HideNote | 
|---|
| 77 | #include "mainwnd2.h" | 
|---|
| 78 | #include "remap.h"                      // RemapDlgProc | 
|---|
| 79 | #include "treecnr.h"                    // StartTreeCnr | 
|---|
| 80 | #include "walkem.h"                     // WalkTwoCmpDlgProc, WalkTwoSetDlgProc | 
|---|
| 81 | #include "dirs.h"                       // switch_to | 
|---|
| 82 | #include "filter.h"                     // Filter | 
|---|
| 83 | #include "collect.h"                    // StartCollector | 
|---|
| 84 | #include "select.h"                     // UnHilite | 
|---|
| 85 | #include "valid.h"                      // MakeValidDir | 
|---|
| 86 | #include "systemf.h"                    // runemf2 | 
|---|
| 87 | #include "wrappers.h"                   // xfree | 
|---|
| 88 | #include "fortify.h" | 
|---|
| 89 | #include "excputil.h"                   // xbeginthread | 
|---|
| 90 |  | 
|---|
| 91 | typedef struct | 
|---|
| 92 | { | 
|---|
| 93 | USHORT size; | 
|---|
| 94 | USHORT dummy; | 
|---|
| 95 | HWND hwndDir1; | 
|---|
| 96 | HWND hwndDir2; | 
|---|
| 97 | HWND hwndCurr; | 
|---|
| 98 | HWND hwndLastDir; | 
|---|
| 99 | HWND hwndMax; | 
|---|
| 100 | } | 
|---|
| 101 | PERSON1DATA; | 
|---|
| 102 |  | 
|---|
| 103 | // Data definitions | 
|---|
| 104 | static PSZ pszSrcFile = __FILE__; | 
|---|
| 105 | static ULONG TreeWidth; | 
|---|
| 106 |  | 
|---|
| 107 | #pragma data_seg(GLOBAL1) | 
|---|
| 108 | PFNWP PFNWPFrame; | 
|---|
| 109 |  | 
|---|
| 110 | #pragma data_seg(GLOBAL2) | 
|---|
| 111 | CHAR realappname[12]; | 
|---|
| 112 |  | 
|---|
| 113 | static MRESULT EXPENTRY MainFrameWndProc2(HWND hwnd, ULONG msg, MPARAM mp1, | 
|---|
| 114 | MPARAM mp2) | 
|---|
| 115 | { | 
|---|
| 116 | PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| 117 |  | 
|---|
| 118 | switch (msg) { | 
|---|
| 119 | case WM_ADJUSTWINDOWPOS: | 
|---|
| 120 | { | 
|---|
| 121 | SWP *pswp; | 
|---|
| 122 |  | 
|---|
| 123 | pswp = (SWP *) mp1; | 
|---|
| 124 | if (pswp->fl & (SWP_SHOW | SWP_RESTORE)) | 
|---|
| 125 | PostMsg(WinWindowFromID(hwnd, FID_CLIENT), UM_SIZE, MPVOID, MPVOID); | 
|---|
| 126 | if (fDataMin && !fAmClosing) { | 
|---|
| 127 | if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE)) { | 
|---|
| 128 |  | 
|---|
| 129 | SWP swp; | 
|---|
| 130 |  | 
|---|
| 131 | WinQueryWindowPos(hwnd, &swp); | 
|---|
| 132 | PostMsg(hwnd, UM_FOCUSME, MPFROMLONG(swp.fl), MPVOID); | 
|---|
| 133 | HideNote(); | 
|---|
| 134 | } | 
|---|
| 135 | else if (pswp->fl & (SWP_SHOW | SWP_RESTORE)) { | 
|---|
| 136 | if (DataHwnd) | 
|---|
| 137 | PostMsg(DataHwnd, WM_CLOSE, MPVOID, MPVOID); | 
|---|
| 138 | } | 
|---|
| 139 | } | 
|---|
| 140 | if (!fAmClosing) { | 
|---|
| 141 | if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE)) | 
|---|
| 142 | HideNote(); | 
|---|
| 143 | } | 
|---|
| 144 | } | 
|---|
| 145 | break; | 
|---|
| 146 |  | 
|---|
| 147 | case UM_FOCUSME: | 
|---|
| 148 | CreateDataBar(HWND_DESKTOP, (ULONG) mp1); | 
|---|
| 149 | return 0; | 
|---|
| 150 |  | 
|---|
| 151 | case WM_BUTTON1UP: | 
|---|
| 152 | case WM_BUTTON2UP: | 
|---|
| 153 | case WM_BUTTON3UP: | 
|---|
| 154 | case WM_MOUSEMOVE: | 
|---|
| 155 | case WM_CHORD: | 
|---|
| 156 | shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); | 
|---|
| 157 | break; | 
|---|
| 158 |  | 
|---|
| 159 | case WM_CHAR: | 
|---|
| 160 | shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL)); | 
|---|
| 161 | break; | 
|---|
| 162 |  | 
|---|
| 163 | case WM_CONTROL: | 
|---|
| 164 | return WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), UM_CONTROL, mp1, | 
|---|
| 165 | mp2); | 
|---|
| 166 |  | 
|---|
| 167 | case WM_COMMAND: | 
|---|
| 168 | return WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), msg, mp1, mp2); | 
|---|
| 169 |  | 
|---|
| 170 | case WM_CALCFRAMERECT: | 
|---|
| 171 | { | 
|---|
| 172 | MRESULT mr; | 
|---|
| 173 | PRECTL prectl; | 
|---|
| 174 | LONG sheight = 20, bheight = 20; | 
|---|
| 175 |  | 
|---|
| 176 | mr = (oldproc) ? oldproc(hwnd, msg, mp1, mp2) : | 
|---|
| 177 | PFNWPFrame(hwnd, msg, mp1, mp2); | 
|---|
| 178 |  | 
|---|
| 179 | /* | 
|---|
| 180 | * Calculate the position of the client rectangle. | 
|---|
| 181 | * Otherwise, we'll see a lot of redraw when we move the | 
|---|
| 182 | * client during WM_FORMATFRAME. | 
|---|
| 183 | */ | 
|---|
| 184 |  | 
|---|
| 185 | if (mr && mp2) { | 
|---|
| 186 | prectl = (PRECTL) mp1; | 
|---|
| 187 | if (prectl->yBottom != prectl->yTop) { | 
|---|
| 188 | { | 
|---|
| 189 | HPS hps; | 
|---|
| 190 | POINTL aptl[TXTBOX_COUNT]; | 
|---|
| 191 |  | 
|---|
| 192 | hps = WinGetPS(hwndStatus); | 
|---|
| 193 | GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl); | 
|---|
| 194 | WinReleasePS(hps); | 
|---|
| 195 | sheight = aptl[TXTBOX_TOPLEFT].y + 6; | 
|---|
| 196 | hps = WinGetPS(hwndName); | 
|---|
| 197 | GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl); | 
|---|
| 198 | WinReleasePS(hps); | 
|---|
| 199 | bheight = aptl[TXTBOX_TOPLEFT].y + 6; | 
|---|
| 200 | } | 
|---|
| 201 | prectl->yBottom += (sheight + 4); | 
|---|
| 202 | prectl->yTop -= (sheight + 4); | 
|---|
| 203 | prectl->yBottom += (bheight + 4); | 
|---|
| 204 | prectl->yTop -= (bheight + 4); | 
|---|
| 205 | if (fToolbar) { | 
|---|
| 206 | if (!fTextTools) | 
|---|
| 207 | prectl->yTop -= ((fToolTitles) ? 50 : 40); | 
|---|
| 208 | else | 
|---|
| 209 | prectl->yTop -= 32; | 
|---|
| 210 | } | 
|---|
| 211 | ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES), | 
|---|
| 212 | ((prectl->xRight - | 
|---|
| 213 | (WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 214 | SV_CYSIZEBORDER) * 2)) - 4)); | 
|---|
| 215 | prectl->yTop -= (16 * (DriveLines * 22)); | 
|---|
| 216 | prectl->yTop -= 2; | 
|---|
| 217 | if (fAutoView) { | 
|---|
| 218 | AutoviewHeight = min(AutoviewHeight, | 
|---|
| 219 | (prectl->yTop - prectl->yBottom) - 116); | 
|---|
| 220 | AutoviewHeight = max(AutoviewHeight, 44); | 
|---|
| 221 | prectl->yBottom += (AutoviewHeight + 6); | 
|---|
| 222 | } | 
|---|
| 223 | } | 
|---|
| 224 | } | 
|---|
| 225 | return mr; | 
|---|
| 226 | } | 
|---|
| 227 |  | 
|---|
| 228 | case WM_FORMATFRAME: | 
|---|
| 229 | { | 
|---|
| 230 | SHORT sCount, soldCount; | 
|---|
| 231 | PSWP pswp, pswpClient, pswpNew; | 
|---|
| 232 | SWP swpClient; | 
|---|
| 233 | ULONG theight = 48L, dheight = DRIVE_BUTTON_HEIGHT, bheight = 20, sheight = 20; | 
|---|
| 234 | LONG width, lastx; | 
|---|
| 235 |  | 
|---|
| 236 | sCount = (SHORT) ((oldproc) ? oldproc(hwnd, msg, mp1, mp2) : | 
|---|
| 237 | PFNWPFrame(hwnd, msg, mp1, mp2)); | 
|---|
| 238 | soldCount = sCount; | 
|---|
| 239 | /* | 
|---|
| 240 | * Reformat the frame to "squeeze" the client | 
|---|
| 241 | * and make room for status window sibling beneath | 
|---|
| 242 | * and toolbar above (if toolbar's on) and userlists | 
|---|
| 243 | * (if userlists are on). | 
|---|
| 244 | */ | 
|---|
| 245 |  | 
|---|
| 246 | pswp = (PSWP) mp1; | 
|---|
| 247 | { | 
|---|
| 248 | SHORT x; | 
|---|
| 249 |  | 
|---|
| 250 | for (x = 0; x < sCount; x++) { | 
|---|
| 251 | if (WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_CLIENT) { | 
|---|
| 252 | pswpClient = pswp; | 
|---|
| 253 | break; | 
|---|
| 254 | } | 
|---|
| 255 | pswp++; | 
|---|
| 256 | } | 
|---|
| 257 | } | 
|---|
| 258 |  | 
|---|
| 259 | { | 
|---|
| 260 | HPS hps; | 
|---|
| 261 | POINTL aptl[TXTBOX_COUNT]; | 
|---|
| 262 |  | 
|---|
| 263 | hps = WinGetPS(hwndStatus); | 
|---|
| 264 | GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl); | 
|---|
| 265 | WinReleasePS(hps); | 
|---|
| 266 | bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6; | 
|---|
| 267 | hps = WinGetPS(hwndName); | 
|---|
| 268 | GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl); | 
|---|
| 269 | WinReleasePS(hps); | 
|---|
| 270 | bheight = aptl[TXTBOX_TOPLEFT].y + 6; | 
|---|
| 271 | } | 
|---|
| 272 |  | 
|---|
| 273 | pswpNew = (PSWP) mp1 + soldCount; | 
|---|
| 274 | *pswpNew = *pswpClient; | 
|---|
| 275 | swpClient = *pswpClient; | 
|---|
| 276 | pswpNew->hwnd = hwndStatus; | 
|---|
| 277 | pswpNew->x = swpClient.x + 3; | 
|---|
| 278 | pswpNew->y = swpClient.y + 2; | 
|---|
| 279 | width = (swpClient.cx / 2) - 6; | 
|---|
| 280 | width = max(width, 10); | 
|---|
| 281 | pswpNew->cx = width - 6; | 
|---|
| 282 | pswpNew->cy = sheight; | 
|---|
| 283 | pswpClient->y = pswpNew->y + pswpNew->cy + 3; | 
|---|
| 284 | pswpClient->cy = (swpClient.cy - pswpNew->cy) - 3; | 
|---|
| 285 | sCount++; | 
|---|
| 286 |  | 
|---|
| 287 | pswpNew = (PSWP) mp1 + (soldCount + 1); | 
|---|
| 288 | *pswpNew = *pswpClient; | 
|---|
| 289 | pswpNew->hwnd = hwndStatus2; | 
|---|
| 290 | pswpNew->x = width + 8; | 
|---|
| 291 | pswpNew->y = swpClient.y + 2; | 
|---|
| 292 | pswpNew->cx = width - 6; | 
|---|
| 293 | pswpNew->cy = sheight; | 
|---|
| 294 | sCount++; | 
|---|
| 295 |  | 
|---|
| 296 | if (fToolbar) { | 
|---|
| 297 | if (fTextTools) | 
|---|
| 298 | theight = 32L; | 
|---|
| 299 | else if (!fToolTitles) | 
|---|
| 300 | theight = 40L; | 
|---|
| 301 | pswpNew = (PSWP) mp1 + (soldCount + 2); | 
|---|
| 302 | *pswpNew = *pswpClient; | 
|---|
| 303 | pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_TOOLS); | 
|---|
| 304 | pswpNew->x = swpClient.x + 2; | 
|---|
| 305 | pswpNew->y = (swpClient.y + swpClient.cy) - (theight - 2); | 
|---|
| 306 | pswpNew->cx = swpClient.cx - 4; | 
|---|
| 307 | pswpNew->cy = theight - 4; | 
|---|
| 308 | pswpClient->cy -= theight; | 
|---|
| 309 | sCount++; | 
|---|
| 310 | } | 
|---|
| 311 | else | 
|---|
| 312 | WinShowWindow(WinWindowFromID(hwnd, MAIN_TOOLS), FALSE); | 
|---|
| 313 |  | 
|---|
| 314 | ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES), pswpClient->cx - 4); | 
|---|
| 315 | pswpNew = (PSWP) mp1 + (soldCount + 2 + (fToolbar != FALSE)); | 
|---|
| 316 | *pswpNew = *pswpClient; | 
|---|
| 317 | pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_DRIVES); | 
|---|
| 318 | pswpNew->x = swpClient.x + 2; | 
|---|
| 319 | dheight += ((dheight) * DriveLines); | 
|---|
| 320 | pswpNew->y = (swpClient.y + swpClient.cy) - (dheight); | 
|---|
| 321 | if (fToolbar) | 
|---|
| 322 | pswpNew->y -= theight; | 
|---|
| 323 | pswpNew->cx = swpClient.cx - 4; | 
|---|
| 324 | pswpNew->cy = dheight; | 
|---|
| 325 | pswpClient->cy -= dheight; | 
|---|
| 326 | pswpClient->cy -= 2; | 
|---|
| 327 | sCount++; | 
|---|
| 328 |  | 
|---|
| 329 | if (fAutoView) { | 
|---|
| 330 | pswpNew = (PSWP) mp1 + (soldCount + 3 + (fToolbar != FALSE)); | 
|---|
| 331 | *pswpNew = *pswpClient; | 
|---|
| 332 | pswpNew->hwnd = (fComments) ? hwndAutoMLE : hwndAutoview; | 
|---|
| 333 | pswpNew->x = pswpClient->x + 3; | 
|---|
| 334 | pswpNew->y = pswpClient->y + 3; | 
|---|
| 335 | if (fMoreButtons) | 
|---|
| 336 | pswpNew->y += (bheight + 4); | 
|---|
| 337 | pswpNew->cx = pswpClient->cx - 6; | 
|---|
| 338 | AutoviewHeight = min(AutoviewHeight, pswpClient->cy - 116); | 
|---|
| 339 | AutoviewHeight = max(AutoviewHeight, 44); | 
|---|
| 340 | pswpNew->cy = AutoviewHeight; | 
|---|
| 341 | pswpClient->y += (AutoviewHeight + 6); | 
|---|
| 342 | pswpClient->cy -= (AutoviewHeight + 6); | 
|---|
| 343 | sCount++; | 
|---|
| 344 | WinShowWindow((fComments) ? hwndAutoview : hwndAutoMLE, FALSE); | 
|---|
| 345 | } | 
|---|
| 346 | else { | 
|---|
| 347 | WinShowWindow(hwndAutoview, FALSE); | 
|---|
| 348 | WinShowWindow(hwndAutoMLE, FALSE); | 
|---|
| 349 | } | 
|---|
| 350 |  | 
|---|
| 351 | pswpNew = (PSWP) mp1 + (soldCount + 3 + (fToolbar != FALSE) + | 
|---|
| 352 | (fAutoView != FALSE)); | 
|---|
| 353 | *pswpNew = *pswpClient; | 
|---|
| 354 | pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_LED); | 
|---|
| 355 | pswpNew->x = (swpClient.x + swpClient.cx) - 12; | 
|---|
| 356 | pswpNew->y = swpClient.y; | 
|---|
| 357 | pswpNew->cx = 12; | 
|---|
| 358 | pswpNew->cy = 12; | 
|---|
| 359 | sCount++; | 
|---|
| 360 |  | 
|---|
| 361 | pswpNew = (PSWP) mp1 + (soldCount + 4 + (fToolbar != FALSE) + | 
|---|
| 362 | (fAutoView != FALSE)); | 
|---|
| 363 | *pswpNew = *pswpClient; | 
|---|
| 364 | pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_LEDHDR); | 
|---|
| 365 | pswpNew->x = (swpClient.x + swpClient.cx) - 12; | 
|---|
| 366 | pswpNew->y = swpClient.y + 12; | 
|---|
| 367 | pswpNew->cx = 12; | 
|---|
| 368 | pswpNew->cy = sheight - 8; | 
|---|
| 369 | sCount++; | 
|---|
| 370 |  | 
|---|
| 371 | pswpNew = (PSWP) mp1 + (soldCount + 5 + (fToolbar != FALSE) + | 
|---|
| 372 | (fAutoView != FALSE)); | 
|---|
| 373 | *pswpNew = *pswpClient; | 
|---|
| 374 | pswpNew->hwnd = hwndName; | 
|---|
| 375 | pswpNew->x = swpClient.x + 3; | 
|---|
| 376 | pswpNew->y = swpClient.y + (sheight + 6); | 
|---|
| 377 | pswpNew->cx = ((swpClient.cx / 2) + (swpClient.cx / 5)) - 3; | 
|---|
| 378 | lastx = pswpNew->x + pswpNew->cx; | 
|---|
| 379 | pswpNew->cy = bheight; | 
|---|
| 380 | pswpClient->y += (bheight + 4); | 
|---|
| 381 | pswpClient->cy -= (bheight + 4); | 
|---|
| 382 | sCount++; | 
|---|
| 383 |  | 
|---|
| 384 | pswpNew = (PSWP) mp1 + (soldCount + 6 + (fToolbar != FALSE) + | 
|---|
| 385 | (fAutoView != FALSE)); | 
|---|
| 386 | *pswpNew = *pswpClient; | 
|---|
| 387 | pswpNew->hwnd = hwndDate; | 
|---|
| 388 | pswpNew->x = lastx + 3; | 
|---|
| 389 | pswpNew->y = swpClient.y + (sheight + 6); | 
|---|
| 390 | pswpNew->cx = (swpClient.cx / 6) + (swpClient.cx / 16) - 3; | 
|---|
| 391 | lastx = pswpNew->x + pswpNew->cx; | 
|---|
| 392 | pswpNew->cy = bheight; | 
|---|
| 393 | sCount++; | 
|---|
| 394 |  | 
|---|
| 395 | pswpNew = (PSWP) mp1 + (soldCount + 7 + (fToolbar != FALSE) + | 
|---|
| 396 | (fAutoView != FALSE)); | 
|---|
| 397 | *pswpNew = *pswpClient; | 
|---|
| 398 | pswpNew->hwnd = hwndAttr; | 
|---|
| 399 | pswpNew->x = lastx + 3; | 
|---|
| 400 | pswpNew->y = swpClient.y + (sheight + 6); | 
|---|
| 401 | pswpNew->cx = (swpClient.cx - pswpNew->x) - 1; | 
|---|
| 402 | pswpNew->cy = bheight; | 
|---|
| 403 | sCount++; | 
|---|
| 404 |  | 
|---|
| 405 | return MRFROMSHORT(sCount); | 
|---|
| 406 | } | 
|---|
| 407 |  | 
|---|
| 408 | case WM_QUERYFRAMECTLCOUNT: | 
|---|
| 409 | { | 
|---|
| 410 | SHORT sCount; | 
|---|
| 411 |  | 
|---|
| 412 | sCount = (SHORT) ((oldproc) ? oldproc(hwnd, msg, mp1, mp2) : | 
|---|
| 413 | PFNWPFrame(hwnd, msg, mp1, mp2)); | 
|---|
| 414 | sCount += 8; | 
|---|
| 415 | if (fToolbar) | 
|---|
| 416 | sCount++; | 
|---|
| 417 | if (fAutoView) | 
|---|
| 418 | sCount++; | 
|---|
| 419 | return MRFROMSHORT(sCount); | 
|---|
| 420 | } | 
|---|
| 421 |  | 
|---|
| 422 | case WM_CLOSE: | 
|---|
| 423 | WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), msg, mp1, mp2); | 
|---|
| 424 | return 0; | 
|---|
| 425 | } | 
|---|
| 426 | return (oldproc) ? oldproc(hwnd, msg, mp1, mp2) : | 
|---|
| 427 | PFNWPFrame(hwnd, msg, mp1, mp2); | 
|---|
| 428 | } | 
|---|
| 429 |  | 
|---|
| 430 | static MRESULT EXPENTRY MainWMCommand2(HWND hwnd, ULONG msg, MPARAM mp1, | 
|---|
| 431 | MPARAM mp2) | 
|---|
| 432 | { | 
|---|
| 433 | PERSON1DATA *pd; | 
|---|
| 434 |  | 
|---|
| 435 | SetShiftState(); | 
|---|
| 436 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 437 | case IDM_TOAUTOMLE: | 
|---|
| 438 | case IDM_CLI: | 
|---|
| 439 | case IDM_CREATETOOL: | 
|---|
| 440 | case IDM_ABOUT: | 
|---|
| 441 | case IDM_WINFULLSCREEN: | 
|---|
| 442 | case IDM_DOSCOMMANDLINE: | 
|---|
| 443 | case IDM_INIVIEWER: | 
|---|
| 444 | case IDM_INIVIEWERFM2: | 
|---|
| 445 | case IDM_INIVIEWERSYS: | 
|---|
| 446 | case IDM_EDITASSOC: | 
|---|
| 447 | case IDM_COMMANDLINE: | 
|---|
| 448 | case IDM_KILLPROC: | 
|---|
| 449 | case IDM_TOOLBAR: | 
|---|
| 450 | case IDM_TEXTTOOLS: | 
|---|
| 451 | case IDM_TOOLTITLES: | 
|---|
| 452 | case IDM_TOOLLEFT: | 
|---|
| 453 | case IDM_TOOLRIGHT: | 
|---|
| 454 | case IDM_AUTOVIEWCOMMENTS: | 
|---|
| 455 | case IDM_AUTOVIEWFILE: | 
|---|
| 456 | case IDM_AUTOVIEW: | 
|---|
| 457 | //    case IDM_SYSINFO: | 
|---|
| 458 | case IDM_HIDENOTEWND: | 
|---|
| 459 | case IDM_SHOWNOTEWND: | 
|---|
| 460 | case IDM_INSTANT: | 
|---|
| 461 | case IDM_HELPCONTEXT: | 
|---|
| 462 | case IDM_HELPHINTS: | 
|---|
| 463 | case IDM_HELPPIX: | 
|---|
| 464 | case IDM_KILLME: | 
|---|
| 465 | case IDM_EXIT: | 
|---|
| 466 | case IDM_HELPTUTOR: | 
|---|
| 467 | case IDM_HELPCONTENTS: | 
|---|
| 468 | case IDM_HELPGENERAL: | 
|---|
| 469 | case IDM_HELPKEYS: | 
|---|
| 470 | case IDM_HELPMOUSE: | 
|---|
| 471 | case IDM_HELP: | 
|---|
| 472 | case IDM_FONTPALETTE: | 
|---|
| 473 | case IDM_HICOLORPALETTE: | 
|---|
| 474 | case IDM_COLORPALETTE: | 
|---|
| 475 | case IDM_SYSTEMCLOCK: | 
|---|
| 476 | return MainWMCommand(hwnd, msg, mp1, mp2); | 
|---|
| 477 |  | 
|---|
| 478 | case IDM_REMAP: | 
|---|
| 479 | WinDlgBox(HWND_DESKTOP, | 
|---|
| 480 | hwnd, RemapDlgProc, FM3ModHandle, MAP_FRAME, NULL); | 
|---|
| 481 | break; | 
|---|
| 482 |  | 
|---|
| 483 | case IDM_TWODIRS:                     // Menu action | 
|---|
| 484 | case IDM_WINDOWDLG:                   // Toolbar action | 
|---|
| 485 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4); | 
|---|
| 486 | if (pd) { | 
|---|
| 487 |  | 
|---|
| 488 | WALK2 wa; | 
|---|
| 489 |  | 
|---|
| 490 | memset(&wa, 0, sizeof(wa)); | 
|---|
| 491 | wa.size = sizeof(wa); | 
|---|
| 492 | *wa.szCurrentPath1 = 0; | 
|---|
| 493 | WinSendMsg(pd->hwndDir1, | 
|---|
| 494 | UM_CONTAINERDIR, MPFROMP(wa.szCurrentPath1), MPVOID); | 
|---|
| 495 | MakeValidDir(wa.szCurrentPath1); | 
|---|
| 496 | *wa.szCurrentPath2 = 0; | 
|---|
| 497 | WinSendMsg(pd->hwndDir2, | 
|---|
| 498 | UM_CONTAINERDIR, MPFROMP(wa.szCurrentPath2), MPVOID); | 
|---|
| 499 | MakeValidDir(wa.szCurrentPath2); | 
|---|
| 500 | if (WinDlgBox(HWND_DESKTOP, | 
|---|
| 501 | hwnd, | 
|---|
| 502 | WalkTwoSetDlgProc, | 
|---|
| 503 | FM3ModHandle, | 
|---|
| 504 | WALK2_FRAME, | 
|---|
| 505 | MPFROMP(&wa)) && | 
|---|
| 506 | (IsRoot(wa.szCurrentPath1) || | 
|---|
| 507 | !IsFile(wa.szCurrentPath1)) && | 
|---|
| 508 | (IsRoot(wa.szCurrentPath2) || !IsFile(wa.szCurrentPath2))) { | 
|---|
| 509 | WinSendMsg(WinWindowFromID(WinWindowFromID(pd->hwndDir1, | 
|---|
| 510 | FID_CLIENT), DIR_CNR), | 
|---|
| 511 | UM_SETDIR, MPFROMP(wa.szCurrentPath1), MPVOID); | 
|---|
| 512 | WinSendMsg(WinWindowFromID(WinWindowFromID(pd->hwndDir2, | 
|---|
| 513 | FID_CLIENT), DIR_CNR), | 
|---|
| 514 | UM_SETDIR, MPFROMP(wa.szCurrentPath2), MPVOID); | 
|---|
| 515 | } | 
|---|
| 516 | } | 
|---|
| 517 | break; | 
|---|
| 518 |  | 
|---|
| 519 | case IDM_COMPARE: | 
|---|
| 520 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4); | 
|---|
| 521 | if (pd) { | 
|---|
| 522 |  | 
|---|
| 523 | WALK2 wa; | 
|---|
| 524 |  | 
|---|
| 525 | memset(&wa, 0, sizeof(wa)); | 
|---|
| 526 | wa.size = sizeof(wa); | 
|---|
| 527 | *wa.szCurrentPath1 = 0; | 
|---|
| 528 | WinSendMsg(pd->hwndDir1, | 
|---|
| 529 | UM_CONTAINERDIR, MPFROMP(wa.szCurrentPath1), MPVOID); | 
|---|
| 530 | MakeValidDir(wa.szCurrentPath1); | 
|---|
| 531 | *wa.szCurrentPath2 = 0; | 
|---|
| 532 | WinSendMsg(pd->hwndDir2, | 
|---|
| 533 | UM_CONTAINERDIR, MPFROMP(wa.szCurrentPath2), MPVOID); | 
|---|
| 534 | MakeValidDir(wa.szCurrentPath2); | 
|---|
| 535 | if (WinDlgBox(HWND_DESKTOP, | 
|---|
| 536 | hwnd, | 
|---|
| 537 | WalkTwoCmpDlgProc, | 
|---|
| 538 | FM3ModHandle, | 
|---|
| 539 | WALK2_FRAME, | 
|---|
| 540 | MPFROMP(&wa)) && | 
|---|
| 541 | (IsRoot(wa.szCurrentPath1) || | 
|---|
| 542 | !IsFile(wa.szCurrentPath1)) && | 
|---|
| 543 | (IsRoot(wa.szCurrentPath2) || !IsFile(wa.szCurrentPath2))) { | 
|---|
| 544 | if (!*dircompare) { | 
|---|
| 545 |  | 
|---|
| 546 | COMPARE *cmp; | 
|---|
| 547 |  | 
|---|
| 548 | cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__); | 
|---|
| 549 | if (cmp) { | 
|---|
| 550 | cmp->size = sizeof(COMPARE); | 
|---|
| 551 | strcpy(cmp->leftdir, wa.szCurrentPath1); | 
|---|
| 552 | strcpy(cmp->rightdir, wa.szCurrentPath2); | 
|---|
| 553 | cmp->hwndParent = hwnd; | 
|---|
| 554 | cmp->dcd.hwndParent = hwnd; | 
|---|
| 555 | WinDlgBox(HWND_DESKTOP, | 
|---|
| 556 | HWND_DESKTOP, | 
|---|
| 557 | CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp)); | 
|---|
| 558 | } | 
|---|
| 559 | } | 
|---|
| 560 | else { | 
|---|
| 561 | CHAR szPath1[CCHMAXPATH]; | 
|---|
| 562 | CHAR szPath2[CCHMAXPATH]; | 
|---|
| 563 | runemf2(SEPARATE, | 
|---|
| 564 | HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| 565 | NULL, NULL, | 
|---|
| 566 | "%s %s %s", | 
|---|
| 567 | dircompare, | 
|---|
| 568 | BldQuotedFileName(szPath1, wa.szCurrentPath1), | 
|---|
| 569 | BldQuotedFileName(szPath2, wa.szCurrentPath2)); | 
|---|
| 570 | } | 
|---|
| 571 | } | 
|---|
| 572 | } | 
|---|
| 573 | break; | 
|---|
| 574 |  | 
|---|
| 575 | case IDM_VTREE: | 
|---|
| 576 | WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID); | 
|---|
| 577 | if (hwndTree) { | 
|---|
| 578 | WinShowWindow(hwndTree, FALSE); | 
|---|
| 579 | PostMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID); | 
|---|
| 580 | hwndTree = (HWND) 0; | 
|---|
| 581 | } | 
|---|
| 582 | else { | 
|---|
| 583 |  | 
|---|
| 584 | ULONG size = sizeof(ULONG); | 
|---|
| 585 |  | 
|---|
| 586 | hwndTree = StartTreeCnr(hwnd, 3); | 
|---|
| 587 | PrfQueryProfileData(fmprof, | 
|---|
| 588 | realappname, | 
|---|
| 589 | "FM/4 TreeWidth", (PVOID) & TreeWidth, &size); | 
|---|
| 590 | TreeWidth = max(TreeWidth, 80); | 
|---|
| 591 | } | 
|---|
| 592 | { | 
|---|
| 593 | BOOL dummy = (hwndTree != (HWND) 0); | 
|---|
| 594 |  | 
|---|
| 595 | PrfWriteProfileData(fmprof, | 
|---|
| 596 | realappname, | 
|---|
| 597 | "FM/4 TreeUp", (PVOID) & dummy, sizeof(dummy)); | 
|---|
| 598 | } | 
|---|
| 599 | PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID); | 
|---|
| 600 | break; | 
|---|
| 601 |  | 
|---|
| 602 | case IDM_TILEBACKWARDS: | 
|---|
| 603 | WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID); | 
|---|
| 604 | fTileBackwards = (fTileBackwards) ? FALSE : TRUE; | 
|---|
| 605 | PrfWriteProfileData(fmprof, | 
|---|
| 606 | FM3Str, | 
|---|
| 607 | "TileBackwards", | 
|---|
| 608 | (PVOID) & fTileBackwards, sizeof(BOOL)); | 
|---|
| 609 | PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID); | 
|---|
| 610 | break; | 
|---|
| 611 |  | 
|---|
| 612 | case IDM_NEXTWINDOW: | 
|---|
| 613 | case IDM_PREVWINDOW: | 
|---|
| 614 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4); | 
|---|
| 615 | if (pd) { | 
|---|
| 616 |  | 
|---|
| 617 | HWND hwndFocus; | 
|---|
| 618 |  | 
|---|
| 619 | if (hwndTree) { | 
|---|
| 620 | if (pd->hwndMax) { | 
|---|
| 621 | if (hwndTree == pd->hwndCurr) | 
|---|
| 622 | hwndFocus = pd->hwndMax; | 
|---|
| 623 | else | 
|---|
| 624 | hwndFocus = hwndTree; | 
|---|
| 625 | } | 
|---|
| 626 | else { | 
|---|
| 627 | if (hwndTree == pd->hwndCurr) | 
|---|
| 628 | hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ? | 
|---|
| 629 | pd->hwndDir1 : pd->hwndDir2; | 
|---|
| 630 | else if (pd->hwndDir1 == pd->hwndCurr) | 
|---|
| 631 | hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ? | 
|---|
| 632 | pd->hwndDir2 : hwndTree; | 
|---|
| 633 | else | 
|---|
| 634 | hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ? | 
|---|
| 635 | hwndTree : pd->hwndDir1; | 
|---|
| 636 | } | 
|---|
| 637 | } | 
|---|
| 638 | else { | 
|---|
| 639 | if (pd->hwndMax) | 
|---|
| 640 | hwndFocus = pd->hwndMax; | 
|---|
| 641 | else | 
|---|
| 642 | hwndFocus = pd->hwndCurr == pd->hwndDir1 ? | 
|---|
| 643 | pd->hwndDir2 : pd->hwndDir1; | 
|---|
| 644 | } | 
|---|
| 645 | WinSetFocus(HWND_DESKTOP, hwndFocus); | 
|---|
| 646 | } | 
|---|
| 647 | break; | 
|---|
| 648 |  | 
|---|
| 649 | case IDM_NOTEBOOK: | 
|---|
| 650 | case IDM_DIRCNRSETTINGS: | 
|---|
| 651 | case IDM_DIRVIEWSETTINGS: | 
|---|
| 652 | case IDM_DIRSORTSETTINGS: | 
|---|
| 653 | case IDM_COLLECTORVIEWSETTINGS: | 
|---|
| 654 | case IDM_COLLECTORSORTSETTINGS: | 
|---|
| 655 | case IDM_ARCHIVERSETTINGS: | 
|---|
| 656 | case IDM_TREECNRVIEWSETTINGS: | 
|---|
| 657 | case IDM_TREECNRSORTSETTINGS: | 
|---|
| 658 | case IDM_VIEWERSETTINGS: | 
|---|
| 659 | case IDM_VIEWERSETTINGS2: | 
|---|
| 660 | case IDM_COMPARESETTINGS: | 
|---|
| 661 | case IDM_MONOLITHICSETTINGS: | 
|---|
| 662 | case IDM_GENERALSETTINGS: | 
|---|
| 663 | case IDM_SCANSETTINGS: | 
|---|
| 664 | case IDM_BUBBLESSETTINGS: | 
|---|
| 665 | WinDlgBox(HWND_DESKTOP, | 
|---|
| 666 | hwnd, | 
|---|
| 667 | CfgDlgProc, | 
|---|
| 668 | FM3ModHandle, | 
|---|
| 669 | CFG_FRAME, | 
|---|
| 670 | MPFROMLONG(mp1)); // 15 Feb 08 SHL | 
|---|
| 671 | PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID); | 
|---|
| 672 | break; | 
|---|
| 673 |  | 
|---|
| 674 | case IDM_SEEALL: | 
|---|
| 675 | case IDM_GREP: | 
|---|
| 676 | case IDM_COLLECTOR: | 
|---|
| 677 | { | 
|---|
| 678 | HWND hwndC; | 
|---|
| 679 |  | 
|---|
| 680 | hwndC = StartCollector(HWND_DESKTOP, 4); | 
|---|
| 681 | if (hwndC) { | 
|---|
| 682 | WinSetWindowPos(hwndC, | 
|---|
| 683 | HWND_TOP, | 
|---|
| 684 | 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE | SWP_ACTIVATE); | 
|---|
| 685 | if (SHORT1FROMMP(mp1) == IDM_GREP) | 
|---|
| 686 | PostMsg(WinWindowFromID(hwndC, FID_CLIENT), | 
|---|
| 687 | WM_COMMAND, MPFROM2SHORT(IDM_GREP, 0), MPVOID); | 
|---|
| 688 | if (SHORT1FROMMP(mp1) == IDM_SEEALL) | 
|---|
| 689 | PostMsg(WinWindowFromID(hwndC, FID_CLIENT), | 
|---|
| 690 | WM_COMMAND, MPFROM2SHORT(IDM_SEEALL, 0), MPVOID); | 
|---|
| 691 | } | 
|---|
| 692 | } | 
|---|
| 693 | break; | 
|---|
| 694 |  | 
|---|
| 695 | case IDM_EDITCOMMANDS: | 
|---|
| 696 | EditCommands(hwnd); | 
|---|
| 697 | break; | 
|---|
| 698 |  | 
|---|
| 699 | default: | 
|---|
| 700 | if (SHORT1FROMMP(mp1) >= IDM_SWITCHSTART && | 
|---|
| 701 | SHORT1FROMMP(mp1) < IDM_SWITCHSTART + 499) { | 
|---|
| 702 | if (SHORT1FROMMP(mp1) - IDM_SWITCHSTART < numswitches) | 
|---|
| 703 | WinSwitchToProgram(switches[SHORT1FROMMP(mp1) - IDM_SWITCHSTART]); | 
|---|
| 704 | break; | 
|---|
| 705 | } | 
|---|
| 706 | else if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART && | 
|---|
| 707 | SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) { | 
|---|
| 708 |  | 
|---|
| 709 | INT x; | 
|---|
| 710 | HWND hwndCnr; | 
|---|
| 711 |  | 
|---|
| 712 | if (!cmdloaded) | 
|---|
| 713 | load_commands(); | 
|---|
| 714 | hwndCnr = TopWindow(hwnd, (HWND) 0); | 
|---|
| 715 | hwndCnr = (HWND) WinSendMsg(WinWindowFromID(hwndCnr, FID_CLIENT), | 
|---|
| 716 | UM_CONTAINERHWND, MPVOID, MPVOID); | 
|---|
| 717 | if (!hwndCnr) { | 
|---|
| 718 | Runtime_Error(pszSrcFile, __LINE__, NULL); | 
|---|
| 719 | break; | 
|---|
| 720 | } | 
|---|
| 721 | x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART; | 
|---|
| 722 | if (x >= 0) { | 
|---|
| 723 | x++; | 
|---|
| 724 | RunCommand(hwndCnr, x); | 
|---|
| 725 | if (fUnHilite) { | 
|---|
| 726 |  | 
|---|
| 727 | PCNRITEM pci; | 
|---|
| 728 | DIRCNRDATA *dcd = NULL; | 
|---|
| 729 |  | 
|---|
| 730 | if (WinQueryWindowUShort(hwndCnr, QWS_ID) != TREE_CNR) | 
|---|
| 731 | dcd = INSTDATA(hwndCnr); | 
|---|
| 732 | pci = (PCNRITEM) WinSendMsg(hwndCnr, | 
|---|
| 733 | CM_QUERYRECORDEMPHASIS, | 
|---|
| 734 | MPFROMLONG(CMA_FIRST), | 
|---|
| 735 | MPFROMSHORT(CRA_CURSORED)); | 
|---|
| 736 | if (pci && (INT) pci != -1 && (pci->rc.flRecordAttr & CRA_SELECTED)) { | 
|---|
| 737 | UnHilite(hwnd, | 
|---|
| 738 | TRUE, | 
|---|
| 739 | dcd ? &dcd->lastselection : NULL, | 
|---|
| 740 | dcd ? dcd->ulItemsToUnHilite : 0); | 
|---|
| 741 | } | 
|---|
| 742 | } | 
|---|
| 743 | } | 
|---|
| 744 | } | 
|---|
| 745 | else if (SHORT1FROMMP(mp1) >= IDM_QUICKTOOLSTART && | 
|---|
| 746 | SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART + 51) { | 
|---|
| 747 | if (!qtloaded) | 
|---|
| 748 | load_quicktools(); | 
|---|
| 749 | if (quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]) { | 
|---|
| 750 | if (fToolsChanged) | 
|---|
| 751 | save_tools(NULL); | 
|---|
| 752 | if (!load_tools(quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1])) | 
|---|
| 753 | load_tools(NULL); | 
|---|
| 754 | else { | 
|---|
| 755 | strcpy(lasttoolbar, | 
|---|
| 756 | quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]); | 
|---|
| 757 | PrfWriteProfileString(fmprof, appname, "LastToolbar", lasttoolbar); | 
|---|
| 758 | } | 
|---|
| 759 | PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID); | 
|---|
| 760 | } | 
|---|
| 761 | } | 
|---|
| 762 | else { | 
|---|
| 763 |  | 
|---|
| 764 | HWND hwndActive; | 
|---|
| 765 |  | 
|---|
| 766 | hwndActive = TopWindow(hwnd, (HWND) 0); | 
|---|
| 767 | if (hwndActive) | 
|---|
| 768 | PostMsg(WinWindowFromID(hwndActive, FID_CLIENT), msg, mp1, mp2); | 
|---|
| 769 | } | 
|---|
| 770 | break; | 
|---|
| 771 | } | 
|---|
| 772 | return 0; | 
|---|
| 773 | } | 
|---|
| 774 |  | 
|---|
| 775 | static MRESULT EXPENTRY MainWMOnce2(HWND hwnd, ULONG msg, MPARAM mp1, | 
|---|
| 776 | MPARAM mp2) | 
|---|
| 777 | { | 
|---|
| 778 | PERSON1DATA *pd; | 
|---|
| 779 |  | 
|---|
| 780 | switch (msg) { | 
|---|
| 781 | case WM_CREATE: | 
|---|
| 782 | { | 
|---|
| 783 | TID tid; | 
|---|
| 784 |  | 
|---|
| 785 | WinQueryWindowProcess(hwnd, &mypid, &tid); | 
|---|
| 786 | } | 
|---|
| 787 | hwndMain = hwnd; | 
|---|
| 788 | WinSetWindowUShort(hwnd, QWL_USER + 8, 0); | 
|---|
| 789 | WinSetWindowUShort(hwnd, QWL_USER + 10, 0); | 
|---|
| 790 | WinSetWindowUShort(hwnd, QWL_USER + 12, 0); | 
|---|
| 791 | WinSetWindowUShort(hwnd, QWL_USER + 16, 0); | 
|---|
| 792 | if (xbeginthread(MakeMainObjWin, | 
|---|
| 793 | 245760, | 
|---|
| 794 | MPVOID, | 
|---|
| 795 | pszSrcFile, | 
|---|
| 796 | __LINE__) == -1) | 
|---|
| 797 | { | 
|---|
| 798 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID); | 
|---|
| 799 | return 0; | 
|---|
| 800 | } | 
|---|
| 801 | else | 
|---|
| 802 | DosSleep(32);//05 Aug 07 GKY 64 | 
|---|
| 803 |  | 
|---|
| 804 | pd = xmallocz(sizeof(PERSON1DATA), pszSrcFile, __LINE__); | 
|---|
| 805 | if (!pd) | 
|---|
| 806 | WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT)); | 
|---|
| 807 | else { | 
|---|
| 808 | pd->size = sizeof(PERSON1DATA); | 
|---|
| 809 | WinSetWindowPtr(hwnd, QWL_USER + 4, (PVOID) pd); | 
|---|
| 810 | } | 
|---|
| 811 | { | 
|---|
| 812 | SWP swp; | 
|---|
| 813 | PFNWP oldproc; | 
|---|
| 814 |  | 
|---|
| 815 | /* | 
|---|
| 816 | * create frame children (not client children, frame children) | 
|---|
| 817 | */ | 
|---|
| 818 | DosSleep(1); | 
|---|
| 819 | WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp); | 
|---|
| 820 | oldproc = WinSubclassWindow(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 821 | (PFNWP) MainFrameWndProc2); | 
|---|
| 822 | if (oldproc) | 
|---|
| 823 | WinSetWindowPtr(WinQueryWindow(hwnd, QW_PARENT), QWL_USER, (PVOID) oldproc); | 
|---|
| 824 | CommonCreateMainChildren(hwnd, &swp); | 
|---|
| 825 |  | 
|---|
| 826 | { | 
|---|
| 827 | HWND hwndMenu; | 
|---|
| 828 |  | 
|---|
| 829 | hwndMenu = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_MENU); | 
|---|
| 830 | WinSetWindowULong(hwnd, QWL_USER, hwndMenu); | 
|---|
| 831 | CfgMenuInit(hwndMenu, FALSE);   // 14 Feb 08 SHL | 
|---|
| 832 | SetConditionalCascade(hwndMenu, IDM_COMMANDLINESUBMENU, IDM_COMMANDLINE); | 
|---|
| 833 | if (fProtectOnly) { | 
|---|
| 834 | WinEnableMenuItem(hwndMenu, IDM_DOSCOMMANDLINE, FALSE); | 
|---|
| 835 | WinEnableMenuItem(hwndMenu, IDM_WINFULLSCREEN, FALSE); | 
|---|
| 836 | } | 
|---|
| 837 | SetConditionalCascade(hwndMenu, IDM_COMMANDSMENU, IDM_DOITYOURSELF); | 
|---|
| 838 | SetConditionalCascade(hwndMenu, IDM_TOOLSUBMENU, IDM_TOOLBAR); | 
|---|
| 839 | } | 
|---|
| 840 | } | 
|---|
| 841 | WinSetWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 842 | FID_TITLEBAR), "FM/2 Lite"); | 
|---|
| 843 | FixSwitchList(WinQueryWindow(hwnd, QW_PARENT), NULL); | 
|---|
| 844 | SetSysMenu(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_SYSMENU)); | 
|---|
| 845 | break; | 
|---|
| 846 |  | 
|---|
| 847 | case UM_SETUP: | 
|---|
| 848 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4); | 
|---|
| 849 | if (pd) { | 
|---|
| 850 |  | 
|---|
| 851 | CHAR s[CCHMAXPATH]; | 
|---|
| 852 | ULONG size; | 
|---|
| 853 | DIRCNRDATA *dcd; | 
|---|
| 854 | HWND hwndC; | 
|---|
| 855 | BOOL dummy = TRUE; | 
|---|
| 856 |  | 
|---|
| 857 | size = sizeof(BOOL); | 
|---|
| 858 | PrfQueryProfileData(fmprof, realappname, "FM/4 TreeUp", | 
|---|
| 859 | (PVOID) &dummy, &size); | 
|---|
| 860 | if (dummy) { | 
|---|
| 861 | size = sizeof(ULONG); | 
|---|
| 862 | hwndTree = StartTreeCnr(hwnd, 3); | 
|---|
| 863 | PrfQueryProfileData(fmprof, realappname, "FM/4 TreeWidth", | 
|---|
| 864 | (PVOID) &TreeWidth, &size); | 
|---|
| 865 | TreeWidth = max(TreeWidth, 80); | 
|---|
| 866 | } | 
|---|
| 867 | size = sizeof(BOOL); | 
|---|
| 868 | if (PrfQueryProfileData(fmprof, appname, "Toolbar", &dummy, &size) && | 
|---|
| 869 | size && !dummy) | 
|---|
| 870 | WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TOOLBAR, 0), MPVOID); | 
|---|
| 871 |  | 
|---|
| 872 | size = sizeof(s); | 
|---|
| 873 | *s = 0; | 
|---|
| 874 | if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir1", s, &size) && *s) | 
|---|
| 875 | MakeValidDir(s); | 
|---|
| 876 | else | 
|---|
| 877 | save_dir(s); | 
|---|
| 878 | pd->hwndLastDir = pd->hwndCurr = pd->hwndDir1 = | 
|---|
| 879 | StartDirCnr(hwnd, s, (HWND) 0, 3); | 
|---|
| 880 | size = sizeof(s); | 
|---|
| 881 | *s = 0; | 
|---|
| 882 | if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir2", s, &size) && *s) | 
|---|
| 883 | MakeValidDir(s); | 
|---|
| 884 | else | 
|---|
| 885 | save_dir(s); | 
|---|
| 886 | pd->hwndDir2 = StartDirCnr(hwnd, s, (HWND) 0, 3); | 
|---|
| 887 | if (fInitialDriveScan) { | 
|---|
| 888 | DosPostEventSem(hevInitialCnrScanComplete); | 
|---|
| 889 | DosCloseEventSem(hevInitialCnrScanComplete); | 
|---|
| 890 | fInitialDriveScan = FALSE; | 
|---|
| 891 | } | 
|---|
| 892 | WinSetFocus(HWND_DESKTOP, pd->hwndCurr); | 
|---|
| 893 |  | 
|---|
| 894 | hwndC = WinWindowFromID(pd->hwndDir1, FID_CLIENT); | 
|---|
| 895 | if (hwndC) { | 
|---|
| 896 | dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER); | 
|---|
| 897 | if (dcd) { | 
|---|
| 898 | size = sizeof(INT); | 
|---|
| 899 | if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir1.Sort", | 
|---|
| 900 | (PVOID) & dcd->sortFlags, | 
|---|
| 901 | &size) && size == sizeof(INT)) { | 
|---|
| 902 | if (!dcd->sortFlags) | 
|---|
| 903 | dcd->sortFlags = SORT_PATHNAME; | 
|---|
| 904 | } | 
|---|
| 905 | size = sizeof(MASK); | 
|---|
| 906 | if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir1.Filter", | 
|---|
| 907 | (PVOID) & dcd->mask, &size) && size) { | 
|---|
| 908 | if (*dcd->mask.szMask) | 
|---|
| 909 | WinSendMsg(WinWindowFromID(hwndC, DIR_CNR), | 
|---|
| 910 | UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID); | 
|---|
| 911 | } | 
|---|
| 912 | *(dcd->mask.prompt) = 0; | 
|---|
| 913 | size = sizeof(ULONG); | 
|---|
| 914 | if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir1.View", | 
|---|
| 915 | (PVOID) & dcd->flWindowAttr, | 
|---|
| 916 | &size) && size == sizeof(ULONG)) { | 
|---|
| 917 |  | 
|---|
| 918 | CNRINFO cnri; | 
|---|
| 919 |  | 
|---|
| 920 | memset(&cnri, 0, sizeof(CNRINFO)); | 
|---|
| 921 | cnri.cb = sizeof(CNRINFO); | 
|---|
| 922 | if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR), | 
|---|
| 923 | CM_QUERYCNRINFO, | 
|---|
| 924 | MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)))) { | 
|---|
| 925 | cnri.flWindowAttr = dcd->flWindowAttr; | 
|---|
| 926 | WinSendMsg(WinWindowFromID(hwndC, DIR_CNR), | 
|---|
| 927 | CM_SETCNRINFO, | 
|---|
| 928 | MPFROMP(&cnri), MPFROMLONG(CMA_FLWINDOWATTR)); | 
|---|
| 929 | } | 
|---|
| 930 | } | 
|---|
| 931 | } | 
|---|
| 932 | } | 
|---|
| 933 |  | 
|---|
| 934 | hwndC = WinWindowFromID(pd->hwndDir2, FID_CLIENT); | 
|---|
| 935 | if (hwndC) { | 
|---|
| 936 | dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER); | 
|---|
| 937 | if (dcd) { | 
|---|
| 938 | size = sizeof(INT); | 
|---|
| 939 | if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir2.Sort", | 
|---|
| 940 | (PVOID) & dcd->sortFlags, | 
|---|
| 941 | &size) && size == sizeof(INT)) { | 
|---|
| 942 | if (!dcd->sortFlags) | 
|---|
| 943 | dcd->sortFlags = SORT_PATHNAME; | 
|---|
| 944 | } | 
|---|
| 945 | size = sizeof(MASK); | 
|---|
| 946 | if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir2.Filter", | 
|---|
| 947 | (PVOID) & dcd->mask, &size) && size) { | 
|---|
| 948 | if (*dcd->mask.szMask) | 
|---|
| 949 | WinSendMsg(WinWindowFromID(hwndC, DIR_CNR), | 
|---|
| 950 | UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID); | 
|---|
| 951 | } | 
|---|
| 952 | *(dcd->mask.prompt) = 0; | 
|---|
| 953 | size = sizeof(ULONG); | 
|---|
| 954 | if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir2.View", | 
|---|
| 955 | (PVOID) & dcd->flWindowAttr, | 
|---|
| 956 | &size) && size == sizeof(ULONG)) { | 
|---|
| 957 |  | 
|---|
| 958 | CNRINFO cnri; | 
|---|
| 959 |  | 
|---|
| 960 | memset(&cnri, 0, sizeof(CNRINFO)); | 
|---|
| 961 | cnri.cb = sizeof(CNRINFO); | 
|---|
| 962 | if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR), | 
|---|
| 963 | CM_QUERYCNRINFO, | 
|---|
| 964 | MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)))) { | 
|---|
| 965 | cnri.flWindowAttr = dcd->flWindowAttr; | 
|---|
| 966 | WinSendMsg(WinWindowFromID(hwndC, DIR_CNR), | 
|---|
| 967 | CM_SETCNRINFO, | 
|---|
| 968 | MPFROMP(&cnri), MPFROMLONG(CMA_FLWINDOWATTR)); | 
|---|
| 969 | } | 
|---|
| 970 | } | 
|---|
| 971 | } | 
|---|
| 972 | } | 
|---|
| 973 | } | 
|---|
| 974 | { | 
|---|
| 975 | ULONG which = 0, size = sizeof(ULONG); | 
|---|
| 976 |  | 
|---|
| 977 | if (PrfQueryProfileData(fmprof, realappname, "FM/4 Max", | 
|---|
| 978 | (PVOID) & which, | 
|---|
| 979 | &size) && size == sizeof(ULONG) && which) { | 
|---|
| 980 | PostMsg(hwnd, | 
|---|
| 981 | UM_MAXIMIZE, | 
|---|
| 982 | MPFROMLONG(((which == 1) ? | 
|---|
| 983 | pd->hwndDir1 : pd->hwndDir2)), MPVOID); | 
|---|
| 984 | } | 
|---|
| 985 | } | 
|---|
| 986 | PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID); | 
|---|
| 987 | if (!hwndTree) | 
|---|
| 988 | PostMsg(hwnd, UM_BUILDDRIVEBAR, MPVOID, MPVOID); | 
|---|
| 989 | load_tools(NULL); | 
|---|
| 990 | PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID); | 
|---|
| 991 | fRunning = TRUE; | 
|---|
| 992 | return 0; | 
|---|
| 993 |  | 
|---|
| 994 | case WM_SAVEAPPLICATION: | 
|---|
| 995 | WinStoreWindowPos(FM2Str, | 
|---|
| 996 | "MainWindowPos2", WinQueryWindow(hwnd, QW_PARENT)); | 
|---|
| 997 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4); | 
|---|
| 998 | if (pd) { | 
|---|
| 999 |  | 
|---|
| 1000 | CHAR s[CCHMAXPATH]; | 
|---|
| 1001 | HWND hwndC; | 
|---|
| 1002 | DIRCNRDATA *dcd; | 
|---|
| 1003 | ULONG flWindowAttr; | 
|---|
| 1004 |  | 
|---|
| 1005 | *s = 0; | 
|---|
| 1006 | WinSendMsg(pd->hwndDir1, UM_CONTAINERDIR, MPFROMP(s), MPVOID); | 
|---|
| 1007 | if (*s) { | 
|---|
| 1008 | MakeValidDir(s); | 
|---|
| 1009 | PrfWriteProfileString(fmprof, realappname, "FM/4 Dir1", s); | 
|---|
| 1010 | } | 
|---|
| 1011 | *s = 0; | 
|---|
| 1012 | WinSendMsg(pd->hwndDir2, UM_CONTAINERDIR, MPFROMP(s), MPVOID); | 
|---|
| 1013 | if (*s) { | 
|---|
| 1014 | MakeValidDir(s); | 
|---|
| 1015 | PrfWriteProfileString(fmprof, realappname, "FM/4 Dir2", s); | 
|---|
| 1016 | } | 
|---|
| 1017 | flWindowAttr = (pd->hwndMax == pd->hwndDir1) ? | 
|---|
| 1018 | 1 : (pd->hwndMax == pd->hwndDir2) ? 2 : 0; | 
|---|
| 1019 | PrfWriteProfileData(fmprof, | 
|---|
| 1020 | realappname, | 
|---|
| 1021 | "FM/4 Max", &flWindowAttr, sizeof(flWindowAttr)); | 
|---|
| 1022 | hwndC = WinWindowFromID(pd->hwndDir1, FID_CLIENT); | 
|---|
| 1023 | if (hwndC) { | 
|---|
| 1024 | dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER); | 
|---|
| 1025 | if (dcd) { | 
|---|
| 1026 | flWindowAttr = dcd->flWindowAttr; | 
|---|
| 1027 | if (!fLeaveTree && (flWindowAttr & CV_TREE)) { | 
|---|
| 1028 | flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT)); | 
|---|
| 1029 | if (dcd->lastattr) { | 
|---|
| 1030 | if (dcd->lastattr & CV_TEXT) | 
|---|
| 1031 | flWindowAttr |= CV_TEXT; | 
|---|
| 1032 | else if (dcd->lastattr & CV_DETAIL) | 
|---|
| 1033 | flWindowAttr |= CV_DETAIL; | 
|---|
| 1034 | else if (dcd->lastattr & CV_ICON) | 
|---|
| 1035 | flWindowAttr |= CV_ICON; | 
|---|
| 1036 | else | 
|---|
| 1037 | flWindowAttr |= CV_NAME; | 
|---|
| 1038 | } | 
|---|
| 1039 | else | 
|---|
| 1040 | flWindowAttr |= CV_NAME; | 
|---|
| 1041 | } | 
|---|
| 1042 | PrfWriteProfileData(fmprof, realappname, "FM/4 Dir1.Sort", | 
|---|
| 1043 | (PVOID) & dcd->sortFlags, sizeof(INT)); | 
|---|
| 1044 | PrfWriteProfileData(fmprof, realappname, "FM/4 Dir1.Filter", | 
|---|
| 1045 | (PVOID) & dcd->mask, sizeof(MASK)); | 
|---|
| 1046 | PrfWriteProfileData(fmprof, realappname, "FM/4 Dir1.View", | 
|---|
| 1047 | (PVOID) & flWindowAttr, sizeof(ULONG)); | 
|---|
| 1048 | } | 
|---|
| 1049 | } | 
|---|
| 1050 |  | 
|---|
| 1051 | hwndC = WinWindowFromID(pd->hwndDir2, FID_CLIENT); | 
|---|
| 1052 | if (hwndC) { | 
|---|
| 1053 | dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER); | 
|---|
| 1054 | if (dcd) { | 
|---|
| 1055 | flWindowAttr = dcd->flWindowAttr; | 
|---|
| 1056 | if (!fLeaveTree && (flWindowAttr & CV_TREE)) { | 
|---|
| 1057 | flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT)); | 
|---|
| 1058 | if (dcd->lastattr) { | 
|---|
| 1059 | if (dcd->lastattr & CV_TEXT) | 
|---|
| 1060 | flWindowAttr |= CV_TEXT; | 
|---|
| 1061 | else if (dcd->lastattr & CV_DETAIL) | 
|---|
| 1062 | flWindowAttr |= CV_DETAIL; | 
|---|
| 1063 | else if (dcd->lastattr & CV_ICON) | 
|---|
| 1064 | flWindowAttr |= CV_ICON; | 
|---|
| 1065 | else | 
|---|
| 1066 | flWindowAttr |= CV_NAME; | 
|---|
| 1067 | } | 
|---|
| 1068 | else | 
|---|
| 1069 | flWindowAttr |= CV_NAME; | 
|---|
| 1070 | } | 
|---|
| 1071 | PrfWriteProfileData(fmprof, realappname, "FM/4 Dir2.Sort", | 
|---|
| 1072 | (PVOID) & dcd->sortFlags, sizeof(INT)); | 
|---|
| 1073 | PrfWriteProfileData(fmprof, realappname, "FM/4 Dir2.Filter", | 
|---|
| 1074 | (PVOID) & dcd->mask, sizeof(MASK)); | 
|---|
| 1075 | PrfWriteProfileData(fmprof, realappname, "FM/4 Dir2.View", | 
|---|
| 1076 | (PVOID) & flWindowAttr, sizeof(ULONG)); | 
|---|
| 1077 | } | 
|---|
| 1078 | } | 
|---|
| 1079 | } | 
|---|
| 1080 | break; | 
|---|
| 1081 | } | 
|---|
| 1082 | return WinDefWindowProc(hwnd, msg, mp1, mp2); | 
|---|
| 1083 | } | 
|---|
| 1084 |  | 
|---|
| 1085 | MRESULT EXPENTRY MainWndProc2(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 1086 | { | 
|---|
| 1087 | PERSON1DATA *pd; | 
|---|
| 1088 |  | 
|---|
| 1089 | switch (msg) { | 
|---|
| 1090 | case WM_SAVEAPPLICATION: | 
|---|
| 1091 | case UM_SETUP: | 
|---|
| 1092 | case WM_CREATE: | 
|---|
| 1093 | return MainWMOnce2(hwnd, msg, mp1, mp2); | 
|---|
| 1094 |  | 
|---|
| 1095 | case UM_THREADUSE: | 
|---|
| 1096 | case UM_LOADFILE: | 
|---|
| 1097 | case UM_BUILDDRIVEBAR: | 
|---|
| 1098 | case WM_TIMER: | 
|---|
| 1099 | return CommonMainWndProc(hwnd, msg, mp1, mp2); | 
|---|
| 1100 |  | 
|---|
| 1101 | case UM_SETUP2: | 
|---|
| 1102 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4); | 
|---|
| 1103 | if (pd) { | 
|---|
| 1104 | if (mp1) { | 
|---|
| 1105 | if (pd->hwndDir1 && (!pd->hwndMax || pd->hwndMax == pd->hwndDir1)) | 
|---|
| 1106 | BoxWindow(pd->hwndDir1, (HPS) 0, CLR_PALEGRAY); | 
|---|
| 1107 | if (pd->hwndDir2 && (!pd->hwndMax || pd->hwndMax == pd->hwndDir2)) | 
|---|
| 1108 | BoxWindow(pd->hwndDir2, (HPS) 0, CLR_PALEGRAY); | 
|---|
| 1109 | if (hwndTree) | 
|---|
| 1110 | BoxWindow(hwndTree, (HPS) 0, CLR_PALEGRAY); | 
|---|
| 1111 | } | 
|---|
| 1112 | else { | 
|---|
| 1113 | if (hwndTree) | 
|---|
| 1114 | BoxWindow(hwndTree, | 
|---|
| 1115 | (HPS) 0, | 
|---|
| 1116 | (pd->hwndCurr == hwndTree) ? CLR_RED : CLR_WHITE); | 
|---|
| 1117 | if (!pd->hwndMax || pd->hwndMax == pd->hwndDir1) | 
|---|
| 1118 | BoxWindow(pd->hwndDir1, | 
|---|
| 1119 | (HPS) 0, | 
|---|
| 1120 | (pd->hwndDir1 == pd->hwndCurr) ? | 
|---|
| 1121 | CLR_RED : | 
|---|
| 1122 | (pd->hwndDir1 == pd->hwndLastDir) ? | 
|---|
| 1123 | CLR_DARKRED : CLR_PALEGRAY); | 
|---|
| 1124 | if (!pd->hwndMax || pd->hwndMax == pd->hwndDir2) | 
|---|
| 1125 | BoxWindow(pd->hwndDir2, | 
|---|
| 1126 | (HPS) 0, | 
|---|
| 1127 | (pd->hwndDir2 == pd->hwndCurr) ? | 
|---|
| 1128 | CLR_RED : | 
|---|
| 1129 | (pd->hwndDir2 == pd->hwndLastDir) ? | 
|---|
| 1130 | CLR_DARKRED : CLR_PALEGRAY); | 
|---|
| 1131 | } | 
|---|
| 1132 | } | 
|---|
| 1133 | return 0; | 
|---|
| 1134 |  | 
|---|
| 1135 | case WM_BUTTON1DOWN: | 
|---|
| 1136 | shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); | 
|---|
| 1137 | if (hwndTree) { | 
|---|
| 1138 |  | 
|---|
| 1139 | SWP swp; | 
|---|
| 1140 |  | 
|---|
| 1141 | WinQueryWindowPos(hwndTree, &swp); | 
|---|
| 1142 | if (SHORT1FROMMP(mp1) > (swp.x + swp.cx) - 3 && | 
|---|
| 1143 | SHORT1FROMMP(mp1) < (swp.x + swp.cx) + 3) { | 
|---|
| 1144 |  | 
|---|
| 1145 | SWP swpC; | 
|---|
| 1146 | TRACKINFO track; | 
|---|
| 1147 |  | 
|---|
| 1148 | WinQueryWindowPos(hwnd, &swpC); | 
|---|
| 1149 | track.cxBorder = 4; | 
|---|
| 1150 | track.cyBorder = 4; | 
|---|
| 1151 | track.cxGrid = 1; | 
|---|
| 1152 | track.cyGrid = 1; | 
|---|
| 1153 | track.cxKeyboard = 8; | 
|---|
| 1154 | track.cyKeyboard = 8; | 
|---|
| 1155 | track.rclTrack.yBottom = 2; | 
|---|
| 1156 | track.rclTrack.yTop = swpC.cy - 4; | 
|---|
| 1157 | track.rclTrack.xLeft = 2; | 
|---|
| 1158 | track.rclTrack.xRight = swp.x + swp.cx + 2; | 
|---|
| 1159 | track.rclBoundary = track.rclTrack; | 
|---|
| 1160 | track.rclBoundary.xRight = swpC.cx - 80; | 
|---|
| 1161 | track.ptlMinTrackSize.x = 80; | 
|---|
| 1162 | track.ptlMinTrackSize.y = swpC.cy - 4; | 
|---|
| 1163 | track.ptlMaxTrackSize.x = swpC.cx - 80; | 
|---|
| 1164 | track.ptlMaxTrackSize.y = swpC.cy - 4; | 
|---|
| 1165 | track.fs = TF_RIGHT; | 
|---|
| 1166 | if (WinTrackRect(hwnd, (HPS) 0, &track)) { | 
|---|
| 1167 | TreeWidth = track.rclTrack.xRight - track.rclTrack.xLeft; | 
|---|
| 1168 | PrfWriteProfileData(fmprof, | 
|---|
| 1169 | realappname, | 
|---|
| 1170 | "FM/4 TreeWidth", &TreeWidth, sizeof(ULONG)); | 
|---|
| 1171 | WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID); | 
|---|
| 1172 | PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID); | 
|---|
| 1173 | } | 
|---|
| 1174 | return (MRESULT) TRUE; | 
|---|
| 1175 | } | 
|---|
| 1176 | } | 
|---|
| 1177 | break; | 
|---|
| 1178 |  | 
|---|
| 1179 | case WM_MOUSEMOVE: | 
|---|
| 1180 | shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); | 
|---|
| 1181 | if (hwndTree) { | 
|---|
| 1182 |  | 
|---|
| 1183 | SWP swp; | 
|---|
| 1184 |  | 
|---|
| 1185 | if (WinQueryWindowPos(hwndTree, &swp)) { | 
|---|
| 1186 | if (SHORT1FROMMP(mp1) > (swp.x + swp.cx) - 3 && | 
|---|
| 1187 | SHORT1FROMMP(mp1) < (swp.x + swp.cx) + 3) | 
|---|
| 1188 | WinSetPointer(HWND_DESKTOP, hptrEW); | 
|---|
| 1189 | else | 
|---|
| 1190 | WinSetPointer(HWND_DESKTOP, hptrArrow); | 
|---|
| 1191 | } | 
|---|
| 1192 | else | 
|---|
| 1193 | WinSetPointer(HWND_DESKTOP, hptrArrow); | 
|---|
| 1194 | } | 
|---|
| 1195 | return (MRESULT) TRUE; | 
|---|
| 1196 |  | 
|---|
| 1197 | case WM_BUTTON1UP: | 
|---|
| 1198 | case WM_BUTTON2UP: | 
|---|
| 1199 | case WM_BUTTON3UP: | 
|---|
| 1200 | case WM_CHAR: | 
|---|
| 1201 | shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL)); | 
|---|
| 1202 | break; | 
|---|
| 1203 |  | 
|---|
| 1204 | case UM_ADVISEFOCUS: | 
|---|
| 1205 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4); | 
|---|
| 1206 | if (mp1 && pd && (HWND) mp1 != pd->hwndCurr) { | 
|---|
| 1207 | if ((HWND) mp1 != hwndTree) | 
|---|
| 1208 | pd->hwndLastDir = (HWND) mp1; | 
|---|
| 1209 | pd->hwndCurr = (HWND) mp1; | 
|---|
| 1210 | WinSendMsg(hwnd, UM_SETUP2, MPVOID, MPVOID); | 
|---|
| 1211 | } | 
|---|
| 1212 | return 0; | 
|---|
| 1213 |  | 
|---|
| 1214 | case UM_MAXIMIZE: | 
|---|
| 1215 | if (mp1) { | 
|---|
| 1216 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4); | 
|---|
| 1217 | if (pd) { | 
|---|
| 1218 | WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID); | 
|---|
| 1219 | if (pd->hwndMax != (HWND) mp1) { | 
|---|
| 1220 | pd->hwndMax = (HWND) mp1; | 
|---|
| 1221 | WinSetFocus(HWND_DESKTOP, pd->hwndMax); | 
|---|
| 1222 | } | 
|---|
| 1223 | else | 
|---|
| 1224 | pd->hwndMax = (HWND) 0; | 
|---|
| 1225 | PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID); | 
|---|
| 1226 | } | 
|---|
| 1227 | } | 
|---|
| 1228 | return 0; | 
|---|
| 1229 |  | 
|---|
| 1230 | case WM_INITMENU: | 
|---|
| 1231 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 1232 | case IDM_FILESMENU: | 
|---|
| 1233 | case IDM_VIEWSMENU: | 
|---|
| 1234 | case IDM_DETAILSSETUP: | 
|---|
| 1235 | case IDM_COMMANDSMENU: | 
|---|
| 1236 | case IDM_SORTSUBMENU: | 
|---|
| 1237 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4); | 
|---|
| 1238 | if (pd) | 
|---|
| 1239 | WinSendMsg(pd->hwndCurr, UM_INITMENU, mp1, mp2); | 
|---|
| 1240 | break; | 
|---|
| 1241 | case IDM_CONFIGMENU: | 
|---|
| 1242 | WinCheckMenuItem((HWND) mp2, IDM_TOOLSUBMENU, fToolbar); | 
|---|
| 1243 | WinCheckMenuItem((HWND) mp2, IDM_AUTOVIEW, fAutoView); | 
|---|
| 1244 | break; | 
|---|
| 1245 | case IDM_TOOLSUBMENU: | 
|---|
| 1246 | WinCheckMenuItem((HWND) mp2, IDM_TOOLBAR, fToolbar); | 
|---|
| 1247 | WinCheckMenuItem((HWND) mp2, IDM_TEXTTOOLS, fTextTools); | 
|---|
| 1248 | WinCheckMenuItem((HWND) mp2, IDM_TOOLTITLES, fToolTitles); | 
|---|
| 1249 | break; | 
|---|
| 1250 | case IDM_WINDOWSMENU: | 
|---|
| 1251 | WinCheckMenuItem((HWND) mp2, IDM_VTREE, (hwndTree != (HWND) 0)); | 
|---|
| 1252 | WinCheckMenuItem((HWND) mp2, IDM_TILEBACKWARDS, fTileBackwards); | 
|---|
| 1253 | SetupWinList((HWND) mp2, hwnd, WinQueryWindow(hwnd, QW_PARENT)); | 
|---|
| 1254 | break; | 
|---|
| 1255 | } | 
|---|
| 1256 | break; | 
|---|
| 1257 |  | 
|---|
| 1258 | case WM_SETFOCUS: | 
|---|
| 1259 | if (mp2) | 
|---|
| 1260 | PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID); | 
|---|
| 1261 | break; | 
|---|
| 1262 |  | 
|---|
| 1263 | case UM_FOCUSME: | 
|---|
| 1264 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4); | 
|---|
| 1265 | if (pd) | 
|---|
| 1266 | WinSetFocus(HWND_DESKTOP, pd->hwndCurr); | 
|---|
| 1267 | return 0; | 
|---|
| 1268 |  | 
|---|
| 1269 | case UM_RESCAN: | 
|---|
| 1270 | return 0; | 
|---|
| 1271 |  | 
|---|
| 1272 | case UM_SIZE: | 
|---|
| 1273 | { | 
|---|
| 1274 | SWP swp; | 
|---|
| 1275 |  | 
|---|
| 1276 | if (WinQueryWindowPos(hwnd, &swp)) { | 
|---|
| 1277 | mp1 = MPFROM2SHORT(swp.cx, swp.cy); | 
|---|
| 1278 | mp2 = MPFROM2SHORT(swp.cx, swp.cy); | 
|---|
| 1279 | } | 
|---|
| 1280 | else | 
|---|
| 1281 | return 0; | 
|---|
| 1282 | } | 
|---|
| 1283 | /* intentional fallthru */ | 
|---|
| 1284 | case WM_SIZE: | 
|---|
| 1285 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4); | 
|---|
| 1286 | if (mp1 && mp2 && pd && pd->hwndDir1 && pd->hwndDir2) { | 
|---|
| 1287 | if (hwndTree) | 
|---|
| 1288 | WinSetWindowPos(hwndTree, | 
|---|
| 1289 | HWND_TOP, | 
|---|
| 1290 | 2, | 
|---|
| 1291 | 2, | 
|---|
| 1292 | TreeWidth - 4, | 
|---|
| 1293 | SHORT2FROMMP(mp2) - 4, | 
|---|
| 1294 | SWP_SHOW | SWP_MOVE | SWP_SIZE); | 
|---|
| 1295 | else | 
|---|
| 1296 | TreeWidth = 0; | 
|---|
| 1297 | if (!pd->hwndMax) { | 
|---|
| 1298 | if (fTileBackwards) { | 
|---|
| 1299 | WinSetWindowPos(pd->hwndDir1, HWND_TOP, | 
|---|
| 1300 | (((SHORT1FROMMP(mp2) - TreeWidth) / 2) + | 
|---|
| 1301 | TreeWidth) + 2, | 
|---|
| 1302 | 2, | 
|---|
| 1303 | ((SHORT1FROMMP(mp2) - TreeWidth) / 2) - 4, | 
|---|
| 1304 | SHORT2FROMMP(mp2) - 4, | 
|---|
| 1305 | SWP_SHOW | SWP_MOVE | SWP_SIZE); | 
|---|
| 1306 | WinSetWindowPos(pd->hwndDir2, HWND_TOP, | 
|---|
| 1307 | TreeWidth + 2, | 
|---|
| 1308 | 2, | 
|---|
| 1309 | ((SHORT1FROMMP(mp2) - TreeWidth) / 2) - 4, | 
|---|
| 1310 | SHORT2FROMMP(mp2) - 4, | 
|---|
| 1311 | SWP_SHOW | SWP_MOVE | SWP_SIZE); | 
|---|
| 1312 | } | 
|---|
| 1313 | else { | 
|---|
| 1314 | WinSetWindowPos(pd->hwndDir1, HWND_TOP, | 
|---|
| 1315 | TreeWidth + 2, | 
|---|
| 1316 | 2, | 
|---|
| 1317 | (SHORT1FROMMP(mp2) - TreeWidth) - 4, | 
|---|
| 1318 | (SHORT2FROMMP(mp2) / 2) - 4, | 
|---|
| 1319 | SWP_SHOW | SWP_MOVE | SWP_SIZE); | 
|---|
| 1320 | WinSetWindowPos(pd->hwndDir2, HWND_TOP, | 
|---|
| 1321 | TreeWidth + 2, | 
|---|
| 1322 | (SHORT2FROMMP(mp2) / 2) + 2, | 
|---|
| 1323 | (SHORT1FROMMP(mp2) - TreeWidth) - 4, | 
|---|
| 1324 | (SHORT2FROMMP(mp2) / 2) - 4, | 
|---|
| 1325 | SWP_SHOW | SWP_MOVE | SWP_SIZE); | 
|---|
| 1326 | } | 
|---|
| 1327 | } | 
|---|
| 1328 | else { | 
|---|
| 1329 |  | 
|---|
| 1330 | HWND hwndOther; | 
|---|
| 1331 |  | 
|---|
| 1332 | WinSetWindowPos(pd->hwndMax, HWND_TOP, | 
|---|
| 1333 | TreeWidth + 2, | 
|---|
| 1334 | 2, | 
|---|
| 1335 | (SHORT1FROMMP(mp2) - TreeWidth) - 4, | 
|---|
| 1336 | SHORT2FROMMP(mp2) - 4, | 
|---|
| 1337 | SWP_SHOW | SWP_MOVE | SWP_SIZE); | 
|---|
| 1338 | hwndOther = (pd->hwndMax == pd->hwndDir1) ? | 
|---|
| 1339 | pd->hwndDir2 : pd->hwndDir1; | 
|---|
| 1340 | WinSetWindowPos(hwndOther, HWND_BOTTOM, 0, 0, 0, 0, SWP_HIDE); | 
|---|
| 1341 | } | 
|---|
| 1342 | WinSendMsg(hwnd, UM_SETUP2, MPVOID, MPVOID); | 
|---|
| 1343 | } | 
|---|
| 1344 | if (msg == UM_SIZE) | 
|---|
| 1345 | return 0; | 
|---|
| 1346 | break; | 
|---|
| 1347 |  | 
|---|
| 1348 | case WM_ERASEBACKGROUND: | 
|---|
| 1349 | WinFillRect((HPS) mp1, (PRECTL) mp2, 0x00d0d0d0); | 
|---|
| 1350 | return 0; | 
|---|
| 1351 |  | 
|---|
| 1352 | case WM_PAINT: | 
|---|
| 1353 | { | 
|---|
| 1354 | HPS hps; | 
|---|
| 1355 | RECTL rcl; | 
|---|
| 1356 |  | 
|---|
| 1357 | hps = WinBeginPaint(hwnd, NULLHANDLE, NULL); | 
|---|
| 1358 | if (hps) { | 
|---|
| 1359 | WinQueryWindowRect(hwnd, &rcl); | 
|---|
| 1360 | WinFillRect(hps, (PRECTL) & rcl, CLR_PALEGRAY); | 
|---|
| 1361 | WinEndPaint(hps); | 
|---|
| 1362 | WinSendMsg(hwnd, UM_SETUP2, MPVOID, MPVOID); | 
|---|
| 1363 | } | 
|---|
| 1364 | } | 
|---|
| 1365 | break; | 
|---|
| 1366 |  | 
|---|
| 1367 | case UM_COMMAND: | 
|---|
| 1368 | case WM_COMMAND: | 
|---|
| 1369 | return MainWMCommand2(hwnd, msg, mp1, mp2); | 
|---|
| 1370 |  | 
|---|
| 1371 | case WM_CLOSE: | 
|---|
| 1372 | fAmClosing = TRUE; | 
|---|
| 1373 | WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID); | 
|---|
| 1374 | CloseChildren(hwnd); | 
|---|
| 1375 | PostMsg(hwnd, UM_CLOSE, MPVOID, MPVOID); | 
|---|
| 1376 | DosSleep(1); | 
|---|
| 1377 | return 0; | 
|---|
| 1378 |  | 
|---|
| 1379 | case UM_CLOSE: | 
|---|
| 1380 | WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT)); | 
|---|
| 1381 | return 0; | 
|---|
| 1382 |  | 
|---|
| 1383 | case WM_DESTROY: | 
|---|
| 1384 | hwndMain = (HWND) 0; | 
|---|
| 1385 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4); | 
|---|
| 1386 | xfree(pd, pszSrcFile, __LINE__); | 
|---|
| 1387 | if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID)) | 
|---|
| 1388 | WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID); | 
|---|
| 1389 | break; | 
|---|
| 1390 | } | 
|---|
| 1391 | return WinDefWindowProc(hwnd, msg, mp1, mp2); | 
|---|
| 1392 | } | 
|---|
| 1393 |  | 
|---|
| 1394 | HWND StartFM32(HAB hab, INT argc, CHAR ** argv) | 
|---|
| 1395 | { | 
|---|
| 1396 | HWND hwndFrame, hwndClient; | 
|---|
| 1397 | ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU | | 
|---|
| 1398 | FCF_SIZEBORDER | FCF_MINMAX | | 
|---|
| 1399 | FCF_ACCELTABLE | FCF_MENU | FCF_ICON | FCF_TASKLIST | FCF_NOBYTEALIGN; | 
|---|
| 1400 |  | 
|---|
| 1401 | { | 
|---|
| 1402 | INT x; | 
|---|
| 1403 |  | 
|---|
| 1404 | for (x = 1; x < argc; x++) { | 
|---|
| 1405 | if (*argv[x] == '+' && !argv[x][1]) | 
|---|
| 1406 | fLogFile = TRUE; | 
|---|
| 1407 | if (*argv[x] == '-') { | 
|---|
| 1408 | if (argv[x][1]) | 
|---|
| 1409 | strcpy(profile, &argv[x][1]); | 
|---|
| 1410 | } | 
|---|
| 1411 | } | 
|---|
| 1412 | } | 
|---|
| 1413 | { | 
|---|
| 1414 | CHAR inipath[CCHMAXPATH], fullpath[CCHMAXPATH]; | 
|---|
| 1415 | FILESTATUS3 fsa; | 
|---|
| 1416 |  | 
|---|
| 1417 | if (PrfQueryProfileString(HINI_USERPROFILE, | 
|---|
| 1418 | FM2Str, | 
|---|
| 1419 | "Home", NULL, inipath, sizeof(inipath))) { | 
|---|
| 1420 | if (!DosQueryPathInfo(inipath, FIL_STANDARD, &fsa, sizeof(fsa))) { | 
|---|
| 1421 | if (fsa.attrFile & FILE_DIRECTORY) { | 
|---|
| 1422 | if (DosQueryPathInfo(inipath, | 
|---|
| 1423 | FIL_QUERYFULLNAME, fullpath, sizeof(fullpath))) | 
|---|
| 1424 | strcpy(fullpath, inipath); | 
|---|
| 1425 | switch_to(fullpath); | 
|---|
| 1426 | } | 
|---|
| 1427 | } | 
|---|
| 1428 | } | 
|---|
| 1429 | } | 
|---|
| 1430 |  | 
|---|
| 1431 | hwndFrame = WinCreateStdWindow(HWND_DESKTOP, | 
|---|
| 1432 | WS_VISIBLE, | 
|---|
| 1433 | &FrameFlags, | 
|---|
| 1434 | WC_MAINWND2, | 
|---|
| 1435 | NULL, | 
|---|
| 1436 | WS_VISIBLE | WS_ANIMATE, | 
|---|
| 1437 | FM3ModHandle, MAIN2_FRAME, &hwndClient); | 
|---|
| 1438 | if (hwndFrame) { | 
|---|
| 1439 | hwndMainMenu = WinWindowFromID(hwndFrame, FID_MENU); | 
|---|
| 1440 | if (!WinRestoreWindowPos(FM2Str, "MainWindowPos2", hwndFrame)) { | 
|---|
| 1441 |  | 
|---|
| 1442 | ULONG fl = SWP_MOVE | SWP_SIZE; | 
|---|
| 1443 | RECTL rcl; | 
|---|
| 1444 | ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 3L; | 
|---|
| 1445 | ULONG bsz = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER); | 
|---|
| 1446 |  | 
|---|
| 1447 | WinQueryWindowRect(HWND_DESKTOP, &rcl); | 
|---|
| 1448 | rcl.yBottom += icz; | 
|---|
| 1449 | rcl.yTop -= bsz; | 
|---|
| 1450 | rcl.xLeft += bsz; | 
|---|
| 1451 | rcl.xRight -= bsz; | 
|---|
| 1452 | WinSetWindowPos(hwndFrame, | 
|---|
| 1453 | HWND_TOP, | 
|---|
| 1454 | rcl.xLeft, | 
|---|
| 1455 | rcl.yBottom, | 
|---|
| 1456 | rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, fl); | 
|---|
| 1457 | } | 
|---|
| 1458 | if (fLogFile) | 
|---|
| 1459 | LogFileHandle = _fsopen("FM2.LOG", "a+", SH_DENYWR); | 
|---|
| 1460 | if (hwndHelp) | 
|---|
| 1461 | WinAssociateHelpInstance(hwndHelp, hwndFrame); | 
|---|
| 1462 | PostMsg(hwndClient, UM_SETUP, MPFROMLONG(argc), MPFROMP(argv)); | 
|---|
| 1463 | } | 
|---|
| 1464 | return hwndFrame; | 
|---|
| 1465 | } | 
|---|
| 1466 |  | 
|---|
| 1467 | #pragma alloc_text(PERSON11,MainFrameWndProc2,MainWndProc2) | 
|---|
| 1468 | #pragma alloc_text(PERSON12,StartFM32,MainWMOnce2) | 
|---|
| 1469 | #pragma alloc_text(PERSON13,MainWMCommand2) | 
|---|