| 1 |  | 
|---|
| 2 | /*********************************************************************** | 
|---|
| 3 |  | 
|---|
| 4 | $Id: mainwnd.c 1778 2014-06-26 22:30:54Z stevenhl $ | 
|---|
| 5 |  | 
|---|
| 6 | fm/2 main window | 
|---|
| 7 |  | 
|---|
| 8 | Copyright (c) 1993-98 M. Kimes | 
|---|
| 9 | Copyright (c) 2001, 2013 Steven H. Levine | 
|---|
| 10 |  | 
|---|
| 11 | 11 Jun 02 SHL Drop obsolete xor code | 
|---|
| 12 | 16 Oct 02 SHL Handle large partitions | 
|---|
| 13 | 01 Aug 04 SHL Rework lstrip/rstrip usage | 
|---|
| 14 | 23 May 05 SHL Use QWL_USER | 
|---|
| 15 | 23 May 05 SHL Use datamin.h | 
|---|
| 16 | 25 May 05 SHL Use ULONGLONG and CommaFmtULL | 
|---|
| 17 | 26 May 05 SHL Comments and localize code | 
|---|
| 18 | 05 Jun 05 SHL Use QWL_USER | 
|---|
| 19 | 06 Jun 05 SHL Rework MainWMCommand for VAC3.65 compat | 
|---|
| 20 | 13 Aug 05 SHL Renames and comments | 
|---|
| 21 | 08 Dec 05 SHL DriveProc: disable menu items if drive not ready | 
|---|
| 22 | 17 Dec 05 SHL DriveProc: correct my stupid | 
|---|
| 23 | 29 May 06 SHL IDM_EDITANYARCHIVER: sanitize code | 
|---|
| 24 | 17 Jul 06 SHL Use Runtime_Error | 
|---|
| 25 | 17 Aug 06 SHL Complain nicer if state name does not exist | 
|---|
| 26 | 18 Feb 07 GKY More drive type and icon support | 
|---|
| 27 | 08 Mar 07 SHL SaveDirCnrState: do not save state of NOPRESCAN volumes | 
|---|
| 28 | 09 Mar 07 SHL RestoreDirCnrState/SaveDirCnrState: optimize and avoid overflows | 
|---|
| 29 | 30 Mar 07 GKY Remove GetPString for window class names | 
|---|
| 30 | 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limits | 
|---|
| 31 | 06 Apr 07 GKY Add some error checking in drag/drop | 
|---|
| 32 | 15 Apr 07 SHL mainwnd MAIN_SETUPLIST restore state not found reporting | 
|---|
| 33 | 19 Apr 07 SHL Sync with AcceptOneDrop GetOneDrop mods | 
|---|
| 34 | 20 Apr 07 SHL Avoid spurious add_udir error reports | 
|---|
| 35 | 12 May 07 SHL Use dcd->ulItemsToUnHilite | 
|---|
| 36 | 10 Jun 07 GKY Add CheckPmDrgLimit including IsFm2Window as part of work around PM drag limit | 
|---|
| 37 | 06 Aug 07 GKY Reduce DosSleep times (ticket 148) | 
|---|
| 38 | 07 Aug 07 SHL Use BldQuotedFileName | 
|---|
| 39 | 16 Aug 07 SHL Update IDM_SAVEDIRCNRSTATE logic for ticket# 109 | 
|---|
| 40 | 18 Aug 07 SHL Rework UM_FILLSETUPLIST for new setups storage | 
|---|
| 41 | 19 Aug 07 SHL Move #pragma alloc_text to end of file for OpenWatcom | 
|---|
| 42 | 19 Aug 07 SHL Rework SaveDirCnrState to return better error info | 
|---|
| 43 | 30 Aug 07 SHL Add accelerator support to quicklist windows | 
|---|
| 44 | 22 Nov 07 GKY Use CopyPresParams to fix presparam inconsistencies in menus | 
|---|
| 45 | 12 Jan 08 SHL Support drag&drop dialog toggle | 
|---|
| 46 | 16 Jan 08 SHL Add sync updates toggle | 
|---|
| 47 | 16 Jan 08 GKY Fix changing background color on toolbar | 
|---|
| 48 | 17 Jan 08 GKY Add presparam save & restore for individual directory containers | 
|---|
| 49 | 19 Jan 08 JBS Ticket 150: fix/improve save and restore of dir cnr state at FM/2 close/reopen | 
|---|
| 50 | 19 Jan 08 GKY Rework Utilities menu | 
|---|
| 51 | 05 Feb 08 SHL Restore no-prescan drives if restoring named state | 
|---|
| 52 | 14 Feb 08 SHL Rework to support settings menu conditional cascade | 
|---|
| 53 | 15 Feb 08 SHL Rework ResizeChildren to honor fNoTreeGap and resize drive tree better | 
|---|
| 54 | 19 Feb 08 JBS Stop deleting "State at last FM/2 Close" from INI file so it be accessed from States combo box. | 
|---|
| 55 | 22 Feb 08 JBS Ticket 230: Fix/improve various code related to state or presparam values in the INI file. | 
|---|
| 56 | 29 Feb 08 GKY Use xfree where appropriate | 
|---|
| 57 | 19 Jun 08 JBS Ticket 227: Allow temporary saving/deleting of the shutdown state of directory containers | 
|---|
| 58 | 22 Jun 08 GKY Use free_... functions for fortify checking | 
|---|
| 59 | 30 Jun 08 JBS Ticket 103: Fix restore of previous shutdown state when opening FM/2 | 
|---|
| 60 | 07 Jul 08 JBS Ticket 242: Delete obsolete INI keys when re-saving a state | 
|---|
| 61 | 11 Jul 08 JBS Ticket 230: Simplified code and eliminated some local variables by incorporating | 
|---|
| 62 | all the details view settings (both the global variables and those in the | 
|---|
| 63 | DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS. | 
|---|
| 64 | 12 Jul 08 JBS Ticket 246: Allow saved directory container states to have no directory containers | 
|---|
| 65 | (i.e. just a directory tree container). | 
|---|
| 66 | 18 Jul 08 SHL Use new Fortify feature to avoid spurious reports | 
|---|
| 67 | 19 Jul 08 GKY Replace save_dir2(dir) with pFM2SaveDirectory | 
|---|
| 68 | 26 Aug 08 GKY Require unique ID plus text and help strings for all tools save toolbar on button delete | 
|---|
| 69 | 27 Aug 08 JBS Ticket 259: Support saving/restoring toolbars with states | 
|---|
| 70 | 29 Aug 08 JBS Ticket 259: Support saving/restoring target directories with states (except the shutdown state) | 
|---|
| 71 | 01 Sep 08 GKY Save toolbars immediately on change. Add bmps for default toolbars | 
|---|
| 72 | 29 Nov 08 GKY Remove or replace with a mutex semaphore DosEnterCriSec where appropriate. | 
|---|
| 73 | 04 Dec 08 GKY Use event semaphore to prevent scan of "last" directory container prior to | 
|---|
| 74 | tree scan completion; prevents duplicate directory names in tree. | 
|---|
| 75 | 10 Dec 08 SHL Integrate exception handler support | 
|---|
| 76 | 28 Dec 08 GKY Added Databar to utilities menu | 
|---|
| 77 | 30 Dec 08 GKY Initialize tool bar background color to palegray not black | 
|---|
| 78 | 03 Jan 09 GKY Check for system that is protectonly to gray out Dos/Win command lines and prevent | 
|---|
| 79 | Dos/Win programs from being inserted into the execute dialog with message why. | 
|---|
| 80 | 11 Jan 09 GKY Replace font names in the string file with global set at compile in init.c | 
|---|
| 81 | 07 Feb 09 GKY Eliminate Win_Error2 by moving function names to PCSZs used in Win_Error | 
|---|
| 82 | 08 Mar 09 GKY Renamed commafmt.h i18nutil.h | 
|---|
| 83 | 08 Mar 09 GKY Additional strings move to PCSZs & String Table | 
|---|
| 84 | 08 Mar 09 GKY Add WriteDetailsSwitches and use LoadDetailsSwitches to replace in line code | 
|---|
| 85 | 19 Mar 09 GKY Moved DeletePresParams to presparam.c | 
|---|
| 86 | 28 Mar 09 GKY Add RemoveOldCnrSwitches to remove pre 3.16 style ini keys; | 
|---|
| 87 | add State.version key for check | 
|---|
| 88 | 07 Jun 09 GKY Fix IDM_BLINK to not leave a DataBar? on the screen when fDataMin is TRUE. | 
|---|
| 89 | 21 Jun 09 GKY Added drive letter to bitmap buttons in drive bar; Eliminate static drive | 
|---|
| 90 | letter windows; Use button ID to identify drive letter for processing. | 
|---|
| 91 | 12 Jul 09 GKY Removed duplicate UM_SETUP2 message from RestoreDirCnrState caused dbl dir | 
|---|
| 92 | listings in tree | 
|---|
| 93 | 13 Jul 09 GKY Fixed under allocation of memory in the paint code for the drivebar bitmap buttons | 
|---|
| 94 | 22 Jul 09 GKY Drivebar enhancements add refresh removable, rescan all drives, drive button | 
|---|
| 95 | loads drive root directory in directory container or expands drive tree | 
|---|
| 96 | and rescans drive in tree container depending on container focus, greyed out | 
|---|
| 97 | inappropriate menu context choices | 
|---|
| 98 | 22 Jul 09 GKY Code changes to use semaphores to serialize drive scanning | 
|---|
| 99 | 12 Sep 09 GKY Add FM3.INI User ini and system ini to submenu for view ini | 
|---|
| 100 | 14 Sep 09 SHL Blink thread LEDs when workers busy | 
|---|
| 101 | 13 Dec 09 GKY Fixed separate paramenters. Please note that appname should be used in | 
|---|
| 102 | profile calls for user settings that work and are setable in more than one | 
|---|
| 103 | miniapp; FM3Str should be used for setting only relavent to FM/2 or that | 
|---|
| 104 | aren't user settable; realappname should be used for setting applicable to | 
|---|
| 105 | one or more miniapp but not to FM/2 | 
|---|
| 106 | 17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast | 
|---|
| 107 | CHAR CONSTANT * as CHAR *. | 
|---|
| 108 | 11 Apr 10 GKY Fix drive tree rescan failure and program hang caused by event sem | 
|---|
| 109 | never being posted | 
|---|
| 110 | 23 Oct 10 GKY Changes to populate and utilize a HELPTABLE for context specific help | 
|---|
| 111 | 03 Oct 11 SHL Add needTile to ensure containers opened on command line render correctly | 
|---|
| 112 | 03 Oct 11 SHL Minor code cleanup | 
|---|
| 113 | 05 Aug 12 GKY Make the Target Directory (DriveBar) a drop target. | 
|---|
| 114 | 12 Aug 12 GKY Allow for selection of include subdirectories or a list file on initial startup of compare dirs | 
|---|
| 115 | 30 Dec 12 GKY Enhance traget directory drop to give the option of changing the directory or carrying out an | 
|---|
| 116 | operation to the current target; Added an error message for target = None; | 
|---|
| 117 |  | 
|---|
| 118 | ***********************************************************************/ | 
|---|
| 119 |  | 
|---|
| 120 | #include <stdlib.h> | 
|---|
| 121 | #include <string.h> | 
|---|
| 122 | #include <ctype.h> | 
|---|
| 123 |  | 
|---|
| 124 | #define INCL_DOS | 
|---|
| 125 | #define INCL_WIN | 
|---|
| 126 | #define INCL_SHLERRORS                  // PMERR_NOT_IN_IDX | 
|---|
| 127 | #define INCL_WINHELP | 
|---|
| 128 | #define INCL_GPI | 
|---|
| 129 | #define INCL_LONGLONG | 
|---|
| 130 |  | 
|---|
| 131 | #include "fm3dll.h" | 
|---|
| 132 | #include "fm3dll2.h"                    // #define's for UM_*, control id's, etc. | 
|---|
| 133 | #include "grep.h"                       // Data declaration(s) | 
|---|
| 134 | #include "autoview.h"                   // Data declaration(s) | 
|---|
| 135 | #include "dircnrs.h"                    // Data declaration(s) | 
|---|
| 136 | #include "info.h"                       // Data declaration(s) | 
|---|
| 137 | #include "defview.h"                    // Data declaration(s) | 
|---|
| 138 | #include "init.h"                       // Data declaration(s) | 
|---|
| 139 | #include "fm3dlg.h" | 
|---|
| 140 | #include "fm3str.h" | 
|---|
| 141 | #include "tools.h" | 
|---|
| 142 | #include "comp.h" | 
|---|
| 143 | #include "datamin.h" | 
|---|
| 144 | #include "pathutil.h"                   // BldQuotedFileName | 
|---|
| 145 | #include "errutil.h"                    // Dos_Error... | 
|---|
| 146 | #include "strutil.h"                    // GetPString | 
|---|
| 147 | #include "notebook.h"                   // CfgDlgProc CfgMenuInit | 
|---|
| 148 | #include "command.h"                    // LINKCMDS | 
|---|
| 149 | #include "avl.h"                        // free_archivers | 
|---|
| 150 | #include "walkem.h"                     // free_setups... | 
|---|
| 151 | #include "key.h"                        // AboutDlgProc | 
|---|
| 152 | #include "menu.h"                       // AddToMenu | 
|---|
| 153 | #include "mainwnd.h" | 
|---|
| 154 | #include "cmdline.h"                    // CmdLine2DlgProc, save_cmdlines | 
|---|
| 155 | #include "common.h"                     // CommonCreateMainChildren, CommonDriveCmd, CommonMainWndProc | 
|---|
| 156 | // CommonTextButton | 
|---|
| 157 | #include "notify.h"                     // DoNotify, HideNote, ShowNote | 
|---|
| 158 | #include "draglist.h"                   // DragOne | 
|---|
| 159 | #include "chklist.h"                    // DropListProc | 
|---|
| 160 | #include "avv.h"                        // EditArchiverDefinition | 
|---|
| 161 | #include "assoc.h"                      // EditAssociations | 
|---|
| 162 | #include "fm2cmd.h"                     // FM2Command | 
|---|
| 163 | #include "misc.h"                       // FindDirCnr, FixSwitchList, PaintSTextWindow, | 
|---|
| 164 | // SetConditionalCascade, SetMenuCheck, SetSysMenu | 
|---|
| 165 | // SwitchCommand, CheckMenu, DrawTargetEmphasis | 
|---|
| 166 | // IsFm2Window | 
|---|
| 167 | #include "instant.h"                    // InstantDlgProc | 
|---|
| 168 | #include "killproc.h"                   // KillDlgProc | 
|---|
| 169 | #include "loadbmp.h"                    // LoadBitmapFromFileNum | 
|---|
| 170 | #include "presparm.h"                   // SavePresParams | 
|---|
| 171 | #include "treecnr.h"                    // ShowTreeRec, StartTreeCnr | 
|---|
| 172 | #include "inis.h"                       // StartIniEditor | 
|---|
| 173 | #include "sysinfo.h"                    // SysInfoDlgProc | 
|---|
| 174 | #include "viewinf.h"                    // ViewInfProc | 
|---|
| 175 | #include "walkem.h"                     // WalkDlgProc, WalkTwoCmpDlgProc, add_setup, add_udir | 
|---|
| 176 | // fill_setups_list, free_ldir, free_udirs, load_udirs | 
|---|
| 177 | // remove_setup, remove_udir, save_setups, save_udirs | 
|---|
| 178 | #include "winlist.h"                    // WindowList | 
|---|
| 179 | #include "cmdline.h"                    // add_cmdline | 
|---|
| 180 | #include "assoc.h"                      // free_associations | 
|---|
| 181 | #include "droplist.h"                   // AcceptOneDrop, CheckPmDrgLimit, DropHelp, GetOneDrop | 
|---|
| 182 | #include "common.h"                     // CommonTextProc | 
|---|
| 183 | #include "presparm.h"                   // CopyPresParams | 
|---|
| 184 | #include "systemf.h"                    // ExecOnList | 
|---|
| 185 | #include "shadow.h"                     // OpenObject | 
|---|
| 186 | #include "mkdir.h"                      // PMMkDir | 
|---|
| 187 | #include "collect.h"                    // StartCollector | 
|---|
| 188 | #include "select.h"                     // UnHilite | 
|---|
| 189 | #include "strips.h"                     // bstrip | 
|---|
| 190 | #include "i18nutil.h"                   // CommaFmtULL | 
|---|
| 191 | #include "valid.h"                      // IsFullName | 
|---|
| 192 | #include "dirs.h"                       // save_dir2 | 
|---|
| 193 | #include "wrappers.h"                   // xfree | 
|---|
| 194 | #include "fortify.h" | 
|---|
| 195 | #include "excputil.h"                   // xbeginthread | 
|---|
| 196 |  | 
|---|
| 197 | #define DRIVEBAR_FONT_LCID 10 | 
|---|
| 198 |  | 
|---|
| 199 | static BOOL CloseDirCnrChildren(HWND hwndClient); | 
|---|
| 200 | static BOOL RestoreDirCnrState(HWND hwndClient, PSZ pszStateName, BOOL noview); | 
|---|
| 201 | static VOID BuildTools(HWND hwndT, BOOL resize); | 
|---|
| 202 |  | 
|---|
| 203 | // Data definitions | 
|---|
| 204 | #pragma data_seg(GLOBAL1) | 
|---|
| 205 | ULONG DriveLines; | 
|---|
| 206 | HWND MainObjectHwnd; | 
|---|
| 207 | HWND MainPopupMenu; | 
|---|
| 208 | BOOL MenuInvisible; | 
|---|
| 209 | PFNWP PFNWPButton; | 
|---|
| 210 | PFNWP PFNWPStatic; | 
|---|
| 211 | BOOL fAmClosing; | 
|---|
| 212 | BOOL fAutoTile; | 
|---|
| 213 | BOOL fAutoView; | 
|---|
| 214 | BOOL fComments; | 
|---|
| 215 | BOOL fDrivebar; | 
|---|
| 216 | BOOL fFreeTree; | 
|---|
| 217 | BOOL fMoreButtons; | 
|---|
| 218 | BOOL fNoFinger; | 
|---|
| 219 | BOOL fNoSaveState; | 
|---|
| 220 | BOOL fNoTileUpdate; | 
|---|
| 221 | BOOL fRunning; | 
|---|
| 222 | BOOL fSplitStatus; | 
|---|
| 223 | BOOL fTextTools; | 
|---|
| 224 | BOOL fToolTitles; | 
|---|
| 225 | BOOL fToolbar; | 
|---|
| 226 | BOOL fUserComboBox; | 
|---|
| 227 | HBITMAP hbmLEDoff; | 
|---|
| 228 | HBITMAP hbmLEDon; | 
|---|
| 229 | HPOINTER hptrFinger; | 
|---|
| 230 | HWND hwndAutoview; | 
|---|
| 231 | HWND hwndBubble; | 
|---|
| 232 | HWND hwndName; | 
|---|
| 233 | HWND hwndStatelist; | 
|---|
| 234 | HWND hwndToolback; | 
|---|
| 235 | HWND hwndTree; | 
|---|
| 236 | USHORT shiftstate; | 
|---|
| 237 |  | 
|---|
| 238 | #pragma data_seg(GLOBAL2) | 
|---|
| 239 | HMODULE FM3ModHandle; | 
|---|
| 240 | PCSZ FM3Str  = "FM/3"; | 
|---|
| 241 | RGB2 RGBGREY; | 
|---|
| 242 | PSZ pszFocusDir; | 
|---|
| 243 |  | 
|---|
| 244 | #pragma data_seg(DATA1) | 
|---|
| 245 |  | 
|---|
| 246 | static PSZ pszSrcFile = __FILE__; | 
|---|
| 247 | static USHORT firsttool = 0; | 
|---|
| 248 | static HWND hwndButtonlist; | 
|---|
| 249 | static HWND hwndCmdlist; | 
|---|
| 250 | static HWND hwndDrivelist; | 
|---|
| 251 | static HWND hwndUserlist; | 
|---|
| 252 |  | 
|---|
| 253 |  | 
|---|
| 254 | static MRESULT EXPENTRY MainObjectWndProc(HWND hwnd, ULONG msg, MPARAM mp1, | 
|---|
| 255 | MPARAM mp2) | 
|---|
| 256 | { | 
|---|
| 257 | switch (msg) { | 
|---|
| 258 | case WM_CREATE: | 
|---|
| 259 | break; | 
|---|
| 260 |  | 
|---|
| 261 | case UM_SETUP: | 
|---|
| 262 | case UM_SETUP2: | 
|---|
| 263 | case UM_SETUP3: | 
|---|
| 264 | case UM_SETUP4: | 
|---|
| 265 | case UM_SETUP5: | 
|---|
| 266 | // feed setup messages to main window | 
|---|
| 267 | PostMsg(hwndMain, msg, mp1, mp2); | 
|---|
| 268 | return 0; | 
|---|
| 269 |  | 
|---|
| 270 | case UM_SETUP6: | 
|---|
| 271 | // handle bubble help requests from drive bar buttons | 
|---|
| 272 | { | 
|---|
| 273 | char dv[3], d; | 
|---|
| 274 | HWND hwndB = (HWND) mp1; | 
|---|
| 275 | USHORT id; | 
|---|
| 276 | CHAR s[90]= {0}; | 
|---|
| 277 |  | 
|---|
| 278 | id = WinQueryWindowUShort(hwndB, QWS_ID); | 
|---|
| 279 | switch (id) { | 
|---|
| 280 | case IDM_RESCAN: | 
|---|
| 281 | strcpy(s, GetPString(IDS_RESCANALLDRIVESTEXT)); | 
|---|
| 282 | break; | 
|---|
| 283 |  | 
|---|
| 284 | case IDM_REFRESHREMOVABLES: | 
|---|
| 285 | strcpy(s, GetPString(IDS_REFRESHREMOVABLESTEXT)); | 
|---|
| 286 | break; | 
|---|
| 287 |  | 
|---|
| 288 | default: | 
|---|
| 289 | *dv = 0; | 
|---|
| 290 | *dv = id - IDM_DRIVEA + 'A'; | 
|---|
| 291 | strcpy(dv + 1, ":"); | 
|---|
| 292 | d = toupper(*dv); | 
|---|
| 293 | if (isalpha(d) && d > 'B' && | 
|---|
| 294 | !(driveflags[d - 'A'] & (DRIVE_CDROM | DRIVE_INVALID | | 
|---|
| 295 | DRIVE_SLOW)) && | 
|---|
| 296 | (!hwndBubble || | 
|---|
| 297 | WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) && | 
|---|
| 298 | !WinQueryCapture(HWND_DESKTOP)) { | 
|---|
| 299 |  | 
|---|
| 300 | FSALLOCATE fsa; | 
|---|
| 301 | CHAR szQty[38]; | 
|---|
| 302 | ULONG ulPctFree; | 
|---|
| 303 | ULONGLONG ullFreeQty; | 
|---|
| 304 |  | 
|---|
| 305 | if (!DosQueryFSInfo((d - 'A') + 1, | 
|---|
| 306 | FSIL_ALLOC, &fsa, sizeof(FSALLOCATE))) { | 
|---|
| 307 | ullFreeQty = (ULONGLONG) fsa.cUnitAvail * | 
|---|
| 308 | (fsa.cSectorUnit * fsa.cbSector); | 
|---|
| 309 | ulPctFree = (fsa.cUnit && fsa.cUnitAvail) ? | 
|---|
| 310 | (fsa.cUnitAvail * 100) / fsa.cUnit : 0; | 
|---|
| 311 | CommaFmtULL(szQty, sizeof(szQty), ullFreeQty, ' '); | 
|---|
| 312 | sprintf(s, "%s %s (%lu%%) %s", dv, szQty, ulPctFree, GetPString(IDS_FREETEXT)); | 
|---|
| 313 | } | 
|---|
| 314 | else | 
|---|
| 315 | sprintf(s, "%s ", dv); | 
|---|
| 316 | } | 
|---|
| 317 | } | 
|---|
| 318 | if ((!hwndBubble || | 
|---|
| 319 | WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) && | 
|---|
| 320 | !WinQueryCapture(HWND_DESKTOP)) | 
|---|
| 321 | WinSendMsg(hwndB, UM_SETUP6, MPFROMP(s), MPVOID); | 
|---|
| 322 | } | 
|---|
| 323 | return 0; | 
|---|
| 324 |  | 
|---|
| 325 | case UM_SETDIR: | 
|---|
| 326 | { | 
|---|
| 327 | CHAR s[8] = " :\\OS2"; | 
|---|
| 328 | ULONG bd; | 
|---|
| 329 |  | 
|---|
| 330 | if (DosQuerySysInfo(QSV_BOOT_DRIVE, | 
|---|
| 331 | QSV_BOOT_DRIVE, | 
|---|
| 332 | (PVOID) & bd, (ULONG) sizeof(ULONG))) | 
|---|
| 333 | bd = 3L; | 
|---|
| 334 | *s = (CHAR) bd + '@'; | 
|---|
| 335 | WinSendMsg(hwndMain, UM_SETDIR, MPFROMP(s), MPFROMLONG(1)); | 
|---|
| 336 | if (!mp1) { | 
|---|
| 337 | s[3] = 0; | 
|---|
| 338 | WinSendMsg(hwndMain, UM_SETDIR, MPFROMP(s), MPVOID); | 
|---|
| 339 | } | 
|---|
| 340 | PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMLONG(1), MPFROMLONG(1)); | 
|---|
| 341 | } | 
|---|
| 342 | return 0; | 
|---|
| 343 |  | 
|---|
| 344 | case UM_RESTORE: | 
|---|
| 345 | switch ((ULONG)mp2) { | 
|---|
| 346 | case 1: | 
|---|
| 347 | TileChildren(hwndMain, TRUE); | 
|---|
| 348 | break; | 
|---|
| 349 | case 2: | 
|---|
| 350 | CloseDirCnrChildren(hwndMain); | 
|---|
| 351 | break; | 
|---|
| 352 | case 0: | 
|---|
| 353 | fNoTileUpdate = TRUE; | 
|---|
| 354 | WinEnableWindow(WinQueryWindow(hwndMain, QW_PARENT), FALSE); | 
|---|
| 355 | RestoreDirCnrState(hwndMain, (char *)mp1, FALSE); | 
|---|
| 356 | WinEnableWindow(WinQueryWindow(hwndMain, QW_PARENT), TRUE); | 
|---|
| 357 | fNoTileUpdate = FALSE; ; | 
|---|
| 358 | break; | 
|---|
| 359 | default: | 
|---|
| 360 | Runtime_Error(pszSrcFile, __LINE__, "%u unexpected", mp2); | 
|---|
| 361 | } | 
|---|
| 362 | return 0; | 
|---|
| 363 |  | 
|---|
| 364 | case UM_NOTIFY: | 
|---|
| 365 | // bring up notify messages for various windows | 
|---|
| 366 | if (mp1) | 
|---|
| 367 | return MRFROMLONG(DoNotify((char *)mp1)); | 
|---|
| 368 | return 0; | 
|---|
| 369 |  | 
|---|
| 370 | case WM_DESTROY: | 
|---|
| 371 | if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID)) | 
|---|
| 372 | WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID); | 
|---|
| 373 | break; | 
|---|
| 374 | } | 
|---|
| 375 | return WinDefWindowProc(hwnd, msg, mp1, mp2); | 
|---|
| 376 | } | 
|---|
| 377 |  | 
|---|
| 378 | VOID MakeMainObjWin(VOID * args) | 
|---|
| 379 | { | 
|---|
| 380 | HAB hab2; | 
|---|
| 381 | HMQ hmq2; | 
|---|
| 382 | QMSG qmsg2; | 
|---|
| 383 |  | 
|---|
| 384 | priority_bumped(); | 
|---|
| 385 | hab2 = WinInitialize(0); | 
|---|
| 386 | if (hab2) { | 
|---|
| 387 | hmq2 = WinCreateMsgQueue(hab2, 128); | 
|---|
| 388 | if (hmq2) { | 
|---|
| 389 | DosError(FERR_DISABLEHARDERR); | 
|---|
| 390 | WinRegisterClass(hab2, | 
|---|
| 391 | (PSZ) WC_OBJECTWINDOW, | 
|---|
| 392 | MainObjectWndProc, 0, sizeof(PVOID)); | 
|---|
| 393 | MainObjectHwnd = WinCreateWindow(HWND_OBJECT, | 
|---|
| 394 | (CHAR *) WC_OBJECTWINDOW, | 
|---|
| 395 | (PSZ) NULL, | 
|---|
| 396 | 0, | 
|---|
| 397 | 0L, | 
|---|
| 398 | 0L, | 
|---|
| 399 | 0L, | 
|---|
| 400 | 0L, | 
|---|
| 401 | 0L, HWND_TOP, OBJ_FRAME, NULL, NULL); | 
|---|
| 402 | if (!MainObjectHwnd) | 
|---|
| 403 | Win_Error(HWND_OBJECT, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| 404 | PCSZ_WINCREATEWINDOW); | 
|---|
| 405 | else { | 
|---|
| 406 | WinSetWindowPtr(MainObjectHwnd, QWL_USER, args); | 
|---|
| 407 | #       ifdef FORTIFY | 
|---|
| 408 | Fortify_EnterScope(); | 
|---|
| 409 | #       endif | 
|---|
| 410 | while (WinGetMsg(hab2, &qmsg2, (HWND) 0, 0, 0)) | 
|---|
| 411 | WinDispatchMsg(hab2, &qmsg2); | 
|---|
| 412 | WinDestroyWindow(MainObjectHwnd); | 
|---|
| 413 | #       ifdef FORTIFY | 
|---|
| 414 | Fortify_LeaveScope(); | 
|---|
| 415 | #       endif | 
|---|
| 416 | } | 
|---|
| 417 | WinDestroyMsgQueue(hmq2); | 
|---|
| 418 | } | 
|---|
| 419 | WinTerminate(hab2); | 
|---|
| 420 | } | 
|---|
| 421 | } | 
|---|
| 422 |  | 
|---|
| 423 | static MRESULT EXPENTRY IdealButtonProc(HWND hwnd, ULONG msg, MPARAM mp1, | 
|---|
| 424 | MPARAM mp2) | 
|---|
| 425 | { | 
|---|
| 426 | switch (msg) { | 
|---|
| 427 | case WM_MOUSEMOVE: | 
|---|
| 428 | BubbleHelp(hwnd, TRUE, FALSE, FALSE, GetPString(IDS_IDEALBUTTONHELP)); | 
|---|
| 429 | break; | 
|---|
| 430 | } | 
|---|
| 431 | return PFNWPButton(hwnd, msg, mp1, mp2); | 
|---|
| 432 | } | 
|---|
| 433 |  | 
|---|
| 434 | HWND TopWindow(HWND hwndParent, HWND exclude) | 
|---|
| 435 | { | 
|---|
| 436 | HENUM henum; | 
|---|
| 437 | HWND hwndC = (HWND) 0; | 
|---|
| 438 | USHORT id; | 
|---|
| 439 |  | 
|---|
| 440 | if (hwndParent) { | 
|---|
| 441 | henum = WinBeginEnumWindows(hwndMain); | 
|---|
| 442 | while ((hwndC = WinGetNextWindow(henum)) != NULLHANDLE) { | 
|---|
| 443 | if (hwndC != exclude) { | 
|---|
| 444 | id = WinQueryWindowUShort(hwndC, QWS_ID); | 
|---|
| 445 | if (id) | 
|---|
| 446 | break; | 
|---|
| 447 | } | 
|---|
| 448 | } | 
|---|
| 449 | WinEndEnumWindows(henum); | 
|---|
| 450 | } | 
|---|
| 451 | return hwndC; | 
|---|
| 452 | } | 
|---|
| 453 |  | 
|---|
| 454 | HWND TopWindowName(HWND hwndParent, HWND exclude, CHAR * ret) | 
|---|
| 455 | { | 
|---|
| 456 | HENUM henum; | 
|---|
| 457 | HWND hwndC = (HWND) 0, hwndDir, hwndClient; | 
|---|
| 458 | USHORT id; | 
|---|
| 459 | PCNRITEM pci = NULL; | 
|---|
| 460 |  | 
|---|
| 461 | if (ret) { | 
|---|
| 462 | *ret = 0; | 
|---|
| 463 | if (hwndParent) { | 
|---|
| 464 | henum = WinBeginEnumWindows(hwndMain); | 
|---|
| 465 | while ((hwndC = WinGetNextWindow(henum)) != NULLHANDLE) { | 
|---|
| 466 | if (hwndC != exclude && hwndC != hwndTree) { | 
|---|
| 467 | id = WinQueryWindowUShort(hwndC, QWS_ID); | 
|---|
| 468 | if (id) { | 
|---|
| 469 | hwndClient = WinWindowFromID(hwndC, FID_CLIENT); | 
|---|
| 470 | if (hwndClient) { | 
|---|
| 471 | hwndDir = WinWindowFromID(hwndClient, DIR_CNR); | 
|---|
| 472 | if (hwndDir) { | 
|---|
| 473 | if (fLookInDir) { | 
|---|
| 474 | pci = (PCNRITEM) WinSendMsg(hwndDir, | 
|---|
| 475 | CM_QUERYRECORDEMPHASIS, | 
|---|
| 476 | MPFROMLONG(CMA_FIRST), | 
|---|
| 477 | MPFROMSHORT(CRA_CURSORED)); | 
|---|
| 478 | if (pci && (INT) pci != -1) | 
|---|
| 479 | break; | 
|---|
| 480 | } | 
|---|
| 481 | if (WinSendMsg(hwndClient, | 
|---|
| 482 | UM_CONTAINERDIR, MPFROMP(ret), MPVOID)) { | 
|---|
| 483 | MakeValidDir(ret); | 
|---|
| 484 | WinEndEnumWindows(henum); | 
|---|
| 485 | return hwndC; | 
|---|
| 486 | } | 
|---|
| 487 | } | 
|---|
| 488 | } | 
|---|
| 489 | } | 
|---|
| 490 | } | 
|---|
| 491 | } | 
|---|
| 492 | WinEndEnumWindows(henum); | 
|---|
| 493 | if (!pci || (INT) pci == -1) { | 
|---|
| 494 | hwndC = hwndTree; | 
|---|
| 495 | pci = (PCNRITEM) WinSendMsg(WinWindowFromID(WinWindowFromID(hwndTree, | 
|---|
| 496 | FID_CLIENT), | 
|---|
| 497 | TREE_CNR), | 
|---|
| 498 | CM_QUERYRECORDEMPHASIS, | 
|---|
| 499 | MPFROMLONG(CMA_FIRST), | 
|---|
| 500 | MPFROMSHORT(CRA_CURSORED)); | 
|---|
| 501 | } | 
|---|
| 502 | if (pci && (INT) pci != -1) { | 
|---|
| 503 | strcpy(ret, pci->pszFileName); | 
|---|
| 504 | MakeValidDir(ret); | 
|---|
| 505 | } | 
|---|
| 506 | else | 
|---|
| 507 | strcpy(ret, pFM2SaveDirectory); | 
|---|
| 508 | } | 
|---|
| 509 | } | 
|---|
| 510 | return hwndC; | 
|---|
| 511 | } | 
|---|
| 512 |  | 
|---|
| 513 | ULONG CountDirCnrs(HWND hwndParent) | 
|---|
| 514 | { | 
|---|
| 515 | HENUM henum; | 
|---|
| 516 | HWND hwndF = (HWND) 0, hwndC, hwndDir; | 
|---|
| 517 | ULONG ret = 0; | 
|---|
| 518 |  | 
|---|
| 519 | henum = WinBeginEnumWindows(hwndParent); | 
|---|
| 520 | while ((hwndF = WinGetNextWindow(henum)) != NULLHANDLE) { | 
|---|
| 521 | hwndC = WinWindowFromID(hwndF, FID_CLIENT); | 
|---|
| 522 | if (hwndC) { | 
|---|
| 523 | hwndDir = WinWindowFromID(hwndC, DIR_CNR); | 
|---|
| 524 | if (hwndDir) | 
|---|
| 525 | ret++; | 
|---|
| 526 | } | 
|---|
| 527 | } | 
|---|
| 528 | WinEndEnumWindows(henum); | 
|---|
| 529 | return ret; | 
|---|
| 530 | } | 
|---|
| 531 |  | 
|---|
| 532 | HWND FindDirCnrByName(CHAR * directory, BOOL restore) | 
|---|
| 533 | { | 
|---|
| 534 | HENUM henum; | 
|---|
| 535 | HWND hwndF = (HWND) 0, hwndC, hwndDir; | 
|---|
| 536 | CHAR retstr[CCHMAXPATH]; | 
|---|
| 537 |  | 
|---|
| 538 | if (hwndMain) { | 
|---|
| 539 | henum = WinBeginEnumWindows(hwndMain); | 
|---|
| 540 | while ((hwndF = WinGetNextWindow(henum)) != NULLHANDLE) { | 
|---|
| 541 | hwndC = WinWindowFromID(hwndF, FID_CLIENT); | 
|---|
| 542 | if (hwndC) { | 
|---|
| 543 | hwndDir = WinWindowFromID(hwndC, DIR_CNR); | 
|---|
| 544 | if (hwndDir) { | 
|---|
| 545 | *retstr = 0; | 
|---|
| 546 | WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(retstr), MPVOID); | 
|---|
| 547 | if (*retstr && !stricmp(retstr, directory)) { | 
|---|
| 548 | if (restore) | 
|---|
| 549 | WinSetWindowPos(hwndF, | 
|---|
| 550 | HWND_TOP, | 
|---|
| 551 | 0, | 
|---|
| 552 | 0, | 
|---|
| 553 | 0, | 
|---|
| 554 | 0, | 
|---|
| 555 | SWP_RESTORE | SWP_SHOW | | 
|---|
| 556 | SWP_ACTIVATE | SWP_ZORDER); | 
|---|
| 557 | break; | 
|---|
| 558 | } | 
|---|
| 559 | } | 
|---|
| 560 | } | 
|---|
| 561 | } | 
|---|
| 562 | WinEndEnumWindows(henum); | 
|---|
| 563 | } | 
|---|
| 564 | return hwndF; | 
|---|
| 565 | } | 
|---|
| 566 |  | 
|---|
| 567 | /** | 
|---|
| 568 | * Sync menu item checkmarks to match globals | 
|---|
| 569 | * Called before submenu or context menu opened | 
|---|
| 570 | * Does more work than really needed, but makes code easier to maintain | 
|---|
| 571 | */ | 
|---|
| 572 |  | 
|---|
| 573 | static VOID SetToggleChecks(HWND hwndMenu) | 
|---|
| 574 | { | 
|---|
| 575 | WinCheckMenuItem(hwndMenu, IDM_TEXTTOOLS, fTextTools); | 
|---|
| 576 | WinCheckMenuItem(hwndMenu, IDM_TOOLTITLES, fToolTitles); | 
|---|
| 577 | WinCheckMenuItem(hwndMenu, IDM_USERLIST, fUserComboBox); | 
|---|
| 578 | WinCheckMenuItem(hwndMenu, IDM_TOOLSUBMENU, fToolbar); | 
|---|
| 579 | WinCheckMenuItem(hwndMenu, IDM_AUTOVIEWSUBMENU, fAutoView); | 
|---|
| 580 | WinCheckMenuItem(hwndMenu, IDM_AUTOVIEWFILE, !fComments); | 
|---|
| 581 | WinCheckMenuItem(hwndMenu, IDM_AUTOVIEWCOMMENTS, fComments); | 
|---|
| 582 | WinCheckMenuItem(hwndMenu, IDM_MOREBUTTONS, fMoreButtons); | 
|---|
| 583 | WinCheckMenuItem(hwndMenu, IDM_DRIVEBAR, fDrivebar); | 
|---|
| 584 | WinCheckMenuItem(hwndMenu, IDM_AUTOTILE, fAutoTile); | 
|---|
| 585 | WinCheckMenuItem(hwndMenu, IDM_TILEBACKWARDS, fTileBackwards); | 
|---|
| 586 | WinCheckMenuItem(hwndMenu, IDM_CONFIRMDELETE, fConfirmDelete);        // 2014-05-17 SHL | 
|---|
| 587 | WinCheckMenuItem(hwndMenu, IDM_TOGGLEDRAGDIALOG, fDragndropDlg); | 
|---|
| 588 | WinCheckMenuItem(hwndMenu, IDM_SYNCUPDATES, fSyncUpdates); | 
|---|
| 589 | } | 
|---|
| 590 |  | 
|---|
| 591 | static VOID ResizeTools(HWND hwnd) | 
|---|
| 592 | { | 
|---|
| 593 | register ULONG butx = 18L; | 
|---|
| 594 | INT attrib = SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER | SWP_NOREDRAW, | 
|---|
| 595 | noattrib; | 
|---|
| 596 | register TOOL *tool, *starttool; | 
|---|
| 597 | SWP *swp; | 
|---|
| 598 | register ULONG numtools, x; | 
|---|
| 599 |  | 
|---|
| 600 | if (!fToolbar) | 
|---|
| 601 | return; | 
|---|
| 602 | noattrib = attrib; | 
|---|
| 603 | noattrib &= (~(SWP_SHOW | SWP_ZORDER)); | 
|---|
| 604 | noattrib |= SWP_HIDE; | 
|---|
| 605 | // count tools | 
|---|
| 606 | tool = toolhead; | 
|---|
| 607 | for (numtools = 0L; tool; numtools++) | 
|---|
| 608 | tool = tool->next; | 
|---|
| 609 | // allocate swp array for WinSetMultWindowPos | 
|---|
| 610 | swp = xmallocz(sizeof(SWP) * (numtools + 2), pszSrcFile, __LINE__); | 
|---|
| 611 | if (swp) { | 
|---|
| 612 | for (x = 0; x < numtools + 2L; x++) { | 
|---|
| 613 | swp[x].hwndInsertBehind = HWND_TOP; | 
|---|
| 614 | swp[x].fl = attrib; | 
|---|
| 615 | swp[x].y = (fToolTitles) ? 14L : 3L; | 
|---|
| 616 | swp[x].cx = 32L; | 
|---|
| 617 | swp[x].cy = 32L; | 
|---|
| 618 | } | 
|---|
| 619 | swp[0].x = swp[1].x = 2L; | 
|---|
| 620 | swp[0].y = (fTextTools) ? 14L : 18L; | 
|---|
| 621 | swp[1].y = (fTextTools) ? 1L : 2L; | 
|---|
| 622 | swp[0].cx = swp[1].cx = 14L; | 
|---|
| 623 | swp[0].cy = swp[1].cy = 14L; | 
|---|
| 624 | swp[0].hwnd = WinWindowFromID(hwnd, IDM_TOOLLEFT); | 
|---|
| 625 | swp[1].hwnd = WinWindowFromID(hwnd, IDM_TOOLRIGHT); | 
|---|
| 626 | x = 2L; | 
|---|
| 627 | tool = find_tool(firsttool); | 
|---|
| 628 | if (!tool) | 
|---|
| 629 | tool = toolhead; | 
|---|
| 630 | starttool = tool; | 
|---|
| 631 | while (tool) { | 
|---|
| 632 | if (!(tool->flags & T_INVISIBLE)) { | 
|---|
| 633 | swp[x].x = butx; | 
|---|
| 634 | if (fTextTools || (tool->flags & T_TEXT)) { | 
|---|
| 635 | butx += 55L; | 
|---|
| 636 | swp[x].cx = 54L; | 
|---|
| 637 | swp[x].cy = 24L; | 
|---|
| 638 | swp[x].y = 3L; | 
|---|
| 639 | } | 
|---|
| 640 | else | 
|---|
| 641 | butx += 33L; | 
|---|
| 642 | if (tool->flags & T_SEPARATOR) | 
|---|
| 643 | butx += 12; | 
|---|
| 644 | } | 
|---|
| 645 | else | 
|---|
| 646 | swp[x].fl = noattrib; | 
|---|
| 647 | swp[x].hwnd = WinWindowFromID(hwnd, tool->id); | 
|---|
| 648 | x++; | 
|---|
| 649 | tool = tool->next; | 
|---|
| 650 | } | 
|---|
| 651 | tool = toolhead; | 
|---|
| 652 | while (tool && tool != starttool) { | 
|---|
| 653 | swp[x].x = butx; | 
|---|
| 654 | if (!(tool->flags & T_INVISIBLE)) { | 
|---|
| 655 | if (fTextTools || (tool->flags & T_TEXT)) { | 
|---|
| 656 | butx += 55L; | 
|---|
| 657 | swp[x].cx = 54L; | 
|---|
| 658 | swp[x].cy = 24L; | 
|---|
| 659 | swp[x].y = 3L; | 
|---|
| 660 | } | 
|---|
| 661 | else | 
|---|
| 662 | butx += 33L; | 
|---|
| 663 | if (tool->flags & T_SEPARATOR) | 
|---|
| 664 | butx += 12; | 
|---|
| 665 | } | 
|---|
| 666 | else | 
|---|
| 667 | swp[x].fl = noattrib; | 
|---|
| 668 | swp[x].hwnd = WinWindowFromID(hwnd, tool->id); | 
|---|
| 669 | x++; | 
|---|
| 670 | tool = tool->next; | 
|---|
| 671 | } | 
|---|
| 672 | WinSetMultWindowPos(WinQueryAnchorBlock(hwnd), swp, numtools + 2L); | 
|---|
| 673 | if (!fTextTools && fToolTitles) { | 
|---|
| 674 | for (x = 2L; x < numtools + 2L; x++) { | 
|---|
| 675 | if (fTextTools || !fToolTitles) | 
|---|
| 676 | swp[x].fl = noattrib; | 
|---|
| 677 | else { | 
|---|
| 678 | tool = find_tool(WinQueryWindowUShort(swp[x].hwnd, QWS_ID)); | 
|---|
| 679 | if (tool && (tool->flags & T_TEXT)) | 
|---|
| 680 | swp[x].fl = noattrib; | 
|---|
| 681 | else { | 
|---|
| 682 | swp[x].hwndInsertBehind = HWND_TOP; | 
|---|
| 683 | swp[x].y = 1L; | 
|---|
| 684 | swp[x].cy = 10L; | 
|---|
| 685 | } | 
|---|
| 686 | } | 
|---|
| 687 | swp[x].hwnd = WinWindowFromID(hwnd, | 
|---|
| 688 | WinQueryWindowUShort(swp[x].hwnd, | 
|---|
| 689 | QWS_ID) + 25000); | 
|---|
| 690 | } | 
|---|
| 691 | WinSetMultWindowPos(WinQueryAnchorBlock(hwnd), &swp[2], numtools); | 
|---|
| 692 | } | 
|---|
| 693 | free(swp); | 
|---|
| 694 | } | 
|---|
| 695 | WinInvalidateRect(hwnd, NULL, TRUE); | 
|---|
| 696 | } | 
|---|
| 697 |  | 
|---|
| 698 | static MRESULT EXPENTRY DropDownListProc(HWND hwnd, ULONG msg, MPARAM mp1, | 
|---|
| 699 | MPARAM mp2) | 
|---|
| 700 | { | 
|---|
| 701 | PFNWP oldproc = (PFNWP) INSTDATA(hwnd); | 
|---|
| 702 | USHORT id; | 
|---|
| 703 |  | 
|---|
| 704 | static HWND hwndMenu = (HWND)0; | 
|---|
| 705 | static BOOL emphasized = FALSE; | 
|---|
| 706 |  | 
|---|
| 707 | switch (msg) { | 
|---|
| 708 | case WM_MOUSEMOVE: | 
|---|
| 709 | shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); | 
|---|
| 710 | break; | 
|---|
| 711 |  | 
|---|
| 712 | case WM_CHAR: | 
|---|
| 713 | shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL)); | 
|---|
| 714 | break; | 
|---|
| 715 |  | 
|---|
| 716 | case WM_MENUEND: | 
|---|
| 717 | if (hwndMenu == (HWND) mp2) { | 
|---|
| 718 | WinDestroyWindow(hwndMenu); | 
|---|
| 719 | hwndMenu = (HWND) 0; | 
|---|
| 720 | } | 
|---|
| 721 | break; | 
|---|
| 722 |  | 
|---|
| 723 | case WM_FOCUSCHANGE: | 
|---|
| 724 | { | 
|---|
| 725 | HAB hab = WinQueryAnchorBlock(hwnd); | 
|---|
| 726 | HWND hwndParent = WinQueryWindow(hwnd, QW_PARENT); | 
|---|
| 727 | HWND hwndFrame = WinQueryWindow(hwndParent, QW_PARENT); | 
|---|
| 728 | static HACCEL haccelSaved = NULLHANDLE; | 
|---|
| 729 | static HACCEL haccelDriveList = NULLHANDLE; | 
|---|
| 730 | static HACCEL haccelSetupList = NULLHANDLE; | 
|---|
| 731 | static HACCEL haccelUserList = NULLHANDLE; | 
|---|
| 732 | static HACCEL haccelCmdList = NULLHANDLE; | 
|---|
| 733 | static HACCEL haccelButtonList = NULLHANDLE; | 
|---|
| 734 | // DbgMsg(pszSrcFile, __LINE__, "WM_FOCUSCHANGE %u", SHORT1FROMMP(mp2)); | 
|---|
| 735 | id = WinQueryWindowUShort(hwndParent, QWS_ID); | 
|---|
| 736 | if (SHORT1FROMMP(mp2)) { | 
|---|
| 737 | // If getting focus 1st time - save original accelerator | 
|---|
| 738 | if (haccelSaved == NULLHANDLE) { | 
|---|
| 739 | haccelSaved = WinQueryAccelTable(hab, hwndFrame); | 
|---|
| 740 | if (haccelSaved == NULLHANDLE) | 
|---|
| 741 | Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinQueryAccelTable"); | 
|---|
| 742 | } | 
|---|
| 743 | if (haccelSaved != NULLHANDLE) { | 
|---|
| 744 | switch (id) { | 
|---|
| 745 | case MAIN_DRIVELIST: | 
|---|
| 746 | if (haccelDriveList == NULLHANDLE) { | 
|---|
| 747 | haccelDriveList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_DRIVELIST); | 
|---|
| 748 | if (haccelDriveList == NULLHANDLE) | 
|---|
| 749 | Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, PCSZ_WINLOADACCELTABLE); | 
|---|
| 750 | } | 
|---|
| 751 | if (haccelDriveList != NULLHANDLE) { | 
|---|
| 752 | if (!WinSetAccelTable(hab, haccelDriveList, hwndFrame)) | 
|---|
| 753 | Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, PCSZ_WINSETACCELTABLE); | 
|---|
| 754 | } | 
|---|
| 755 | break; | 
|---|
| 756 | case MAIN_SETUPLIST: | 
|---|
| 757 | if (haccelSetupList == NULLHANDLE) { | 
|---|
| 758 | haccelSetupList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_SETUPLIST); | 
|---|
| 759 | if (haccelSetupList == NULLHANDLE) | 
|---|
| 760 | Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, PCSZ_WINLOADACCELTABLE); | 
|---|
| 761 | } | 
|---|
| 762 | if (haccelSetupList != NULLHANDLE) { | 
|---|
| 763 | if (!WinSetAccelTable(hab, haccelSetupList, hwndFrame)) | 
|---|
| 764 | Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, PCSZ_WINSETACCELTABLE); | 
|---|
| 765 | } | 
|---|
| 766 | break; | 
|---|
| 767 | case MAIN_CMDLIST: | 
|---|
| 768 | if (haccelCmdList == NULLHANDLE) { | 
|---|
| 769 | haccelCmdList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_CMDLIST); | 
|---|
| 770 | if (haccelCmdList == NULLHANDLE) | 
|---|
| 771 | Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, PCSZ_WINLOADACCELTABLE); | 
|---|
| 772 | } | 
|---|
| 773 | if (haccelCmdList != NULLHANDLE) { | 
|---|
| 774 | if (!WinSetAccelTable(hab, haccelCmdList, hwndFrame)) | 
|---|
| 775 | Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, PCSZ_WINSETACCELTABLE); | 
|---|
| 776 | } | 
|---|
| 777 | break; | 
|---|
| 778 | case MAIN_USERLIST: | 
|---|
| 779 | if (haccelUserList == NULLHANDLE) { | 
|---|
| 780 | haccelUserList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_USERLIST); | 
|---|
| 781 | if (haccelUserList == NULLHANDLE) | 
|---|
| 782 | Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, PCSZ_WINLOADACCELTABLE); | 
|---|
| 783 | } | 
|---|
| 784 | if (haccelUserList != NULLHANDLE) { | 
|---|
| 785 | if (!WinSetAccelTable(hab, haccelUserList, hwndFrame)) | 
|---|
| 786 | Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, PCSZ_WINSETACCELTABLE); | 
|---|
| 787 | } | 
|---|
| 788 | break; | 
|---|
| 789 | case MAIN_BUTTONLIST: | 
|---|
| 790 | if (haccelButtonList == NULLHANDLE) { | 
|---|
| 791 | haccelButtonList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_BUTTONLIST); | 
|---|
| 792 | if (haccelButtonList == NULLHANDLE) | 
|---|
| 793 | Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, PCSZ_WINLOADACCELTABLE); | 
|---|
| 794 | } | 
|---|
| 795 | if (haccelButtonList != NULLHANDLE) { | 
|---|
| 796 | if (!WinSetAccelTable(hab, haccelButtonList, hwndFrame)) | 
|---|
| 797 | Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, PCSZ_WINSETACCELTABLE); | 
|---|
| 798 | } | 
|---|
| 799 | break; | 
|---|
| 800 | } // switch | 
|---|
| 801 | } | 
|---|
| 802 | } | 
|---|
| 803 | else { | 
|---|
| 804 | // Losing focus | 
|---|
| 805 | switch (id) { | 
|---|
| 806 | case MAIN_DRIVELIST: | 
|---|
| 807 | case MAIN_SETUPLIST: | 
|---|
| 808 | case MAIN_CMDLIST: | 
|---|
| 809 | case MAIN_USERLIST: | 
|---|
| 810 | case MAIN_BUTTONLIST: | 
|---|
| 811 | if (haccelSaved != NULLHANDLE) { | 
|---|
| 812 | if (!WinSetAccelTable(hab, haccelSaved, hwndFrame)) | 
|---|
| 813 | Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, PCSZ_WINSETACCELTABLE); | 
|---|
| 814 | } | 
|---|
| 815 | break; | 
|---|
| 816 | } // switch | 
|---|
| 817 | } | 
|---|
| 818 | } | 
|---|
| 819 | break; // WM_FOCUSCHANGE | 
|---|
| 820 |  | 
|---|
| 821 | case WM_CONTEXTMENU: | 
|---|
| 822 | { | 
|---|
| 823 | MRESULT ret = MRFROMSHORT(TRUE); | 
|---|
| 824 |  | 
|---|
| 825 | if (hwndMenu) | 
|---|
| 826 | WinDestroyWindow(hwndMenu); | 
|---|
| 827 | hwndMenu = (HWND) 0; | 
|---|
| 828 | id = WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID); | 
|---|
| 829 | switch (id) { | 
|---|
| 830 | case MAIN_CMDLIST: | 
|---|
| 831 | WinPostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd, | 
|---|
| 832 | QW_PARENT), | 
|---|
| 833 | QW_PARENT), | 
|---|
| 834 | FID_CLIENT), | 
|---|
| 835 | WM_COMMAND, MPFROM2SHORT(IDM_EDITCOMMANDS, 0), MPVOID); | 
|---|
| 836 | break; | 
|---|
| 837 | case MAIN_USERLIST: | 
|---|
| 838 | case MAIN_SETUPLIST: | 
|---|
| 839 | hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id); | 
|---|
| 840 | if (hwndMenu) | 
|---|
| 841 | PopupMenu(hwnd, | 
|---|
| 842 | WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd, | 
|---|
| 843 | QW_PARENT), | 
|---|
| 844 | QW_PARENT), | 
|---|
| 845 | FID_CLIENT), hwndMenu); | 
|---|
| 846 | break; | 
|---|
| 847 | default: | 
|---|
| 848 | ret = FALSE; | 
|---|
| 849 | break; | 
|---|
| 850 | } // switch | 
|---|
| 851 | return ret; | 
|---|
| 852 | } | 
|---|
| 853 |  | 
|---|
| 854 | case WM_CONTROL: | 
|---|
| 855 | if (hwndStatus2) { | 
|---|
| 856 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 857 | case CBID_EDIT: | 
|---|
| 858 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 859 | switch (SHORT2FROMMP(mp1)) { | 
|---|
| 860 | case EN_SETFOCUS: | 
|---|
| 861 | switch (id) { | 
|---|
| 862 | case MAIN_CMDLIST: | 
|---|
| 863 | WinSetWindowText(hwndStatus2, (CHAR *) GetPString(IDS_CMDLISTHELP)); | 
|---|
| 864 | break; | 
|---|
| 865 | case MAIN_SETUPLIST: | 
|---|
| 866 | WinSetWindowText(hwndStatus2, (CHAR *) GetPString(IDS_SETUPLISTHELP)); | 
|---|
| 867 | break; | 
|---|
| 868 | case MAIN_USERLIST: | 
|---|
| 869 | WinSetWindowText(hwndStatus2, (CHAR *) GetPString(IDS_USERLISTHELP)); | 
|---|
| 870 | break; | 
|---|
| 871 | case MAIN_DRIVELIST: | 
|---|
| 872 | WinSetWindowText(hwndStatus2, (CHAR *) GetPString(IDS_DRIVELISTHELP)); | 
|---|
| 873 | break; | 
|---|
| 874 | case MAIN_BUTTONLIST: | 
|---|
| 875 | WinSetWindowText(hwndStatus2, (CHAR *) GetPString(IDS_BUTTONLISTHELP)); | 
|---|
| 876 | break; | 
|---|
| 877 | default: | 
|---|
| 878 | break; | 
|---|
| 879 | } | 
|---|
| 880 | break; | 
|---|
| 881 |  | 
|---|
| 882 | default: | 
|---|
| 883 | break; | 
|---|
| 884 | } | 
|---|
| 885 | } | 
|---|
| 886 | break; | 
|---|
| 887 |  | 
|---|
| 888 | default: | 
|---|
| 889 | break; | 
|---|
| 890 | } | 
|---|
| 891 | break; | 
|---|
| 892 |  | 
|---|
| 893 | case WM_BEGINDRAG: | 
|---|
| 894 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 895 | if (id == CBID_EDIT && | 
|---|
| 896 | WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID) == | 
|---|
| 897 | MAIN_USERLIST) { | 
|---|
| 898 |  | 
|---|
| 899 | CHAR path[CCHMAXPATH]; | 
|---|
| 900 |  | 
|---|
| 901 | *path = 0; | 
|---|
| 902 | WinQueryWindowText(hwnd, CCHMAXPATH, path); | 
|---|
| 903 | bstrip(path); | 
|---|
| 904 | if (*path && !IsRoot(path)) | 
|---|
| 905 | DragOne(hwnd, (HWND) 0, path, FALSE); | 
|---|
| 906 | return 0; | 
|---|
| 907 | } | 
|---|
| 908 | break; | 
|---|
| 909 |  | 
|---|
| 910 | case DM_DRAGOVER: | 
|---|
| 911 | id = WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID); | 
|---|
| 912 | if (id == MAIN_USERLIST) { | 
|---|
| 913 | if (!emphasized) { | 
|---|
| 914 | emphasized = TRUE; | 
|---|
| 915 | DrawTargetEmphasis(hwnd, emphasized); | 
|---|
| 916 | } | 
|---|
| 917 | if (AcceptOneDrop(hwnd, mp1, mp2)) | 
|---|
| 918 | return MRFROM2SHORT(DOR_DROP, DO_MOVE); | 
|---|
| 919 | return MRFROM2SHORT(DOR_NEVERDROP, 0); | 
|---|
| 920 | } | 
|---|
| 921 | break; | 
|---|
| 922 |  | 
|---|
| 923 | case DM_DRAGLEAVE: | 
|---|
| 924 | id = WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID); | 
|---|
| 925 | if (id == MAIN_USERLIST) { | 
|---|
| 926 | if (emphasized) { | 
|---|
| 927 | emphasized = FALSE; | 
|---|
| 928 | DrawTargetEmphasis(hwnd, emphasized); | 
|---|
| 929 | } | 
|---|
| 930 | } | 
|---|
| 931 | break; | 
|---|
| 932 |  | 
|---|
| 933 | case DM_DROPHELP: | 
|---|
| 934 | id = WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID); | 
|---|
| 935 | if (id == MAIN_USERLIST) { | 
|---|
| 936 | DropHelp(mp1, mp2, hwnd, GetPString(IDS_USERLISTDROPHELP)); | 
|---|
| 937 | return 0; | 
|---|
| 938 | } | 
|---|
| 939 | break; | 
|---|
| 940 |  | 
|---|
| 941 | case DM_DROP: | 
|---|
| 942 | id = WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID); | 
|---|
| 943 | if (id == MAIN_USERLIST) { | 
|---|
| 944 |  | 
|---|
| 945 | char szFrom[CCHMAXPATH + 2]; | 
|---|
| 946 |  | 
|---|
| 947 | if (emphasized) { | 
|---|
| 948 | emphasized = FALSE; | 
|---|
| 949 | DrawTargetEmphasis(hwnd, emphasized); | 
|---|
| 950 | } | 
|---|
| 951 | if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom))) { | 
|---|
| 952 | MakeValidDir(szFrom); | 
|---|
| 953 | WinSetWindowText(hwnd, szFrom); | 
|---|
| 954 | PostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd, | 
|---|
| 955 | QW_PARENT), | 
|---|
| 956 | QW_PARENT), | 
|---|
| 957 | FID_CLIENT), | 
|---|
| 958 | UM_COMMAND, MPFROM2SHORT(IDM_ADDTOUSERLIST, 0), MPVOID); | 
|---|
| 959 | return 0; | 
|---|
| 960 | } | 
|---|
| 961 | } | 
|---|
| 962 | break; | 
|---|
| 963 |  | 
|---|
| 964 | case WM_DESTROY: | 
|---|
| 965 | if (hwndMenu) | 
|---|
| 966 | WinDestroyWindow(hwndMenu); | 
|---|
| 967 | hwndMenu = (HWND) 0; | 
|---|
| 968 | break; | 
|---|
| 969 | } | 
|---|
| 970 |  | 
|---|
| 971 | return oldproc(hwnd, msg, mp1, mp2); | 
|---|
| 972 | } | 
|---|
| 973 |  | 
|---|
| 974 | void BubbleHelp(HWND hwnd, BOOL other, BOOL drive, BOOL above, PCSZ help) | 
|---|
| 975 | { | 
|---|
| 976 | if (help && *help && | 
|---|
| 977 | ((drive && fDrivebarHelp) || | 
|---|
| 978 | (other && fOtherHelp) || (!other && !drive && fToolbarHelp))) { | 
|---|
| 979 | if ((!hwndBubble || | 
|---|
| 980 | WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) && | 
|---|
| 981 | !WinQueryCapture(HWND_DESKTOP)) | 
|---|
| 982 | MakeBubble(hwnd, above, help); | 
|---|
| 983 | } | 
|---|
| 984 | } | 
|---|
| 985 |  | 
|---|
| 986 | VOID MakeBubble(HWND hwnd, BOOL above, PCSZ help) | 
|---|
| 987 | { | 
|---|
| 988 | if (!hwnd || !help || !*help) | 
|---|
| 989 | return; | 
|---|
| 990 |  | 
|---|
| 991 | if (hwndBubble) | 
|---|
| 992 | WinDestroyWindow(hwndBubble); | 
|---|
| 993 |  | 
|---|
| 994 | { | 
|---|
| 995 | HWND hwndActive; | 
|---|
| 996 | char ucClassname[8]; | 
|---|
| 997 |  | 
|---|
| 998 | hwndActive = WinQueryActiveWindow(HWND_DESKTOP); | 
|---|
| 999 | if (hwndActive) { | 
|---|
| 1000 | // don't bring up help if window isn't active | 
|---|
| 1001 | if (!WinIsChild(hwnd, hwndActive)) | 
|---|
| 1002 | return; | 
|---|
| 1003 | } | 
|---|
| 1004 | hwndActive = WinQueryFocus(HWND_DESKTOP); | 
|---|
| 1005 | if (WinQueryClassName(hwndActive, sizeof(ucClassname), ucClassname)) { | 
|---|
| 1006 | // don't bring up help if a menu is active | 
|---|
| 1007 | if (!strcmp(ucClassname, "#4")) | 
|---|
| 1008 | return; | 
|---|
| 1009 | } | 
|---|
| 1010 | } | 
|---|
| 1011 |  | 
|---|
| 1012 | hwndBubble = WinCreateWindow(HWND_DESKTOP, | 
|---|
| 1013 | (CHAR *) WC_BUBBLE, | 
|---|
| 1014 | (CHAR *) help, | 
|---|
| 1015 | WS_CLIPSIBLINGS | SS_TEXT | | 
|---|
| 1016 | DT_CENTER | DT_VCENTER, | 
|---|
| 1017 | 0, | 
|---|
| 1018 | 0, | 
|---|
| 1019 | 0, | 
|---|
| 1020 | 0, | 
|---|
| 1021 | HWND_DESKTOP, HWND_TOP, MAIN_HELP, NULL, NULL); | 
|---|
| 1022 | if (!hwndBubble) | 
|---|
| 1023 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| 1024 | PCSZ_WINCREATEWINDOW); | 
|---|
| 1025 | else { | 
|---|
| 1026 | HPS hps; | 
|---|
| 1027 | POINTL aptl[TXTBOX_COUNT], ptl, tptl; | 
|---|
| 1028 | LONG lxScreen, sx, sy, extra = 0, lyScreen; | 
|---|
| 1029 | CHAR *p, *pp, *wp; | 
|---|
| 1030 | SWP swp; | 
|---|
| 1031 |  | 
|---|
| 1032 | WinQueryWindowPos(hwnd, &swp); | 
|---|
| 1033 | lyScreen = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN); | 
|---|
| 1034 | lxScreen = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN); | 
|---|
| 1035 | WinSetWindowULong(hwndBubble, QWL_USER, hwnd); | 
|---|
| 1036 | //fixme to allow user to change presparams 1-10-09 GKY | 
|---|
| 1037 | SetPresParams(hwndBubble, NULL, NULL, NULL, FNT_8HELVETICA); | 
|---|
| 1038 | hps = WinGetPS(hwndBubble); | 
|---|
| 1039 | // 03 Feb 09 SHL fixme to not overwrite? | 
|---|
| 1040 | p = (PSZ)help; | 
|---|
| 1041 | tptl.x = tptl.y = 0; | 
|---|
| 1042 | while (p && *p) { | 
|---|
| 1043 | wp = NULL; | 
|---|
| 1044 | pp = strchr(p, '\r'); | 
|---|
| 1045 | if (pp) { | 
|---|
| 1046 | wp = pp; | 
|---|
| 1047 | *pp = 0; | 
|---|
| 1048 | pp++; | 
|---|
| 1049 | } | 
|---|
| 1050 | GpiQueryTextBox(hps, strlen(p), p, TXTBOX_COUNT, aptl); | 
|---|
| 1051 | tptl.x = max(aptl[TXTBOX_TOPRIGHT].x, tptl.x); | 
|---|
| 1052 | if (tptl.y) | 
|---|
| 1053 | tptl.y += extra; | 
|---|
| 1054 | else | 
|---|
| 1055 | extra = aptl[TXTBOX_TOPLEFT].y / 4; | 
|---|
| 1056 | tptl.y += aptl[TXTBOX_TOPLEFT].y; | 
|---|
| 1057 | if (wp) | 
|---|
| 1058 | *wp = '\r'; | 
|---|
| 1059 | p = pp; | 
|---|
| 1060 | } | 
|---|
| 1061 | WinSetWindowULong(hwndBubble, QWL_USER + 4, extra); | 
|---|
| 1062 | WinReleasePS(hps); | 
|---|
| 1063 | ptl.x = ptl.y = 0; | 
|---|
| 1064 | WinMapWindowPoints(hwnd, HWND_DESKTOP, &ptl, 1); | 
|---|
| 1065 | if (above) { | 
|---|
| 1066 | sy = ptl.y + swp.cy + 4; | 
|---|
| 1067 | if (sy + tptl.y + 12 > lyScreen) { | 
|---|
| 1068 | above = FALSE; | 
|---|
| 1069 | sy = ptl.y - (tptl.y + 14); | 
|---|
| 1070 | } | 
|---|
| 1071 | } | 
|---|
| 1072 | else | 
|---|
| 1073 | sy = ptl.y - (tptl.y + 14); | 
|---|
| 1074 | if (ptl.x > (lxScreen / 2)) | 
|---|
| 1075 | sx = (ptl.x - tptl.x) - 16; | 
|---|
| 1076 | else | 
|---|
| 1077 | sx = ptl.x + (54 * (above == FALSE)) + 2; | 
|---|
| 1078 | if (sx < 0) | 
|---|
| 1079 | sx = 0; | 
|---|
| 1080 | if (sx + tptl.x + 14 > lxScreen) | 
|---|
| 1081 | sx = lxScreen - (tptl.x + 14); | 
|---|
| 1082 | if (sy < 0) { | 
|---|
| 1083 | sy = ptl.y + swp.cy + 4; | 
|---|
| 1084 | if (sy + tptl.y + 12 > lyScreen) | 
|---|
| 1085 | sy = 0; | 
|---|
| 1086 | } | 
|---|
| 1087 | WinSetWindowPos(hwndBubble, HWND_TOP, sx, sy, | 
|---|
| 1088 | tptl.x + 14, | 
|---|
| 1089 | tptl.y + 12, | 
|---|
| 1090 | SWP_DEACTIVATE | SWP_SHOW | SWP_ZORDER | | 
|---|
| 1091 | SWP_MOVE | SWP_SIZE); | 
|---|
| 1092 | } | 
|---|
| 1093 | } | 
|---|
| 1094 |  | 
|---|
| 1095 | MRESULT EXPENTRY BubbleProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 1096 | { | 
|---|
| 1097 | switch (msg) { | 
|---|
| 1098 | case WM_SETFOCUS: | 
|---|
| 1099 | if (mp2) | 
|---|
| 1100 | PostMsg(hwnd, UM_FOCUSME, mp1, MPVOID); | 
|---|
| 1101 | break; | 
|---|
| 1102 |  | 
|---|
| 1103 | case UM_FOCUSME: | 
|---|
| 1104 | WinSetFocus(HWND_DESKTOP, (HWND) mp1); | 
|---|
| 1105 | return 0; | 
|---|
| 1106 |  | 
|---|
| 1107 | case WM_MOUSEMOVE: | 
|---|
| 1108 | WinShowWindow(hwnd, FALSE); | 
|---|
| 1109 | break; | 
|---|
| 1110 |  | 
|---|
| 1111 | case UM_TIMER: | 
|---|
| 1112 | { | 
|---|
| 1113 | POINTL ptl; | 
|---|
| 1114 |  | 
|---|
| 1115 | WinQueryPointerPos(HWND_DESKTOP, &ptl); | 
|---|
| 1116 | if (WinWindowFromPoint(HWND_DESKTOP, &ptl, TRUE) != | 
|---|
| 1117 | WinQueryWindowULong(hwnd, QWL_USER) || !WinIsWindowVisible(hwnd)) | 
|---|
| 1118 | WinDestroyWindow(hwnd); | 
|---|
| 1119 | } | 
|---|
| 1120 | return 0; | 
|---|
| 1121 |  | 
|---|
| 1122 | case WM_PAINT: | 
|---|
| 1123 | { | 
|---|
| 1124 | HPS hps; | 
|---|
| 1125 | SWP swp; | 
|---|
| 1126 | POINTL ptl, aptl[TXTBOX_COUNT]; | 
|---|
| 1127 | CHAR *s, *p, *pp, *wp; | 
|---|
| 1128 | ULONG extra, tlen, y; | 
|---|
| 1129 |  | 
|---|
| 1130 | hps = WinBeginPaint(hwnd, (HPS) 0, NULL); | 
|---|
| 1131 | if (hps) { | 
|---|
| 1132 | WinQueryWindowPos(hwnd, &swp); | 
|---|
| 1133 | GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, 0); | 
|---|
| 1134 | GpiSetColor(hps, ((255 << 16) | (255 << 8) | 198)); | 
|---|
| 1135 | GpiSetBackMix(hps, BM_LEAVEALONE); | 
|---|
| 1136 | GpiSetMix(hps, FM_OVERPAINT); | 
|---|
| 1137 | ptl.x = ptl.y = 0; | 
|---|
| 1138 | GpiMove(hps, &ptl); | 
|---|
| 1139 | ptl.x = swp.cx - 1; | 
|---|
| 1140 | ptl.y = swp.cy - 1; | 
|---|
| 1141 | GpiBox(hps, DRO_OUTLINEFILL, &ptl, 0, 0); | 
|---|
| 1142 | tlen = WinQueryWindowTextLength(hwnd); | 
|---|
| 1143 | if (tlen) { | 
|---|
| 1144 | s = xmalloc(tlen + 2, pszSrcFile, __LINE__); | 
|---|
| 1145 | if (s) { | 
|---|
| 1146 | WinQueryWindowText(hwnd, tlen + 1, s); | 
|---|
| 1147 | if (*s) { | 
|---|
| 1148 | p = s; | 
|---|
| 1149 | y = swp.cy - 3; | 
|---|
| 1150 | extra = WinQueryWindowULong(hwnd, QWL_USER + 4); | 
|---|
| 1151 | GpiSetColor(hps, 0); | 
|---|
| 1152 | GpiSetMix(hps, FM_OVERPAINT); | 
|---|
| 1153 | while (p && *p) { | 
|---|
| 1154 | wp = NULL; | 
|---|
| 1155 | pp = strchr(p, '\r'); | 
|---|
| 1156 | if (pp) { | 
|---|
| 1157 | wp = pp; | 
|---|
| 1158 | *pp = 0; | 
|---|
| 1159 | pp++; | 
|---|
| 1160 | } | 
|---|
| 1161 | GpiQueryTextBox(hps, strlen(p), p, TXTBOX_COUNT, aptl); | 
|---|
| 1162 | ptl.x = 7; | 
|---|
| 1163 | y -= aptl[TXTBOX_TOPLEFT].y; | 
|---|
| 1164 | if (p != s) | 
|---|
| 1165 | y -= extra; | 
|---|
| 1166 | ptl.y = y; | 
|---|
| 1167 | GpiCharStringAt(hps, &ptl, strlen(p), p); | 
|---|
| 1168 | if (wp) | 
|---|
| 1169 | *wp = '\r'; | 
|---|
| 1170 | p = pp; | 
|---|
| 1171 | } | 
|---|
| 1172 | } | 
|---|
| 1173 | free(s); | 
|---|
| 1174 | } | 
|---|
| 1175 | } | 
|---|
| 1176 | if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE)) && swp.cx > 6 && swp.cy > 6) { | 
|---|
| 1177 | GpiSetColor(hps, CLR_WHITE); | 
|---|
| 1178 | ptl.x = 1; | 
|---|
| 1179 | ptl.y = 1; | 
|---|
| 1180 | GpiMove(hps, &ptl); | 
|---|
| 1181 | ptl.y = swp.cy - 2; | 
|---|
| 1182 | GpiLine(hps, &ptl); | 
|---|
| 1183 | ptl.x = swp.cx - 2; | 
|---|
| 1184 | GpiLine(hps, &ptl); | 
|---|
| 1185 | ptl.x = 2; | 
|---|
| 1186 | ptl.y = 2; | 
|---|
| 1187 | GpiMove(hps, &ptl); | 
|---|
| 1188 | ptl.y = swp.cy - 3; | 
|---|
| 1189 | GpiLine(hps, &ptl); | 
|---|
| 1190 | ptl.x = swp.cx - 3; | 
|---|
| 1191 | GpiLine(hps, &ptl); | 
|---|
| 1192 | GpiSetColor(hps, CLR_BROWN); | 
|---|
| 1193 | ptl.x = 1; | 
|---|
| 1194 | ptl.y = 1; | 
|---|
| 1195 | GpiMove(hps, &ptl); | 
|---|
| 1196 | ptl.x = swp.cx - 2; | 
|---|
| 1197 | GpiLine(hps, &ptl); | 
|---|
| 1198 | ptl.y = swp.cy - 2; | 
|---|
| 1199 | GpiLine(hps, &ptl); | 
|---|
| 1200 | ptl.x = 2; | 
|---|
| 1201 | ptl.y = 2; | 
|---|
| 1202 | GpiMove(hps, &ptl); | 
|---|
| 1203 | ptl.x = swp.cx - 3; | 
|---|
| 1204 | GpiLine(hps, &ptl); | 
|---|
| 1205 | ptl.y = swp.cy - 3; | 
|---|
| 1206 | GpiLine(hps, &ptl); | 
|---|
| 1207 | } | 
|---|
| 1208 | WinEndPaint(hps); | 
|---|
| 1209 | } | 
|---|
| 1210 | } | 
|---|
| 1211 | return 0; | 
|---|
| 1212 |  | 
|---|
| 1213 | case WM_CLOSE: | 
|---|
| 1214 | WinDestroyWindow(hwnd); | 
|---|
| 1215 | return 0; | 
|---|
| 1216 |  | 
|---|
| 1217 | case WM_DESTROY: | 
|---|
| 1218 | hwndBubble = (HWND) 0; | 
|---|
| 1219 | break; | 
|---|
| 1220 | } | 
|---|
| 1221 | return PFNWPStatic(hwnd, msg, mp1, mp2); | 
|---|
| 1222 | } | 
|---|
| 1223 |  | 
|---|
| 1224 | MRESULT EXPENTRY LEDProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 1225 | { | 
|---|
| 1226 | switch (msg) { | 
|---|
| 1227 | case WM_CREATE: | 
|---|
| 1228 | { | 
|---|
| 1229 | MRESULT mr = PFNWPStatic(hwnd, msg, mp1, mp2); | 
|---|
| 1230 |  | 
|---|
| 1231 | switch (WinQueryWindowUShort(hwnd, QWS_ID)) { | 
|---|
| 1232 | case MAIN_LED: | 
|---|
| 1233 | { | 
|---|
| 1234 | HPS hps = WinGetPS(hwnd); | 
|---|
| 1235 | HBITMAP hbmold = (HBITMAP)WinSendMsg(hwnd, SM_QUERYHANDLE, MPVOID, MPVOID); | 
|---|
| 1236 | if (!fBlueLED) { | 
|---|
| 1237 | hbmLEDon = GpiLoadBitmap(hps, 0, LEDON_BMP, 12, 12); | 
|---|
| 1238 | hbmLEDoff = GpiLoadBitmap(hps, 0, LEDOFF_BMP, 12, 12); | 
|---|
| 1239 | } | 
|---|
| 1240 | else { | 
|---|
| 1241 | hbmLEDon = GpiLoadBitmap(hps, 0, LEDON2_BMP, 12, 12); | 
|---|
| 1242 | hbmLEDoff = GpiLoadBitmap(hps, 0, LEDOFF2_BMP, 12, 12); | 
|---|
| 1243 | } | 
|---|
| 1244 | if (hbmLEDoff && hbmLEDon) | 
|---|
| 1245 | WinSendMsg(hwnd, SM_SETHANDLE, MPFROMLONG(hbmLEDoff), MPVOID); | 
|---|
| 1246 | else { | 
|---|
| 1247 | if (hbmLEDoff) | 
|---|
| 1248 | GpiDeleteBitmap(hbmLEDoff); | 
|---|
| 1249 | if (hbmLEDon) | 
|---|
| 1250 | GpiDeleteBitmap(hbmLEDon); | 
|---|
| 1251 | } | 
|---|
| 1252 | if (hbmold && | 
|---|
| 1253 | hbmLEDon && | 
|---|
| 1254 | hbmLEDoff && hbmold != hbmLEDon && hbmold != hbmLEDoff) | 
|---|
| 1255 | GpiDeleteBitmap(hbmold); | 
|---|
| 1256 | if (hps) | 
|---|
| 1257 | WinReleasePS(hps); | 
|---|
| 1258 | } | 
|---|
| 1259 | break; | 
|---|
| 1260 | default: | 
|---|
| 1261 | //fixme to allow user to change presparams 1-10-09 GKY | 
|---|
| 1262 | SetPresParams(hwnd, | 
|---|
| 1263 | &RGBGREY, | 
|---|
| 1264 | &RGBBLACK, &RGBGREY, FNT_6HELVETICA ); | 
|---|
| 1265 | break; | 
|---|
| 1266 | } | 
|---|
| 1267 | return mr; | 
|---|
| 1268 | } | 
|---|
| 1269 |  | 
|---|
| 1270 | case WM_SETFOCUS: | 
|---|
| 1271 | if (mp2) | 
|---|
| 1272 | PostMsg(hwnd, UM_FOCUSME, mp1, MPVOID); | 
|---|
| 1273 | break; | 
|---|
| 1274 |  | 
|---|
| 1275 | case UM_FOCUSME: | 
|---|
| 1276 | WinSetFocus(HWND_DESKTOP, (HWND) mp1); | 
|---|
| 1277 | return 0; | 
|---|
| 1278 |  | 
|---|
| 1279 | case WM_MOUSEMOVE: | 
|---|
| 1280 | BubbleHelp(hwnd, TRUE, FALSE, FALSE, GetPString(IDS_LEDHELP)); | 
|---|
| 1281 | if (!fNoFinger) { | 
|---|
| 1282 | WinSetPointer(HWND_DESKTOP, hptrFinger); | 
|---|
| 1283 | return MRFROMLONG(TRUE); | 
|---|
| 1284 | } | 
|---|
| 1285 | break; | 
|---|
| 1286 |  | 
|---|
| 1287 | case WM_BUTTON1CLICK: | 
|---|
| 1288 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 1289 | WM_COMMAND, MPFROM2SHORT(IDM_SHOWNOTEWND, 0), MPVOID); | 
|---|
| 1290 | break; | 
|---|
| 1291 |  | 
|---|
| 1292 | case WM_BUTTON2CLICK: | 
|---|
| 1293 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 1294 | WM_COMMAND, MPFROM2SHORT(IDM_HIDENOTEWND, 0), MPVOID); | 
|---|
| 1295 | break; | 
|---|
| 1296 |  | 
|---|
| 1297 | case WM_CHORD: | 
|---|
| 1298 | case WM_BUTTON3CLICK: | 
|---|
| 1299 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 1300 | WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID); | 
|---|
| 1301 | break; | 
|---|
| 1302 | } | 
|---|
| 1303 | return PFNWPStatic(hwnd, msg, mp1, mp2); | 
|---|
| 1304 | } | 
|---|
| 1305 |  | 
|---|
| 1306 | MRESULT EXPENTRY ChildButtonProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 1307 | { | 
|---|
| 1308 | USHORT id; | 
|---|
| 1309 | TOOL *tool; | 
|---|
| 1310 |  | 
|---|
| 1311 | static HWND hwndMenu = (HWND) 0; | 
|---|
| 1312 |  | 
|---|
| 1313 | switch (msg) { | 
|---|
| 1314 | case WM_BUTTON1DOWN: | 
|---|
| 1315 | case WM_BUTTON2DOWN: | 
|---|
| 1316 | case WM_BUTTON3DOWN: | 
|---|
| 1317 | shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); | 
|---|
| 1318 | break; | 
|---|
| 1319 |  | 
|---|
| 1320 | case WM_MOUSEMOVE: | 
|---|
| 1321 | if (fToolbarHelp) { | 
|---|
| 1322 | if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) | 
|---|
| 1323 | && !WinQueryCapture(HWND_DESKTOP)) { | 
|---|
| 1324 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 1325 | tool = find_tool(id); | 
|---|
| 1326 | if (tool && tool->help && *tool->help) { | 
|---|
| 1327 |  | 
|---|
| 1328 | char s[128]; | 
|---|
| 1329 |  | 
|---|
| 1330 | strcpy(s, tool->help); | 
|---|
| 1331 | if (tool->flags & T_DROPABLE) | 
|---|
| 1332 | strcat(s, GetPString(IDS_DROPONMETEXT)); | 
|---|
| 1333 | MakeBubble(hwnd, FALSE, s); | 
|---|
| 1334 | } | 
|---|
| 1335 | } | 
|---|
| 1336 | } | 
|---|
| 1337 | break; | 
|---|
| 1338 |  | 
|---|
| 1339 | case WM_COMMAND: | 
|---|
| 1340 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 1341 | case IDM_HELP: | 
|---|
| 1342 | if (hwndHelp) | 
|---|
| 1343 | WinSendMsg(hwndHelp, | 
|---|
| 1344 | HM_DISPLAY_HELP, | 
|---|
| 1345 | MPFROM2SHORT(HELP_TOOLBAR, 0), MPFROMSHORT(HM_RESOURCEID)); | 
|---|
| 1346 | break; | 
|---|
| 1347 |  | 
|---|
| 1348 | case IDM_HIDEANYTOOL:               // hide any tool | 
|---|
| 1349 | case IDM_HIDETOOL:                  // hide tool | 
|---|
| 1350 | if (SHORT1FROMMP(mp1) == IDM_HIDETOOL) | 
|---|
| 1351 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 1352 | else | 
|---|
| 1353 | id = (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, | 
|---|
| 1354 | PickToolProc, FM3ModHandle, | 
|---|
| 1355 | PICKBTN_FRAME, (PSZ)GetPString(IDS_HIDETEXT)); | 
|---|
| 1356 | if (id) { | 
|---|
| 1357 | tool = find_tool(id); | 
|---|
| 1358 | if (tool) { | 
|---|
| 1359 | tool->flags |= T_INVISIBLE; | 
|---|
| 1360 | save_tools(NULL); | 
|---|
| 1361 | } | 
|---|
| 1362 | } | 
|---|
| 1363 | break; | 
|---|
| 1364 |  | 
|---|
| 1365 | case IDM_SHOWTOOLS:                 // show all tools | 
|---|
| 1366 | tool = toolhead; | 
|---|
| 1367 | while (tool) { | 
|---|
| 1368 | tool->flags &= (~T_INVISIBLE); | 
|---|
| 1369 | tool = tool->next; | 
|---|
| 1370 | } | 
|---|
| 1371 | save_tools(NULL); | 
|---|
| 1372 | break; | 
|---|
| 1373 |  | 
|---|
| 1374 | case IDM_DELETEANYTOOL:             // delete any button | 
|---|
| 1375 | case IDM_DELETETOOL:                // delete button | 
|---|
| 1376 | if (SHORT1FROMMP(mp1) == IDM_DELETETOOL) | 
|---|
| 1377 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 1378 | else | 
|---|
| 1379 | id = | 
|---|
| 1380 | (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, PickToolProc, FM3ModHandle, | 
|---|
| 1381 | PICKBTN_FRAME, (PSZ)GetPString(IDS_DELETETEXT)); | 
|---|
| 1382 | if (id) | 
|---|
| 1383 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), UM_SETUP, | 
|---|
| 1384 | MPFROM2SHORT(id, 0), MPVOID); | 
|---|
| 1385 | return 0; | 
|---|
| 1386 |  | 
|---|
| 1387 | case IDM_EDITANYTOOL:               // edit any button | 
|---|
| 1388 | case IDM_EDITTOOL:                  // edit button | 
|---|
| 1389 | if (SHORT1FROMMP(mp1) == IDM_EDITTOOL) | 
|---|
| 1390 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 1391 | else | 
|---|
| 1392 | id = | 
|---|
| 1393 | (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, PickToolProc, FM3ModHandle, | 
|---|
| 1394 | PICKBTN_FRAME, (PSZ)GetPString(IDS_EDITTEXT)); | 
|---|
| 1395 | if (id) { | 
|---|
| 1396 | tool = find_tool(id); | 
|---|
| 1397 | if (tool) { | 
|---|
| 1398 | if (WinDlgBox(HWND_DESKTOP, hwnd, AddToolProc, FM3ModHandle, | 
|---|
| 1399 | ADDBTN_FRAME, (PVOID) tool)) | 
|---|
| 1400 | WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd, | 
|---|
| 1401 | QW_PARENT), | 
|---|
| 1402 | QW_PARENT), FID_CLIENT), | 
|---|
| 1403 | WM_COMMAND, MPFROM2SHORT(IDM_CREATETOOL, 0), | 
|---|
| 1404 | MPFROM2SHORT(id, 0)); | 
|---|
| 1405 | } | 
|---|
| 1406 | } | 
|---|
| 1407 | break; | 
|---|
| 1408 |  | 
|---|
| 1409 | case IDM_ADDTOOL:                   // add tool | 
|---|
| 1410 | id = (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, AddToolProc, FM3ModHandle, | 
|---|
| 1411 | ADDBTN_FRAME, MPVOID); | 
|---|
| 1412 | if (id && id != (USHORT) - 1) | 
|---|
| 1413 | WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd, | 
|---|
| 1414 | QW_PARENT), | 
|---|
| 1415 | QW_PARENT), FID_CLIENT), | 
|---|
| 1416 | WM_COMMAND, MPFROM2SHORT(IDM_CREATETOOL, 0), | 
|---|
| 1417 | MPFROM2SHORT(id, 0)); | 
|---|
| 1418 | break; | 
|---|
| 1419 |  | 
|---|
| 1420 | case IDM_REORDERTOOLS:              // reorder tools | 
|---|
| 1421 | WinDlgBox(HWND_DESKTOP, | 
|---|
| 1422 | hwnd, ReOrderToolsProc, FM3ModHandle, RE_FRAME, MPVOID); | 
|---|
| 1423 | break; | 
|---|
| 1424 |  | 
|---|
| 1425 | case IDM_SAVETOOLS: | 
|---|
| 1426 | case IDM_LOADTOOLS: | 
|---|
| 1427 | if (WinDlgBox(HWND_DESKTOP, | 
|---|
| 1428 | hwnd, | 
|---|
| 1429 | ToolIODlgProc, | 
|---|
| 1430 | FM3ModHandle, | 
|---|
| 1431 | SVBTN_FRAME, | 
|---|
| 1432 | (PVOID) (SHORT1FROMMP(mp1) == IDM_SAVETOOLS) ? | 
|---|
| 1433 | "TRUE" : NULL)) | 
|---|
| 1434 | PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID); | 
|---|
| 1435 | break; | 
|---|
| 1436 | } | 
|---|
| 1437 | ResizeTools(WinQueryWindow(hwnd, QW_PARENT)); | 
|---|
| 1438 | return 0; | 
|---|
| 1439 |  | 
|---|
| 1440 | case WM_MENUEND: | 
|---|
| 1441 | if (hwndMenu == (HWND) mp2) { | 
|---|
| 1442 | WinDestroyWindow(hwndMenu); | 
|---|
| 1443 | hwndMenu = (HWND) 0; | 
|---|
| 1444 | } | 
|---|
| 1445 | break; | 
|---|
| 1446 |  | 
|---|
| 1447 | case WM_CONTEXTMENU: | 
|---|
| 1448 | DosRequestMutexSem(hmtxFM2Globals, SEM_INDEFINITE_WAIT); | 
|---|
| 1449 | if (!hwndMenu) | 
|---|
| 1450 | hwndMenu = WinLoadMenu(hwnd, FM3ModHandle, ID_BUTTONMENU); | 
|---|
| 1451 | DosReleaseMutexSem(hmtxFM2Globals); | 
|---|
| 1452 | //fixme to allow user to change font 1-10-09 GKY | 
|---|
| 1453 | SetPresParams(hwndMenu, NULL, NULL, NULL, FNT_10SYSTEMPROPORT); | 
|---|
| 1454 | if (PopupMenu(hwnd, hwnd, hwndMenu)) | 
|---|
| 1455 | WinShowWindow(hwndMenu, TRUE); | 
|---|
| 1456 | return MRFROMSHORT(TRUE); | 
|---|
| 1457 |  | 
|---|
| 1458 | case DM_DRAGOVER: | 
|---|
| 1459 | { | 
|---|
| 1460 | PDRAGINFO pDInfo;                 // Pointer to DRAGINFO | 
|---|
| 1461 |  | 
|---|
| 1462 | pDInfo = (PDRAGINFO) mp1;         // Get DRAGINFO pointer | 
|---|
| 1463 | DrgAccessDraginfo(pDInfo);        // Access DRAGINFO | 
|---|
| 1464 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 1465 | tool = find_tool(id); | 
|---|
| 1466 | if (!tool) { | 
|---|
| 1467 | DrgFreeDraginfo(pDInfo); | 
|---|
| 1468 | return (MRFROM2SHORT(DOR_NEVERDROP, 0));        // Drop not valid | 
|---|
| 1469 | } | 
|---|
| 1470 | if (!(tool->flags & T_DROPABLE)) { | 
|---|
| 1471 | DrgFreeDraginfo(pDInfo); | 
|---|
| 1472 | return (MRFROM2SHORT(DOR_NEVERDROP, 0));        // Drop not valid | 
|---|
| 1473 | } | 
|---|
| 1474 | { | 
|---|
| 1475 | PDRAGITEM pDItem;               // Pointer to DRAGITEM | 
|---|
| 1476 |  | 
|---|
| 1477 | pDItem = DrgQueryDragitemPtr(pDInfo,    // Access DRAGITEM | 
|---|
| 1478 | 0);        // Index to DRAGITEM | 
|---|
| 1479 | if (DrgVerifyRMF(pDItem,                // Check valid rendering | 
|---|
| 1480 | (CHAR *) DRM_OS2FILE,  // mechanisms and data | 
|---|
| 1481 | NULL)) {               // formats | 
|---|
| 1482 | if (!(tool->flags & T_EMPHASIZED)) { | 
|---|
| 1483 | tool->flags |= T_EMPHASIZED; | 
|---|
| 1484 | DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0)); | 
|---|
| 1485 | DrgFreeDraginfo(pDInfo); | 
|---|
| 1486 | } | 
|---|
| 1487 | return (MRFROM2SHORT(DOR_DROP,        // Return okay to drop | 
|---|
| 1488 | DO_MOVE));       // Move operation valid | 
|---|
| 1489 | } | 
|---|
| 1490 | DrgFreeDraginfo(pDInfo); | 
|---|
| 1491 | } | 
|---|
| 1492 | } | 
|---|
| 1493 | return (MRFROM2SHORT(DOR_NEVERDROP, 0));    // Drop not valid | 
|---|
| 1494 |  | 
|---|
| 1495 | case DM_DROPHELP: | 
|---|
| 1496 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 1497 | tool = find_tool(id); | 
|---|
| 1498 | PFNWPButton(hwnd, msg, mp1, mp2); | 
|---|
| 1499 | DropHelp(mp1, mp2, hwnd, GetPString(IDS_TOOLDROPHELP)); | 
|---|
| 1500 | return 0; | 
|---|
| 1501 |  | 
|---|
| 1502 | case DM_DRAGLEAVE: | 
|---|
| 1503 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 1504 | tool = find_tool(id); | 
|---|
| 1505 | if (tool && (tool->flags & T_DROPABLE)) { | 
|---|
| 1506 | if (tool->flags & T_EMPHASIZED) { | 
|---|
| 1507 | tool->flags &= (~T_EMPHASIZED); | 
|---|
| 1508 | DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0)); | 
|---|
| 1509 | } | 
|---|
| 1510 | } | 
|---|
| 1511 | break; | 
|---|
| 1512 |  | 
|---|
| 1513 | case DM_DROP: | 
|---|
| 1514 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 1515 | tool = find_tool(id); | 
|---|
| 1516 | if (tool && (tool->flags & T_DROPABLE) != 0) { | 
|---|
| 1517 | LISTINFO *li; | 
|---|
| 1518 | CNRDRAGINFO cdi; | 
|---|
| 1519 |  | 
|---|
| 1520 | if (tool->flags & T_EMPHASIZED) { | 
|---|
| 1521 | DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0)); | 
|---|
| 1522 | tool->flags &= (~T_EMPHASIZED); | 
|---|
| 1523 | } | 
|---|
| 1524 | memset(&cdi, 0, sizeof(cdi)); | 
|---|
| 1525 | cdi.pDragInfo = mp1; | 
|---|
| 1526 | li = DoFileDrop(hwnd, NULL, FALSE, mp1, MPFROMP(&cdi)); | 
|---|
| 1527 | CheckPmDrgLimit(cdi.pDragInfo); | 
|---|
| 1528 | if (li) { | 
|---|
| 1529 | li->type = id; | 
|---|
| 1530 | if (!li->list || !li->list[0]) | 
|---|
| 1531 | FreeListInfo(li); | 
|---|
| 1532 | else { | 
|---|
| 1533 | HWND hwndActive; | 
|---|
| 1534 |  | 
|---|
| 1535 | hwndActive = TopWindow(hwndMain, (HWND) 0); | 
|---|
| 1536 | if (hwndActive) { | 
|---|
| 1537 | if (!WinSendMsg(hwndActive, UM_COMMAND, MPFROMP(li), MPVOID)) | 
|---|
| 1538 | FreeListInfo(li); | 
|---|
| 1539 | } | 
|---|
| 1540 | else | 
|---|
| 1541 | FreeListInfo(li); | 
|---|
| 1542 | } | 
|---|
| 1543 | } | 
|---|
| 1544 | } | 
|---|
| 1545 | return 0; | 
|---|
| 1546 |  | 
|---|
| 1547 | case WM_CLOSE: | 
|---|
| 1548 | WinDestroyWindow(hwnd); | 
|---|
| 1549 | return 0; | 
|---|
| 1550 | } | 
|---|
| 1551 | return PFNWPButton(hwnd, msg, mp1, mp2); | 
|---|
| 1552 | } | 
|---|
| 1553 |  | 
|---|
| 1554 | static VOID BuildTools(HWND hwndT, BOOL resize) | 
|---|
| 1555 | { | 
|---|
| 1556 | TOOL *tool; | 
|---|
| 1557 | ULONG ctrlxpos = 18L; | 
|---|
| 1558 | CHAR s[33]; | 
|---|
| 1559 | HENUM henum; | 
|---|
| 1560 | HWND hwndTool; | 
|---|
| 1561 |  | 
|---|
| 1562 | henum = WinBeginEnumWindows(hwndT); | 
|---|
| 1563 | while ((hwndTool = WinGetNextWindow(henum)) != NULLHANDLE) | 
|---|
| 1564 | if (!WinDestroyWindow(hwndTool)) | 
|---|
| 1565 | Runtime_Error(pszSrcFile, __LINE__, "Unable to destroy toolbar button"); | 
|---|
| 1566 | WinEndEnumWindows(henum); | 
|---|
| 1567 | if (!fToolbar) { | 
|---|
| 1568 | load_quicktools(); | 
|---|
| 1569 | load_tools(NULL); | 
|---|
| 1570 | return; | 
|---|
| 1571 | } | 
|---|
| 1572 | if (!toolhead) | 
|---|
| 1573 | load_tools(NULL); | 
|---|
| 1574 | tool = toolhead; | 
|---|
| 1575 | while (tool) { | 
|---|
| 1576 | sprintf(s, "#%u", tool->id); | 
|---|
| 1577 | hwndTool = (HWND) 0; | 
|---|
| 1578 | if (!fTextTools) { | 
|---|
| 1579 | if (!(tool->flags & T_MYICON)) { | 
|---|
| 1580 | hwndTool = WinCreateWindow(hwndT, | 
|---|
| 1581 | (CHAR *) WC_TOOLBUTTONS, | 
|---|
| 1582 | s, | 
|---|
| 1583 | BS_NOPOINTERFOCUS | | 
|---|
| 1584 | BS_BITMAP | BS_PUSHBUTTON, | 
|---|
| 1585 | ctrlxpos, | 
|---|
| 1586 | 14, | 
|---|
| 1587 | 32, | 
|---|
| 1588 | 32, hwndT, HWND_TOP, tool->id, NULL, NULL); | 
|---|
| 1589 | } | 
|---|
| 1590 | if (!hwndTool) { | 
|---|
| 1591 | HBITMAP hbm = LoadBitmapFromFileIdentifier(tool->id, tool->text); | 
|---|
| 1592 |  | 
|---|
| 1593 | if (hbm) { | 
|---|
| 1594 | BTNCDATA btc; | 
|---|
| 1595 |  | 
|---|
| 1596 | memset(&btc, 0, sizeof(btc)); | 
|---|
| 1597 | btc.cb = sizeof(btc); | 
|---|
| 1598 | btc.hImage = hbm; | 
|---|
| 1599 | hwndTool = WinCreateWindow(hwndT, | 
|---|
| 1600 | (CHAR *) WC_TOOLBUTTONS, | 
|---|
| 1601 | NullStr, | 
|---|
| 1602 | BS_NOPOINTERFOCUS | | 
|---|
| 1603 | BS_BITMAP | BS_PUSHBUTTON, | 
|---|
| 1604 | ctrlxpos, | 
|---|
| 1605 | 14, | 
|---|
| 1606 | 32, | 
|---|
| 1607 | 32, | 
|---|
| 1608 | hwndT, HWND_TOP, tool->id, &btc, NULL); | 
|---|
| 1609 | if (!hwndTool) | 
|---|
| 1610 | GpiDeleteBitmap(hbm); | 
|---|
| 1611 | } | 
|---|
| 1612 | } | 
|---|
| 1613 | if (hwndTool) | 
|---|
| 1614 | tool->flags &= (~T_TEXT); | 
|---|
| 1615 | } | 
|---|
| 1616 | if (!hwndTool) { | 
|---|
| 1617 | hwndTool = WinCreateWindow(hwndT, | 
|---|
| 1618 | (CHAR *) WC_TOOLBUTTONS, | 
|---|
| 1619 | (!tool->text && tool->id >= IDM_COMMANDSTART | 
|---|
| 1620 | && tool->id < | 
|---|
| 1621 | IDM_QUICKTOOLSTART) ? command_title(tool->id - | 
|---|
| 1622 | IDM_COMMANDSTART) | 
|---|
| 1623 | : tool->text, | 
|---|
| 1624 | BS_NOPOINTERFOCUS | BS_PUSHBUTTON, ctrlxpos, | 
|---|
| 1625 | 2, 54, 24, hwndT, HWND_TOP, tool->id, NULL, | 
|---|
| 1626 | NULL); | 
|---|
| 1627 | if (!hwndTool) | 
|---|
| 1628 | Win_Error(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| 1629 | PCSZ_WINCREATEWINDOW); | 
|---|
| 1630 | tool->flags |= T_TEXT; | 
|---|
| 1631 | } | 
|---|
| 1632 | if (fToolTitles && !fTextTools) { | 
|---|
| 1633 | hwndTool = WinCreateWindow(hwndT, | 
|---|
| 1634 | (CHAR *) WC_STATIC, | 
|---|
| 1635 | tool->text, | 
|---|
| 1636 | SS_TEXT | DT_LEFT | DT_VCENTER, | 
|---|
| 1637 | ctrlxpos, | 
|---|
| 1638 | 1, | 
|---|
| 1639 | 32, | 
|---|
| 1640 | 10, | 
|---|
| 1641 | hwndT, | 
|---|
| 1642 | HWND_TOP, tool->id + 25000, NULL, NULL); | 
|---|
| 1643 | if (!hwndTool) | 
|---|
| 1644 | Win_Error(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| 1645 | PCSZ_WINCREATEWINDOW); | 
|---|
| 1646 | else { | 
|---|
| 1647 | SetPresParams(hwndTool, | 
|---|
| 1648 | &RGBGREY, | 
|---|
| 1649 | &RGBBLACK, &RGBGREY, FNT_2SYSTEMVIO); | 
|---|
| 1650 | } | 
|---|
| 1651 | } | 
|---|
| 1652 | ctrlxpos += ((tool->flags & T_TEXT) ? 55L : 33L); | 
|---|
| 1653 | //fixme to allow user to change presparams 1-10-09 GKY | 
|---|
| 1654 | SetPresParams(WinWindowFromID(hwndT, tool->id), | 
|---|
| 1655 | NULL, NULL, NULL, FNT_8HELVETICA); | 
|---|
| 1656 | tool = tool->next; | 
|---|
| 1657 | }                                     // while tool | 
|---|
| 1658 |  | 
|---|
| 1659 | hwndTool = WinCreateWindow(hwndT, | 
|---|
| 1660 | (CHAR *) WC_BUTTON, | 
|---|
| 1661 | "#6010", | 
|---|
| 1662 | BS_NOPOINTERFOCUS | | 
|---|
| 1663 | BS_BITMAP | BS_PUSHBUTTON, | 
|---|
| 1664 | 1, | 
|---|
| 1665 | 19, | 
|---|
| 1666 | 14, | 
|---|
| 1667 | 13, hwndT, HWND_TOP, IDM_TOOLLEFT, NULL, NULL); | 
|---|
| 1668 | if (!hwndTool) | 
|---|
| 1669 | Win_Error(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| 1670 | PCSZ_WINCREATEWINDOW); | 
|---|
| 1671 | hwndTool = | 
|---|
| 1672 | WinCreateWindow(hwndT, (CHAR *) WC_BUTTON, "#6011", | 
|---|
| 1673 | BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON, 1, 4, 14, | 
|---|
| 1674 | 13, hwndT, HWND_TOP, IDM_TOOLRIGHT, NULL, NULL); | 
|---|
| 1675 | if (!hwndTool) | 
|---|
| 1676 | Win_Error(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| 1677 | PCSZ_WINCREATEWINDOW); | 
|---|
| 1678 | if (resize) | 
|---|
| 1679 | ResizeTools(hwndT); | 
|---|
| 1680 | } | 
|---|
| 1681 |  | 
|---|
| 1682 | static MRESULT EXPENTRY CommandLineProc(HWND hwnd, ULONG msg, MPARAM mp1, | 
|---|
| 1683 | MPARAM mp2) | 
|---|
| 1684 | { | 
|---|
| 1685 | PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| 1686 | static BOOL lbup = FALSE; | 
|---|
| 1687 |  | 
|---|
| 1688 | switch (msg) { | 
|---|
| 1689 | case UM_FOCUSME: | 
|---|
| 1690 | WinSetFocus(HWND_DESKTOP, hwnd); | 
|---|
| 1691 | return 0; | 
|---|
| 1692 |  | 
|---|
| 1693 | case WM_SETFOCUS: | 
|---|
| 1694 | if (!mp2 && !lbup) { | 
|---|
| 1695 |  | 
|---|
| 1696 | PID pid; | 
|---|
| 1697 | TID tid; | 
|---|
| 1698 |  | 
|---|
| 1699 | if (WinQueryWindowUShort((HWND) mp1, QWS_ID) == COMMAND_BUTTON) | 
|---|
| 1700 | break; | 
|---|
| 1701 | if (!WinQueryWindowProcess((HWND) mp1, &pid, &tid) || pid == mypid) | 
|---|
| 1702 | WinDestroyWindow(hwnd); | 
|---|
| 1703 | } | 
|---|
| 1704 | break; | 
|---|
| 1705 |  | 
|---|
| 1706 | case UM_RESCAN: | 
|---|
| 1707 | { | 
|---|
| 1708 | PSZ pszCmdLine; | 
|---|
| 1709 |  | 
|---|
| 1710 | pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__); | 
|---|
| 1711 | if (pszCmdLine) { | 
|---|
| 1712 | lbup = TRUE; | 
|---|
| 1713 | if (WinDlgBox(HWND_DESKTOP, | 
|---|
| 1714 | hwnd, | 
|---|
| 1715 | CmdLine2DlgProc, | 
|---|
| 1716 | FM3ModHandle, EXEC2_FRAME, MPFROMP(pszCmdLine))) { | 
|---|
| 1717 | lstrip(pszCmdLine); | 
|---|
| 1718 | WinSetWindowText(hwnd, pszCmdLine); | 
|---|
| 1719 | } | 
|---|
| 1720 | PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID); | 
|---|
| 1721 | PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID); | 
|---|
| 1722 | free(pszCmdLine); | 
|---|
| 1723 | } | 
|---|
| 1724 | } | 
|---|
| 1725 | return 0; | 
|---|
| 1726 |  | 
|---|
| 1727 | case UM_SETUP: | 
|---|
| 1728 | lbup = FALSE; | 
|---|
| 1729 | return 0; | 
|---|
| 1730 |  | 
|---|
| 1731 | case WM_BUTTON1DBLCLK: | 
|---|
| 1732 | PostMsg(hwnd, UM_OPENWINDOWFORME, MPVOID, MPVOID); | 
|---|
| 1733 | return 0; | 
|---|
| 1734 |  | 
|---|
| 1735 | case WM_COMMAND: | 
|---|
| 1736 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 1737 | case COMMAND_BUTTON: | 
|---|
| 1738 | if (!lbup) | 
|---|
| 1739 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID); | 
|---|
| 1740 | break; | 
|---|
| 1741 | } | 
|---|
| 1742 | return 0; | 
|---|
| 1743 |  | 
|---|
| 1744 | case UM_OPENWINDOWFORME: | 
|---|
| 1745 | { | 
|---|
| 1746 | static char directory[CCHMAXPATH], cl[1000]; | 
|---|
| 1747 | char **list = NULL; | 
|---|
| 1748 | ULONG len; | 
|---|
| 1749 | HWND hwndCnr; | 
|---|
| 1750 |  | 
|---|
| 1751 | *directory = *cl = 0; | 
|---|
| 1752 | strcpy(cl, GetCmdSpec(FALSE)); | 
|---|
| 1753 | strcat(cl, " /C "); | 
|---|
| 1754 | len = strlen(cl); | 
|---|
| 1755 | WinQueryWindowText(hwnd, 1000 - len, cl + len); | 
|---|
| 1756 | bstrip(cl + len); | 
|---|
| 1757 | if (strlen(cl) > len) { | 
|---|
| 1758 | WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 1759 | UM_SETUP, MPFROMP(cl + len), MPVOID); | 
|---|
| 1760 | WinQueryWindowText(hwndStatus, CCHMAXPATH, directory); | 
|---|
| 1761 | bstrip(directory); | 
|---|
| 1762 | if (*directory && (IsRoot(directory) || !IsFile(directory))) { | 
|---|
| 1763 | if (!FM2Command(directory, cl + len)) { | 
|---|
| 1764 | hwndCnr = TopWindow(hwndMain, (HWND) 0); | 
|---|
| 1765 | if (hwndCnr) { | 
|---|
| 1766 | hwndCnr = WinWindowFromID(hwndCnr, FID_CLIENT); | 
|---|
| 1767 | if (hwndCnr) { | 
|---|
| 1768 | hwndCnr = WinWindowFromID(hwndCnr, DIR_CNR); | 
|---|
| 1769 | if (hwndCnr) | 
|---|
| 1770 | list = BuildList(hwndCnr); | 
|---|
| 1771 | } | 
|---|
| 1772 | } | 
|---|
| 1773 | WinSetActiveWindow(HWND_DESKTOP, hwndCnr); | 
|---|
| 1774 | if (add_cmdline(cl + len, FALSE) && fSaveMiniCmds) | 
|---|
| 1775 | save_cmdlines(FALSE); | 
|---|
| 1776 | ExecOnList(hwndCnr, | 
|---|
| 1777 | cl, | 
|---|
| 1778 | WINDOWED | ((fKeepCmdLine) ? | 
|---|
| 1779 | SEPARATEKEEP : SEPARATE), | 
|---|
| 1780 | directory, NULL, list, NULL, pszSrcFile, __LINE__); | 
|---|
| 1781 | xfree(list, pszSrcFile, __LINE__); | 
|---|
| 1782 | WinDestroyWindow(hwnd); | 
|---|
| 1783 | break; | 
|---|
| 1784 | } | 
|---|
| 1785 | } | 
|---|
| 1786 | } | 
|---|
| 1787 | WinSendMsg(hwnd, EM_SETSEL, MPFROM2SHORT(0, 1024), MPVOID); | 
|---|
| 1788 | } | 
|---|
| 1789 | return 0; | 
|---|
| 1790 |  | 
|---|
| 1791 | case WM_CHAR: | 
|---|
| 1792 | if (!lbup && !(SHORT1FROMMP(mp1) & KC_KEYUP)) { | 
|---|
| 1793 | if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) { | 
|---|
| 1794 | if ((SHORT1FROMMP(mp2) & 255) == '\r') | 
|---|
| 1795 | PostMsg(hwnd, UM_OPENWINDOWFORME, MPVOID, MPVOID); | 
|---|
| 1796 | else if ((SHORT1FROMMP(mp2) & 0xff) == 0x1b) | 
|---|
| 1797 | WinDestroyWindow(hwnd); | 
|---|
| 1798 | else if (SHORT2FROMMP(mp2) == VK_UP || SHORT2FROMMP(mp2) == VK_DOWN) | 
|---|
| 1799 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID); | 
|---|
| 1800 | } | 
|---|
| 1801 | } | 
|---|
| 1802 | else if ((SHORT1FROMMP(mp1) & KC_VIRTUALKEY) && | 
|---|
| 1803 | ((SHORT2FROMMP(mp2) == VK_UP || | 
|---|
| 1804 | SHORT2FROMMP(mp2) == VK_DOWN) || | 
|---|
| 1805 | (SHORT1FROMMP(mp2) == '\x1b') || (SHORT1FROMMP(mp2) == '\r'))) | 
|---|
| 1806 | return 0; | 
|---|
| 1807 | break; | 
|---|
| 1808 |  | 
|---|
| 1809 | case WM_DESTROY: | 
|---|
| 1810 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), UM_RESCAN, MPVOID, MPVOID); | 
|---|
| 1811 | lbup = FALSE; | 
|---|
| 1812 | break; | 
|---|
| 1813 | } | 
|---|
| 1814 | return oldproc(hwnd, msg, mp1, mp2); | 
|---|
| 1815 | } | 
|---|
| 1816 |  | 
|---|
| 1817 | MRESULT EXPENTRY DriveBackProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 1818 | { | 
|---|
| 1819 | static BOOL emphasized = FALSE; | 
|---|
| 1820 |  | 
|---|
| 1821 | switch (msg) { | 
|---|
| 1822 | case WM_CREATE: | 
|---|
| 1823 | PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID); | 
|---|
| 1824 | break; | 
|---|
| 1825 |  | 
|---|
| 1826 | case UM_SETUP: | 
|---|
| 1827 | { | 
|---|
| 1828 | RGB2 rgb; | 
|---|
| 1829 |  | 
|---|
| 1830 | memset(&rgb, 0, sizeof(rgb)); | 
|---|
| 1831 | rgb.bRed = (BYTE)128; | 
|---|
| 1832 | //fixme to allow user to change presparams 1-10-09 GKY | 
|---|
| 1833 | SetPresParams(hwnd, | 
|---|
| 1834 | &RGBGREY, &rgb, &RGBGREY, FNT_8HELVETICA); | 
|---|
| 1835 | SetTargetDir(hwnd, TRUE, NULL); | 
|---|
| 1836 | } | 
|---|
| 1837 | return 0; | 
|---|
| 1838 |  | 
|---|
| 1839 | case WM_SETFOCUS: | 
|---|
| 1840 | case UM_FOCUSME: | 
|---|
| 1841 | case WM_BUTTON1DOWN: | 
|---|
| 1842 | case WM_BUTTON1UP: | 
|---|
| 1843 | case WM_BUTTON2DOWN: | 
|---|
| 1844 | case WM_BUTTON2UP: | 
|---|
| 1845 | case WM_BUTTON3DOWN: | 
|---|
| 1846 | case WM_BUTTON3UP: | 
|---|
| 1847 | return CommonTextButton(hwnd, msg, mp1, mp2); | 
|---|
| 1848 |  | 
|---|
| 1849 | case WM_MOUSEMOVE: | 
|---|
| 1850 | shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL)); | 
|---|
| 1851 | break; | 
|---|
| 1852 |  | 
|---|
| 1853 | case UM_CLICKED: | 
|---|
| 1854 | case UM_CLICKED3: | 
|---|
| 1855 | PostMsg(hwndMain, WM_COMMAND, MPFROM2SHORT(IDM_SETTARGET, 0), MPVOID); | 
|---|
| 1856 | return 0; | 
|---|
| 1857 |  | 
|---|
| 1858 | case DM_DRAGOVER: | 
|---|
| 1859 | if (!emphasized) { | 
|---|
| 1860 | emphasized = TRUE; | 
|---|
| 1861 | DrawTargetEmphasis(hwnd, emphasized); | 
|---|
| 1862 | } | 
|---|
| 1863 | if (AcceptOneDrop(hwnd, mp1, mp2)) | 
|---|
| 1864 | return MRFROM2SHORT(DOR_DROP, DO_MOVE); | 
|---|
| 1865 | return MRFROM2SHORT(DOR_NEVERDROP, 0); | 
|---|
| 1866 |  | 
|---|
| 1867 | case DM_DRAGLEAVE: | 
|---|
| 1868 | if (emphasized) { | 
|---|
| 1869 | emphasized = FALSE; | 
|---|
| 1870 | DrawTargetEmphasis(hwnd, emphasized); | 
|---|
| 1871 | } | 
|---|
| 1872 | break; | 
|---|
| 1873 |  | 
|---|
| 1874 | case DM_DROPHELP: | 
|---|
| 1875 | if (mp1) { | 
|---|
| 1876 |  | 
|---|
| 1877 | CNRDRAGINFO cnd; | 
|---|
| 1878 | ULONG numitems; | 
|---|
| 1879 | USHORT usOperation; | 
|---|
| 1880 |  | 
|---|
| 1881 | cnd.pDragInfo = (PDRAGINFO) mp1; | 
|---|
| 1882 | if (!DrgAccessDraginfo((PDRAGINFO) cnd.pDragInfo)) { | 
|---|
| 1883 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, | 
|---|
| 1884 | PCSZ_DRGACCESSDRAGINFO); | 
|---|
| 1885 | return 0; | 
|---|
| 1886 | } | 
|---|
| 1887 | numitems = DrgQueryDragitemCount((PDRAGINFO) cnd.pDragInfo); | 
|---|
| 1888 | usOperation = cnd.pDragInfo->usOperation; | 
|---|
| 1889 | if (usOperation == DO_DEFAULT) | 
|---|
| 1890 | usOperation = fCopyDefault ? DO_COPY : DO_MOVE; | 
|---|
| 1891 | saymsg(MB_ENTER | MB_ICONASTERISK, | 
|---|
| 1892 | hwnd, | 
|---|
| 1893 | GetPString(IDS_DROPHELPHDRTEXT), | 
|---|
| 1894 | GetPString(IDS_DROPHELPTEXT), | 
|---|
| 1895 | numitems, | 
|---|
| 1896 | &"s"[numitems == 1L], | 
|---|
| 1897 | NullStr, | 
|---|
| 1898 | NullStr, | 
|---|
| 1899 | targetdir, | 
|---|
| 1900 | " ", | 
|---|
| 1901 | GetPString((usOperation == DO_MOVE) ? | 
|---|
| 1902 | IDS_MOVETEXT : | 
|---|
| 1903 | (usOperation == DO_LINK) ? | 
|---|
| 1904 | IDS_LINKTEXT : IDS_COPYTEXT)); | 
|---|
| 1905 | } | 
|---|
| 1906 | return 0; | 
|---|
| 1907 |  | 
|---|
| 1908 |  | 
|---|
| 1909 | case DM_DROP: | 
|---|
| 1910 | if (targetdir && strlen(targetdir) > 2) { | 
|---|
| 1911 | CNRDRAGINFO cnd; | 
|---|
| 1912 | LISTINFO *li; | 
|---|
| 1913 | ULONG action = UM_ACTION, ret; | 
|---|
| 1914 |  | 
|---|
| 1915 | if (emphasized) { | 
|---|
| 1916 | emphasized = FALSE; | 
|---|
| 1917 | DrawTargetEmphasis(hwnd, emphasized); | 
|---|
| 1918 | } | 
|---|
| 1919 | memset(&cnd, 0, sizeof(cnd)); | 
|---|
| 1920 | cnd.pDragInfo = (PDRAGINFO) mp1; | 
|---|
| 1921 | cnd.pRecord = NULL; | 
|---|
| 1922 | li = DoFileDrop(hwnd, | 
|---|
| 1923 | NULL, | 
|---|
| 1924 | TRUE, MPFROM2SHORT(TREE_CNR, CN_DROP), MPFROMP(&cnd)); | 
|---|
| 1925 | CheckPmDrgLimit(cnd.pDragInfo); | 
|---|
| 1926 | if (li) { | 
|---|
| 1927 | if (!li->list[1] && !IsFile(li->list[0])) { | 
|---|
| 1928 | ret = saymsg(MB_YESNO, | 
|---|
| 1929 | HWND_DESKTOP, | 
|---|
| 1930 | NullStr, | 
|---|
| 1931 | GetPString(IDS_DROPSETSTARGET)); | 
|---|
| 1932 | if (ret == MBID_YES) { | 
|---|
| 1933 | SetTargetDir(hwnd, TRUE, li->list[0]); | 
|---|
| 1934 | break; | 
|---|
| 1935 | } | 
|---|
| 1936 | } | 
|---|
| 1937 | strcpy(li->targetpath, targetdir); | 
|---|
| 1938 | strcat(li->targetpath, PCSZ_BACKSLASH); | 
|---|
| 1939 | if (li->list && li->list[0] && IsRoot(li->list[0])) | 
|---|
| 1940 | li->type = DO_LINK; | 
|---|
| 1941 | else if (fDragndropDlg && (!*li->arcname || !li->info)) { | 
|---|
| 1942 |  | 
|---|
| 1943 | CHECKLIST cl; | 
|---|
| 1944 |  | 
|---|
| 1945 | memset(&cl, 0, sizeof(cl)); | 
|---|
| 1946 | cl.size = sizeof(cl); | 
|---|
| 1947 | cl.flags = li->type; | 
|---|
| 1948 | cl.list = li->list; | 
|---|
| 1949 | cl.cmd = li->type; | 
|---|
| 1950 | cl.prompt = li->targetpath; | 
|---|
| 1951 | li->type = WinDlgBox(HWND_DESKTOP, | 
|---|
| 1952 | hwndMain, | 
|---|
| 1953 | DropListProc, | 
|---|
| 1954 | FM3ModHandle, DND_FRAME, MPFROMP(&cl)); | 
|---|
| 1955 | if (li->type == DID_ERROR) | 
|---|
| 1956 | Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| 1957 | GetPString(IDS_DRAGDROPDIALOGTEXT)); | 
|---|
| 1958 | if (!li->type) { | 
|---|
| 1959 | FreeListInfo(li); | 
|---|
| 1960 | return 0; | 
|---|
| 1961 | } | 
|---|
| 1962 | li->list = cl.list; | 
|---|
| 1963 | if (!li->list || !li->list[0]) { | 
|---|
| 1964 | FreeListInfo(li); | 
|---|
| 1965 | return 0; | 
|---|
| 1966 | } | 
|---|
| 1967 | } | 
|---|
| 1968 | else { | 
|---|
| 1969 | FreeListInfo(li); | 
|---|
| 1970 | return 0; | 
|---|
| 1971 | } | 
|---|
| 1972 | } | 
|---|
| 1973 | switch (li->type) { | 
|---|
| 1974 | case DND_LAUNCH: | 
|---|
| 1975 | strcat(li->targetpath, " %a"); | 
|---|
| 1976 | ExecOnList(hwndMain, | 
|---|
| 1977 | li->targetpath, PROMPT | WINDOWED, NULL, NULL, li->list, NULL, | 
|---|
| 1978 | pszSrcFile, __LINE__); | 
|---|
| 1979 | FreeList(li->list); | 
|---|
| 1980 | li->list = NULL; | 
|---|
| 1981 | break; | 
|---|
| 1982 | case DO_LINK: | 
|---|
| 1983 | if (fLinkSetsIcon) { | 
|---|
| 1984 | li->type = IDM_SETICON; | 
|---|
| 1985 | action = UM_MASSACTION; | 
|---|
| 1986 | } | 
|---|
| 1987 | else | 
|---|
| 1988 | li->type = IDM_COMPARE; | 
|---|
| 1989 | break; | 
|---|
| 1990 | case DND_EXTRACT: | 
|---|
| 1991 | if (*li->targetpath && !IsFile(li->targetpath)) | 
|---|
| 1992 | li->type = IDM_EXTRACT; | 
|---|
| 1993 | break; | 
|---|
| 1994 | case DND_MOVE: | 
|---|
| 1995 | li->type = IDM_MOVE; | 
|---|
| 1996 | if (*li->targetpath && IsFile(li->targetpath) == 1) { | 
|---|
| 1997 | action = UM_MASSACTION; | 
|---|
| 1998 | li->type = IDM_ARCHIVEM; | 
|---|
| 1999 | } | 
|---|
| 2000 | break; | 
|---|
| 2001 | case DND_WILDMOVE: | 
|---|
| 2002 | li->type = IDM_WILDMOVE; | 
|---|
| 2003 | if (*li->targetpath && IsFile(li->targetpath) == 1) { | 
|---|
| 2004 | action = UM_MASSACTION; | 
|---|
| 2005 | li->type = IDM_ARCHIVEM; | 
|---|
| 2006 | } | 
|---|
| 2007 | break; | 
|---|
| 2008 | case DND_OBJECT: | 
|---|
| 2009 | li->type = IDM_OBJECT; | 
|---|
| 2010 | action = UM_MASSACTION; | 
|---|
| 2011 | break; | 
|---|
| 2012 | case DND_SHADOW: | 
|---|
| 2013 | li->type = IDM_SHADOW; | 
|---|
| 2014 | action = UM_MASSACTION; | 
|---|
| 2015 | break; | 
|---|
| 2016 | case DND_COMPARE: | 
|---|
| 2017 | li->type = IDM_COMPARE; | 
|---|
| 2018 | break; | 
|---|
| 2019 | case DND_SETICON: | 
|---|
| 2020 | action = UM_MASSACTION; | 
|---|
| 2021 | li->type = IDM_SETICON; | 
|---|
| 2022 | break; | 
|---|
| 2023 | case DND_COPY: | 
|---|
| 2024 | li->type = IDM_COPY; | 
|---|
| 2025 | if (*li->targetpath && IsFile(li->targetpath) == 1) { | 
|---|
| 2026 | action = UM_MASSACTION; | 
|---|
| 2027 | li->type = IDM_ARCHIVE; | 
|---|
| 2028 | } | 
|---|
| 2029 | break; | 
|---|
| 2030 | case DND_WILDCOPY: | 
|---|
| 2031 | li->type = IDM_WILDCOPY; | 
|---|
| 2032 | if (*li->targetpath && IsFile(li->targetpath) == 1) { | 
|---|
| 2033 | action = UM_MASSACTION; | 
|---|
| 2034 | li->type = IDM_ARCHIVE; | 
|---|
| 2035 | } | 
|---|
| 2036 | break; | 
|---|
| 2037 | default: | 
|---|
| 2038 | if (*li->arcname && li->info) { | 
|---|
| 2039 | action = UM_MASSACTION; | 
|---|
| 2040 | li->type = (li->type == DO_MOVE) ? IDM_FAKEEXTRACTM : | 
|---|
| 2041 | IDM_FAKEEXTRACT; | 
|---|
| 2042 | } | 
|---|
| 2043 | else if (*li->targetpath && IsFile(li->targetpath) == 1) { | 
|---|
| 2044 | action = UM_MASSACTION; | 
|---|
| 2045 | li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE; | 
|---|
| 2046 | } | 
|---|
| 2047 | else | 
|---|
| 2048 | li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY; | 
|---|
| 2049 | break; | 
|---|
| 2050 | } | 
|---|
| 2051 | if (!li->list || !li->list[0]) | 
|---|
| 2052 | FreeListInfo(li); | 
|---|
| 2053 | else | 
|---|
| 2054 | WinSendMsg(hwndTree, UM_ACTION, MPFROMP(li), MPFROMLONG(action)); | 
|---|
| 2055 | } | 
|---|
| 2056 | else { | 
|---|
| 2057 | CNRDRAGINFO cnd; | 
|---|
| 2058 | LISTINFO *li; | 
|---|
| 2059 |  | 
|---|
| 2060 | if (emphasized) { | 
|---|
| 2061 | emphasized = FALSE; | 
|---|
| 2062 | DrawTargetEmphasis(hwnd, emphasized); | 
|---|
| 2063 | } | 
|---|
| 2064 | memset(&cnd, 0, sizeof(cnd)); | 
|---|
| 2065 | cnd.pDragInfo = (PDRAGINFO) mp1; | 
|---|
| 2066 | cnd.pRecord = NULL; | 
|---|
| 2067 | li = DoFileDrop(hwnd, | 
|---|
| 2068 | NULL, | 
|---|
| 2069 | TRUE, MPFROM2SHORT(TREE_CNR, CN_DROP), MPFROMP(&cnd)); | 
|---|
| 2070 | CheckPmDrgLimit(cnd.pDragInfo); | 
|---|
| 2071 | if (li && !li->list[1] && !IsFile(li->list[0])) | 
|---|
| 2072 | SetTargetDir(hwnd, TRUE, li->list[0]); | 
|---|
| 2073 | else | 
|---|
| 2074 | saymsg(MB_ENTER | MB_ICONASTERISK, hwnd, | 
|---|
| 2075 | GetPString(IDS_WARNINGTEXT), | 
|---|
| 2076 | GetPString(IDS_NOTARGETSET)); | 
|---|
| 2077 | } | 
|---|
| 2078 | break; | 
|---|
| 2079 |  | 
|---|
| 2080 | case WM_CHAR: | 
|---|
| 2081 | shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL)); | 
|---|
| 2082 | break; | 
|---|
| 2083 |  | 
|---|
| 2084 | case WM_CONTROLPOINTER: | 
|---|
| 2085 | if (!fNoFinger && | 
|---|
| 2086 | (SHORT1FROMMP(mp1) >= IDM_DRIVEA && | 
|---|
| 2087 | SHORT1FROMMP(mp1) < IDM_DRIVEA + 26)) | 
|---|
| 2088 | return MRFROMLONG(hptrFinger); | 
|---|
| 2089 | break; | 
|---|
| 2090 |  | 
|---|
| 2091 | case WM_COMMAND: | 
|---|
| 2092 | DosWaitEventSem(hevTreeCnrScanComplete, SEM_INDEFINITE_WAIT); | 
|---|
| 2093 | switch(SHORT1FROMMP(mp1)) { | 
|---|
| 2094 | case IDM_RESCAN: | 
|---|
| 2095 | { | 
|---|
| 2096 | BOOL toggleTree = FALSE; | 
|---|
| 2097 |  | 
|---|
| 2098 | if (!hwndTree) { | 
|---|
| 2099 | WinSendMsg(hwndMain, WM_COMMAND, MPFROM2SHORT(IDM_VTREE, 0), MPVOID); | 
|---|
| 2100 | toggleTree = TRUE; | 
|---|
| 2101 | } | 
|---|
| 2102 | WinSendMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_RESCAN, 0), MPVOID); | 
|---|
| 2103 | if (toggleTree) | 
|---|
| 2104 | WinSendMsg(hwndMain, WM_COMMAND, MPFROM2SHORT(IDM_VTREE, 0), MPVOID); | 
|---|
| 2105 | } | 
|---|
| 2106 | break; | 
|---|
| 2107 | case IDM_REFRESHREMOVABLES: | 
|---|
| 2108 | { | 
|---|
| 2109 | BOOL toggleTree = FALSE; | 
|---|
| 2110 |  | 
|---|
| 2111 | if (!hwndTree) { | 
|---|
| 2112 | WinSendMsg(hwndMain, WM_COMMAND, MPFROM2SHORT(IDM_VTREE, 0), MPVOID); | 
|---|
| 2113 | toggleTree = TRUE; | 
|---|
| 2114 | } | 
|---|
| 2115 | WinSendMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_REFRESHREMOVABLES, 0), MPVOID); | 
|---|
| 2116 | if (toggleTree) | 
|---|
| 2117 | WinSendMsg(hwndMain, WM_COMMAND, MPFROM2SHORT(IDM_VTREE, 0), MPVOID); | 
|---|
| 2118 | } | 
|---|
| 2119 | break; | 
|---|
| 2120 | default: | 
|---|
| 2121 | { | 
|---|
| 2122 | CHAR dv[4]; | 
|---|
| 2123 |  | 
|---|
| 2124 | *dv = SHORT1FROMMP(mp1) - IDM_DRIVEA + 'A'; | 
|---|
| 2125 | strcpy(dv + 1, ":\\"); | 
|---|
| 2126 | if (isalpha(*dv)) { | 
|---|
| 2127 |  | 
|---|
| 2128 | HWND hwndActive; | 
|---|
| 2129 |  | 
|---|
| 2130 | dv[1] = ':'; | 
|---|
| 2131 | dv[2] = '\\'; | 
|---|
| 2132 | dv[3] = 0; | 
|---|
| 2133 | hwndActive = TopWindow(hwnd, (HWND) 0); | 
|---|
| 2134 | if (hwndActive) | 
|---|
| 2135 | WinSendMsg(WinWindowFromID(hwndActive, FID_CLIENT), | 
|---|
| 2136 | UM_DRIVECMD, MPFROMP(dv), MPVOID); | 
|---|
| 2137 | } | 
|---|
| 2138 | } | 
|---|
| 2139 | } | 
|---|
| 2140 | return 0; | 
|---|
| 2141 |  | 
|---|
| 2142 | case WM_PAINT: | 
|---|
| 2143 | PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE); | 
|---|
| 2144 | break; | 
|---|
| 2145 |  | 
|---|
| 2146 | case WM_CLOSE: | 
|---|
| 2147 | WinDestroyWindow(hwnd); | 
|---|
| 2148 | return 0; | 
|---|
| 2149 | } | 
|---|
| 2150 | return PFNWPStatic(hwnd, msg, mp1, mp2); | 
|---|
| 2151 | } | 
|---|
| 2152 |  | 
|---|
| 2153 | MRESULT EXPENTRY DriveProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 2154 | { | 
|---|
| 2155 | USHORT id; | 
|---|
| 2156 | CHAR szDrv[CCHMAXPATH]; | 
|---|
| 2157 |  | 
|---|
| 2158 | static BOOL emphasized = FALSE; | 
|---|
| 2159 | static HWND hwndMenu = NULLHANDLE; | 
|---|
| 2160 | static USHORT helpid = 0; | 
|---|
| 2161 |  | 
|---|
| 2162 | switch (msg) { | 
|---|
| 2163 | case WM_MOUSEMOVE: | 
|---|
| 2164 | if (fDrivebarHelp && (!hwndBubble || | 
|---|
| 2165 | WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) && | 
|---|
| 2166 | !WinQueryCapture(HWND_DESKTOP)) { | 
|---|
| 2167 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 2168 | if (helpid != id) { | 
|---|
| 2169 | helpid = id; | 
|---|
| 2170 | PostMsg(MainObjectHwnd, UM_SETUP6, MPFROMLONG((ULONG) hwnd), MPVOID); | 
|---|
| 2171 | } | 
|---|
| 2172 | else | 
|---|
| 2173 | helpid = 0; | 
|---|
| 2174 | } | 
|---|
| 2175 | break; | 
|---|
| 2176 |  | 
|---|
| 2177 | case WM_PAINT: | 
|---|
| 2178 | { | 
|---|
| 2179 | HPS hps; | 
|---|
| 2180 | POINTL aptl[4] = {0, 0, DRIVE_BUTTON_WIDTH - 1, DRIVE_BUTTON_HEIGHT - 1, | 
|---|
| 2181 | 0, 0, DRIVE_BUTTON_WIDTH - 1, DRIVE_BUTTON_HEIGHT - 1}; | 
|---|
| 2182 | //The last 2 numbers should be the width and height of the bitmap | 
|---|
| 2183 | HBITMAP hbm; | 
|---|
| 2184 | PBITMAPINFOHEADER    pbmpData; | 
|---|
| 2185 | POINTL ptlStart; | 
|---|
| 2186 | ULONG x, iconid; | 
|---|
| 2187 | FATTRS fat; | 
|---|
| 2188 | SIZEF sizfCharBox; | 
|---|
| 2189 |  | 
|---|
| 2190 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 2191 | if (id == IDM_REFRESHREMOVABLES || id == IDM_RESCAN) | 
|---|
| 2192 | break; | 
|---|
| 2193 | *szDrv = 0; | 
|---|
| 2194 | x = id - IDM_DRIVEA; | 
|---|
| 2195 | *szDrv = (CHAR) x + 'A'; | 
|---|
| 2196 | strcpy(szDrv + 1, ":"); | 
|---|
| 2197 | if (x > 1) { | 
|---|
| 2198 | if (driveflags[x] & DRIVE_CDROM) | 
|---|
| 2199 | iconid = CDROM_ICON; | 
|---|
| 2200 | else | 
|---|
| 2201 | iconid = (driveflags[x] & DRIVE_REMOVABLE) ? | 
|---|
| 2202 | REMOVABLE_ICON : | 
|---|
| 2203 | (driveflags[x] & DRIVE_VIRTUAL) ? | 
|---|
| 2204 | VIRTUAL_ICON : | 
|---|
| 2205 | (driveflags[x] & DRIVE_REMOTE) ? | 
|---|
| 2206 | REMOTE_ICON : | 
|---|
| 2207 | (driveflags[x] & DRIVE_RAMDISK) ? | 
|---|
| 2208 | RAMDISK_ICON : | 
|---|
| 2209 | (driveflags[x] & DRIVE_ZIPSTREAM) ? | 
|---|
| 2210 | ZIPSTREAM_ICON : | 
|---|
| 2211 | (driveflags[x] & DRIVE_LOCALHD) ? | 
|---|
| 2212 | DRIVE_ICON : DONNO_ICON; | 
|---|
| 2213 | } | 
|---|
| 2214 | else | 
|---|
| 2215 | iconid = FLOPPY_ICON; | 
|---|
| 2216 | hps = WinBeginPaint(hwnd, (HPS) 0, NULL); | 
|---|
| 2217 | if (hps) { | 
|---|
| 2218 | hbm = GpiLoadBitmap(hps, 0, iconid, 0, 0); | 
|---|
| 2219 | if (hbm) { | 
|---|
| 2220 | pbmpData = xmallocz(sizeof(PBITMAPINFOHEADER) * 3, pszSrcFile, __LINE__); | 
|---|
| 2221 | if (pbmpData) { | 
|---|
| 2222 | GpiQueryBitmapParameters(hbm, pbmpData); | 
|---|
| 2223 | aptl[1].x = pbmpData->cx; | 
|---|
| 2224 | aptl[1].y = pbmpData->cy; | 
|---|
| 2225 | aptl[3].x = pbmpData->cx; | 
|---|
| 2226 | aptl[3].y = pbmpData->cy; | 
|---|
| 2227 | GpiWCBitBlt(hps, hbm, 4L, aptl, ROP_SRCCOPY, BBO_PAL_COLORS); | 
|---|
| 2228 | free(pbmpData); | 
|---|
| 2229 | } | 
|---|
| 2230 | } | 
|---|
| 2231 | memset(&fat, 0, sizeof(fat)); | 
|---|
| 2232 | fat.usRecordLength = sizeof(FATTRS); | 
|---|
| 2233 | fat.fsSelection = FATTR_SEL_BOLD ; | 
|---|
| 2234 | fat.usCodePage = 850; | 
|---|
| 2235 | fat.fsFontUse = FATTR_FONTUSE_NOMIX; | 
|---|
| 2236 | strcpy(fat.szFacename , FNT_HELVETICA); | 
|---|
| 2237 | x = GpiCreateLogFont(hps, NULL, DRIVEBAR_FONT_LCID, &fat); | 
|---|
| 2238 | if (x != GPI_ERROR) { | 
|---|
| 2239 | GpiSetCharSet(hps, DRIVEBAR_FONT_LCID); | 
|---|
| 2240 | sizfCharBox.cx = MAKEFIXED(10,0); //Font size | 
|---|
| 2241 | sizfCharBox.cy = MAKEFIXED(14,0); | 
|---|
| 2242 | GpiSetCharBox( hps, &sizfCharBox ); | 
|---|
| 2243 | GpiSetColor(hps, iconid == RAMDISK_ICON ? CLR_YELLOW : CLR_DARKBLUE); | 
|---|
| 2244 | ptlStart.x = 1L;  //Char box position | 
|---|
| 2245 | ptlStart.y = 8L; | 
|---|
| 2246 | GpiCharStringAt(hps, &ptlStart, strlen(szDrv), szDrv); | 
|---|
| 2247 | GpiDeleteSetId(hps, DRIVEBAR_FONT_LCID); | 
|---|
| 2248 | } | 
|---|
| 2249 | WinEndPaint(hps); | 
|---|
| 2250 | } | 
|---|
| 2251 | } | 
|---|
| 2252 | break; | 
|---|
| 2253 |  | 
|---|
| 2254 | case UM_SETUP6: | 
|---|
| 2255 | if (helpid == WinQueryWindowUShort(hwnd, QWS_ID)) { | 
|---|
| 2256 | if ((char *)mp1 && | 
|---|
| 2257 | (!hwndBubble || | 
|---|
| 2258 | WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) && | 
|---|
| 2259 | !WinQueryCapture(HWND_DESKTOP)) { | 
|---|
| 2260 |  | 
|---|
| 2261 | RECTL rcl; | 
|---|
| 2262 | POINTL ptl; | 
|---|
| 2263 |  | 
|---|
| 2264 | WinQueryPointerPos(HWND_DESKTOP, &ptl); | 
|---|
| 2265 | WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1); | 
|---|
| 2266 | WinQueryWindowRect(hwnd, &rcl); | 
|---|
| 2267 | if (WinPtInRect(WinQueryAnchorBlock(hwnd), &rcl, &ptl)) { | 
|---|
| 2268 | BubbleHelp(hwnd, FALSE, TRUE, FALSE, (char *)mp1); | 
|---|
| 2269 | } | 
|---|
| 2270 | } | 
|---|
| 2271 | } | 
|---|
| 2272 | return 0; | 
|---|
| 2273 |  | 
|---|
| 2274 | case WM_MENUEND: | 
|---|
| 2275 | if (hwndMenu == (HWND) mp2) { | 
|---|
| 2276 | WinDestroyWindow(hwndMenu); | 
|---|
| 2277 | hwndMenu = (HWND) 0; | 
|---|
| 2278 | } | 
|---|
| 2279 | break; | 
|---|
| 2280 |  | 
|---|
| 2281 | case WM_CONTEXTMENU: | 
|---|
| 2282 | if (hwndMenu) | 
|---|
| 2283 | WinDestroyWindow(hwndMenu); | 
|---|
| 2284 | hwndMenu = (HWND) 0; | 
|---|
| 2285 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 2286 | *szDrv = id - IDM_DRIVEA + 'A'; | 
|---|
| 2287 | strcpy(szDrv + 1, ":"); | 
|---|
| 2288 | if (isalpha(*szDrv)) { | 
|---|
| 2289 | hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, MAIN_DRIVES); | 
|---|
| 2290 | if (hwndMenu) { | 
|---|
| 2291 | BOOL rdy, local; | 
|---|
| 2292 | CHAR chDrv = *szDrv; | 
|---|
| 2293 | UINT iDrv = chDrv - 'A'; | 
|---|
| 2294 |  | 
|---|
| 2295 | strcat(szDrv, PCSZ_BACKSLASH); | 
|---|
| 2296 | MakeValidDir(szDrv); | 
|---|
| 2297 | // Disable menus if MakeValidDir changes drive letter fixme this section doesn't do anything see treecnt.c | 
|---|
| 2298 | local = ~driveflags[iDrv] & DRIVE_REMOTE && ~driveflags[iDrv] & DRIVE_VIRTUAL && | 
|---|
| 2299 | ~driveflags[iDrv] & DRIVE_RAMDISK; | 
|---|
| 2300 | rdy = toupper(*szDrv) == toupper(chDrv); | 
|---|
| 2301 | iDrv = toupper(*szDrv) - 'A'; | 
|---|
| 2302 | if (!rdy || ~driveflags[iDrv] & DRIVE_REMOTE) | 
|---|
| 2303 | WinEnableMenuItem(hwndMenu, IDM_DETACH, FALSE); | 
|---|
| 2304 |  | 
|---|
| 2305 | if (!rdy || driveflags[iDrv] & DRIVE_NOTWRITEABLE) | 
|---|
| 2306 | WinEnableMenuItem(hwndMenu, IDM_MKDIR, FALSE); | 
|---|
| 2307 |  | 
|---|
| 2308 | if (!rdy || driveflags[iDrv] & DRIVE_NOTWRITEABLE || !local) { | 
|---|
| 2309 | WinEnableMenuItem(hwndMenu, IDM_FORMAT, FALSE); | 
|---|
| 2310 | WinEnableMenuItem(hwndMenu, IDM_OPTIMIZE, FALSE); | 
|---|
| 2311 | WinEnableMenuItem(hwndMenu, IDM_UNDELETE, FALSE); | 
|---|
| 2312 | } | 
|---|
| 2313 | if (!rdy || ~driveflags[iDrv] & DRIVE_REMOVABLE) { | 
|---|
| 2314 | WinEnableMenuItem(hwndMenu, IDM_EJECT, FALSE); | 
|---|
| 2315 | WinEnableMenuItem(hwndMenu, IDM_LOCK, FALSE); | 
|---|
| 2316 | WinEnableMenuItem(hwndMenu, IDM_UNLOCK, FALSE); | 
|---|
| 2317 | } | 
|---|
| 2318 | if (!rdy) { | 
|---|
| 2319 | WinEnableMenuItem(hwndMenu, IDM_INFO, FALSE); | 
|---|
| 2320 | WinEnableMenuItem(hwndMenu, IDM_ARCHIVE, FALSE); | 
|---|
| 2321 | WinEnableMenuItem(hwndMenu, IDM_SIZES, FALSE); | 
|---|
| 2322 | WinEnableMenuItem(hwndMenu, IDM_SHOWALLFILES, FALSE); | 
|---|
| 2323 |  | 
|---|
| 2324 | if (!rdy || !local) | 
|---|
| 2325 | WinEnableMenuItem(hwndMenu, IDM_CHKDSK, FALSE); | 
|---|
| 2326 | } | 
|---|
| 2327 | PopupMenu(hwnd, hwnd, hwndMenu); | 
|---|
| 2328 | } | 
|---|
| 2329 | } | 
|---|
| 2330 | return MRFROMSHORT(TRUE); | 
|---|
| 2331 |  | 
|---|
| 2332 | case WM_BUTTON2CLICK: | 
|---|
| 2333 | shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); | 
|---|
| 2334 | if (!(shiftstate & KC_CTRL)) | 
|---|
| 2335 | break; | 
|---|
| 2336 |  | 
|---|
| 2337 | case WM_CHORD: | 
|---|
| 2338 | case WM_BUTTON3CLICK: | 
|---|
| 2339 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 2340 | *szDrv = id - IDM_DRIVEA + 'A'; | 
|---|
| 2341 | strcpy(szDrv + 1, ":"); | 
|---|
| 2342 | if (isalpha(*szDrv)) { | 
|---|
| 2343 | strcat(szDrv, PCSZ_BACKSLASH); | 
|---|
| 2344 | if (!FindDirCnrByName(szDrv, TRUE)) | 
|---|
| 2345 | OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, szDrv); | 
|---|
| 2346 | } | 
|---|
| 2347 | break; | 
|---|
| 2348 |  | 
|---|
| 2349 | case WM_COMMAND: | 
|---|
| 2350 | PostMsg(hwnd, UM_COMMAND, mp1, mp2); | 
|---|
| 2351 | return 0; | 
|---|
| 2352 |  | 
|---|
| 2353 | case UM_COMMAND: | 
|---|
| 2354 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 2355 | *szDrv = id - IDM_DRIVEA + 'A'; | 
|---|
| 2356 | strcpy(szDrv + 1, ":"); | 
|---|
| 2357 | if (isalpha(*szDrv)) { | 
|---|
| 2358 | strcat(szDrv, PCSZ_BACKSLASH); | 
|---|
| 2359 | CommonDriveCmd(hwnd, szDrv, SHORT1FROMMP(mp1)); | 
|---|
| 2360 | } | 
|---|
| 2361 | return 0; | 
|---|
| 2362 |  | 
|---|
| 2363 | case DM_DRAGOVER: | 
|---|
| 2364 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 2365 | *szDrv = id - IDM_DRIVEA + 'A'; | 
|---|
| 2366 | strcpy(szDrv + 1, ":"); | 
|---|
| 2367 | if (isalpha(*szDrv) && | 
|---|
| 2368 | !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) { | 
|---|
| 2369 | if (!emphasized) { | 
|---|
| 2370 | emphasized = TRUE; | 
|---|
| 2371 | DrawTargetEmphasis(hwnd, emphasized); | 
|---|
| 2372 | } | 
|---|
| 2373 | if (AcceptOneDrop(hwnd, mp1, mp2)) | 
|---|
| 2374 | return MRFROM2SHORT(DOR_DROP, DO_MOVE); | 
|---|
| 2375 | return MRFROM2SHORT(DOR_NEVERDROP, 0); | 
|---|
| 2376 | } | 
|---|
| 2377 | break; | 
|---|
| 2378 |  | 
|---|
| 2379 | case DM_DRAGLEAVE: | 
|---|
| 2380 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 2381 | *szDrv = id - IDM_DRIVEA + 'A'; | 
|---|
| 2382 | strcpy(szDrv + 1, ":"); | 
|---|
| 2383 | if (isalpha(*szDrv) && | 
|---|
| 2384 | !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) { | 
|---|
| 2385 | if (emphasized) { | 
|---|
| 2386 | emphasized = FALSE; | 
|---|
| 2387 | DrawTargetEmphasis(hwnd, emphasized); | 
|---|
| 2388 | } | 
|---|
| 2389 | } | 
|---|
| 2390 | break; | 
|---|
| 2391 |  | 
|---|
| 2392 | case DM_DROPHELP: | 
|---|
| 2393 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 2394 | *szDrv = id - IDM_DRIVEA + 'A'; | 
|---|
| 2395 | strcpy(szDrv + 1, ":"); | 
|---|
| 2396 | if (isalpha(*szDrv) && | 
|---|
| 2397 | !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) { | 
|---|
| 2398 | DropHelp(mp1, mp2, hwnd, GetPString(IDS_DRIVEDROPHELP)); | 
|---|
| 2399 | return 0; | 
|---|
| 2400 | } | 
|---|
| 2401 | break; | 
|---|
| 2402 |  | 
|---|
| 2403 | case DM_DROP: | 
|---|
| 2404 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 2405 | *szDrv = id - IDM_DRIVEA + 'A'; | 
|---|
| 2406 | strcpy(szDrv + 1, ":"); | 
|---|
| 2407 | if (isalpha(*szDrv) && | 
|---|
| 2408 | !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) { | 
|---|
| 2409 |  | 
|---|
| 2410 | CNRDRAGINFO cnd; | 
|---|
| 2411 | LISTINFO *li; | 
|---|
| 2412 | ULONG action = UM_ACTION; | 
|---|
| 2413 |  | 
|---|
| 2414 | if (emphasized) { | 
|---|
| 2415 | emphasized = FALSE; | 
|---|
| 2416 | DrawTargetEmphasis(hwnd, emphasized); | 
|---|
| 2417 | } | 
|---|
| 2418 | memset(&cnd, 0, sizeof(cnd)); | 
|---|
| 2419 | cnd.pDragInfo = (PDRAGINFO) mp1; | 
|---|
| 2420 | cnd.pRecord = NULL; | 
|---|
| 2421 | li = DoFileDrop(hwnd, | 
|---|
| 2422 | NULL, | 
|---|
| 2423 | TRUE, MPFROM2SHORT(TREE_CNR, CN_DROP), MPFROMP(&cnd)); | 
|---|
| 2424 | CheckPmDrgLimit(cnd.pDragInfo); | 
|---|
| 2425 | if (li) { | 
|---|
| 2426 | strcpy(li->targetpath, szDrv); | 
|---|
| 2427 | strcat(li->targetpath, PCSZ_BACKSLASH); | 
|---|
| 2428 | if (li->list && li->list[0] && IsRoot(li->list[0])) | 
|---|
| 2429 | li->type = DO_LINK; | 
|---|
| 2430 | else if (fDragndropDlg && (!*li->arcname || !li->info)) { | 
|---|
| 2431 |  | 
|---|
| 2432 | CHECKLIST cl; | 
|---|
| 2433 |  | 
|---|
| 2434 | memset(&cl, 0, sizeof(cl)); | 
|---|
| 2435 | cl.size = sizeof(cl); | 
|---|
| 2436 | cl.flags = li->type; | 
|---|
| 2437 | cl.list = li->list; | 
|---|
| 2438 | cl.cmd = li->type; | 
|---|
| 2439 | cl.prompt = li->targetpath; | 
|---|
| 2440 | li->type = WinDlgBox(HWND_DESKTOP, | 
|---|
| 2441 | hwndMain, | 
|---|
| 2442 | DropListProc, | 
|---|
| 2443 | FM3ModHandle, DND_FRAME, MPFROMP(&cl)); | 
|---|
| 2444 | if (li->type == DID_ERROR) | 
|---|
| 2445 | Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| 2446 | GetPString(IDS_DRAGDROPDIALOGTEXT)); | 
|---|
| 2447 | if (!li->type) { | 
|---|
| 2448 | FreeListInfo(li); | 
|---|
| 2449 | return 0; | 
|---|
| 2450 | } | 
|---|
| 2451 | li->list = cl.list; | 
|---|
| 2452 | if (!li->list || !li->list[0]) { | 
|---|
| 2453 | FreeListInfo(li); | 
|---|
| 2454 | return 0; | 
|---|
| 2455 | } | 
|---|
| 2456 | } | 
|---|
| 2457 | else { | 
|---|
| 2458 | if (!WinDlgBox(HWND_DESKTOP, | 
|---|
| 2459 | hwndMain, | 
|---|
| 2460 | WalkDlgProc, | 
|---|
| 2461 | FM3ModHandle, | 
|---|
| 2462 | WALK_FRAME, | 
|---|
| 2463 | MPFROMP(li->targetpath)) || !*li->targetpath) { | 
|---|
| 2464 | FreeListInfo(li); | 
|---|
| 2465 | return 0; | 
|---|
| 2466 | } | 
|---|
| 2467 | } | 
|---|
| 2468 | switch (li->type) { | 
|---|
| 2469 | case DND_LAUNCH: | 
|---|
| 2470 | strcat(li->targetpath, " %a"); | 
|---|
| 2471 | ExecOnList(hwndMain, | 
|---|
| 2472 | li->targetpath, PROMPT | WINDOWED, NULL, NULL, li->list, NULL, | 
|---|
| 2473 | pszSrcFile, __LINE__); | 
|---|
| 2474 | FreeList(li->list); | 
|---|
| 2475 | li->list = NULL; | 
|---|
| 2476 | break; | 
|---|
| 2477 | case DO_LINK: | 
|---|
| 2478 | if (fLinkSetsIcon) { | 
|---|
| 2479 | li->type = IDM_SETICON; | 
|---|
| 2480 | action = UM_MASSACTION; | 
|---|
| 2481 | } | 
|---|
| 2482 | else | 
|---|
| 2483 | li->type = IDM_COMPARE; | 
|---|
| 2484 | break; | 
|---|
| 2485 | case DND_EXTRACT: | 
|---|
| 2486 | if (*li->targetpath && !IsFile(li->targetpath)) | 
|---|
| 2487 | li->type = IDM_EXTRACT; | 
|---|
| 2488 | break; | 
|---|
| 2489 | case DND_MOVE: | 
|---|
| 2490 | li->type = IDM_MOVE; | 
|---|
| 2491 | if (*li->targetpath && IsFile(li->targetpath) == 1) { | 
|---|
| 2492 | action = UM_MASSACTION; | 
|---|
| 2493 | li->type = IDM_ARCHIVEM; | 
|---|
| 2494 | } | 
|---|
| 2495 | break; | 
|---|
| 2496 | case DND_WILDMOVE: | 
|---|
| 2497 | li->type = IDM_WILDMOVE; | 
|---|
| 2498 | if (*li->targetpath && IsFile(li->targetpath) == 1) { | 
|---|
| 2499 | action = UM_MASSACTION; | 
|---|
| 2500 | li->type = IDM_ARCHIVEM; | 
|---|
| 2501 | } | 
|---|
| 2502 | break; | 
|---|
| 2503 | case DND_OBJECT: | 
|---|
| 2504 | li->type = IDM_OBJECT; | 
|---|
| 2505 | action = UM_MASSACTION; | 
|---|
| 2506 | break; | 
|---|
| 2507 | case DND_SHADOW: | 
|---|
| 2508 | li->type = IDM_SHADOW; | 
|---|
| 2509 | action = UM_MASSACTION; | 
|---|
| 2510 | break; | 
|---|
| 2511 | case DND_COMPARE: | 
|---|
| 2512 | li->type = IDM_COMPARE; | 
|---|
| 2513 | break; | 
|---|
| 2514 | case DND_SETICON: | 
|---|
| 2515 | action = UM_MASSACTION; | 
|---|
| 2516 | li->type = IDM_SETICON; | 
|---|
| 2517 | break; | 
|---|
| 2518 | case DND_COPY: | 
|---|
| 2519 | li->type = IDM_COPY; | 
|---|
| 2520 | if (*li->targetpath && IsFile(li->targetpath) == 1) { | 
|---|
| 2521 | action = UM_MASSACTION; | 
|---|
| 2522 | li->type = IDM_ARCHIVE; | 
|---|
| 2523 | } | 
|---|
| 2524 | break; | 
|---|
| 2525 | case DND_WILDCOPY: | 
|---|
| 2526 | li->type = IDM_WILDCOPY; | 
|---|
| 2527 | if (*li->targetpath && IsFile(li->targetpath) == 1) { | 
|---|
| 2528 | action = UM_MASSACTION; | 
|---|
| 2529 | li->type = IDM_ARCHIVE; | 
|---|
| 2530 | } | 
|---|
| 2531 | break; | 
|---|
| 2532 | default: | 
|---|
| 2533 | if (*li->arcname && li->info) { | 
|---|
| 2534 | action = UM_MASSACTION; | 
|---|
| 2535 | li->type = (li->type == DO_MOVE) ? IDM_FAKEEXTRACTM : | 
|---|
| 2536 | IDM_FAKEEXTRACT; | 
|---|
| 2537 | } | 
|---|
| 2538 | else if (*li->targetpath && IsFile(li->targetpath) == 1) { | 
|---|
| 2539 | action = UM_MASSACTION; | 
|---|
| 2540 | li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE; | 
|---|
| 2541 | } | 
|---|
| 2542 | else | 
|---|
| 2543 | li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY; | 
|---|
| 2544 | break; | 
|---|
| 2545 | } | 
|---|
| 2546 | if (!li->list || !li->list[0]) | 
|---|
| 2547 | FreeListInfo(li); | 
|---|
| 2548 | else | 
|---|
| 2549 | WinSendMsg(hwndTree, UM_ACTION, MPFROMP(li), MPFROMLONG(action)); | 
|---|
| 2550 | } | 
|---|
| 2551 | return 0; | 
|---|
| 2552 | } | 
|---|
| 2553 | break; | 
|---|
| 2554 |  | 
|---|
| 2555 | case WM_DESTROY: | 
|---|
| 2556 | if (hwndMenu) | 
|---|
| 2557 | WinDestroyWindow(hwndMenu); | 
|---|
| 2558 | hwndMenu = (HWND) 0; | 
|---|
| 2559 | break; | 
|---|
| 2560 | } | 
|---|
| 2561 | return PFNWPButton(hwnd, msg, mp1, mp2); | 
|---|
| 2562 | } | 
|---|
| 2563 |  | 
|---|
| 2564 | VOID BuildDriveBarButtons(HWND hwndT) | 
|---|
| 2565 | { | 
|---|
| 2566 | register ULONG x; | 
|---|
| 2567 | ULONG ulDriveNum, ulDriveMap; | 
|---|
| 2568 | HENUM henum; | 
|---|
| 2569 | HWND hwndB; | 
|---|
| 2570 |  | 
|---|
| 2571 | henum = WinBeginEnumWindows(hwndT); | 
|---|
| 2572 |  | 
|---|
| 2573 | while ((hwndB = WinGetNextWindow(henum)) != NULLHANDLE) | 
|---|
| 2574 | WinDestroyWindow(hwndB); | 
|---|
| 2575 |  | 
|---|
| 2576 | WinEndEnumWindows(henum); | 
|---|
| 2577 | if (fDrivebar) { | 
|---|
| 2578 | DosError(FERR_DISABLEHARDERR); | 
|---|
| 2579 | DosQCurDisk(&ulDriveNum, &ulDriveMap); | 
|---|
| 2580 | for (x = 0; x < 26; x++) { | 
|---|
| 2581 | if ((ulDriveMap & (1L << x)) && !(driveflags[x] & DRIVE_IGNORE)) { | 
|---|
| 2582 | hwndB = WinCreateWindow(hwndT, | 
|---|
| 2583 | (CHAR *) WC_DRIVEBUTTONS, | 
|---|
| 2584 | 0, | 
|---|
| 2585 | BS_NOPOINTERFOCUS | BS_USERBUTTON, | 
|---|
| 2586 | 0, | 
|---|
| 2587 | 0, | 
|---|
| 2588 | DRIVE_BUTTON_WIDTH, | 
|---|
| 2589 | DRIVE_BUTTON_HEIGHT, | 
|---|
| 2590 | hwndT, HWND_TOP, x + IDM_DRIVEA, NULL, NULL); | 
|---|
| 2591 | if (!hwndB) | 
|---|
| 2592 | Win_Error(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| 2593 | PCSZ_WINCREATEWINDOW); | 
|---|
| 2594 | else { | 
|---|
| 2595 | WinSetWindowPos(hwndB, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER); | 
|---|
| 2596 | } | 
|---|
| 2597 | } | 
|---|
| 2598 | }                                   // for | 
|---|
| 2599 | hwndB = WinCreateWindow(hwndT, | 
|---|
| 2600 | (CHAR *) WC_DRIVEBUTTONS, | 
|---|
| 2601 | "#7001", | 
|---|
| 2602 | BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON, | 
|---|
| 2603 | 0, | 
|---|
| 2604 | 0, | 
|---|
| 2605 | DRIVE_BUTTON_WIDTH, | 
|---|
| 2606 | DRIVE_BUTTON_HEIGHT, | 
|---|
| 2607 | hwndT, HWND_TOP, IDM_REFRESHREMOVABLES, NULL, NULL); | 
|---|
| 2608 | if (!hwndB) | 
|---|
| 2609 | Win_Error(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| 2610 | PCSZ_WINCREATEWINDOW); | 
|---|
| 2611 | hwndB = WinCreateWindow(hwndT, | 
|---|
| 2612 | (CHAR *) WC_DRIVEBUTTONS, | 
|---|
| 2613 | "#7000", | 
|---|
| 2614 | BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON, | 
|---|
| 2615 | 0, | 
|---|
| 2616 | 0, | 
|---|
| 2617 | DRIVE_BUTTON_WIDTH, | 
|---|
| 2618 | DRIVE_BUTTON_HEIGHT, | 
|---|
| 2619 | hwndT, HWND_TOP, IDM_RESCAN, NULL, NULL); | 
|---|
| 2620 | if (!hwndB) | 
|---|
| 2621 | Win_Error(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| 2622 | PCSZ_WINCREATEWINDOW); | 
|---|
| 2623 | }                                     // if drivebar | 
|---|
| 2624 | PostMsg(WinQueryWindow(hwndT, QW_PARENT), | 
|---|
| 2625 | WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID); | 
|---|
| 2626 | } | 
|---|
| 2627 |  | 
|---|
| 2628 | VOID ResizeDrives(HWND hwndT, long xwidth) | 
|---|
| 2629 | { | 
|---|
| 2630 | register ULONG ctrlxpos = 1, ctrlypos = 0, ctrlxsize; | 
|---|
| 2631 | HENUM henum; | 
|---|
| 2632 | HWND hwndB; | 
|---|
| 2633 | RECTL rcl; | 
|---|
| 2634 |  | 
|---|
| 2635 | DriveLines = 0; | 
|---|
| 2636 | if (!fDrivebar) | 
|---|
| 2637 | return; | 
|---|
| 2638 | if (!xwidth) { | 
|---|
| 2639 | WinQueryWindowRect(hwndT, &rcl); | 
|---|
| 2640 | xwidth = rcl.xRight - ((WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 2641 | SV_CYSIZEBORDER) * 2) + 1); | 
|---|
| 2642 | } | 
|---|
| 2643 | henum = WinBeginEnumWindows(hwndT); | 
|---|
| 2644 | while ((hwndB = WinGetNextWindow(henum)) != NULLHANDLE) { | 
|---|
| 2645 | ctrlxsize = DRIVE_BUTTON_WIDTH; | 
|---|
| 2646 | WinSetWindowPos(hwndB, | 
|---|
| 2647 | HWND_TOP, | 
|---|
| 2648 | ctrlxpos, ctrlypos, ctrlxsize, DRIVE_BUTTON_HEIGHT, SWP_MOVE | SWP_SHOW); | 
|---|
| 2649 | ctrlxpos += (ctrlxsize + 2); | 
|---|
| 2650 | if (ctrlxpos + (DRIVE_BUTTON_WIDTH + 2 + ((fShowTarget && DriveLines == 0) ? | 
|---|
| 2651 | 256 : 0)) > xwidth) { | 
|---|
| 2652 | ctrlxpos = 1; | 
|---|
| 2653 | ctrlypos += DRIVE_BUTTON_HEIGHT; | 
|---|
| 2654 | DriveLines++; | 
|---|
| 2655 | } | 
|---|
| 2656 | } | 
|---|
| 2657 | if (ctrlxpos == 1 && DriveLines) | 
|---|
| 2658 | DriveLines--; | 
|---|
| 2659 | } | 
|---|
| 2660 |  | 
|---|
| 2661 | MRESULT EXPENTRY StatusProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 2662 | { | 
|---|
| 2663 | static HWND hwndE = (HWND) 0, hwndB = (HWND) 0; | 
|---|
| 2664 | static CHAR lastcmd[1024] = ""; | 
|---|
| 2665 |  | 
|---|
| 2666 | switch (msg) { | 
|---|
| 2667 | case WM_CREATE: | 
|---|
| 2668 | { | 
|---|
| 2669 | MRESULT mr = PFNWPStatic(hwnd, msg, mp1, mp2); | 
|---|
| 2670 | //fixme to allow user to change presparams 1-10-09 GKY | 
|---|
| 2671 | SetPresParams(hwnd, | 
|---|
| 2672 | &RGBGREY, | 
|---|
| 2673 | &RGBBLACK, &RGBGREY, FNT_8HELVETICABOLD); | 
|---|
| 2674 | return mr; | 
|---|
| 2675 | } | 
|---|
| 2676 |  | 
|---|
| 2677 | case WM_PRESPARAMCHANGED: | 
|---|
| 2678 | if (fRunning) { | 
|---|
| 2679 |  | 
|---|
| 2680 | ULONG AttrFound, AttrValue[64], cbRetLen; | 
|---|
| 2681 |  | 
|---|
| 2682 | cbRetLen = WinQueryPresParam(hwnd, | 
|---|
| 2683 | (ULONG) mp1, | 
|---|
| 2684 | 0, | 
|---|
| 2685 | &AttrFound, | 
|---|
| 2686 | (ULONG) sizeof(AttrValue), &AttrValue, 0); | 
|---|
| 2687 | if (cbRetLen) { | 
|---|
| 2688 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 2689 | WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID); | 
|---|
| 2690 | } | 
|---|
| 2691 | } | 
|---|
| 2692 | break; | 
|---|
| 2693 |  | 
|---|
| 2694 | case WM_CONTEXTMENU: | 
|---|
| 2695 | PostMsg(hwndMain, UM_CONTEXTMENU, MPVOID, MPVOID); | 
|---|
| 2696 | return MRFROMSHORT(TRUE); | 
|---|
| 2697 |  | 
|---|
| 2698 | case WM_BEGINDRAG: | 
|---|
| 2699 | if (hwndTree) { | 
|---|
| 2700 |  | 
|---|
| 2701 | SWP swp; | 
|---|
| 2702 | ULONG fl = SWP_ACTIVATE | SWP_SHOW | SWP_ZORDER; | 
|---|
| 2703 |  | 
|---|
| 2704 | WinQueryWindowPos(hwndTree, &swp); | 
|---|
| 2705 | if (!(swp.fl & SWP_MAXIMIZE)) | 
|---|
| 2706 | fl |= SWP_RESTORE; | 
|---|
| 2707 | WinSetWindowPos(hwndTree, HWND_TOP, 0, 0, 0, 0, fl); | 
|---|
| 2708 | } | 
|---|
| 2709 | break; | 
|---|
| 2710 |  | 
|---|
| 2711 | case UM_SETUP: | 
|---|
| 2712 | if (mp1) | 
|---|
| 2713 | strcpy(lastcmd, (CHAR *)mp1); | 
|---|
| 2714 | return 0; | 
|---|
| 2715 |  | 
|---|
| 2716 | case UM_RESCAN: | 
|---|
| 2717 | if (hwndE && WinIsWindow(WinQueryAnchorBlock(hwnd), hwndE)) | 
|---|
| 2718 | WinDestroyWindow(hwndE); | 
|---|
| 2719 | if (hwndB && WinIsWindow(WinQueryAnchorBlock(hwnd), hwndB)) | 
|---|
| 2720 | WinDestroyWindow(hwndB); | 
|---|
| 2721 | hwndE = hwndB = (HWND) 0; | 
|---|
| 2722 | return 0; | 
|---|
| 2723 |  | 
|---|
| 2724 | case WM_COMMAND: | 
|---|
| 2725 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 2726 | case COMMAND_BUTTON: | 
|---|
| 2727 | PostMsg(hwndE, msg, mp1, mp2); | 
|---|
| 2728 | break; | 
|---|
| 2729 | } | 
|---|
| 2730 | return 0; | 
|---|
| 2731 |  | 
|---|
| 2732 | case WM_MOUSEMOVE: | 
|---|
| 2733 | shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); | 
|---|
| 2734 | { | 
|---|
| 2735 | USHORT id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 2736 | PCSZ s = NULL; | 
|---|
| 2737 |  | 
|---|
| 2738 | if (fOtherHelp) { | 
|---|
| 2739 | if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) | 
|---|
| 2740 | && !WinQueryCapture(HWND_DESKTOP)) { | 
|---|
| 2741 | switch (id) { | 
|---|
| 2742 | case IDM_ATTRS: | 
|---|
| 2743 | if (WinQueryWindowTextLength(hwnd)) | 
|---|
| 2744 | s = GetPString(IDS_ATTRSBUTTONHELP); | 
|---|
| 2745 | break; | 
|---|
| 2746 | case IDM_INFO: | 
|---|
| 2747 | if (WinQueryWindowTextLength(hwnd)) | 
|---|
| 2748 | s = GetPString(IDS_INFOBUTTONHELP); | 
|---|
| 2749 | break; | 
|---|
| 2750 | case IDM_RENAME: | 
|---|
| 2751 | if (WinQueryWindowTextLength(hwnd)) | 
|---|
| 2752 | s = GetPString(IDS_NAMEBUTTONHELP); | 
|---|
| 2753 | break; | 
|---|
| 2754 | case MAIN_STATUS2: | 
|---|
| 2755 | if (!hwndE) | 
|---|
| 2756 | s = GetPString(IDS_STATUS2HELP); | 
|---|
| 2757 | break; | 
|---|
| 2758 | default: | 
|---|
| 2759 | break; | 
|---|
| 2760 | } | 
|---|
| 2761 | if (s) | 
|---|
| 2762 | MakeBubble(hwnd, FALSE, s); | 
|---|
| 2763 | else if (hwndBubble) | 
|---|
| 2764 | WinDestroyWindow(hwndBubble); | 
|---|
| 2765 | } | 
|---|
| 2766 | } | 
|---|
| 2767 | switch (id) { | 
|---|
| 2768 | case IDM_ATTRS: | 
|---|
| 2769 | case IDM_INFO: | 
|---|
| 2770 | case IDM_RENAME: | 
|---|
| 2771 | case MAIN_STATUS2: | 
|---|
| 2772 | return CommonTextProc(hwnd, msg, mp1, mp2); | 
|---|
| 2773 | default: | 
|---|
| 2774 | break; | 
|---|
| 2775 | } | 
|---|
| 2776 | } | 
|---|
| 2777 | break; | 
|---|
| 2778 |  | 
|---|
| 2779 | case WM_BUTTON2DOWN: | 
|---|
| 2780 | case WM_BUTTON2UP: | 
|---|
| 2781 | case UM_FOCUSME: | 
|---|
| 2782 | return CommonTextButton(hwnd, msg, mp1, mp2); | 
|---|
| 2783 |  | 
|---|
| 2784 | case WM_BUTTON1DOWN: | 
|---|
| 2785 | case WM_BUTTON1UP: | 
|---|
| 2786 | case WM_BUTTON3DOWN: | 
|---|
| 2787 | case WM_BUTTON3UP: | 
|---|
| 2788 | { | 
|---|
| 2789 | USHORT id; | 
|---|
| 2790 |  | 
|---|
| 2791 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 2792 | switch (id) { | 
|---|
| 2793 | case IDM_ATTRS: | 
|---|
| 2794 | case IDM_INFO: | 
|---|
| 2795 | case IDM_RENAME: | 
|---|
| 2796 | case MAIN_STATUS2: | 
|---|
| 2797 | return CommonTextButton(hwnd, msg, mp1, mp2); | 
|---|
| 2798 | default: | 
|---|
| 2799 | PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID); | 
|---|
| 2800 | break; | 
|---|
| 2801 | } | 
|---|
| 2802 | } | 
|---|
| 2803 | break; | 
|---|
| 2804 |  | 
|---|
| 2805 | case WM_SETFOCUS: | 
|---|
| 2806 | if (mp2) { | 
|---|
| 2807 |  | 
|---|
| 2808 | USHORT id; | 
|---|
| 2809 |  | 
|---|
| 2810 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 2811 | if (id == MAIN_STATUS2 && hwndE) | 
|---|
| 2812 | WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID); | 
|---|
| 2813 | else | 
|---|
| 2814 | return CommonTextButton(hwnd, msg, mp1, mp2); | 
|---|
| 2815 | } | 
|---|
| 2816 | break; | 
|---|
| 2817 |  | 
|---|
| 2818 | case WM_BUTTON1CLICK: | 
|---|
| 2819 | { | 
|---|
| 2820 | USHORT id; | 
|---|
| 2821 |  | 
|---|
| 2822 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 2823 | if (id == MAIN_STATUS) { | 
|---|
| 2824 | if (SHORT2FROMMP(mp2) & KC_CTRL) | 
|---|
| 2825 | PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 2826 | FID_CLIENT), | 
|---|
| 2827 | WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID); | 
|---|
| 2828 | else if (hwndTree) | 
|---|
| 2829 | PostMsg(hwndTree, UM_TIMER, MPVOID, MPVOID); | 
|---|
| 2830 | } | 
|---|
| 2831 | } | 
|---|
| 2832 | break; | 
|---|
| 2833 |  | 
|---|
| 2834 | case UM_CLICKED: | 
|---|
| 2835 | case UM_CLICKED3: | 
|---|
| 2836 | { | 
|---|
| 2837 | USHORT id; | 
|---|
| 2838 |  | 
|---|
| 2839 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 2840 | if (id == MAIN_STATUS2 && !hwndE) { | 
|---|
| 2841 |  | 
|---|
| 2842 | SWP swp; | 
|---|
| 2843 | CHAR directory[CCHMAXPATH]; | 
|---|
| 2844 | PFNWP oldproce; | 
|---|
| 2845 |  | 
|---|
| 2846 | *directory = 0; | 
|---|
| 2847 | TopWindowName(hwndMain, (HWND) 0, directory); | 
|---|
| 2848 | WinQueryWindowPos(hwnd, &swp); | 
|---|
| 2849 | hwndB = WinCreateWindow(hwnd, | 
|---|
| 2850 | (CHAR *) WC_BUTTON, | 
|---|
| 2851 | "+", | 
|---|
| 2852 | WS_VISIBLE | BS_PUSHBUTTON | | 
|---|
| 2853 | BS_NOPOINTERFOCUS, | 
|---|
| 2854 | swp.cx - swp.cy, | 
|---|
| 2855 | 0, | 
|---|
| 2856 | swp.cy, | 
|---|
| 2857 | swp.cy, | 
|---|
| 2858 | hwnd, HWND_TOP, COMMAND_BUTTON, NULL, NULL); | 
|---|
| 2859 | if (!hwndB) | 
|---|
| 2860 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, | 
|---|
| 2861 | PCSZ_WINCREATEWINDOW); | 
|---|
| 2862 | hwndE = WinCreateWindow(hwnd, | 
|---|
| 2863 | (CHAR *) WC_ENTRYFIELD, | 
|---|
| 2864 | NULL, | 
|---|
| 2865 | WS_VISIBLE | ES_AUTOSCROLL, | 
|---|
| 2866 | 0, | 
|---|
| 2867 | 0, | 
|---|
| 2868 | swp.cx - swp.cy, | 
|---|
| 2869 | swp.cy, | 
|---|
| 2870 | hwnd, HWND_TOP, COMMAND_LINE, NULL, NULL); | 
|---|
| 2871 | if (!hwndE) | 
|---|
| 2872 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, | 
|---|
| 2873 | PCSZ_WINCREATEWINDOW); | 
|---|
| 2874 | if (!hwndE || !hwndB) { | 
|---|
| 2875 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID); | 
|---|
| 2876 | return 0; | 
|---|
| 2877 | } | 
|---|
| 2878 | WinSendMsg(hwndE, EM_SETTEXTLIMIT, MPFROM2SHORT(1024, 0), MPVOID); | 
|---|
| 2879 | WinSetWindowText(hwndStatus, directory); | 
|---|
| 2880 | if (*lastcmd) | 
|---|
| 2881 | WinSetWindowText(hwndE, lastcmd); | 
|---|
| 2882 | else | 
|---|
| 2883 | WinSetWindowText(hwndE, (CHAR *) GetPString(IDS_HELPCMDTEXT)); | 
|---|
| 2884 | oldproce = WinSubclassWindow(hwndE, (PFNWP) CommandLineProc); | 
|---|
| 2885 | if (oldproce) | 
|---|
| 2886 | WinSetWindowPtr(hwndE, QWL_USER, (PVOID) oldproce); | 
|---|
| 2887 | PostMsg(hwndE, UM_FOCUSME, MPVOID, MPVOID); | 
|---|
| 2888 | PostMsg(hwndE, EM_SETSEL, MPFROM2SHORT(0, 1024), MPVOID); | 
|---|
| 2889 | return 0; | 
|---|
| 2890 | } | 
|---|
| 2891 | if (msg == UM_CLICKED3 || (SHORT2FROMMP(mp2) & KC_CTRL)) { | 
|---|
| 2892 | switch (id) { | 
|---|
| 2893 | case IDM_ATTRS: | 
|---|
| 2894 | id = IDM_SORTSIZE; | 
|---|
| 2895 | break; | 
|---|
| 2896 | case IDM_INFO: | 
|---|
| 2897 | id = IDM_SORTLWDATE; | 
|---|
| 2898 | break; | 
|---|
| 2899 | case IDM_RENAME: | 
|---|
| 2900 | id = IDM_SORTFILENAME; | 
|---|
| 2901 | break; | 
|---|
| 2902 | } | 
|---|
| 2903 | } | 
|---|
| 2904 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 2905 | WM_COMMAND, MPFROM2SHORT(id, 0), MPVOID); | 
|---|
| 2906 | } | 
|---|
| 2907 | return 0; | 
|---|
| 2908 |  | 
|---|
| 2909 | case WM_PAINT: | 
|---|
| 2910 | { | 
|---|
| 2911 | USHORT id; | 
|---|
| 2912 |  | 
|---|
| 2913 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 2914 | switch (id) { | 
|---|
| 2915 | case IDM_ATTRS: | 
|---|
| 2916 | case IDM_INFO: | 
|---|
| 2917 | case IDM_RENAME: | 
|---|
| 2918 | case MAIN_STATUS2: | 
|---|
| 2919 | PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE); | 
|---|
| 2920 | break; | 
|---|
| 2921 | default: | 
|---|
| 2922 | PaintRecessedWindow(hwnd, (HPS) 0, FALSE, TRUE); | 
|---|
| 2923 | break; | 
|---|
| 2924 | } | 
|---|
| 2925 | if (id == IDM_RENAME) { | 
|---|
| 2926 |  | 
|---|
| 2927 | HPS hps; | 
|---|
| 2928 |  | 
|---|
| 2929 | hps = WinBeginPaint(hwnd, (HPS) 0, NULL); | 
|---|
| 2930 | if (hps) { | 
|---|
| 2931 | PaintSTextWindow(hwnd, hps); | 
|---|
| 2932 | WinEndPaint(hps); | 
|---|
| 2933 | } | 
|---|
| 2934 | return 0; | 
|---|
| 2935 | } | 
|---|
| 2936 | } | 
|---|
| 2937 | break; | 
|---|
| 2938 |  | 
|---|
| 2939 | } | 
|---|
| 2940 | return PFNWPStatic(hwnd, msg, mp1, mp2); | 
|---|
| 2941 | } | 
|---|
| 2942 |  | 
|---|
| 2943 | MRESULT EXPENTRY ToolBackProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 2944 | { | 
|---|
| 2945 | switch (msg) { | 
|---|
| 2946 | case WM_CREATE: | 
|---|
| 2947 | hwndToolback = hwnd; | 
|---|
| 2948 | break; | 
|---|
| 2949 |  | 
|---|
| 2950 | case WM_MOUSEMOVE: | 
|---|
| 2951 | shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); | 
|---|
| 2952 | break; | 
|---|
| 2953 |  | 
|---|
| 2954 | case WM_CONTROLPOINTER: | 
|---|
| 2955 | if (!fNoFinger && SHORT1FROMMP(mp1) < 25000) | 
|---|
| 2956 | return MRFROMLONG(hptrFinger); | 
|---|
| 2957 | break; | 
|---|
| 2958 |  | 
|---|
| 2959 | case WM_CHAR: | 
|---|
| 2960 | shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL)); | 
|---|
| 2961 | break; | 
|---|
| 2962 |  | 
|---|
| 2963 | case WM_COMMAND: | 
|---|
| 2964 | case UM_COMMAND: | 
|---|
| 2965 | return WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 2966 | FID_CLIENT), msg, mp1, mp2); | 
|---|
| 2967 |  | 
|---|
| 2968 | case WM_PAINT: | 
|---|
| 2969 | { | 
|---|
| 2970 | HPS hps; | 
|---|
| 2971 | RECTL rcl; | 
|---|
| 2972 | ULONG lColor = 0L; | 
|---|
| 2973 |  | 
|---|
| 2974 | hps = WinBeginPaint(hwnd, (HPS)0, NULL); | 
|---|
| 2975 | if (hps) { | 
|---|
| 2976 | GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, NULL); | 
|---|
| 2977 | if (!WinQueryPresParam(hwnd, PP_BACKGROUNDCOLOR, 0, NULL, | 
|---|
| 2978 | sizeof(lColor), &lColor, 0)) | 
|---|
| 2979 | lColor = 0x00CCCCCCL; //Palegray | 
|---|
| 2980 | WinQueryWindowRect(hwnd, &rcl); | 
|---|
| 2981 | WinFillRect(hps, &rcl, lColor); | 
|---|
| 2982 | WinEndPaint(hps); | 
|---|
| 2983 | } | 
|---|
| 2984 |  | 
|---|
| 2985 | } | 
|---|
| 2986 | break; | 
|---|
| 2987 |  | 
|---|
| 2988 | case WM_PRESPARAMCHANGED: | 
|---|
| 2989 | PresParamChanged(hwnd, PCSZ_TOOLBAR, mp1, mp2); | 
|---|
| 2990 | WinInvalidateRect(hwnd, NULL, TRUE); | 
|---|
| 2991 | break; | 
|---|
| 2992 |  | 
|---|
| 2993 | case UM_SETUP: | 
|---|
| 2994 | { | 
|---|
| 2995 | USHORT id; | 
|---|
| 2996 | TOOL *tool; | 
|---|
| 2997 |  | 
|---|
| 2998 | RestorePresParams(hwnd, PCSZ_TOOLBAR); | 
|---|
| 2999 | id = SHORT1FROMMP(mp1); | 
|---|
| 3000 | tool = find_tool(id); | 
|---|
| 3001 | if (tool) { | 
|---|
| 3002 | del_tool(tool); | 
|---|
| 3003 | WinShowWindow(WinWindowFromID(hwnd, id), FALSE); | 
|---|
| 3004 | if (fToolTitles) | 
|---|
| 3005 | WinShowWindow(WinWindowFromID(hwnd, id + 25000), FALSE); | 
|---|
| 3006 | ResizeTools(hwnd); | 
|---|
| 3007 | save_tools(NULL); | 
|---|
| 3008 | } | 
|---|
| 3009 | } | 
|---|
| 3010 | return 0; | 
|---|
| 3011 |  | 
|---|
| 3012 | case UM_SETUP2:  // Used to load a new a toolbar | 
|---|
| 3013 | BuildTools(hwnd, TRUE); | 
|---|
| 3014 | return 0; | 
|---|
| 3015 |  | 
|---|
| 3016 | case WM_CHORD: | 
|---|
| 3017 | { | 
|---|
| 3018 | USHORT id; | 
|---|
| 3019 |  | 
|---|
| 3020 | id = (USHORT) WinDlgBox(HWND_DESKTOP, | 
|---|
| 3021 | hwnd, | 
|---|
| 3022 | AddToolProc, | 
|---|
| 3023 | FM3ModHandle, ADDBTN_FRAME, MPVOID); | 
|---|
| 3024 | if (id && id != (USHORT) - 1) | 
|---|
| 3025 | WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 3026 | FID_CLIENT), | 
|---|
| 3027 | WM_COMMAND, | 
|---|
| 3028 | MPFROM2SHORT(IDM_CREATETOOL, 0), MPFROM2SHORT(id, 0)); | 
|---|
| 3029 | } | 
|---|
| 3030 | break; | 
|---|
| 3031 |  | 
|---|
| 3032 | case WM_CONTEXTMENU: | 
|---|
| 3033 | if (WinDlgBox(HWND_DESKTOP, | 
|---|
| 3034 | hwnd, ToolIODlgProc, FM3ModHandle, SVBTN_FRAME, MPVOID)) | 
|---|
| 3035 | PostMsg(hwnd, UM_SETUP2, MPVOID, MPVOID); | 
|---|
| 3036 | return MRFROMSHORT(TRUE); | 
|---|
| 3037 |  | 
|---|
| 3038 | case WM_CLOSE: | 
|---|
| 3039 | WinDestroyWindow(hwnd); | 
|---|
| 3040 | return 0; | 
|---|
| 3041 |  | 
|---|
| 3042 | case WM_DESTROY: | 
|---|
| 3043 | break; | 
|---|
| 3044 | } | 
|---|
| 3045 | return WinDefWindowProc(hwnd, msg, mp1, mp2); | 
|---|
| 3046 | } | 
|---|
| 3047 |  | 
|---|
| 3048 | static VOID AdjustSizeOfClient(PSWP pswp, PRECTL prectl) | 
|---|
| 3049 | { | 
|---|
| 3050 | SWP swp; | 
|---|
| 3051 | RECTL rectl; | 
|---|
| 3052 |  | 
|---|
| 3053 | if (fFreeTree) | 
|---|
| 3054 | return; | 
|---|
| 3055 | if (pswp) { | 
|---|
| 3056 | if (WinQueryWindowPos(hwndTree, &swp) && | 
|---|
| 3057 | !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE))) { | 
|---|
| 3058 | pswp->x = swp.cx; | 
|---|
| 3059 | pswp->cx -= swp.cx; | 
|---|
| 3060 | } | 
|---|
| 3061 | } | 
|---|
| 3062 | if (prectl) { | 
|---|
| 3063 | if (WinQueryWindowPos(hwndTree, &swp) && | 
|---|
| 3064 | !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE)) && | 
|---|
| 3065 | WinQueryWindowRect(hwndTree, &rectl)) { | 
|---|
| 3066 | prectl->xLeft = rectl.xRight; | 
|---|
| 3067 | prectl->xRight -= rectl.xRight; | 
|---|
| 3068 | } | 
|---|
| 3069 | } | 
|---|
| 3070 | } | 
|---|
| 3071 |  | 
|---|
| 3072 | VOID FillClient(HWND hwndClient, PSWP pswp, PRECTL prectl, BOOL avoidtree) | 
|---|
| 3073 | { | 
|---|
| 3074 | ULONG adjust; | 
|---|
| 3075 |  | 
|---|
| 3076 | adjust = WinQuerySysValue(HWND_DESKTOP, SV_CYICON); | 
|---|
| 3077 | if (pswp) | 
|---|
| 3078 | WinQueryWindowPos(hwndClient, pswp); | 
|---|
| 3079 | if (prectl) | 
|---|
| 3080 | WinQueryWindowRect(hwndClient, prectl); | 
|---|
| 3081 | if (avoidtree && !fFreeTree) | 
|---|
| 3082 | AdjustSizeOfClient(pswp, prectl); | 
|---|
| 3083 | if (prectl) | 
|---|
| 3084 | prectl->yBottom += adjust; | 
|---|
| 3085 | if (pswp) { | 
|---|
| 3086 | if (!avoidtree || fFreeTree) | 
|---|
| 3087 | pswp->x = 0; | 
|---|
| 3088 | pswp->y = adjust; | 
|---|
| 3089 | if (pswp->cy >= adjust) | 
|---|
| 3090 | pswp->cy -= adjust; | 
|---|
| 3091 | else | 
|---|
| 3092 | pswp->cy = 0; | 
|---|
| 3093 | } | 
|---|
| 3094 | } | 
|---|
| 3095 |  | 
|---|
| 3096 | static VOID MoveChildrenAwayFromTree(HWND hwndClient) | 
|---|
| 3097 | { | 
|---|
| 3098 | SWP swpC, swpT, swp; | 
|---|
| 3099 | USHORT id; | 
|---|
| 3100 | HWND hwndChild; | 
|---|
| 3101 | HENUM henum; | 
|---|
| 3102 |  | 
|---|
| 3103 | if (fFreeTree) | 
|---|
| 3104 | return; | 
|---|
| 3105 | WinQueryWindowPos(hwndClient, &swpC); | 
|---|
| 3106 | if (swpC.fl & (SWP_MINIMIZE | SWP_HIDE)) | 
|---|
| 3107 | return; | 
|---|
| 3108 | WinQueryWindowPos(hwndTree, &swpT); | 
|---|
| 3109 | henum = WinBeginEnumWindows(hwndClient); | 
|---|
| 3110 | while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) { | 
|---|
| 3111 | id = WinQueryWindowUShort(hwndChild, QWS_ID); | 
|---|
| 3112 | if (!id || id == TREE_FRAME) | 
|---|
| 3113 | continue; | 
|---|
| 3114 | WinQueryWindowPos(hwndChild, &swp); | 
|---|
| 3115 | if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) { | 
|---|
| 3116 | if (swp.x < swpT.cx) { | 
|---|
| 3117 | swp.x = swpT.cx; | 
|---|
| 3118 | if (swp.x + swp.cx > swpC.cx) | 
|---|
| 3119 | swp.cx = swpC.cx - swp.x; | 
|---|
| 3120 | if (swp.cx > 24) | 
|---|
| 3121 | WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy, | 
|---|
| 3122 | SWP_SIZE | SWP_MOVE | SWP_SHOW); | 
|---|
| 3123 | } | 
|---|
| 3124 | } | 
|---|
| 3125 | } | 
|---|
| 3126 | WinEndEnumWindows(henum); | 
|---|
| 3127 | } | 
|---|
| 3128 |  | 
|---|
| 3129 | static VOID ArrangeIcons(HWND hwndClient) | 
|---|
| 3130 | { | 
|---|
| 3131 | HENUM henum; | 
|---|
| 3132 | HWND hwndChild; | 
|---|
| 3133 | SWP swp; | 
|---|
| 3134 |  | 
|---|
| 3135 | henum = WinBeginEnumWindows(hwndClient); | 
|---|
| 3136 | while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) { | 
|---|
| 3137 | WinQueryWindowPos(hwndChild, &swp); | 
|---|
| 3138 | if (swp.fl & (SWP_MINIMIZE | SWP_HIDE)) { | 
|---|
| 3139 | WinSetWindowUShort(hwndChild, QWS_XMINIMIZE, (USHORT) - 1); | 
|---|
| 3140 | WinSetWindowUShort(hwndChild, QWS_YMINIMIZE, (USHORT) - 1); | 
|---|
| 3141 | WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0, | 
|---|
| 3142 | SWP_MOVE | SWP_SHOW | SWP_FOCUSDEACTIVATE); | 
|---|
| 3143 | } | 
|---|
| 3144 | } | 
|---|
| 3145 | WinEndEnumWindows(henum); | 
|---|
| 3146 | } | 
|---|
| 3147 |  | 
|---|
| 3148 | static VOID NextChild(HWND hwndClient, BOOL previous) | 
|---|
| 3149 | { | 
|---|
| 3150 | HENUM henum; | 
|---|
| 3151 | HWND hwndActive, hwndNext, hwndPrev = (HWND) 0; | 
|---|
| 3152 | BOOL next = FALSE, once = FALSE; | 
|---|
| 3153 |  | 
|---|
| 3154 | previous = !previous; | 
|---|
| 3155 |  | 
|---|
| 3156 | hwndActive = WinQueryActiveWindow(hwndClient); | 
|---|
| 3157 | if (!hwndActive) | 
|---|
| 3158 | next = TRUE; | 
|---|
| 3159 | henum = WinBeginEnumWindows(hwndClient); | 
|---|
| 3160 | for (;;) { | 
|---|
| 3161 | hwndNext = WinGetNextWindow(henum); | 
|---|
| 3162 | if (hwndNext) { | 
|---|
| 3163 | if (!WinQueryWindowUShort(hwndNext, QWS_ID)) | 
|---|
| 3164 | continue; | 
|---|
| 3165 | if (next) | 
|---|
| 3166 | break; | 
|---|
| 3167 | if (hwndNext == hwndActive) { | 
|---|
| 3168 | if (!previous && hwndPrev) { | 
|---|
| 3169 | hwndNext = hwndPrev; | 
|---|
| 3170 | break; | 
|---|
| 3171 | } | 
|---|
| 3172 | else if (previous) | 
|---|
| 3173 | next = TRUE; | 
|---|
| 3174 | } | 
|---|
| 3175 | hwndPrev = hwndNext; | 
|---|
| 3176 | } | 
|---|
| 3177 | else { | 
|---|
| 3178 | if ((!next && previous) || once) | 
|---|
| 3179 | break; | 
|---|
| 3180 | else if (!previous) { | 
|---|
| 3181 | hwndNext = hwndPrev; | 
|---|
| 3182 | break; | 
|---|
| 3183 | } | 
|---|
| 3184 | else | 
|---|
| 3185 | once = next = TRUE; | 
|---|
| 3186 | } | 
|---|
| 3187 | } | 
|---|
| 3188 | WinEndEnumWindows(henum); | 
|---|
| 3189 |  | 
|---|
| 3190 | if (hwndNext && hwndNext != hwndActive) { | 
|---|
| 3191 | WinSetWindowPos(hwndNext, HWND_TOP, 0, 0, 0, 0, | 
|---|
| 3192 | SWP_ZORDER | SWP_ACTIVATE); | 
|---|
| 3193 | WinSetWindowPos(hwndActive, ((previous) ? HWND_BOTTOM : hwndNext), 0, 0, | 
|---|
| 3194 | 0, 0, SWP_ZORDER); | 
|---|
| 3195 | } | 
|---|
| 3196 | } | 
|---|
| 3197 |  | 
|---|
| 3198 | /** | 
|---|
| 3199 | * Close child windows | 
|---|
| 3200 | * @return TRUE if application data saved otherwise FALSE | 
|---|
| 3201 | */ | 
|---|
| 3202 |  | 
|---|
| 3203 | BOOL CloseChildren(HWND hwndClient) | 
|---|
| 3204 | { | 
|---|
| 3205 | HENUM henum; | 
|---|
| 3206 | HWND hwndChild; | 
|---|
| 3207 | BOOL ret = FALSE; | 
|---|
| 3208 |  | 
|---|
| 3209 | fNoTileUpdate = TRUE; | 
|---|
| 3210 | henum = WinBeginEnumWindows(hwndClient); | 
|---|
| 3211 | while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) { | 
|---|
| 3212 | if (hwndChild != hwndTree) { | 
|---|
| 3213 | WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT), | 
|---|
| 3214 | WM_SAVEAPPLICATION, MPVOID, MPVOID); | 
|---|
| 3215 | if (WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT), | 
|---|
| 3216 | WM_CLOSE, MPVOID, MPVOID)) { | 
|---|
| 3217 | ret = TRUE; | 
|---|
| 3218 | break; | 
|---|
| 3219 | } | 
|---|
| 3220 | } | 
|---|
| 3221 | } | 
|---|
| 3222 | WinEndEnumWindows(henum); | 
|---|
| 3223 | fNoTileUpdate = FALSE; | 
|---|
| 3224 | return ret; | 
|---|
| 3225 | } | 
|---|
| 3226 |  | 
|---|
| 3227 | BOOL CloseDirCnrChildren(HWND hwndClient) | 
|---|
| 3228 | { | 
|---|
| 3229 | // returns TRUE if a directory container window was told to close | 
|---|
| 3230 |  | 
|---|
| 3231 | HENUM henum; | 
|---|
| 3232 | HWND hwndChild, hwndDir, hwndTemp; | 
|---|
| 3233 | BOOL ret = FALSE; | 
|---|
| 3234 |  | 
|---|
| 3235 | fNoTileUpdate = TRUE; | 
|---|
| 3236 | henum = WinBeginEnumWindows(hwndClient); | 
|---|
| 3237 | while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) { | 
|---|
| 3238 | if (hwndChild != hwndTree) { | 
|---|
| 3239 | hwndTemp = WinWindowFromID(hwndChild, FID_CLIENT); | 
|---|
| 3240 | if (hwndTemp) { | 
|---|
| 3241 | hwndDir = WinWindowFromID(hwndTemp, DIR_CNR); | 
|---|
| 3242 | if (hwndDir) { | 
|---|
| 3243 | WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT), | 
|---|
| 3244 | WM_CLOSE, MPVOID, MPVOID); | 
|---|
| 3245 | ret = TRUE; | 
|---|
| 3246 | } | 
|---|
| 3247 | } | 
|---|
| 3248 | } | 
|---|
| 3249 | } | 
|---|
| 3250 | WinEndEnumWindows(henum); | 
|---|
| 3251 | fNoTileUpdate = FALSE; | 
|---|
| 3252 | return ret; | 
|---|
| 3253 | } | 
|---|
| 3254 |  | 
|---|
| 3255 | /** Save directory container state | 
|---|
| 3256 | * @param hwndClient Client window handle | 
|---|
| 3257 | * @param pszStateName State name to save, NULL to save global state | 
|---|
| 3258 | * @returns Number of directory container windows that were saved or -1 if error | 
|---|
| 3259 | * @seealso RestoreDirCnrState | 
|---|
| 3260 | */ | 
|---|
| 3261 |  | 
|---|
| 3262 | INT SaveDirCnrState(HWND hwndClient, PCSZ pszStateName) | 
|---|
| 3263 | { | 
|---|
| 3264 | HENUM henum; | 
|---|
| 3265 | HWND hwndChild, hwndDir, hwndC; | 
|---|
| 3266 | ULONG numsaves = 0, flWindowAttr; | 
|---|
| 3267 | ULONG previous_numsaves, ulTemp = sizeof(ULONG); | 
|---|
| 3268 | CHAR szPrefix[STATE_NAME_MAX_BYTES + 1]; | 
|---|
| 3269 | CHAR szKey[STATE_NAME_MAX_BYTES + 80], szKeyBase[STATE_NAME_MAX_BYTES + 80], *eos; | 
|---|
| 3270 | CHAR szDir[CCHMAXPATH]; | 
|---|
| 3271 | SWP swp; | 
|---|
| 3272 | DIRCNRDATA *dcd; | 
|---|
| 3273 | BOOL fIsShutDownState; | 
|---|
| 3274 |  | 
|---|
| 3275 | if (!pszStateName || !*pszStateName) { | 
|---|
| 3276 | Runtime_Error(pszSrcFile, __LINE__, NULL); | 
|---|
| 3277 | return -1; | 
|---|
| 3278 | } | 
|---|
| 3279 | if (strlen(pszStateName) > sizeof(szPrefix) - 2) { | 
|---|
| 3280 | Runtime_Error(pszSrcFile, __LINE__, "SaveDirCnrState"); | 
|---|
| 3281 | return -1; | 
|---|
| 3282 | } | 
|---|
| 3283 |  | 
|---|
| 3284 | fIsShutDownState = strcmp(pszStateName, PCSZ_SHUTDOWNSTATE) == 0; | 
|---|
| 3285 | sprintf(szPrefix, "%s.", pszStateName); | 
|---|
| 3286 |  | 
|---|
| 3287 | if (*lasttoolbar) { | 
|---|
| 3288 | sprintf(szKey, "%sToolbar", szPrefix); | 
|---|
| 3289 | PrfWriteProfileString(fmprof, FM3Str, szKey, lasttoolbar); | 
|---|
| 3290 | } | 
|---|
| 3291 |  | 
|---|
| 3292 | if (!fIsShutDownState) { | 
|---|
| 3293 | sprintf(szKey, "%sTargetDir", szPrefix); | 
|---|
| 3294 | PrfWriteProfileString(fmprof, FM3Str, szKey, targetdir); | 
|---|
| 3295 | sprintf(szKey, "%sVersion", szPrefix); | 
|---|
| 3296 | PrfWriteProfileString(fmprof, FM3Str, szKey, "3.16"); | 
|---|
| 3297 | } | 
|---|
| 3298 |  | 
|---|
| 3299 | henum = WinBeginEnumWindows(hwndClient); | 
|---|
| 3300 | while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) { | 
|---|
| 3301 | if (hwndChild != hwndTree) { | 
|---|
| 3302 | hwndC = WinWindowFromID(hwndChild, FID_CLIENT); | 
|---|
| 3303 | if (hwndC) { | 
|---|
| 3304 | hwndDir = WinWindowFromID(hwndC, DIR_CNR); | 
|---|
| 3305 | if (hwndDir) { | 
|---|
| 3306 | WinQueryWindowPos(hwndChild, &swp); | 
|---|
| 3307 | *szDir = 0; | 
|---|
| 3308 | WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(szDir), MPVOID); | 
|---|
| 3309 | if (*szDir) { | 
|---|
| 3310 | // If saving shutdown state skip no prescan drives | 
|---|
| 3311 | if (fIsShutDownState && | 
|---|
| 3312 | driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN) { | 
|---|
| 3313 | continue; | 
|---|
| 3314 | } | 
|---|
| 3315 | sprintf(szKeyBase, "%sDirCnr.%lu", szPrefix, numsaves); | 
|---|
| 3316 | strcpy(szKey, szKeyBase); | 
|---|
| 3317 | strcat(szKey, "."); | 
|---|
| 3318 | eos = &szKey[strlen(szKey)]; | 
|---|
| 3319 | strcpy(eos, "Pos"); | 
|---|
| 3320 | PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & swp, | 
|---|
| 3321 | sizeof(SWP)); | 
|---|
| 3322 | dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER); | 
|---|
| 3323 | if (dcd) { | 
|---|
| 3324 | strcpy(eos, "Sort"); | 
|---|
| 3325 | PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->sortFlags, | 
|---|
| 3326 | sizeof(INT)); | 
|---|
| 3327 | strcpy(eos, "Filter"); | 
|---|
| 3328 | PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->mask, | 
|---|
| 3329 | sizeof(MASK)); | 
|---|
| 3330 | strcpy(eos, "View"); | 
|---|
| 3331 | flWindowAttr = dcd->flWindowAttr; | 
|---|
| 3332 | if (!fLeaveTree && (flWindowAttr & CV_TREE)) { | 
|---|
| 3333 | flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT)); | 
|---|
| 3334 | if (dcd->lastattr) { | 
|---|
| 3335 | if (dcd->lastattr & CV_TEXT) | 
|---|
| 3336 | flWindowAttr |= CV_TEXT; | 
|---|
| 3337 | else if (dcd->lastattr & CV_DETAIL) | 
|---|
| 3338 | flWindowAttr |= CV_DETAIL; | 
|---|
| 3339 | else if (dcd->lastattr & CV_ICON) | 
|---|
| 3340 | flWindowAttr |= CV_ICON; | 
|---|
| 3341 | else | 
|---|
| 3342 | flWindowAttr |= CV_NAME; | 
|---|
| 3343 | } | 
|---|
| 3344 | else | 
|---|
| 3345 | flWindowAttr |= CV_NAME; | 
|---|
| 3346 | } | 
|---|
| 3347 | PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) &flWindowAttr, | 
|---|
| 3348 | sizeof(ULONG)); | 
|---|
| 3349 | WriteDetailsSwitches(szKeyBase, &dcd->ds, TRUE); | 
|---|
| 3350 | SavePresParams(hwndDir, szKeyBase); | 
|---|
| 3351 | } | 
|---|
| 3352 | strcpy(eos, "Dir"); | 
|---|
| 3353 | PrfWriteProfileString(fmprof, FM3Str, szKey, szDir); | 
|---|
| 3354 | numsaves++; | 
|---|
| 3355 | } | 
|---|
| 3356 | } | 
|---|
| 3357 | } | 
|---|
| 3358 | } | 
|---|
| 3359 | } // while | 
|---|
| 3360 | WinEndEnumWindows(henum); | 
|---|
| 3361 |  | 
|---|
| 3362 | sprintf(szKey, "%sNumDirsLastTime", szPrefix); | 
|---|
| 3363 | if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) &previous_numsaves, &ulTemp)) { | 
|---|
| 3364 | ULONG size = 0; | 
|---|
| 3365 |  | 
|---|
| 3366 | sprintf(szKey, "%sVersion", szPrefix); | 
|---|
| 3367 | PrfQueryProfileSize(fmprof, FM3Str, szKey, &size); | 
|---|
| 3368 | if (!size && fSaveState) { | 
|---|
| 3369 | for (ulTemp = 0; ulTemp < previous_numsaves; ulTemp++) | 
|---|
| 3370 | RemoveOldCnrSwitches(szPrefix, ulTemp); | 
|---|
| 3371 | sprintf(szKey, "%sVersion", szPrefix); | 
|---|
| 3372 | PrfWriteProfileString(fmprof, FM3Str, szKey, "3.16"); | 
|---|
| 3373 | } | 
|---|
| 3374 | for (ulTemp = numsaves; ulTemp < previous_numsaves; ulTemp++) { | 
|---|
| 3375 | sprintf(szKeyBase, "%sDirCnr.%lu", szPrefix, ulTemp); | 
|---|
| 3376 | RemoveCnrSwitches(szKeyBase, NULL); | 
|---|
| 3377 | } | 
|---|
| 3378 | } | 
|---|
| 3379 | sprintf(szKey, "%sNumDirsLastTime", szPrefix); | 
|---|
| 3380 | if (numsaves) { | 
|---|
| 3381 | PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) &numsaves, sizeof(ULONG)); | 
|---|
| 3382 | WinQueryWindowPos(WinQueryWindow(hwndClient, QW_PARENT), &swp); | 
|---|
| 3383 | sprintf(szKey, "%sMySizeLastTime", szPrefix); | 
|---|
| 3384 | PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) &swp, sizeof(SWP)); | 
|---|
| 3385 | if (WinQueryWindowPos(hwndTree, &swp)) { | 
|---|
| 3386 | sprintf(szKey, "%sLastTreePos", szPrefix); | 
|---|
| 3387 | PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) &swp, sizeof(SWP)); | 
|---|
| 3388 | } | 
|---|
| 3389 | } | 
|---|
| 3390 | else if (fIsShutDownState) { | 
|---|
| 3391 | PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) &numsaves, sizeof(ULONG)); | 
|---|
| 3392 | } | 
|---|
| 3393 | return numsaves; | 
|---|
| 3394 | } | 
|---|
| 3395 |  | 
|---|
| 3396 | static VOID TransformSwp(PSWP pswp, double xtrans, double ytrans) | 
|---|
| 3397 | { | 
|---|
| 3398 | SWP swp; | 
|---|
| 3399 | HWND hwnd; | 
|---|
| 3400 |  | 
|---|
| 3401 | if ((LONG) pswp->x < 0L) { | 
|---|
| 3402 | pswp->cx -= abs(pswp->x); | 
|---|
| 3403 | pswp->x = 0; | 
|---|
| 3404 | } | 
|---|
| 3405 | if ((LONG) pswp->y < 0L) { | 
|---|
| 3406 | pswp->cy -= abs(pswp->y); | 
|---|
| 3407 | pswp->y = 0; | 
|---|
| 3408 | } | 
|---|
| 3409 | pswp->x = (LONG) (((double)pswp->x * 100.0) / xtrans); | 
|---|
| 3410 | pswp->cx = (LONG) (((double)pswp->cx * 100.0) / xtrans); | 
|---|
| 3411 | pswp->y = (LONG) (((double)pswp->y * 100.0) / ytrans); | 
|---|
| 3412 | pswp->cy = (LONG) (((double)pswp->cy * 100.0) / ytrans); | 
|---|
| 3413 | if (pswp->hwnd) { | 
|---|
| 3414 | hwnd = WinQueryWindow(pswp->hwnd, QW_PARENT); | 
|---|
| 3415 | if (hwnd) { | 
|---|
| 3416 | if (WinQueryWindowPos(hwnd, &swp)) { | 
|---|
| 3417 | if (pswp->x > swp.cx) | 
|---|
| 3418 | pswp->x = (swp.cx > 24) ? swp.cx - 24 : swp.cx; | 
|---|
| 3419 | if (pswp->y > swp.cy) | 
|---|
| 3420 | pswp->y = (swp.cy > 24) ? swp.cy - 24 : swp.cy; | 
|---|
| 3421 | if (pswp->x + pswp->cx > swp.cx) | 
|---|
| 3422 | pswp->cx = swp.cx - pswp->x; | 
|---|
| 3423 | if (pswp->y + pswp->cy > swp.cy) | 
|---|
| 3424 | pswp->cy = swp.cy - pswp->y; | 
|---|
| 3425 | } | 
|---|
| 3426 | } | 
|---|
| 3427 | } | 
|---|
| 3428 | } | 
|---|
| 3429 |  | 
|---|
| 3430 | /** Restore directory container state | 
|---|
| 3431 | * @param hwndClient Client window handle | 
|---|
| 3432 | * @param pszStateName State name to restore, NULL to restore global state | 
|---|
| 3433 | * @param noview request view state restore bypass | 
|---|
| 3434 | * @returns TRUE if one or more directory containers were opened | 
|---|
| 3435 | * @seealso SaveDirCnrState | 
|---|
| 3436 | */ | 
|---|
| 3437 |  | 
|---|
| 3438 | static BOOL RestoreDirCnrState(HWND hwndClient, PSZ pszStateName, BOOL noview) | 
|---|
| 3439 | { | 
|---|
| 3440 | CHAR szKey[STATE_NAME_MAX_BYTES + 80], szKeyBase[STATE_NAME_MAX_BYTES + 80]; | 
|---|
| 3441 | CHAR szDir[CCHMAXPATH]; | 
|---|
| 3442 | CHAR szPrefix[STATE_NAME_MAX_BYTES + 2]; | 
|---|
| 3443 | HWND hwndDir, hwndC, hwndPPSave = NULLHANDLE; | 
|---|
| 3444 | SWP swp, swpO, swpN; | 
|---|
| 3445 | ULONG size, numsaves = 0; | 
|---|
| 3446 | LONG x; | 
|---|
| 3447 | double xtrans, ytrans; | 
|---|
| 3448 | BOOL fRestored = FALSE; | 
|---|
| 3449 | DIRCNRDATA localdcd, *dcd; | 
|---|
| 3450 | BOOL fIsShutDownState; | 
|---|
| 3451 | BOOL fDeleteState; | 
|---|
| 3452 |  | 
|---|
| 3453 | if (!pszStateName || !*pszStateName) { | 
|---|
| 3454 | Runtime_Error(pszSrcFile, __LINE__, "no name"); | 
|---|
| 3455 | return fRestored; | 
|---|
| 3456 | } | 
|---|
| 3457 | if (strlen(pszStateName) > sizeof(szPrefix) - 2) { | 
|---|
| 3458 | Runtime_Error(pszSrcFile, __LINE__, "name too long"); | 
|---|
| 3459 | return fRestored; | 
|---|
| 3460 | } | 
|---|
| 3461 |  | 
|---|
| 3462 | sprintf(szPrefix, "%s.", pszStateName); | 
|---|
| 3463 |  | 
|---|
| 3464 | // If restoring shutdown state bypass no-prescan drives | 
|---|
| 3465 | fIsShutDownState = strcmp(pszStateName, PCSZ_SHUTDOWNSTATE) == 0; | 
|---|
| 3466 | // Delete saved state if internally saved state | 
|---|
| 3467 | fDeleteState = strcmp(pszStateName, PCSZ_FM2TEMPTEXT) == 0; | 
|---|
| 3468 | sprintf(szKey, "%sToolbar", szPrefix); | 
|---|
| 3469 | { | 
|---|
| 3470 | if (fToolsChanged) | 
|---|
| 3471 | save_tools(NULL); | 
|---|
| 3472 | PrfQueryProfileString(fmprof, FM3Str, szKey, NULL, lasttoolbar, sizeof(lasttoolbar)); | 
|---|
| 3473 | PrfWriteProfileString(fmprof, FM3Str, "LastToolbar", lasttoolbar); | 
|---|
| 3474 | load_tools(NULL); | 
|---|
| 3475 | PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID); | 
|---|
| 3476 | } | 
|---|
| 3477 | sprintf(szKey, "%sTargetDir", szPrefix); | 
|---|
| 3478 | { | 
|---|
| 3479 | PrfQueryProfileString(fmprof, FM3Str, szKey, NULL, targetdir, sizeof(targetdir)); | 
|---|
| 3480 | PrfWriteProfileString(fmprof, FM3Str, "TargetDir", targetdir); | 
|---|
| 3481 | SetTargetDir(NULLHANDLE, TRUE, NULL); | 
|---|
| 3482 | } | 
|---|
| 3483 | size = sizeof(SWP); | 
|---|
| 3484 | sprintf(szKey, "%sMySizeLastTime", szPrefix); | 
|---|
| 3485 | if (!PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) &swpO, &size) || | 
|---|
| 3486 | size != sizeof(SWP) || !swp.cx || !swp.cy) | 
|---|
| 3487 | { | 
|---|
| 3488 | WinQueryWindowPos(WinQueryWindow(hwndClient, QW_PARENT), &swpO); | 
|---|
| 3489 | } | 
|---|
| 3490 | // If restoring internally saved state, forget info | 
|---|
| 3491 | if (fDeleteState) | 
|---|
| 3492 | PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L); | 
|---|
| 3493 | WinQueryWindowPos(WinQueryWindow(hwndClient, QW_PARENT), &swpN); | 
|---|
| 3494 | if (swpN.fl & (SWP_MINIMIZE | SWP_HIDE)) | 
|---|
| 3495 | swpN = swpO; | 
|---|
| 3496 | xtrans = ((double)swpO.cx * 100.0) / (double)swpN.cx; | 
|---|
| 3497 | ytrans = ((double)swpO.cy * 100.0) / (double)swpN.cy; | 
|---|
| 3498 | size = sizeof(SWP); | 
|---|
| 3499 | sprintf(szKey, "%sLastTreePos", szPrefix); | 
|---|
| 3500 | if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) &swp, &size)) { | 
|---|
| 3501 | if (fDeleteState) | 
|---|
| 3502 | PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L); | 
|---|
| 3503 | swp.hwnd = hwndTree; | 
|---|
| 3504 | TransformSwp(&swp, xtrans, ytrans); | 
|---|
| 3505 | if (!fFreeTree) { | 
|---|
| 3506 | WinQueryWindowPos(hwndClient, &swpN); | 
|---|
| 3507 | swp.x = 0; | 
|---|
| 3508 | swp.y = (swpN.cy - swp.cy); | 
|---|
| 3509 | } | 
|---|
| 3510 | if (!(swp.fl & (SWP_MINIMIZE | SWP_HIDE))) { | 
|---|
| 3511 | swp.fl &= (~SWP_ACTIVATE); | 
|---|
| 3512 | WinSetWindowPos(hwndTree, | 
|---|
| 3513 | HWND_TOP, | 
|---|
| 3514 | swp.x, | 
|---|
| 3515 | swp.y, | 
|---|
| 3516 | swp.cx, | 
|---|
| 3517 | swp.cy, | 
|---|
| 3518 | swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER); | 
|---|
| 3519 | } | 
|---|
| 3520 | else { | 
|---|
| 3521 | WinSetWindowPos(hwndTree, | 
|---|
| 3522 | HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE | SWP_SHOW); | 
|---|
| 3523 | WinSetWindowUShort(hwndTree, QWS_XRESTORE, (USHORT) swp.x); | 
|---|
| 3524 | WinSetWindowUShort(hwndTree, QWS_CXRESTORE, (USHORT) swp.cx); | 
|---|
| 3525 | WinSetWindowUShort(hwndTree, QWS_YRESTORE, (USHORT) swp.y); | 
|---|
| 3526 | WinSetWindowUShort(hwndTree, QWS_CYRESTORE, (USHORT) swp.cy); | 
|---|
| 3527 | } | 
|---|
| 3528 | } | 
|---|
| 3529 | sprintf(szKey, "%sNumDirsLastTime", szPrefix); | 
|---|
| 3530 | size = sizeof(ULONG); | 
|---|
| 3531 | if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) &numsaves, &size)) { | 
|---|
| 3532 | if (fDeleteState) | 
|---|
| 3533 | PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L); | 
|---|
| 3534 | for (x = numsaves - 1; x >= 0; x--) { | 
|---|
| 3535 | CHAR *eos = szKey; | 
|---|
| 3536 |  | 
|---|
| 3537 | sprintf(szKeyBase, "%sDirCnr.%lu", szPrefix, x); | 
|---|
| 3538 | strcpy(szKey, szKeyBase); | 
|---|
| 3539 | strcat(szKey, "."); | 
|---|
| 3540 | eos = &szKey[strlen(szKey)]; | 
|---|
| 3541 | strcpy(eos, "Pos"); | 
|---|
| 3542 | size = sizeof(SWP); | 
|---|
| 3543 | if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) &swp, &size)) { | 
|---|
| 3544 | strcpy(eos, "Dir"); ; | 
|---|
| 3545 | size = sizeof(szDir); | 
|---|
| 3546 | if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) szDir, &size)) { | 
|---|
| 3547 | // If restoring shutdown state and drive marked no prescan | 
|---|
| 3548 | // bypass window restore | 
|---|
| 3549 | if (fIsShutDownState && | 
|---|
| 3550 | driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN) { | 
|---|
| 3551 | RemoveCnrSwitches(szKeyBase, NULL); | 
|---|
| 3552 | RemoveOldCnrSwitches(szPrefix, x); | 
|---|
| 3553 | continue; | 
|---|
| 3554 | } | 
|---|
| 3555 | if (x == 0 && fSwitchTreeOnDirChg) | 
|---|
| 3556 | pszFocusDir = xstrdup(szDir, pszSrcFile, __LINE__); | 
|---|
| 3557 | LoadDetailsSwitches(szKeyBase, &localdcd.ds, TRUE); | 
|---|
| 3558 | hwndDir = (HWND) WinSendMsg(hwndClient, | 
|---|
| 3559 | UM_SETDIR, | 
|---|
| 3560 | MPFROMP(szDir), MPFROMLONG(1)); | 
|---|
| 3561 | if (hwndDir) { | 
|---|
| 3562 | hwndC = WinWindowFromID(hwndDir, FID_CLIENT); | 
|---|
| 3563 | if (hwndC) { | 
|---|
| 3564 | HWND hwndCnr = WinWindowFromID(hwndC, DIR_CNR); | 
|---|
| 3565 | if (!hwndPPSave) { | 
|---|
| 3566 | hwndPPSave = WinCreateWindow(hwndCnr,         // Create a window (used to save default presparams) | 
|---|
| 3567 | (CHAR *) WC_CONTAINER, | 
|---|
| 3568 | NULL, | 
|---|
| 3569 | CCS_AUTOPOSITION | CCS_MINIICONS | | 
|---|
| 3570 | CCS_MINIRECORDCORE | ulCnrType, | 
|---|
| 3571 | 0, | 
|---|
| 3572 | 0, | 
|---|
| 3573 | 0, | 
|---|
| 3574 | 0, | 
|---|
| 3575 | hwndCnr, | 
|---|
| 3576 | HWND_TOP, (ULONG) -1, NULL, NULL); | 
|---|
| 3577 | CopyPresParams(hwndPPSave, hwndC); | 
|---|
| 3578 | RestorePresParams(hwndPPSave, PCSZ_DIRCNR); | 
|---|
| 3579 | } | 
|---|
| 3580 | RestorePresParams(hwndCnr, szKeyBase); | 
|---|
| 3581 | dcd = WinQueryWindowPtr(hwndCnr, QWL_USER); | 
|---|
| 3582 | if (dcd) { | 
|---|
| 3583 | dcd->ds.detailslongname = localdcd.ds.detailslongname; | 
|---|
| 3584 | dcd->ds.detailssubject  = localdcd.ds.detailssubject ; | 
|---|
| 3585 | dcd->ds.detailsattr     = localdcd.ds.detailsattr    ; | 
|---|
| 3586 | dcd->ds.detailsea       = localdcd.ds.detailsea      ; | 
|---|
| 3587 | dcd->ds.detailssize     = localdcd.ds.detailssize    ; | 
|---|
| 3588 | dcd->ds.detailsicon     = localdcd.ds.detailsicon    ; | 
|---|
| 3589 | dcd->ds.detailscrdate   = localdcd.ds.detailscrdate  ; | 
|---|
| 3590 | dcd->ds.detailscrtime   = localdcd.ds.detailscrtime  ; | 
|---|
| 3591 | dcd->ds.detailsladate   = localdcd.ds.detailsladate  ; | 
|---|
| 3592 | dcd->ds.detailslatime   = localdcd.ds.detailslatime  ; | 
|---|
| 3593 | dcd->ds.detailslwdate   = localdcd.ds.detailslwdate  ; | 
|---|
| 3594 | dcd->ds.detailslwtime   = localdcd.ds.detailslwtime  ; | 
|---|
| 3595 | strcpy(eos, "Sort"); | 
|---|
| 3596 | size = sizeof(INT); | 
|---|
| 3597 | if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) &dcd->sortFlags, | 
|---|
| 3598 | &size)) { | 
|---|
| 3599 | if (!dcd->sortFlags) | 
|---|
| 3600 | dcd->sortFlags = SORT_PATHNAME; | 
|---|
| 3601 | } | 
|---|
| 3602 | size = sizeof(MASK); | 
|---|
| 3603 | strcpy(eos, "Filter"); | 
|---|
| 3604 | if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) &dcd->mask, &size)) { | 
|---|
| 3605 | if (*dcd->mask.szMask) | 
|---|
| 3606 | WinSendMsg(WinWindowFromID(hwndC, DIR_CNR), | 
|---|
| 3607 | UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID); | 
|---|
| 3608 | } | 
|---|
| 3609 | *(dcd->mask.prompt) = 0; | 
|---|
| 3610 | strcpy(eos, "View"); | 
|---|
| 3611 | if (!noview) { | 
|---|
| 3612 | size = sizeof(ULONG); | 
|---|
| 3613 | if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) &dcd->flWindowAttr, | 
|---|
| 3614 | &size)) { | 
|---|
| 3615 |  | 
|---|
| 3616 | CNRINFO cnri; | 
|---|
| 3617 |  | 
|---|
| 3618 | memset(&cnri, 0, sizeof(CNRINFO)); | 
|---|
| 3619 | cnri.cb = sizeof(CNRINFO); | 
|---|
| 3620 | if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR), | 
|---|
| 3621 | CM_QUERYCNRINFO, | 
|---|
| 3622 | MPFROMP(&cnri), | 
|---|
| 3623 | MPFROMLONG(sizeof(CNRINFO)))) { | 
|---|
| 3624 | cnri.flWindowAttr = dcd->flWindowAttr; | 
|---|
| 3625 | WinSendMsg(WinWindowFromID(hwndC, DIR_CNR), | 
|---|
| 3626 | CM_SETCNRINFO, | 
|---|
| 3627 | MPFROMP(&cnri), | 
|---|
| 3628 | MPFROMLONG(CMA_FLWINDOWATTR)); | 
|---|
| 3629 | } | 
|---|
| 3630 | } | 
|---|
| 3631 | } | 
|---|
| 3632 | if (!PostMsg(hwndCnr, UM_SETUP2, NULL, NULL)) | 
|---|
| 3633 | WinSendMsg(hwndCnr, UM_SETUP2, NULL, NULL); | 
|---|
| 3634 | } | 
|---|
| 3635 | } | 
|---|
| 3636 | fRestored = TRUE; | 
|---|
| 3637 | swp.hwnd = hwndDir; | 
|---|
| 3638 | TransformSwp(&swp, xtrans, ytrans); | 
|---|
| 3639 | if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) { | 
|---|
| 3640 | WinSetWindowPos(hwndDir, | 
|---|
| 3641 | HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE | SWP_SHOW); | 
|---|
| 3642 | WinSetWindowUShort(hwndDir, QWS_XRESTORE, (USHORT) swp.x); | 
|---|
| 3643 | WinSetWindowUShort(hwndDir, QWS_CXRESTORE, (USHORT) swp.cx); | 
|---|
| 3644 | WinSetWindowUShort(hwndDir, QWS_YRESTORE, (USHORT) swp.y); | 
|---|
| 3645 | WinSetWindowUShort(hwndDir, QWS_CYRESTORE, (USHORT) swp.cy); | 
|---|
| 3646 | } else | 
|---|
| 3647 | WinSetWindowPos(hwndDir, | 
|---|
| 3648 | HWND_TOP, | 
|---|
| 3649 | swp.x, | 
|---|
| 3650 | swp.y, | 
|---|
| 3651 | swp.cx, | 
|---|
| 3652 | swp.cy, | 
|---|
| 3653 | swp.fl | SWP_MOVE | | 
|---|
| 3654 | SWP_SIZE | SWP_SHOW |  SWP_ZORDER | | 
|---|
| 3655 | SWP_ACTIVATE); | 
|---|
| 3656 | } | 
|---|
| 3657 | if (fDeleteState) | 
|---|
| 3658 | RemoveCnrSwitches(szKeyBase, pszStateName); | 
|---|
| 3659 | } | 
|---|
| 3660 | } | 
|---|
| 3661 | } // for | 
|---|
| 3662 | if (hwndPPSave) { | 
|---|
| 3663 | SavePresParams(hwndPPSave, PCSZ_DIRCNR); | 
|---|
| 3664 | WinDestroyWindow(hwndPPSave); | 
|---|
| 3665 | } | 
|---|
| 3666 | } | 
|---|
| 3667 | return fRestored; | 
|---|
| 3668 | } | 
|---|
| 3669 |  | 
|---|
| 3670 | static ULONG CountChildren(HWND hwndClient, ULONG * ulNumMinChildren) | 
|---|
| 3671 | { | 
|---|
| 3672 | HENUM henum; | 
|---|
| 3673 | HWND hwndChild; | 
|---|
| 3674 | SWP swp; | 
|---|
| 3675 | register ULONG ulCnt = 0L; | 
|---|
| 3676 | USHORT id; | 
|---|
| 3677 |  | 
|---|
| 3678 | if (ulNumMinChildren) | 
|---|
| 3679 | *ulNumMinChildren = 0L; | 
|---|
| 3680 | henum = WinBeginEnumWindows(hwndClient); | 
|---|
| 3681 | while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) { | 
|---|
| 3682 | id = WinQueryWindowUShort(hwndChild, QWS_ID); | 
|---|
| 3683 | if (!id || (!fFreeTree && id == TREE_FRAME)) | 
|---|
| 3684 | continue; | 
|---|
| 3685 | ulCnt++; | 
|---|
| 3686 | if (ulNumMinChildren) { | 
|---|
| 3687 | if (WinQueryWindowPos(hwndChild, &swp) && (swp.fl & SWP_MINIMIZE)) | 
|---|
| 3688 | (*ulNumMinChildren)++; | 
|---|
| 3689 | } | 
|---|
| 3690 | } | 
|---|
| 3691 | WinEndEnumWindows(henum); | 
|---|
| 3692 | return ulCnt; | 
|---|
| 3693 | } | 
|---|
| 3694 |  | 
|---|
| 3695 | VOID GetNextWindowPos(HWND hwndClient, PSWP pswp, ULONG * ulCntR, | 
|---|
| 3696 | ULONG * ulNumMinChildrenR) | 
|---|
| 3697 | { | 
|---|
| 3698 | register ULONG ulCnt; | 
|---|
| 3699 | ULONG ulNumMinChildren; | 
|---|
| 3700 | RECTL Rectl; | 
|---|
| 3701 | register ULONG ulXDiff, ulYDiff, ulWindowsPerStack; | 
|---|
| 3702 |  | 
|---|
| 3703 | if (!ulCntR || !ulNumMinChildrenR) | 
|---|
| 3704 | ulCnt = CountChildren(hwndClient, &ulNumMinChildren); | 
|---|
| 3705 | else { | 
|---|
| 3706 | ulCnt = *ulCntR; | 
|---|
| 3707 | ulNumMinChildren = *ulNumMinChildrenR; | 
|---|
| 3708 | if (ulCnt == (ULONG) - 1) { | 
|---|
| 3709 | ulCnt = CountChildren(hwndClient, &ulNumMinChildren); | 
|---|
| 3710 | // return these values to the caller for later use | 
|---|
| 3711 | *ulCntR = ulCnt; | 
|---|
| 3712 | *ulNumMinChildrenR = ulNumMinChildren; | 
|---|
| 3713 | } | 
|---|
| 3714 | } | 
|---|
| 3715 | WinQueryWindowRect(hwndClient, &Rectl); | 
|---|
| 3716 | AdjustSizeOfClient(NULL, &Rectl); | 
|---|
| 3717 | if (!fFreeTree) { | 
|---|
| 3718 |  | 
|---|
| 3719 | SWP swp; | 
|---|
| 3720 |  | 
|---|
| 3721 | WinQueryWindowPos(hwndTree, &swp); | 
|---|
| 3722 | if (ulNumMinChildren || (swp.fl & (SWP_HIDE | SWP_MINIMIZE))) | 
|---|
| 3723 | Rectl.yBottom += WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2; | 
|---|
| 3724 | } | 
|---|
| 3725 | else if (ulNumMinChildren) | 
|---|
| 3726 | Rectl.yBottom += WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2; | 
|---|
| 3727 |  | 
|---|
| 3728 | ulXDiff = WinQuerySysValue(HWND_DESKTOP, SV_CXSIZEBORDER) + | 
|---|
| 3729 | WinQuerySysValue(HWND_DESKTOP, SV_CXMINMAXBUTTON) / 2; | 
|---|
| 3730 | ulYDiff = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER) + | 
|---|
| 3731 | WinQuerySysValue(HWND_DESKTOP, SV_CYMINMAXBUTTON); | 
|---|
| 3732 | ulWindowsPerStack = (Rectl.yTop - Rectl.yBottom) / (3 * ulYDiff); | 
|---|
| 3733 | pswp->cx = Rectl.xRight - (ulWindowsPerStack * ulXDiff); | 
|---|
| 3734 | pswp->cy = (Rectl.yTop - Rectl.yBottom) - (ulWindowsPerStack * ulYDiff); | 
|---|
| 3735 | ulWindowsPerStack++; | 
|---|
| 3736 | pswp->x = Rectl.xLeft + ((ulCnt % ulWindowsPerStack) * ulXDiff); | 
|---|
| 3737 | pswp->y = (Rectl.yTop - pswp->cy - ((ulCnt % ulWindowsPerStack) * ulYDiff)); | 
|---|
| 3738 | } | 
|---|
| 3739 |  | 
|---|
| 3740 | static VOID CascadeChildren(HWND hwndClient) | 
|---|
| 3741 | { | 
|---|
| 3742 | ULONG ulCnt = 0L, ulNumMinChildren; | 
|---|
| 3743 | HWND hwndChild; | 
|---|
| 3744 | HENUM henum; | 
|---|
| 3745 | SWP swp; | 
|---|
| 3746 | USHORT id; | 
|---|
| 3747 | RECTL Rectl; | 
|---|
| 3748 |  | 
|---|
| 3749 | WinQueryWindowPos(hwndClient, &swp); | 
|---|
| 3750 | if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) | 
|---|
| 3751 | return; | 
|---|
| 3752 |  | 
|---|
| 3753 | CountChildren(hwndClient, &ulNumMinChildren); | 
|---|
| 3754 | if (!fFreeTree) { | 
|---|
| 3755 | WinQueryWindowRect(hwndClient, &Rectl); | 
|---|
| 3756 | AdjustSizeOfClient(NULL, &Rectl); | 
|---|
| 3757 | WinQueryWindowPos(hwndTree, &swp); | 
|---|
| 3758 | if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) { | 
|---|
| 3759 | if (swp.y + swp.cy < Rectl.yTop - Rectl.yBottom) | 
|---|
| 3760 | swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y; | 
|---|
| 3761 | if (swp.x != 0) | 
|---|
| 3762 | swp.x = 0; | 
|---|
| 3763 | if (swp.y < 0) | 
|---|
| 3764 | swp.y = 0; | 
|---|
| 3765 | if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft) | 
|---|
| 3766 | swp.cx = Rectl.xRight - Rectl.xLeft; | 
|---|
| 3767 | WinSetWindowPos(hwndTree, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy, | 
|---|
| 3768 | SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE); | 
|---|
| 3769 | } | 
|---|
| 3770 | } | 
|---|
| 3771 | henum = WinBeginEnumWindows(hwndClient); | 
|---|
| 3772 | while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) { | 
|---|
| 3773 | id = WinQueryWindowUShort(hwndChild, QWS_ID); | 
|---|
| 3774 | if (!id || (!fFreeTree && id == TREE_FRAME)) | 
|---|
| 3775 | continue; | 
|---|
| 3776 | WinQueryWindowPos(hwndChild, &swp); | 
|---|
| 3777 | if (!(swp.fl & (SWP_MINIMIZE | SWP_HIDE))) { | 
|---|
| 3778 | GetNextWindowPos(hwndClient, &swp, &ulCnt, &ulNumMinChildren); | 
|---|
| 3779 | WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy, | 
|---|
| 3780 | SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_RESTORE | | 
|---|
| 3781 | SWP_ZORDER | SWP_ACTIVATE); | 
|---|
| 3782 | ulCnt++; | 
|---|
| 3783 | } | 
|---|
| 3784 | } | 
|---|
| 3785 | WinEndEnumWindows(henum); | 
|---|
| 3786 | } | 
|---|
| 3787 |  | 
|---|
| 3788 | VOID TileChildren(HWND hwndClient, BOOL absolute) | 
|---|
| 3789 | { | 
|---|
| 3790 | register ULONG ulChildCnt, ulSquare, ulNumRows, ulNumCols, ulExtraCols, | 
|---|
| 3791 | ulWidth, ulHeight; | 
|---|
| 3792 | ULONG ulNumMinChildren; | 
|---|
| 3793 | RECTL Rectl; | 
|---|
| 3794 | HWND hwndChild; | 
|---|
| 3795 | SWP swp; | 
|---|
| 3796 |  | 
|---|
| 3797 | if (fNoTileUpdate || hwndClient == HWND_DESKTOP) | 
|---|
| 3798 | return; | 
|---|
| 3799 |  | 
|---|
| 3800 | WinQueryWindowPos(hwndClient, &swp); | 
|---|
| 3801 | if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) | 
|---|
| 3802 | return; | 
|---|
| 3803 |  | 
|---|
| 3804 | ulChildCnt = CountChildren(hwndClient, &ulNumMinChildren); | 
|---|
| 3805 | ulChildCnt -= ulNumMinChildren; | 
|---|
| 3806 | if (!ulChildCnt) | 
|---|
| 3807 | return; | 
|---|
| 3808 |  | 
|---|
| 3809 | fNoTileUpdate = TRUE; | 
|---|
| 3810 |  | 
|---|
| 3811 | for (ulSquare = 2; ulSquare * ulSquare <= ulChildCnt; ulSquare++) { | 
|---|
| 3812 | ; | 
|---|
| 3813 | } | 
|---|
| 3814 | if (!fTileBackwards) { | 
|---|
| 3815 | ulNumCols = ulSquare - 1; | 
|---|
| 3816 | ulNumRows = ulChildCnt / ulNumCols; | 
|---|
| 3817 | } | 
|---|
| 3818 | else { | 
|---|
| 3819 | ulNumRows = ulSquare - 1; | 
|---|
| 3820 | ulNumCols = ulChildCnt / ulNumRows; | 
|---|
| 3821 | } | 
|---|
| 3822 | ulExtraCols = ulChildCnt % ulNumCols; | 
|---|
| 3823 |  | 
|---|
| 3824 | WinQueryWindowRect(hwndClient, &Rectl); | 
|---|
| 3825 |  | 
|---|
| 3826 | if (!fFreeTree) { | 
|---|
| 3827 | WinQueryWindowPos(hwndTree, &swp); | 
|---|
| 3828 | if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) { | 
|---|
| 3829 | if (swp.y < 0) | 
|---|
| 3830 | swp.y = 0; | 
|---|
| 3831 | if (swp.y + swp.cy < Rectl.yTop - Rectl.yBottom) | 
|---|
| 3832 | swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y; | 
|---|
| 3833 | if (swp.x != 0) | 
|---|
| 3834 | swp.x = 0; | 
|---|
| 3835 | if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft) | 
|---|
| 3836 | swp.cx = Rectl.xRight - Rectl.xLeft; | 
|---|
| 3837 | WinSetWindowPos(hwndTree, | 
|---|
| 3838 | HWND_TOP, | 
|---|
| 3839 | swp.x, | 
|---|
| 3840 | swp.y, | 
|---|
| 3841 | swp.cx, | 
|---|
| 3842 | swp.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE); | 
|---|
| 3843 | WinQueryWindowPos(hwndTree, &swp); | 
|---|
| 3844 | } | 
|---|
| 3845 | if (ulNumMinChildren || (swp.fl & (SWP_HIDE | SWP_MINIMIZE))) | 
|---|
| 3846 | Rectl.yBottom += WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2; | 
|---|
| 3847 | } | 
|---|
| 3848 | else if (ulNumMinChildren) | 
|---|
| 3849 | Rectl.yBottom += WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2; | 
|---|
| 3850 |  | 
|---|
| 3851 | AdjustSizeOfClient(NULL, &Rectl); | 
|---|
| 3852 |  | 
|---|
| 3853 | if (Rectl.xRight > 0L && (Rectl.yBottom < Rectl.yTop)) { | 
|---|
| 3854 |  | 
|---|
| 3855 | HENUM henum; | 
|---|
| 3856 |  | 
|---|
| 3857 | henum = WinBeginEnumWindows(hwndClient); | 
|---|
| 3858 | if ((hwndChild = WinGetNextWindow(henum)) != (HWND) 0) { | 
|---|
| 3859 |  | 
|---|
| 3860 | ULONG ulCurRow, ulCurCol; | 
|---|
| 3861 | SWP swp; | 
|---|
| 3862 | USHORT id; | 
|---|
| 3863 |  | 
|---|
| 3864 | ulHeight = (Rectl.yTop - Rectl.yBottom) / ulNumRows; | 
|---|
| 3865 |  | 
|---|
| 3866 | for (ulCurRow = 0; ulCurRow < ulNumRows; ulCurRow++) { | 
|---|
| 3867 | if ((ulNumRows - ulCurRow) <= ulExtraCols) | 
|---|
| 3868 | ulNumCols++; | 
|---|
| 3869 | for (ulCurCol = 0; ulCurCol < ulNumCols; ulCurCol++) { | 
|---|
| 3870 | ulWidth = Rectl.xRight / ulNumCols; | 
|---|
| 3871 |  | 
|---|
| 3872 | while (hwndChild) { | 
|---|
| 3873 | id = WinQueryWindowUShort(hwndChild, QWS_ID); | 
|---|
| 3874 | if (id && (id != TREE_FRAME || fFreeTree)) { | 
|---|
| 3875 | WinQueryWindowPos(hwndChild, &swp); | 
|---|
| 3876 | if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) | 
|---|
| 3877 | break; | 
|---|
| 3878 | } | 
|---|
| 3879 | hwndChild = WinGetNextWindow(henum); | 
|---|
| 3880 | } | 
|---|
| 3881 |  | 
|---|
| 3882 | if (hwndChild) { | 
|---|
| 3883 | if (!absolute && (swp.fl & SWP_MAXIMIZE)) { | 
|---|
| 3884 | WinGetMaxPosition(hwndChild, &swp); | 
|---|
| 3885 | WinSetWindowPos(hwndChild, | 
|---|
| 3886 | HWND_TOP, | 
|---|
| 3887 | swp.x, | 
|---|
| 3888 | swp.y, | 
|---|
| 3889 | swp.cx, swp.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW); | 
|---|
| 3890 | WinSetWindowUShort(hwndChild, | 
|---|
| 3891 | QWS_XRESTORE, | 
|---|
| 3892 | (USHORT) ((USHORT) ulWidth * (USHORT) ulCurCol) | 
|---|
| 3893 | + (USHORT) Rectl.xLeft); | 
|---|
| 3894 | WinSetWindowUShort(hwndChild, | 
|---|
| 3895 | QWS_YRESTORE, | 
|---|
| 3896 | (USHORT) (Rectl.yTop - | 
|---|
| 3897 | (ulHeight * (ulCurRow + 1)))); | 
|---|
| 3898 | WinSetWindowUShort(hwndChild, QWS_CXRESTORE, (USHORT) ulWidth); | 
|---|
| 3899 | WinSetWindowUShort(hwndChild, QWS_CYRESTORE, (USHORT) ulHeight); | 
|---|
| 3900 | } | 
|---|
| 3901 | else | 
|---|
| 3902 | WinSetWindowPos(hwndChild, | 
|---|
| 3903 | HWND_TOP, | 
|---|
| 3904 | (ulWidth * ulCurCol) + Rectl.xLeft, | 
|---|
| 3905 | Rectl.yTop - (ulHeight * (ulCurRow + 1)), | 
|---|
| 3906 | ulWidth, | 
|---|
| 3907 | ulHeight, | 
|---|
| 3908 | SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE); | 
|---|
| 3909 | hwndChild = WinGetNextWindow(henum); | 
|---|
| 3910 | } | 
|---|
| 3911 | } | 
|---|
| 3912 | if ((ulNumRows - ulCurRow) <= ulExtraCols) { | 
|---|
| 3913 | ulNumCols--; | 
|---|
| 3914 | ulExtraCols--; | 
|---|
| 3915 | } | 
|---|
| 3916 | } | 
|---|
| 3917 | } | 
|---|
| 3918 | WinEndEnumWindows(henum); | 
|---|
| 3919 | } | 
|---|
| 3920 |  | 
|---|
| 3921 | fNoTileUpdate = FALSE; | 
|---|
| 3922 | } | 
|---|
| 3923 |  | 
|---|
| 3924 | static VOID ResizeChildren(HWND hwndClient, SHORT oldcx, SHORT oldcy, | 
|---|
| 3925 | SHORT newcx, SHORT newcy) | 
|---|
| 3926 | { | 
|---|
| 3927 | /** | 
|---|
| 3928 | * resize all children of the client to maintain their proportional | 
|---|
| 3929 | * sizes and positions | 
|---|
| 3930 | */ | 
|---|
| 3931 |  | 
|---|
| 3932 | if (!newcx || !newcy || !oldcx || !oldcy) | 
|---|
| 3933 | return; | 
|---|
| 3934 | { | 
|---|
| 3935 | HENUM henum; | 
|---|
| 3936 | HWND hwndChild; | 
|---|
| 3937 | register LONG x, y, cx, cy, ucx, ucy, ux, uy; | 
|---|
| 3938 | SWP swp; | 
|---|
| 3939 |  | 
|---|
| 3940 | henum = WinBeginEnumWindows(hwndClient); | 
|---|
| 3941 | while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) { | 
|---|
| 3942 | if (!WinQueryWindowUShort(hwndChild, QWS_ID)) | 
|---|
| 3943 | continue; | 
|---|
| 3944 | if (WinQueryWindowPos(hwndChild, &swp)) { | 
|---|
| 3945 | if (swp.fl & (SWP_MINIMIZE | SWP_HIDE)) { | 
|---|
| 3946 | swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE); | 
|---|
| 3947 | swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE); | 
|---|
| 3948 | swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE); | 
|---|
| 3949 | swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE); | 
|---|
| 3950 | } | 
|---|
| 3951 | else if (swp.fl & SWP_MAXIMIZE) { | 
|---|
| 3952 | swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE); | 
|---|
| 3953 | swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE); | 
|---|
| 3954 | swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE); | 
|---|
| 3955 | swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE); | 
|---|
| 3956 | } | 
|---|
| 3957 | cx = (swp.cx) ? (LONG) (((double)oldcx * 100.0) / (double)swp.cx) : 0; | 
|---|
| 3958 | cy = (swp.cy) ? (LONG) (((double)oldcy * 100.0) / (double)swp.cy) : 0; | 
|---|
| 3959 | x = (swp.x) ? (LONG) (((double)oldcx * 100.0) / (double)swp.x) : 0; | 
|---|
| 3960 | y = (swp.y) ? (LONG) (((double)oldcy * 100.0) / (double)swp.y) : 0; | 
|---|
| 3961 | if (x < 0) | 
|---|
| 3962 | x = 0; | 
|---|
| 3963 | if (y < 0) | 
|---|
| 3964 | y = 0; | 
|---|
| 3965 | ux = (x) ? (LONG) (((double)newcx * 100.0) / (double)x) : 0; | 
|---|
| 3966 | uy = (y) ? (LONG) (((double)newcy * 100.0) / (double)y) : 0; | 
|---|
| 3967 | ucx = (cx) ? (LONG) (((double)newcx * 100.0) / (double)cx) : 0; | 
|---|
| 3968 | ucy = (cy) ? (LONG) (((double)newcy * 100.0) / (double)cy) : 0; | 
|---|
| 3969 | if (ux + ucx > newcx) | 
|---|
| 3970 | ucx = newcx - ux; | 
|---|
| 3971 | if (uy + ucy > newcy) | 
|---|
| 3972 | ucy = newcy - uy; | 
|---|
| 3973 |  | 
|---|
| 3974 | if (!(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE))) | 
|---|
| 3975 | WinSetWindowPos(hwndChild, HWND_TOP, ux, uy, ucx, ucy, | 
|---|
| 3976 | SWP_MOVE | SWP_SIZE | SWP_SHOW); | 
|---|
| 3977 | else if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) { | 
|---|
| 3978 | WinSetWindowUShort(hwndChild, QWS_XMINIMIZE, (USHORT) - 1); | 
|---|
| 3979 | WinSetWindowUShort(hwndChild, QWS_YMINIMIZE, (USHORT) - 1); | 
|---|
| 3980 | WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0, | 
|---|
| 3981 | SWP_SIZE | SWP_MOVE | SWP_FOCUSDEACTIVATE); | 
|---|
| 3982 | WinSetWindowUShort(hwndChild, QWS_XRESTORE, (USHORT) ux); | 
|---|
| 3983 | WinSetWindowUShort(hwndChild, QWS_YRESTORE, (USHORT) uy); | 
|---|
| 3984 | WinSetWindowUShort(hwndChild, QWS_CXRESTORE, (USHORT) ucx); | 
|---|
| 3985 | WinSetWindowUShort(hwndChild, QWS_CYRESTORE, (USHORT) ucy); | 
|---|
| 3986 | } | 
|---|
| 3987 | else { | 
|---|
| 3988 | WinGetMaxPosition(hwndChild, &swp); | 
|---|
| 3989 | WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy, | 
|---|
| 3990 | SWP_MOVE | SWP_SIZE | SWP_SHOW); | 
|---|
| 3991 | WinSetWindowUShort(hwndChild, QWS_XRESTORE, (USHORT) ux); | 
|---|
| 3992 | WinSetWindowUShort(hwndChild, QWS_YRESTORE, (USHORT) uy); | 
|---|
| 3993 | WinSetWindowUShort(hwndChild, QWS_CXRESTORE, (USHORT) ucx); | 
|---|
| 3994 | WinSetWindowUShort(hwndChild, QWS_CYRESTORE, (USHORT) ucy); | 
|---|
| 3995 | } | 
|---|
| 3996 | } | 
|---|
| 3997 | } | 
|---|
| 3998 | WinEndEnumWindows(henum); | 
|---|
| 3999 | } | 
|---|
| 4000 | if (!fFreeTree) { | 
|---|
| 4001 |  | 
|---|
| 4002 | RECTL Rectl; | 
|---|
| 4003 | SWP swp; | 
|---|
| 4004 |  | 
|---|
| 4005 | WinQueryWindowRect(hwndClient, &Rectl); | 
|---|
| 4006 | AdjustSizeOfClient(NULL, &Rectl); | 
|---|
| 4007 | WinQueryWindowPos(hwndTree, &swp); | 
|---|
| 4008 | if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) { | 
|---|
| 4009 |  | 
|---|
| 4010 | if (!fNoTreeGap) { | 
|---|
| 4011 | INT height = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2; | 
|---|
| 4012 | if (swp.y < height) | 
|---|
| 4013 | swp.y = height;        // Force bottom to position | 
|---|
| 4014 | } | 
|---|
| 4015 | else | 
|---|
| 4016 | swp.y = 0;                // Force bottom to position | 
|---|
| 4017 |  | 
|---|
| 4018 | swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y; | 
|---|
| 4019 | if (swp.cy < 0) | 
|---|
| 4020 | swp.cy = 0; | 
|---|
| 4021 |  | 
|---|
| 4022 | if (swp.x != 0) | 
|---|
| 4023 | swp.x = 0;                // Left align | 
|---|
| 4024 |  | 
|---|
| 4025 | // AdjustSizeOfClient can return bogus xRight values - fixme someday | 
|---|
| 4026 | if (Rectl.xRight >= Rectl.xLeft) { | 
|---|
| 4027 | if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft) | 
|---|
| 4028 | swp.cx = Rectl.xRight - Rectl.xLeft; | 
|---|
| 4029 | } | 
|---|
| 4030 | WinSetWindowPos(hwndTree, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy, | 
|---|
| 4031 | SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE); | 
|---|
| 4032 | } | 
|---|
| 4033 | } | 
|---|
| 4034 | } | 
|---|
| 4035 |  | 
|---|
| 4036 | static VOID MinResChildren(HWND hwndClient, ULONG cmd) | 
|---|
| 4037 | { | 
|---|
| 4038 | HENUM henum; | 
|---|
| 4039 | HWND hwndChild; | 
|---|
| 4040 |  | 
|---|
| 4041 | { | 
|---|
| 4042 | SWP swp; | 
|---|
| 4043 |  | 
|---|
| 4044 | WinQueryWindowPos(hwndClient, &swp); | 
|---|
| 4045 | if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) | 
|---|
| 4046 | return; | 
|---|
| 4047 | } | 
|---|
| 4048 | henum = WinBeginEnumWindows(hwndClient); | 
|---|
| 4049 | while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) { | 
|---|
| 4050 | if (!WinQueryWindowUShort(hwndChild, QWS_ID)) | 
|---|
| 4051 | continue; | 
|---|
| 4052 | WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0, cmd); | 
|---|
| 4053 | } | 
|---|
| 4054 | } | 
|---|
| 4055 |  | 
|---|
| 4056 | //=== ChildFrameButtonProc: subclass handler for WALKBUTTON and QUICKBUTTON windows === | 
|---|
| 4057 |  | 
|---|
| 4058 | static MRESULT EXPENTRY ChildFrameButtonProc(HWND hwnd, | 
|---|
| 4059 | ULONG msg, | 
|---|
| 4060 | MPARAM mp1, MPARAM mp2) | 
|---|
| 4061 | { | 
|---|
| 4062 | USHORT id; | 
|---|
| 4063 | static BOOL emphasized = FALSE; | 
|---|
| 4064 |  | 
|---|
| 4065 | switch (msg) { | 
|---|
| 4066 | case WM_BUTTON1CLICK: | 
|---|
| 4067 | case WM_CHORD: | 
|---|
| 4068 | shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); | 
|---|
| 4069 | break; | 
|---|
| 4070 |  | 
|---|
| 4071 | case WM_MOUSEMOVE: | 
|---|
| 4072 | if (fOtherHelp) { | 
|---|
| 4073 | if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) | 
|---|
| 4074 | && !WinQueryCapture(HWND_DESKTOP)) { | 
|---|
| 4075 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 4076 | switch (id) { | 
|---|
| 4077 | case IDM_OPENWALK: | 
|---|
| 4078 | MakeBubble(hwnd, FALSE, GetPString(IDS_WALKBUTTONHELP)); | 
|---|
| 4079 | break; | 
|---|
| 4080 | case IDM_USERLIST: | 
|---|
| 4081 | MakeBubble(hwnd, FALSE, GetPString(IDS_QUICKBUTTONHELP)); | 
|---|
| 4082 | break; | 
|---|
| 4083 | } | 
|---|
| 4084 | } | 
|---|
| 4085 | } | 
|---|
| 4086 | break; | 
|---|
| 4087 |  | 
|---|
| 4088 | case WM_BUTTON3CLICK: | 
|---|
| 4089 | case WM_BUTTON2CLICK: | 
|---|
| 4090 | { | 
|---|
| 4091 | USHORT cmd = 0; | 
|---|
| 4092 |  | 
|---|
| 4093 | shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); | 
|---|
| 4094 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 4095 | switch (id) { | 
|---|
| 4096 | case IDM_OPENWALK: | 
|---|
| 4097 | switch (msg) { | 
|---|
| 4098 | case WM_BUTTON2CLICK: | 
|---|
| 4099 | if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) == | 
|---|
| 4100 | (KC_ALT | KC_SHIFT | KC_CTRL)) | 
|---|
| 4101 | cmd = IDM_GREP; | 
|---|
| 4102 | else if ((shiftstate & (KC_ALT | KC_CTRL)) == (KC_ALT | KC_CTRL)) | 
|---|
| 4103 | CascadeChildren(hwndMain); | 
|---|
| 4104 |  | 
|---|
| 4105 | #ifdef NEVER | 
|---|
| 4106 | else if ((shiftstate & (KC_ALT | KC_SHIFT)) == (KC_ALT | KC_SHIFT)) | 
|---|
| 4107 | cmd = IDM_SYSINFO; | 
|---|
| 4108 | #endif | 
|---|
| 4109 |  | 
|---|
| 4110 | else if (shiftstate & KC_SHIFT) | 
|---|
| 4111 | cmd = IDM_WINDOWDLG; | 
|---|
| 4112 | else if (shiftstate & KC_CTRL) | 
|---|
| 4113 | cmd = IDM_SEEALL; | 
|---|
| 4114 | else if (shiftstate & KC_ALT) | 
|---|
| 4115 | TileChildren(hwndMain, TRUE); | 
|---|
| 4116 | else | 
|---|
| 4117 | cmd = IDM_WALKDIR; | 
|---|
| 4118 | break; | 
|---|
| 4119 | case WM_BUTTON3CLICK: | 
|---|
| 4120 | TileChildren(hwndMain, TRUE); | 
|---|
| 4121 | break; | 
|---|
| 4122 | } | 
|---|
| 4123 | break; | 
|---|
| 4124 | case IDM_USERLIST: | 
|---|
| 4125 | switch (msg) { | 
|---|
| 4126 | case WM_BUTTON2CLICK: | 
|---|
| 4127 | if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) == | 
|---|
| 4128 | (KC_ALT | KC_SHIFT | KC_CTRL)) | 
|---|
| 4129 | cmd = IDM_COLORPALETTE; | 
|---|
| 4130 | else if ((shiftstate & (KC_ALT | KC_CTRL)) == (KC_ALT | KC_CTRL)) | 
|---|
| 4131 | cmd = IDM_HIDEMENU; | 
|---|
| 4132 | else if ((shiftstate & (KC_ALT | KC_SHIFT)) == (KC_ALT | KC_SHIFT)) | 
|---|
| 4133 | cmd = IDM_NOTEBOOK; | 
|---|
| 4134 | else if (shiftstate & KC_SHIFT) | 
|---|
| 4135 | cmd = IDM_TOOLTITLES; | 
|---|
| 4136 | else if (shiftstate & KC_CTRL) | 
|---|
| 4137 | cmd = IDM_TEXTTOOLS; | 
|---|
| 4138 | else if (shiftstate & KC_ALT) | 
|---|
| 4139 | cmd = IDM_FONTPALETTE; | 
|---|
| 4140 | else | 
|---|
| 4141 | cmd = IDM_TOOLBAR; | 
|---|
| 4142 | break; | 
|---|
| 4143 | case WM_BUTTON3CLICK: | 
|---|
| 4144 | cmd = IDM_DRIVEBAR; | 
|---|
| 4145 | break; | 
|---|
| 4146 | } | 
|---|
| 4147 | break; | 
|---|
| 4148 | }                                 // switch id | 
|---|
| 4149 |  | 
|---|
| 4150 | if (cmd) { | 
|---|
| 4151 | PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_CLIENT), | 
|---|
| 4152 | WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID); | 
|---|
| 4153 | } | 
|---|
| 4154 | } | 
|---|
| 4155 | break; | 
|---|
| 4156 |  | 
|---|
| 4157 | case DM_DRAGOVER: | 
|---|
| 4158 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 4159 | if (id == IDM_OPENWALK) { | 
|---|
| 4160 | if (!emphasized) { | 
|---|
| 4161 | emphasized = TRUE; | 
|---|
| 4162 | DrawTargetEmphasis(hwnd, emphasized); | 
|---|
| 4163 | } | 
|---|
| 4164 | if (AcceptOneDrop(hwnd, mp1, mp2)) | 
|---|
| 4165 | return MRFROM2SHORT(DOR_DROP, DO_MOVE); | 
|---|
| 4166 | } | 
|---|
| 4167 | return MRFROM2SHORT(DOR_NEVERDROP, 0); | 
|---|
| 4168 |  | 
|---|
| 4169 | case DM_DRAGLEAVE: | 
|---|
| 4170 | if (emphasized) { | 
|---|
| 4171 | emphasized = FALSE; | 
|---|
| 4172 | DrawTargetEmphasis(hwnd, emphasized); | 
|---|
| 4173 | } | 
|---|
| 4174 | break; | 
|---|
| 4175 |  | 
|---|
| 4176 | case DM_DROPHELP: | 
|---|
| 4177 | DropHelp(mp1, mp2, hwnd, GetPString(IDS_OPENDROPHELP)); | 
|---|
| 4178 | return 0; | 
|---|
| 4179 |  | 
|---|
| 4180 | case DM_DROP: | 
|---|
| 4181 | { | 
|---|
| 4182 | char szFrom[CCHMAXPATH + 2]; | 
|---|
| 4183 |  | 
|---|
| 4184 | if (emphasized) { | 
|---|
| 4185 | emphasized = FALSE; | 
|---|
| 4186 | DrawTargetEmphasis(hwnd, emphasized); | 
|---|
| 4187 | } | 
|---|
| 4188 | if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom))) { | 
|---|
| 4189 | if (MakeValidDir(szFrom) && !FindDirCnrByName(szFrom, TRUE)) { | 
|---|
| 4190 | OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, szFrom); | 
|---|
| 4191 | } | 
|---|
| 4192 | } | 
|---|
| 4193 | } | 
|---|
| 4194 | return 0; | 
|---|
| 4195 |  | 
|---|
| 4196 | case WM_CLOSE: | 
|---|
| 4197 | WinDestroyWindow(hwnd); | 
|---|
| 4198 | return 0; | 
|---|
| 4199 | } | 
|---|
| 4200 | return PFNWPButton(hwnd, msg, mp1, mp2); | 
|---|
| 4201 | } | 
|---|
| 4202 |  | 
|---|
| 4203 | static MRESULT EXPENTRY MainFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1, | 
|---|
| 4204 | MPARAM mp2) | 
|---|
| 4205 | { | 
|---|
| 4206 | PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| 4207 | static ULONG aheight = 0L; | 
|---|
| 4208 |  | 
|---|
| 4209 | switch (msg) { | 
|---|
| 4210 | case WM_ADJUSTWINDOWPOS: | 
|---|
| 4211 | { | 
|---|
| 4212 | SWP *pswp; | 
|---|
| 4213 |  | 
|---|
| 4214 | pswp = (SWP *) mp1; | 
|---|
| 4215 | if (fDataMin && !fAmClosing) { | 
|---|
| 4216 | if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE)) { | 
|---|
| 4217 |  | 
|---|
| 4218 | SWP swp; | 
|---|
| 4219 |  | 
|---|
| 4220 | WinQueryWindowPos(hwnd, &swp); | 
|---|
| 4221 | PostMsg(hwnd, UM_FOCUSME, MPFROMLONG(swp.fl), MPVOID); | 
|---|
| 4222 | HideNote(); | 
|---|
| 4223 | } | 
|---|
| 4224 | else if (pswp->fl & (SWP_SHOW | SWP_RESTORE)) { | 
|---|
| 4225 | if (DataHwnd) | 
|---|
| 4226 | PostMsg(DataHwnd, WM_CLOSE, MPVOID, MPVOID); | 
|---|
| 4227 | } | 
|---|
| 4228 | } | 
|---|
| 4229 | if (!fAmClosing) { | 
|---|
| 4230 | if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE)) | 
|---|
| 4231 | HideNote(); | 
|---|
| 4232 | } | 
|---|
| 4233 | } | 
|---|
| 4234 | break; | 
|---|
| 4235 |  | 
|---|
| 4236 | case UM_FOCUSME: | 
|---|
| 4237 | CreateDataBar(HWND_DESKTOP, (ULONG) mp1); | 
|---|
| 4238 | return 0; | 
|---|
| 4239 |  | 
|---|
| 4240 | case WM_BUTTON1UP: | 
|---|
| 4241 | case WM_BUTTON2UP: | 
|---|
| 4242 | case WM_BUTTON3UP: | 
|---|
| 4243 | case WM_MOUSEMOVE: | 
|---|
| 4244 | case WM_CHORD: | 
|---|
| 4245 | shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); | 
|---|
| 4246 | break; | 
|---|
| 4247 |  | 
|---|
| 4248 | case WM_CHAR: | 
|---|
| 4249 | shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL)); | 
|---|
| 4250 | break; | 
|---|
| 4251 |  | 
|---|
| 4252 | case WM_CONTROL: | 
|---|
| 4253 | return WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), UM_CONTROL, mp1, | 
|---|
| 4254 | mp2); | 
|---|
| 4255 |  | 
|---|
| 4256 | case WM_COMMAND: | 
|---|
| 4257 | return WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), msg, mp1, mp2); | 
|---|
| 4258 |  | 
|---|
| 4259 | case WM_CALCFRAMERECT: | 
|---|
| 4260 | { | 
|---|
| 4261 | MRESULT mr; | 
|---|
| 4262 | PRECTL prectl; | 
|---|
| 4263 | LONG sheight = 20, bheight = 20; | 
|---|
| 4264 |  | 
|---|
| 4265 | mr = oldproc(hwnd, msg, mp1, mp2); | 
|---|
| 4266 |  | 
|---|
| 4267 | /** | 
|---|
| 4268 | * Calculate the position of the client rectangle. | 
|---|
| 4269 | * Otherwise, we'll see a lot of redraw when we move the | 
|---|
| 4270 | * client during WM_FORMATFRAME. | 
|---|
| 4271 | */ | 
|---|
| 4272 |  | 
|---|
| 4273 | if (mr && mp2) { | 
|---|
| 4274 | prectl = (PRECTL) mp1; | 
|---|
| 4275 | if (prectl->yBottom != prectl->yTop) { | 
|---|
| 4276 | { | 
|---|
| 4277 | HPS hps; | 
|---|
| 4278 | POINTL aptl[TXTBOX_COUNT]; | 
|---|
| 4279 |  | 
|---|
| 4280 | hps = WinGetPS(hwndStatus); | 
|---|
| 4281 | if (hps) { | 
|---|
| 4282 | GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl); | 
|---|
| 4283 | bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6; | 
|---|
| 4284 | WinReleasePS(hps); | 
|---|
| 4285 | } | 
|---|
| 4286 | } | 
|---|
| 4287 | prectl->yBottom += (sheight + 4); | 
|---|
| 4288 | prectl->yTop -= (sheight + 4); | 
|---|
| 4289 | if (fMoreButtons) { | 
|---|
| 4290 |  | 
|---|
| 4291 | HPS hps; | 
|---|
| 4292 | POINTL aptl[TXTBOX_COUNT]; | 
|---|
| 4293 |  | 
|---|
| 4294 | hps = WinGetPS(hwndName); | 
|---|
| 4295 | if (hps) { | 
|---|
| 4296 | GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl); | 
|---|
| 4297 | bheight = aptl[TXTBOX_TOPLEFT].y + 6; | 
|---|
| 4298 | WinReleasePS(hps); | 
|---|
| 4299 | } | 
|---|
| 4300 | prectl->yBottom += (bheight + 4); | 
|---|
| 4301 | prectl->yTop -= (bheight + 4); | 
|---|
| 4302 | } | 
|---|
| 4303 | if (fToolbar) { | 
|---|
| 4304 | if (!fTextTools) | 
|---|
| 4305 | prectl->yTop -= ((fToolTitles) ? 50 : 40); | 
|---|
| 4306 | else | 
|---|
| 4307 | prectl->yTop -= 32; | 
|---|
| 4308 | } | 
|---|
| 4309 | if (fDrivebar) { | 
|---|
| 4310 | ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES), | 
|---|
| 4311 | ((prectl->xRight - | 
|---|
| 4312 | (WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 4313 | SV_CYSIZEBORDER) * 2)) - 4)); | 
|---|
| 4314 | prectl->yTop -= (16 * (DriveLines * DRIVE_BUTTON_HEIGHT)); | 
|---|
| 4315 | } | 
|---|
| 4316 | if (fUserComboBox) { | 
|---|
| 4317 | if (!aheight) { | 
|---|
| 4318 | SWP swpTemp; | 
|---|
| 4319 | WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT), | 
|---|
| 4320 | &swpTemp); | 
|---|
| 4321 | aheight = swpTemp.cy; | 
|---|
| 4322 | } | 
|---|
| 4323 | prectl->yTop -= (aheight + 6L); | 
|---|
| 4324 | } | 
|---|
| 4325 | if (fAutoView) { | 
|---|
| 4326 | AutoviewHeight = min(AutoviewHeight, | 
|---|
| 4327 | (prectl->yTop - prectl->yBottom) - 116); | 
|---|
| 4328 | AutoviewHeight = max(AutoviewHeight, 36); | 
|---|
| 4329 | prectl->yBottom += (AutoviewHeight + 6); | 
|---|
| 4330 | } | 
|---|
| 4331 | } | 
|---|
| 4332 | } | 
|---|
| 4333 | return mr; | 
|---|
| 4334 | } | 
|---|
| 4335 |  | 
|---|
| 4336 | case WM_FORMATFRAME: | 
|---|
| 4337 | { | 
|---|
| 4338 | SHORT sCount, soldCount; | 
|---|
| 4339 | PSWP pswp, pswpClient, pswpNew; | 
|---|
| 4340 | SWP swpClient; | 
|---|
| 4341 | LONG theight = 48L, dheight = DRIVE_BUTTON_HEIGHT, width, sheight = 20, bheight = 20; | 
|---|
| 4342 |  | 
|---|
| 4343 | sCount = (SHORT) oldproc(hwnd, msg, mp1, mp2); | 
|---|
| 4344 | soldCount = sCount; | 
|---|
| 4345 |  | 
|---|
| 4346 | /** | 
|---|
| 4347 | * Reformat the frame to "squeeze" the client | 
|---|
| 4348 | * and make room for status window sibling beneath | 
|---|
| 4349 | * and toolbar above (if toolbar's on) and userlists | 
|---|
| 4350 | * (if userlists are on). | 
|---|
| 4351 | */ | 
|---|
| 4352 |  | 
|---|
| 4353 | pswp = (PSWP) mp1; | 
|---|
| 4354 | { | 
|---|
| 4355 | SHORT x; | 
|---|
| 4356 |  | 
|---|
| 4357 | for (x = 0; x < soldCount; x++) { | 
|---|
| 4358 | if (WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_CLIENT) { | 
|---|
| 4359 | pswpClient = pswp; | 
|---|
| 4360 | break; | 
|---|
| 4361 | } | 
|---|
| 4362 | pswp++; | 
|---|
| 4363 | } | 
|---|
| 4364 | } | 
|---|
| 4365 |  | 
|---|
| 4366 | { | 
|---|
| 4367 | HPS hps; | 
|---|
| 4368 | POINTL aptl[TXTBOX_COUNT]; | 
|---|
| 4369 |  | 
|---|
| 4370 | hps = WinGetPS(hwndStatus); | 
|---|
| 4371 | if (hps) { | 
|---|
| 4372 | GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl); | 
|---|
| 4373 | bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6; | 
|---|
| 4374 | WinReleasePS(hps); | 
|---|
| 4375 | } | 
|---|
| 4376 | if (fMoreButtons) { | 
|---|
| 4377 | hps = WinGetPS(hwndName); | 
|---|
| 4378 | if (hps) { | 
|---|
| 4379 | GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl); | 
|---|
| 4380 | bheight = aptl[TXTBOX_TOPLEFT].y + 6; | 
|---|
| 4381 | WinReleasePS(hps); | 
|---|
| 4382 | } | 
|---|
| 4383 | } | 
|---|
| 4384 | } | 
|---|
| 4385 | pswpNew = (PSWP) mp1 + soldCount; | 
|---|
| 4386 | *pswpNew = *pswpClient; | 
|---|
| 4387 | swpClient = *pswpClient; | 
|---|
| 4388 | pswpNew->hwnd = hwndStatus; | 
|---|
| 4389 | pswpNew->hwndInsertBehind = HWND_BOTTOM; | 
|---|
| 4390 | pswpNew->x = swpClient.x + 3; | 
|---|
| 4391 | pswpNew->y = swpClient.y + 2; | 
|---|
| 4392 | if (!fSplitStatus) | 
|---|
| 4393 | width = swpClient.cx - (16 + (sheight * 2) + 4); | 
|---|
| 4394 | else | 
|---|
| 4395 | width = (swpClient.cx - (16 + (sheight * 2) + 4)) / 2; | 
|---|
| 4396 | width = max(width, 10); | 
|---|
| 4397 | if (fSplitStatus) | 
|---|
| 4398 | pswpNew->cx = width - 6; | 
|---|
| 4399 | else | 
|---|
| 4400 | pswpNew->cx = width - 8; | 
|---|
| 4401 | pswpNew->cy = sheight; | 
|---|
| 4402 | pswpClient->y = pswpNew->y + pswpNew->cy + 3; | 
|---|
| 4403 | pswpClient->cy = (swpClient.cy - pswpNew->cy) - 3; | 
|---|
| 4404 | sCount++; | 
|---|
| 4405 |  | 
|---|
| 4406 | if (fSplitStatus) { | 
|---|
| 4407 | pswpNew = (PSWP) mp1 + (soldCount + 1); | 
|---|
| 4408 | *pswpNew = *pswpClient; | 
|---|
| 4409 | pswpNew->hwnd = hwndStatus2; | 
|---|
| 4410 | pswpNew->hwndInsertBehind = HWND_BOTTOM; | 
|---|
| 4411 | pswpNew->x = width + 8; | 
|---|
| 4412 | pswpNew->y = swpClient.y + 2; | 
|---|
| 4413 | pswpNew->cx = width - 6; | 
|---|
| 4414 | pswpNew->cy = sheight; | 
|---|
| 4415 | sCount++; | 
|---|
| 4416 | } | 
|---|
| 4417 | else { | 
|---|
| 4418 | WinShowWindow(hwndStatus2, FALSE); | 
|---|
| 4419 | WinSetWindowText(hwndStatus2, NullStr); | 
|---|
| 4420 | } | 
|---|
| 4421 |  | 
|---|
| 4422 | if (fToolbar) { | 
|---|
| 4423 | if (fTextTools) | 
|---|
| 4424 | theight = 32L; | 
|---|
| 4425 | else if (!fToolTitles) | 
|---|
| 4426 | theight = 40L; | 
|---|
| 4427 | pswpNew = (PSWP) mp1 + (soldCount + 1 + (fSplitStatus != FALSE)); | 
|---|
| 4428 | *pswpNew = *pswpClient; | 
|---|
| 4429 | pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_TOOLS); | 
|---|
| 4430 | pswpNew->hwndInsertBehind = HWND_BOTTOM; | 
|---|
| 4431 | pswpNew->x = swpClient.x + 2; | 
|---|
| 4432 | pswpNew->y = (swpClient.y + swpClient.cy) - (theight - 2); | 
|---|
| 4433 | pswpNew->cx = swpClient.cx - 4; | 
|---|
| 4434 | pswpNew->cy = theight - 4; | 
|---|
| 4435 | pswpClient->cy -= theight; | 
|---|
| 4436 | sCount++; | 
|---|
| 4437 | } | 
|---|
| 4438 | else | 
|---|
| 4439 | WinShowWindow(WinWindowFromID(hwnd, MAIN_TOOLS), FALSE); | 
|---|
| 4440 |  | 
|---|
| 4441 | if (fDrivebar) { | 
|---|
| 4442 | ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES), pswpClient->cx - 4); | 
|---|
| 4443 | pswpNew = (PSWP) mp1 + (soldCount + 1 + | 
|---|
| 4444 | (fSplitStatus != FALSE) + | 
|---|
| 4445 | (fToolbar != FALSE)); | 
|---|
| 4446 | *pswpNew = *pswpClient; | 
|---|
| 4447 | pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_DRIVES); | 
|---|
| 4448 | pswpNew->hwndInsertBehind = HWND_BOTTOM; | 
|---|
| 4449 | pswpNew->x = swpClient.x + 2; | 
|---|
| 4450 | dheight += ((dheight) * DriveLines); | 
|---|
| 4451 | pswpNew->y = (swpClient.y + swpClient.cy) - (dheight); | 
|---|
| 4452 | if (fToolbar) | 
|---|
| 4453 | pswpNew->y -= theight; | 
|---|
| 4454 | pswpNew->cx = swpClient.cx - 4; | 
|---|
| 4455 | pswpNew->cy = dheight; | 
|---|
| 4456 | pswpClient->cy -= dheight; | 
|---|
| 4457 | sCount++; | 
|---|
| 4458 | } | 
|---|
| 4459 | else | 
|---|
| 4460 | WinShowWindow(WinWindowFromID(hwnd, MAIN_DRIVES), FALSE); | 
|---|
| 4461 |  | 
|---|
| 4462 | if (fAutoView) { | 
|---|
| 4463 | pswpNew = (PSWP) mp1 + (soldCount + 1 + | 
|---|
| 4464 | (fToolbar != FALSE) + | 
|---|
| 4465 | (fDrivebar != FALSE) + | 
|---|
| 4466 | (fSplitStatus != FALSE)); | 
|---|
| 4467 | *pswpNew = *pswpClient; | 
|---|
| 4468 | pswpNew->hwnd = (fComments) ? hwndAutoMLE : hwndAutoview; | 
|---|
| 4469 | pswpNew->x = pswpClient->x + 3; | 
|---|
| 4470 | pswpNew->y = pswpClient->y + 3; | 
|---|
| 4471 | if (fMoreButtons) | 
|---|
| 4472 | pswpNew->y += (bheight + 4); | 
|---|
| 4473 | pswpNew->cx = pswpClient->cx - 6; | 
|---|
| 4474 | AutoviewHeight = min(AutoviewHeight, pswpClient->cy - 116); | 
|---|
| 4475 | AutoviewHeight = max(AutoviewHeight, 40); | 
|---|
| 4476 | pswpNew->cy = AutoviewHeight; | 
|---|
| 4477 | pswpClient->y += (AutoviewHeight + 6); | 
|---|
| 4478 | pswpClient->cy -= (AutoviewHeight + 6); | 
|---|
| 4479 | sCount++; | 
|---|
| 4480 | WinShowWindow((fComments) ? hwndAutoview : hwndAutoMLE, FALSE); | 
|---|
| 4481 | } | 
|---|
| 4482 | else { | 
|---|
| 4483 | WinShowWindow(hwndAutoview, FALSE); | 
|---|
| 4484 | WinShowWindow(hwndAutoMLE, FALSE); | 
|---|
| 4485 | } | 
|---|
| 4486 |  | 
|---|
| 4487 | pswpNew = (PSWP) mp1 + (soldCount + 1 + | 
|---|
| 4488 | (fToolbar != FALSE) + | 
|---|
| 4489 | (fDrivebar != FALSE) + | 
|---|
| 4490 | (fSplitStatus != FALSE) + (fAutoView != FALSE)); | 
|---|
| 4491 | *pswpNew = *pswpClient; | 
|---|
| 4492 | pswpNew->hwnd = WinWindowFromID(hwnd, IDM_OPENWALK); | 
|---|
| 4493 | pswpNew->x = swpClient.cx - ((sheight * 2) + 4); | 
|---|
| 4494 | pswpNew->y = swpClient.y; | 
|---|
| 4495 | pswpNew->cx = sheight + 4; | 
|---|
| 4496 | pswpNew->cy = sheight + 4; | 
|---|
| 4497 | sCount++; | 
|---|
| 4498 | pswpNew = (PSWP) mp1 + (soldCount + 2 + | 
|---|
| 4499 | (fToolbar != FALSE) + | 
|---|
| 4500 | (fDrivebar != FALSE) + | 
|---|
| 4501 | (fSplitStatus != FALSE) + (fAutoView != FALSE)); | 
|---|
| 4502 | *pswpNew = *pswpClient; | 
|---|
| 4503 | pswpNew->hwnd = WinWindowFromID(hwnd, IDM_USERLIST); | 
|---|
| 4504 | pswpNew->x = swpClient.cx - (sheight + 2); | 
|---|
| 4505 | pswpNew->y = swpClient.y; | 
|---|
| 4506 | pswpNew->cx = sheight + 4; | 
|---|
| 4507 | pswpNew->cy = sheight + 4; | 
|---|
| 4508 | sCount++; | 
|---|
| 4509 | pswpNew = (PSWP) mp1 + (soldCount + 3 + | 
|---|
| 4510 | (fToolbar != FALSE) + | 
|---|
| 4511 | (fDrivebar != FALSE) + | 
|---|
| 4512 | (fSplitStatus != FALSE) + (fAutoView != FALSE)); | 
|---|
| 4513 | *pswpNew = *pswpClient; | 
|---|
| 4514 | pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_LED); | 
|---|
| 4515 | pswpNew->x = swpClient.cx - ((sheight * 2) + 16); | 
|---|
| 4516 | pswpNew->y = swpClient.y; | 
|---|
| 4517 | pswpNew->cx = 12; | 
|---|
| 4518 | pswpNew->cy = 12; | 
|---|
| 4519 | sCount++; | 
|---|
| 4520 | pswpNew = (PSWP) mp1 + (soldCount + 4 + | 
|---|
| 4521 | (fToolbar != FALSE) + | 
|---|
| 4522 | (fDrivebar != FALSE) + | 
|---|
| 4523 | (fSplitStatus != FALSE) + (fAutoView != FALSE)); | 
|---|
| 4524 | *pswpNew = *pswpClient; | 
|---|
| 4525 | pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_LEDHDR); | 
|---|
| 4526 | pswpNew->x = swpClient.cx - ((sheight * 2) + 16); | 
|---|
| 4527 | pswpNew->y = swpClient.y + 12; | 
|---|
| 4528 | pswpNew->cx = 12; | 
|---|
| 4529 | pswpNew->cy = sheight - 8; | 
|---|
| 4530 | sCount++; | 
|---|
| 4531 | if (fUserComboBox) { | 
|---|
| 4532 | if (!aheight) { | 
|---|
| 4533 | SWP swpTemp; | 
|---|
| 4534 | WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT), | 
|---|
| 4535 | &swpTemp); | 
|---|
| 4536 | aheight = swpTemp.cy; | 
|---|
| 4537 | } | 
|---|
| 4538 | pswpNew = (PSWP) mp1 + (soldCount + 5 + | 
|---|
| 4539 | (fToolbar != FALSE) + | 
|---|
| 4540 | (fSplitStatus != FALSE) + | 
|---|
| 4541 | (fDrivebar != FALSE) + (fAutoView != FALSE)); | 
|---|
| 4542 | *pswpNew = *pswpClient; | 
|---|
| 4543 | pswpNew->hwnd = hwndDrivelist; | 
|---|
| 4544 | pswpNew->x = swpClient.x; | 
|---|
| 4545 | pswpNew->cx = 48; | 
|---|
| 4546 | pswpClient->cy -= (aheight + 6L); | 
|---|
| 4547 | pswpNew->y = pswpClient->y; | 
|---|
| 4548 | pswpNew->cy = pswpClient->cy + (aheight + 5L); | 
|---|
| 4549 | sCount++; | 
|---|
| 4550 | pswpNew = (PSWP) mp1 + (soldCount + 6 + | 
|---|
| 4551 | (fToolbar != FALSE) + | 
|---|
| 4552 | (fDrivebar != FALSE) + | 
|---|
| 4553 | (fSplitStatus != FALSE) + | 
|---|
| 4554 | (fAutoView != FALSE)); | 
|---|
| 4555 | *pswpNew = *pswpClient; | 
|---|
| 4556 | pswpNew->hwnd = hwndStatelist; | 
|---|
| 4557 | pswpNew->x = swpClient.x + 48; | 
|---|
| 4558 | pswpNew->cx = (swpClient.cx - 48) / 7; | 
|---|
| 4559 | pswpNew->y = pswpClient->y; | 
|---|
| 4560 | pswpNew->cy = pswpClient->cy + (aheight + 5L); | 
|---|
| 4561 | sCount++; | 
|---|
| 4562 | pswpNew = (PSWP) mp1 + (soldCount + 7 + | 
|---|
| 4563 | (fToolbar != FALSE) + | 
|---|
| 4564 | (fDrivebar != FALSE) + | 
|---|
| 4565 | (fSplitStatus != FALSE) + | 
|---|
| 4566 | (fAutoView != FALSE)); | 
|---|
| 4567 | *pswpNew = *pswpClient; | 
|---|
| 4568 | pswpNew->hwnd = hwndCmdlist; | 
|---|
| 4569 | pswpNew->x = swpClient.x + 48 + ((swpClient.cx - 48) / 7); | 
|---|
| 4570 | pswpNew->cx = (swpClient.cx - 48) / 5 + | 
|---|
| 4571 | ((swpClient.cx - 48) / 5) - ((swpClient.cx - 48) / 7); | 
|---|
| 4572 | pswpNew->y = pswpClient->y; | 
|---|
| 4573 | pswpNew->cy = pswpClient->cy + (aheight + 5L); | 
|---|
| 4574 | sCount++; | 
|---|
| 4575 | pswpNew = (PSWP) mp1 + (soldCount + 8 + | 
|---|
| 4576 | (fToolbar != FALSE) + | 
|---|
| 4577 | (fDrivebar != FALSE) + | 
|---|
| 4578 | (fSplitStatus != FALSE) + | 
|---|
| 4579 | (fAutoView != FALSE)); | 
|---|
| 4580 | *pswpNew = *pswpClient; | 
|---|
| 4581 | pswpNew->hwnd = hwndUserlist; | 
|---|
| 4582 | pswpNew->x = swpClient.x + 48 + (((swpClient.cx - 48) / 5) * 2); | 
|---|
| 4583 | pswpNew->cx = ((swpClient.x + swpClient.cx) - pswpNew->x) - | 
|---|
| 4584 | ((fToolbar) ? ((swpClient.cx - 48) / 7) : 0); | 
|---|
| 4585 | pswpNew->y = pswpClient->y; | 
|---|
| 4586 | pswpNew->cy = pswpClient->cy + (aheight + 5L); | 
|---|
| 4587 | sCount++; | 
|---|
| 4588 | if (fToolbar) { | 
|---|
| 4589 | pswpNew = (PSWP) mp1 + (soldCount + 9 + | 
|---|
| 4590 | (fToolbar != FALSE) + | 
|---|
| 4591 | (fDrivebar != FALSE) + | 
|---|
| 4592 | (fSplitStatus != FALSE) + | 
|---|
| 4593 | (fAutoView != FALSE)); | 
|---|
| 4594 | *pswpNew = *pswpClient; | 
|---|
| 4595 | pswpNew->hwnd = hwndButtonlist; | 
|---|
| 4596 | pswpNew->x = swpClient.cx - ((swpClient.cx - 48) / 7) + 4; | 
|---|
| 4597 | pswpNew->cx = (swpClient.x + swpClient.cx) - pswpNew->x; | 
|---|
| 4598 | pswpNew->y = pswpClient->y; | 
|---|
| 4599 | pswpNew->cy = pswpClient->cy + (aheight + 5L); | 
|---|
| 4600 | sCount++; | 
|---|
| 4601 | } | 
|---|
| 4602 | else | 
|---|
| 4603 | WinShowWindow(hwndButtonlist, FALSE); | 
|---|
| 4604 | } | 
|---|
| 4605 | else { | 
|---|
| 4606 | WinShowWindow(hwndUserlist, FALSE); | 
|---|
| 4607 | WinShowWindow(hwndDrivelist, FALSE); | 
|---|
| 4608 | WinShowWindow(hwndStatelist, FALSE); | 
|---|
| 4609 | WinShowWindow(hwndButtonlist, FALSE); | 
|---|
| 4610 | WinShowWindow(hwndCmdlist, FALSE); | 
|---|
| 4611 | } | 
|---|
| 4612 | { | 
|---|
| 4613 | PSWP pswpTitlebar = (PSWP) 0, pswpMinbutton = (PSWP) 0; | 
|---|
| 4614 | SHORT x; | 
|---|
| 4615 |  | 
|---|
| 4616 | pswpNew = (PSWP) mp1 + (soldCount + 5 + | 
|---|
| 4617 | (fToolbar != FALSE) + | 
|---|
| 4618 | (fDrivebar != FALSE) + | 
|---|
| 4619 | (fSplitStatus != FALSE) + | 
|---|
| 4620 | (fAutoView != FALSE) + | 
|---|
| 4621 | ((fUserComboBox != FALSE) * 4) + | 
|---|
| 4622 | (fUserComboBox != FALSE && | 
|---|
| 4623 | fToolbar != FALSE)); | 
|---|
| 4624 | pswp = (PSWP) mp1; | 
|---|
| 4625 | for (x = 0; x < soldCount; x++) { | 
|---|
| 4626 | if (!pswpTitlebar && | 
|---|
| 4627 | WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_TITLEBAR) | 
|---|
| 4628 | pswpTitlebar = pswp; | 
|---|
| 4629 | else if (!pswpMinbutton && | 
|---|
| 4630 | WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_MINMAX) | 
|---|
| 4631 | pswpMinbutton = pswp; | 
|---|
| 4632 | if (pswpTitlebar && pswpMinbutton) | 
|---|
| 4633 | break; | 
|---|
| 4634 | pswp++; | 
|---|
| 4635 | } | 
|---|
| 4636 | if (pswpMinbutton && pswpTitlebar) { | 
|---|
| 4637 | *pswpNew = *pswpMinbutton; | 
|---|
| 4638 | pswpNew->hwnd = WinWindowFromID(hwnd, IDM_IDEALSIZE); | 
|---|
| 4639 | pswpNew->cy = pswpMinbutton->cy + 3; | 
|---|
| 4640 | pswpNew->cx = min(pswpNew->cy, (pswpMinbutton->cx / 2) + 3); | 
|---|
| 4641 | pswpTitlebar->cx -= (pswpNew->cx - 1); | 
|---|
| 4642 | pswpNew->x = pswpTitlebar->x + (pswpTitlebar->cx); | 
|---|
| 4643 | pswpNew->y = pswpMinbutton->y - 1; | 
|---|
| 4644 | sCount++; | 
|---|
| 4645 | } | 
|---|
| 4646 | else | 
|---|
| 4647 | WinShowWindow(WinWindowFromID(hwnd, IDM_IDEALSIZE), FALSE); | 
|---|
| 4648 | } | 
|---|
| 4649 |  | 
|---|
| 4650 | if (fMoreButtons) { | 
|---|
| 4651 |  | 
|---|
| 4652 | LONG lastx; | 
|---|
| 4653 |  | 
|---|
| 4654 | pswpNew = (PSWP) mp1 + (soldCount + 6 + | 
|---|
| 4655 | (fToolbar != FALSE) + | 
|---|
| 4656 | (fDrivebar != FALSE) + | 
|---|
| 4657 | (fSplitStatus != FALSE) + | 
|---|
| 4658 | (fAutoView != FALSE) + | 
|---|
| 4659 | ((fUserComboBox != FALSE) * 4) + | 
|---|
| 4660 | (fUserComboBox != FALSE && | 
|---|
| 4661 | fToolbar != FALSE)); | 
|---|
| 4662 | *pswpNew = *pswpClient; | 
|---|
| 4663 | pswpNew->hwnd = hwndName; | 
|---|
| 4664 | pswpNew->x = swpClient.x + 3; | 
|---|
| 4665 | pswpNew->y = swpClient.y + (sheight + 6); | 
|---|
| 4666 | pswpNew->cx = ((swpClient.cx / 2) + (swpClient.cx / 5)) - 3; | 
|---|
| 4667 | lastx = pswpNew->x + pswpNew->cx; | 
|---|
| 4668 | pswpNew->cy = bheight; | 
|---|
| 4669 | pswpClient->y += (bheight + 4); | 
|---|
| 4670 | pswpClient->cy -= (bheight + 4); | 
|---|
| 4671 | sCount++; | 
|---|
| 4672 | pswpNew = (PSWP) mp1 + (soldCount + 7 + | 
|---|
| 4673 | (fToolbar != FALSE) + | 
|---|
| 4674 | (fDrivebar != FALSE) + | 
|---|
| 4675 | (fSplitStatus != FALSE) + | 
|---|
| 4676 | (fAutoView != FALSE) + | 
|---|
| 4677 | ((fUserComboBox != FALSE) * 4) + | 
|---|
| 4678 | (fUserComboBox != FALSE && | 
|---|
| 4679 | fToolbar != FALSE)); | 
|---|
| 4680 | *pswpNew = *pswpClient; | 
|---|
| 4681 | pswpNew->hwnd = hwndDate; | 
|---|
| 4682 | pswpNew->x = lastx + 3; | 
|---|
| 4683 | pswpNew->y = swpClient.y + (sheight + 6); | 
|---|
| 4684 | pswpNew->cx = (swpClient.cx / 6) + (swpClient.cx / 16) - 3; | 
|---|
| 4685 | lastx = pswpNew->x + pswpNew->cx; | 
|---|
| 4686 | pswpNew->cy = bheight; | 
|---|
| 4687 | sCount++; | 
|---|
| 4688 | pswpNew = (PSWP) mp1 + (soldCount + 8 + | 
|---|
| 4689 | (fToolbar != FALSE) + | 
|---|
| 4690 | (fDrivebar != FALSE) + | 
|---|
| 4691 | (fSplitStatus != FALSE) + | 
|---|
| 4692 | (fAutoView != FALSE) + | 
|---|
| 4693 | ((fUserComboBox != FALSE) * 4) + | 
|---|
| 4694 | (fUserComboBox != FALSE && | 
|---|
| 4695 | fToolbar != FALSE)); | 
|---|
| 4696 | *pswpNew = *pswpClient; | 
|---|
| 4697 | pswpNew->hwnd = hwndAttr; | 
|---|
| 4698 | pswpNew->x = lastx + 3; | 
|---|
| 4699 | pswpNew->y = swpClient.y + (sheight + 6); | 
|---|
| 4700 | pswpNew->cx = (swpClient.cx - pswpNew->x) - 1; | 
|---|
| 4701 | pswpNew->cy = bheight; | 
|---|
| 4702 | sCount++; | 
|---|
| 4703 | } | 
|---|
| 4704 | else { | 
|---|
| 4705 | WinShowWindow(hwndAttr, FALSE); | 
|---|
| 4706 | WinShowWindow(hwndName, FALSE); | 
|---|
| 4707 | WinShowWindow(hwndDate, FALSE); | 
|---|
| 4708 | } | 
|---|
| 4709 | return MRFROMSHORT(sCount); | 
|---|
| 4710 | } | 
|---|
| 4711 |  | 
|---|
| 4712 | case WM_QUERYFRAMECTLCOUNT: | 
|---|
| 4713 | { | 
|---|
| 4714 | SHORT sCount; | 
|---|
| 4715 |  | 
|---|
| 4716 | sCount = (SHORT) oldproc(hwnd, msg, mp1, mp2); | 
|---|
| 4717 |  | 
|---|
| 4718 | sCount += 6; | 
|---|
| 4719 | if (fSplitStatus) | 
|---|
| 4720 | sCount++; | 
|---|
| 4721 | if (fToolbar) | 
|---|
| 4722 | sCount++; | 
|---|
| 4723 | if (fUserComboBox) { | 
|---|
| 4724 | sCount += 4; | 
|---|
| 4725 | if (fToolbar) | 
|---|
| 4726 | sCount++; | 
|---|
| 4727 | } | 
|---|
| 4728 | if (fDrivebar) | 
|---|
| 4729 | sCount++; | 
|---|
| 4730 | if (fAutoView) | 
|---|
| 4731 | sCount++; | 
|---|
| 4732 | if (fMoreButtons) | 
|---|
| 4733 | sCount += 3; | 
|---|
| 4734 | return MRFROMSHORT(sCount); | 
|---|
| 4735 | } | 
|---|
| 4736 |  | 
|---|
| 4737 | case WM_CLOSE: | 
|---|
| 4738 | WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), msg, mp1, mp2); | 
|---|
| 4739 | return 0; | 
|---|
| 4740 | } | 
|---|
| 4741 | return oldproc(hwnd, msg, mp1, mp2); | 
|---|
| 4742 | } | 
|---|
| 4743 |  | 
|---|
| 4744 | MRESULT EXPENTRY MainWMCommand(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 4745 | { | 
|---|
| 4746 | SetShiftState(); | 
|---|
| 4747 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 4748 |  | 
|---|
| 4749 | case IDM_CONTEXTMENU: | 
|---|
| 4750 | { | 
|---|
| 4751 | HWND hwnd = WinQueryFocus(HWND_DESKTOP); | 
|---|
| 4752 | // DbgMsg(pszSrcFile, __LINE__, "IDM_CONTEXTMENU %x", hwnd); | 
|---|
| 4753 | if (hwnd != NULLHANDLE) { | 
|---|
| 4754 | HWND hwndParent = WinQueryWindow(hwnd, QW_PARENT); | 
|---|
| 4755 | USHORT id = WinQueryWindowUShort(hwndParent, QWS_ID); | 
|---|
| 4756 | switch (id) { | 
|---|
| 4757 | case MAIN_SETUPLIST: | 
|---|
| 4758 | case MAIN_USERLIST: | 
|---|
| 4759 | case MAIN_CMDLIST: | 
|---|
| 4760 | // DbgMsg(pszSrcFile, __LINE__, "WM_CONTEXTMENU"); | 
|---|
| 4761 | WinPostMsg(hwnd, WM_CONTEXTMENU, 0, 0); | 
|---|
| 4762 | } | 
|---|
| 4763 | } | 
|---|
| 4764 | } | 
|---|
| 4765 | break; | 
|---|
| 4766 |  | 
|---|
| 4767 | case IDM_SETTARGET: | 
|---|
| 4768 | SetTargetDir(hwnd, FALSE, NULL); | 
|---|
| 4769 | break; | 
|---|
| 4770 |  | 
|---|
| 4771 | case IDM_TOAUTOMLE: | 
|---|
| 4772 | if (fComments && fAutoView) | 
|---|
| 4773 | WinSetFocus(HWND_DESKTOP, hwndAutoMLE); | 
|---|
| 4774 | break; | 
|---|
| 4775 |  | 
|---|
| 4776 | case IDM_HIDENOTEWND: | 
|---|
| 4777 | HideNote(); | 
|---|
| 4778 | break; | 
|---|
| 4779 | case IDM_SHOWNOTEWND: | 
|---|
| 4780 | ShowNote(); | 
|---|
| 4781 | break; | 
|---|
| 4782 |  | 
|---|
| 4783 | case IDM_COMPARE: | 
|---|
| 4784 | { | 
|---|
| 4785 | WALK2 wa; | 
|---|
| 4786 | PCNRITEM pci; | 
|---|
| 4787 |  | 
|---|
| 4788 | memset(&wa, 0, sizeof(wa)); | 
|---|
| 4789 | wa.size = sizeof(wa); | 
|---|
| 4790 | pci = | 
|---|
| 4791 | (PCNRITEM) | 
|---|
| 4792 | WinSendMsg(WinWindowFromID | 
|---|
| 4793 | (WinWindowFromID(hwndTree, FID_CLIENT), TREE_CNR), | 
|---|
| 4794 | CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST), | 
|---|
| 4795 | MPFROMSHORT(CRA_CURSORED)); | 
|---|
| 4796 | if (pci && (INT) pci != -1) { | 
|---|
| 4797 | strcpy(wa.szCurrentPath1, pci->pszFileName); | 
|---|
| 4798 | MakeValidDir(wa.szCurrentPath1); | 
|---|
| 4799 | } | 
|---|
| 4800 | else | 
|---|
| 4801 | strcpy(wa.szCurrentPath1, pFM2SaveDirectory); | 
|---|
| 4802 | TopWindowName(hwndMain, (HWND) 0, wa.szCurrentPath2); | 
|---|
| 4803 | if (!*wa.szCurrentPath2) | 
|---|
| 4804 | strcpy(wa.szCurrentPath2, wa.szCurrentPath1); | 
|---|
| 4805 | MakeValidDir(wa.szCurrentPath2); | 
|---|
| 4806 | if (WinDlgBox(HWND_DESKTOP, | 
|---|
| 4807 | hwnd, | 
|---|
| 4808 | WalkTwoCmpDlgProc, | 
|---|
| 4809 | FM3ModHandle, | 
|---|
| 4810 | WALK2_FRAME, | 
|---|
| 4811 | MPFROMP(&wa)) && | 
|---|
| 4812 | !IsFile(wa.szCurrentPath1) && !IsFile(wa.szCurrentPath2)) { | 
|---|
| 4813 | if (!*dircompare) { | 
|---|
| 4814 |  | 
|---|
| 4815 | COMPARE *cmp; | 
|---|
| 4816 |  | 
|---|
| 4817 | cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__); | 
|---|
| 4818 | if (cmp) { | 
|---|
| 4819 | cmp->size = sizeof(COMPARE); | 
|---|
| 4820 | strcpy(cmp->leftdir, wa.szCurrentPath1); | 
|---|
| 4821 | strcpy(cmp->rightdir, wa.szCurrentPath2); | 
|---|
| 4822 | cmp->listfile = wa.listfile; | 
|---|
| 4823 | cmp->includesubdirs = wa.includesubdirs; | 
|---|
| 4824 | cmp->hwndParent = hwnd; | 
|---|
| 4825 | cmp->dcd.hwndParent = hwnd; | 
|---|
| 4826 | WinDlgBox(HWND_DESKTOP, | 
|---|
| 4827 | HWND_DESKTOP, | 
|---|
| 4828 | CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp)); | 
|---|
| 4829 | } | 
|---|
| 4830 | } | 
|---|
| 4831 | else { | 
|---|
| 4832 |  | 
|---|
| 4833 | CHAR szPath1[CCHMAXPATH]; | 
|---|
| 4834 | CHAR szPath2[CCHMAXPATH]; | 
|---|
| 4835 | runemf2(SEPARATE, | 
|---|
| 4836 | HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| 4837 | NULL, NULL, | 
|---|
| 4838 | "%s %s %s", | 
|---|
| 4839 | dircompare, | 
|---|
| 4840 | BldQuotedFileName(szPath1, wa.szCurrentPath1), | 
|---|
| 4841 | BldQuotedFileName(szPath2, wa.szCurrentPath2)); | 
|---|
| 4842 | } | 
|---|
| 4843 | } | 
|---|
| 4844 | } | 
|---|
| 4845 | break; | 
|---|
| 4846 |  | 
|---|
| 4847 | case IDM_EXIT: | 
|---|
| 4848 | case IDM_KILLME: | 
|---|
| 4849 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID); | 
|---|
| 4850 | break; | 
|---|
| 4851 |  | 
|---|
| 4852 | case IDM_CLI: | 
|---|
| 4853 | if (fSplitStatus && | 
|---|
| 4854 | hwndStatus2 && | 
|---|
| 4855 | !WinIsWindow(WinQueryAnchorBlock(hwnd), | 
|---|
| 4856 | WinWindowFromID(hwndStatus2, COMMAND_LINE))) | 
|---|
| 4857 | PostMsg(hwndStatus2, UM_CLICKED, MPVOID, MPVOID); | 
|---|
| 4858 | break; | 
|---|
| 4859 |  | 
|---|
| 4860 | case IDM_ADDTOUSERLIST: | 
|---|
| 4861 | case IDM_DELETEFROMUSERLIST: | 
|---|
| 4862 | { | 
|---|
| 4863 | CHAR temp[CCHMAXPATH], path[CCHMAXPATH]; | 
|---|
| 4864 |  | 
|---|
| 4865 | *temp = 0; | 
|---|
| 4866 | WinQueryWindowText(hwndUserlist, CCHMAXPATH, temp); | 
|---|
| 4867 | bstrip(temp); | 
|---|
| 4868 | if (*temp && | 
|---|
| 4869 | !DosQueryPathInfo(temp, FIL_QUERYFULLNAME, path, sizeof(path))) { | 
|---|
| 4870 | if (SHORT1FROMMP(mp1) == IDM_ADDTOUSERLIST) { | 
|---|
| 4871 | add_udir(TRUE, path); | 
|---|
| 4872 | if (fUdirsChanged) | 
|---|
| 4873 | save_udirs(); | 
|---|
| 4874 | WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID); | 
|---|
| 4875 | } | 
|---|
| 4876 | else { | 
|---|
| 4877 | if (!remove_udir(path)) | 
|---|
| 4878 | Runtime_Error(pszSrcFile, __LINE__, "remove_udir"); | 
|---|
| 4879 | else { | 
|---|
| 4880 | if (fUdirsChanged) | 
|---|
| 4881 | save_udirs(); | 
|---|
| 4882 | WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID); | 
|---|
| 4883 | } | 
|---|
| 4884 | } | 
|---|
| 4885 | } | 
|---|
| 4886 | } | 
|---|
| 4887 | break; | 
|---|
| 4888 |  | 
|---|
| 4889 | case IDM_SAVEDIRCNRSTATE: | 
|---|
| 4890 | case IDM_DELETEDIRCNRSTATE: | 
|---|
| 4891 | { | 
|---|
| 4892 | CHAR szStateName[STATE_NAME_MAX_BYTES + 1], szKeyBase[STATE_NAME_MAX_BYTES + 1]; | 
|---|
| 4893 |  | 
|---|
| 4894 | *szStateName = 0; | 
|---|
| 4895 | WinQueryWindowText(hwndStatelist, STATE_NAME_MAX_BYTES, szStateName); | 
|---|
| 4896 | bstrip(szStateName); | 
|---|
| 4897 | // Complain if attempting to use reserved name | 
|---|
| 4898 | if (stricmp(szStateName, GetPString(IDS_STATETEXT)) == 0 || | 
|---|
| 4899 | stricmp(szStateName, PCSZ_FM2TEMPTEXT) == 0) | 
|---|
| 4900 | { | 
|---|
| 4901 | saymsg(MB_ENTER | MB_ICONASTERISK, hwnd, | 
|---|
| 4902 | GetPString(IDS_WARNINGTEXT), | 
|---|
| 4903 | GetPString(IDS_STATERESERVENAMETEXT), szStateName); | 
|---|
| 4904 | } | 
|---|
| 4905 | // Ignore request if blank | 
|---|
| 4906 | else if (*szStateName) { | 
|---|
| 4907 | BOOL fAbortOperation = FALSE; | 
|---|
| 4908 | if (!fNoSaveState && fSaveState && stricmp(szStateName, PCSZ_SHUTDOWNSTATE) == 0) | 
|---|
| 4909 | { | 
|---|
| 4910 | if (saymsg(MB_YESNO | MB_DEFBUTTON2 | MB_ICONASTERISK, hwnd, | 
|---|
| 4911 | GetPString(IDS_WARNINGTEXT), | 
|---|
| 4912 | GetPString(IDS_SHUTDOWNSTATE_WARNING), szStateName) == MBID_NO) | 
|---|
| 4913 | fAbortOperation = TRUE; | 
|---|
| 4914 | } | 
|---|
| 4915 | if (!fAbortOperation) { | 
|---|
| 4916 | if (SHORT1FROMMP(mp1) == IDM_SAVEDIRCNRSTATE) { | 
|---|
| 4917 | // Save | 
|---|
| 4918 | INT nSaved = SaveDirCnrState(hwnd, szStateName); | 
|---|
| 4919 | if (nSaved >= 0) { | 
|---|
| 4920 | INT ret = add_setup(szStateName); | 
|---|
| 4921 | if (ret == 0) { | 
|---|
| 4922 | WinSendMsg(hwndStatelist, LM_INSERTITEM, | 
|---|
| 4923 | MPFROM2SHORT(LIT_SORTASCENDING, 0), MPFROMP(szStateName)); | 
|---|
| 4924 | save_setups(); | 
|---|
| 4925 | } | 
|---|
| 4926 | else if (ret != 1) { | 
|---|
| 4927 | saymsg(MB_ENTER | MB_ICONASTERISK, hwnd, | 
|---|
| 4928 | GetPString(IDS_WARNINGTEXT), | 
|---|
| 4929 | GetPString(IDS_STATEADDFAILEDTEXT), szStateName);      // 15 Apr 07 SHL failed | 
|---|
| 4930 | WinSetWindowText(hwndStatelist, (CHAR *) GetPString(IDS_STATETEXT)); | 
|---|
| 4931 | } | 
|---|
| 4932 | } | 
|---|
| 4933 | else { | 
|---|
| 4934 | saymsg(MB_ENTER | MB_ICONASTERISK, | 
|---|
| 4935 | hwnd, | 
|---|
| 4936 | GetPString(IDS_WARNINGTEXT), | 
|---|
| 4937 | GetPString(IDS_STATEDATASAVEFAILED)); | 
|---|
| 4938 | WinSetWindowText(hwndStatelist, (CHAR *) GetPString(IDS_STATETEXT)); | 
|---|
| 4939 | } | 
|---|
| 4940 | } | 
|---|
| 4941 | else { | 
|---|
| 4942 | // Delete | 
|---|
| 4943 | ULONG numsaves = 0, size, x; | 
|---|
| 4944 | CHAR szKey[STATE_NAME_MAX_BYTES + 80]; | 
|---|
| 4945 |  | 
|---|
| 4946 | INT ret = remove_setup(szStateName); | 
|---|
| 4947 | if (ret == 1) | 
|---|
| 4948 | save_setups(); | 
|---|
| 4949 | sprintf(szKey, "%s.NumDirsLastTime", szStateName); | 
|---|
| 4950 | size = sizeof(ULONG); | 
|---|
| 4951 | if (!PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) &numsaves, &size)) { | 
|---|
| 4952 | saymsg(MB_ENTER | MB_ICONASTERISK, hwnd, | 
|---|
| 4953 | GetPString(IDS_WARNINGTEXT), | 
|---|
| 4954 | GetPString(IDS_DOESNTEXISTTEXT), szStateName); | 
|---|
| 4955 | } | 
|---|
| 4956 | else if (!size) | 
|---|
| 4957 | Runtime_Error(pszSrcFile, __LINE__, NULL); | 
|---|
| 4958 | else { | 
|---|
| 4959 | PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L); | 
|---|
| 4960 | for (x = 0; x < numsaves; x++) { | 
|---|
| 4961 | sprintf(szKeyBase, "%s.DirCnr.%lu", szStateName, x); | 
|---|
| 4962 | RemoveCnrSwitches(szKeyBase, szStateName); | 
|---|
| 4963 | size = 0; | 
|---|
| 4964 | sprintf(szKey, "%sVersion", szStateName); | 
|---|
| 4965 | if (PrfQueryProfileSize(fmprof, FM3Str, szKey, &size) && size) | 
|---|
| 4966 | RemoveOldCnrSwitches(szStateName, x); | 
|---|
| 4967 | } | 
|---|
| 4968 | } | 
|---|
| 4969 | PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID); | 
|---|
| 4970 | } | 
|---|
| 4971 | } | 
|---|
| 4972 | } | 
|---|
| 4973 | } | 
|---|
| 4974 | break; | 
|---|
| 4975 |  | 
|---|
| 4976 | case IDM_IDEALSIZE: | 
|---|
| 4977 | { | 
|---|
| 4978 | SWP swp, swpD; | 
|---|
| 4979 | ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2L; | 
|---|
| 4980 | ULONG bsz = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER); | 
|---|
| 4981 |  | 
|---|
| 4982 | WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp); | 
|---|
| 4983 | if (swp.fl & SWP_MAXIMIZE) { | 
|---|
| 4984 | WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_SYSCOMMAND, | 
|---|
| 4985 | MPFROM2SHORT(SC_RESTORE, 0), MPVOID); | 
|---|
| 4986 | WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp); | 
|---|
| 4987 | } | 
|---|
| 4988 | WinGetMaxPosition(WinQueryWindow(hwnd, QW_PARENT), &swpD); | 
|---|
| 4989 | swpD.x += bsz; | 
|---|
| 4990 | swpD.cx -= (bsz * 2); | 
|---|
| 4991 | swpD.y += icz; | 
|---|
| 4992 | swpD.cy -= (icz + bsz); | 
|---|
| 4993 | if (swp.x == swpD.x && swp.y == swpD.y && | 
|---|
| 4994 | swp.cx == swpD.cx && swp.cy == swpD.cy && | 
|---|
| 4995 | // fixme to be #defined someday | 
|---|
| 4996 | WinQueryWindowUShort(hwnd, QWL_USER + 10) && | 
|---|
| 4997 | WinQueryWindowUShort(hwnd, QWL_USER + 14)) { | 
|---|
| 4998 | swpD.x = WinQueryWindowUShort(hwnd, QWL_USER + 8); | 
|---|
| 4999 | swpD.cx = WinQueryWindowUShort(hwnd, QWL_USER + 10); | 
|---|
| 5000 | swpD.y = WinQueryWindowUShort(hwnd, QWL_USER + 12); | 
|---|
| 5001 | swpD.cy = WinQueryWindowUShort(hwnd, QWL_USER + 14); | 
|---|
| 5002 | } | 
|---|
| 5003 | else { | 
|---|
| 5004 | WinSetWindowUShort(hwnd, QWL_USER + 8, (USHORT) swp.x); | 
|---|
| 5005 | WinSetWindowUShort(hwnd, QWL_USER + 10, (USHORT) swp.cx); | 
|---|
| 5006 | WinSetWindowUShort(hwnd, QWL_USER + 12, (USHORT) swp.y); | 
|---|
| 5007 | WinSetWindowUShort(hwnd, QWL_USER + 14, (USHORT) swp.cy); | 
|---|
| 5008 | } | 
|---|
| 5009 | WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, | 
|---|
| 5010 | swpD.x, swpD.y, swpD.cx, swpD.cy, SWP_MOVE | SWP_SIZE); | 
|---|
| 5011 | } | 
|---|
| 5012 | break; | 
|---|
| 5013 |  | 
|---|
| 5014 | case IDM_BLINK: | 
|---|
| 5015 | { | 
|---|
| 5016 | BOOL changed = FALSE; | 
|---|
| 5017 |  | 
|---|
| 5018 | if (fDataMin) { | 
|---|
| 5019 | fDataMin = FALSE; | 
|---|
| 5020 | changed = TRUE; | 
|---|
| 5021 | } | 
|---|
| 5022 | WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0, | 
|---|
| 5023 | SWP_MINIMIZE); | 
|---|
| 5024 | WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0, | 
|---|
| 5025 | SWP_RESTORE | SWP_ZORDER); | 
|---|
| 5026 | if (changed) | 
|---|
| 5027 | fDataMin = TRUE; | 
|---|
| 5028 | break; | 
|---|
| 5029 | } | 
|---|
| 5030 |  | 
|---|
| 5031 | case DID_CANCEL: | 
|---|
| 5032 | { | 
|---|
| 5033 | HWND hwndTop = TopWindow(hwndMain, (HWND) 0); | 
|---|
| 5034 |  | 
|---|
| 5035 | if (hwndTop) | 
|---|
| 5036 | WinSetFocus(HWND_DESKTOP, hwndTop); | 
|---|
| 5037 | } | 
|---|
| 5038 | break; | 
|---|
| 5039 |  | 
|---|
| 5040 | case IDM_NOTEBOOK: | 
|---|
| 5041 | case IDM_DIRCNRSETTINGS: | 
|---|
| 5042 | case IDM_DIRVIEWSETTINGS: | 
|---|
| 5043 | case IDM_DIRSORTSETTINGS: | 
|---|
| 5044 | case IDM_COLLECTORVIEWSETTINGS: | 
|---|
| 5045 | case IDM_COLLECTORSORTSETTINGS: | 
|---|
| 5046 | case IDM_ARCHIVERSETTINGS: | 
|---|
| 5047 | case IDM_TREECNRVIEWSETTINGS: | 
|---|
| 5048 | case IDM_TREECNRSORTSETTINGS: | 
|---|
| 5049 | case IDM_VIEWERSETTINGS: | 
|---|
| 5050 | case IDM_VIEWERSETTINGS2: | 
|---|
| 5051 | case IDM_COMPARESETTINGS: | 
|---|
| 5052 | case IDM_MONOLITHICSETTINGS: | 
|---|
| 5053 | case IDM_GENERALSETTINGS: | 
|---|
| 5054 | case IDM_SCANSETTINGS: | 
|---|
| 5055 | case IDM_BUBBLESSETTINGS: | 
|---|
| 5056 | case IDM_QUICKSETTINGS: | 
|---|
| 5057 | WinDlgBox(HWND_DESKTOP, | 
|---|
| 5058 | hwnd, CfgDlgProc, FM3ModHandle, CFG_FRAME, MPFROMLONG(mp1)); | 
|---|
| 5059 | break; | 
|---|
| 5060 |  | 
|---|
| 5061 | case IDM_VIEWHELPS: | 
|---|
| 5062 | case IDM_VIEWINFS: | 
|---|
| 5063 | WinDlgBox(HWND_DESKTOP, | 
|---|
| 5064 | HWND_DESKTOP, | 
|---|
| 5065 | ViewInfProc, | 
|---|
| 5066 | FM3ModHandle, | 
|---|
| 5067 | VINF_FRAME, | 
|---|
| 5068 | ((SHORT1FROMMP(mp1) == IDM_VIEWHELPS) ? | 
|---|
| 5069 | MPFROMP(NullStr) : MPVOID)); | 
|---|
| 5070 | break; | 
|---|
| 5071 |  | 
|---|
| 5072 | case IDM_OPENWALK: | 
|---|
| 5073 | { | 
|---|
| 5074 | char newpath[CCHMAXPATH]; | 
|---|
| 5075 |  | 
|---|
| 5076 | *newpath = 0; | 
|---|
| 5077 | TopWindowName(hwnd, (HWND) 0, newpath); | 
|---|
| 5078 | if (WinDlgBox(HWND_DESKTOP, | 
|---|
| 5079 | hwnd, | 
|---|
| 5080 | WalkAllDlgProc, | 
|---|
| 5081 | FM3ModHandle, WALK_FRAME, MPFROMP(newpath)) && *newpath) | 
|---|
| 5082 | OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, newpath); | 
|---|
| 5083 | } | 
|---|
| 5084 | break; | 
|---|
| 5085 |  | 
|---|
| 5086 | case IDM_WINDOWDLG: | 
|---|
| 5087 | WindowList(hwnd); | 
|---|
| 5088 | break; | 
|---|
| 5089 |  | 
|---|
| 5090 | case IDM_HELPMOUSE: | 
|---|
| 5091 | case IDM_HELPCONTEXT: | 
|---|
| 5092 | case IDM_HELPHINTS: | 
|---|
| 5093 | case IDM_HELPPIX: | 
|---|
| 5094 | case IDM_HELPTUTOR: | 
|---|
| 5095 | case IDM_HELPUSERLIST: | 
|---|
| 5096 | case IDM_HELP: | 
|---|
| 5097 | case IDM_HELPCONTENTS: | 
|---|
| 5098 | case IDM_HELPKEYS: | 
|---|
| 5099 | case IDM_HELPGENERAL: | 
|---|
| 5100 | if (hwndHelp) { | 
|---|
| 5101 | if (SHORT1FROMMP(mp2) == CMDSRC_MENU) { | 
|---|
| 5102 |  | 
|---|
| 5103 | RECTL rcl; | 
|---|
| 5104 | ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2L; | 
|---|
| 5105 |  | 
|---|
| 5106 | WinQueryWindowRect(HWND_DESKTOP, &rcl); | 
|---|
| 5107 | rcl.yBottom += icz; | 
|---|
| 5108 | rcl.yTop -= icz; | 
|---|
| 5109 | rcl.xLeft += icz; | 
|---|
| 5110 | rcl.xRight -= icz; | 
|---|
| 5111 | WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, MPFROMP(&rcl), MPVOID); | 
|---|
| 5112 | } | 
|---|
| 5113 | else { | 
|---|
| 5114 |  | 
|---|
| 5115 | RECTL rcl; | 
|---|
| 5116 |  | 
|---|
| 5117 | WinQueryWindowRect(HWND_DESKTOP, &rcl); | 
|---|
| 5118 | rcl.yBottom += 8; | 
|---|
| 5119 | rcl.yTop = (rcl.yTop / 2) + (rcl.yTop / 7); | 
|---|
| 5120 | rcl.xLeft = (rcl.xRight / 2) - (rcl.xRight / 7); | 
|---|
| 5121 | rcl.xRight -= 8; | 
|---|
| 5122 | WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, MPFROMP(&rcl), MPVOID); | 
|---|
| 5123 | } | 
|---|
| 5124 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 5125 | case IDM_HELPCONTEXT: | 
|---|
| 5126 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP, | 
|---|
| 5127 | MPFROM2SHORT(HELP_CONTEXT, 0), MPFROMSHORT(HM_RESOURCEID)); | 
|---|
| 5128 | break; | 
|---|
| 5129 |  | 
|---|
| 5130 | case IDM_HELPMOUSE: | 
|---|
| 5131 | if (hwndHelp) | 
|---|
| 5132 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP, | 
|---|
| 5133 | MPFROM2SHORT(HELP_MOUSE, 0), MPFROMSHORT(HM_RESOURCEID)); | 
|---|
| 5134 | break; | 
|---|
| 5135 |  | 
|---|
| 5136 | case IDM_HELPPIX: | 
|---|
| 5137 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP, | 
|---|
| 5138 | MPFROM2SHORT(HELP_BITMAP1, 0), MPFROMSHORT(HM_RESOURCEID)); | 
|---|
| 5139 | break; | 
|---|
| 5140 |  | 
|---|
| 5141 | case IDM_HELPTUTOR: | 
|---|
| 5142 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP, | 
|---|
| 5143 | MPFROM2SHORT(HELP_TUTORIAL, 0), | 
|---|
| 5144 | MPFROMSHORT(HM_RESOURCEID)); | 
|---|
| 5145 | break; | 
|---|
| 5146 |  | 
|---|
| 5147 | case IDM_HELPHINTS: | 
|---|
| 5148 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP, | 
|---|
| 5149 | MPFROM2SHORT(HELP_HINTS, 0), MPFROMSHORT(HM_RESOURCEID)); | 
|---|
| 5150 | break; | 
|---|
| 5151 |  | 
|---|
| 5152 | case IDM_HELPGENERAL: | 
|---|
| 5153 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP, | 
|---|
| 5154 | MPFROM2SHORT(HELP_MAIN, 0), MPFROMSHORT(HM_RESOURCEID)); | 
|---|
| 5155 | break; | 
|---|
| 5156 | case IDM_HELPKEYS: | 
|---|
| 5157 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP, | 
|---|
| 5158 | MPFROM2SHORT(HELP_KEYS, 0), MPFROMSHORT(HM_RESOURCEID)); | 
|---|
| 5159 | break; | 
|---|
| 5160 |  | 
|---|
| 5161 | case IDM_HELP: | 
|---|
| 5162 | case IDM_HELPCONTENTS: | 
|---|
| 5163 | WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID); | 
|---|
| 5164 | break; | 
|---|
| 5165 |  | 
|---|
| 5166 | case IDM_HELPUSERLIST: | 
|---|
| 5167 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP, | 
|---|
| 5168 | MPFROM2SHORT(HELP_USERLISTS, 0), | 
|---|
| 5169 | MPFROMSHORT(HM_RESOURCEID)); | 
|---|
| 5170 | break; | 
|---|
| 5171 | } | 
|---|
| 5172 | } | 
|---|
| 5173 | break; | 
|---|
| 5174 |  | 
|---|
| 5175 | case IDM_EDITANYARCHIVER: | 
|---|
| 5176 | EditArchiverDefinition(hwnd); | 
|---|
| 5177 | break; | 
|---|
| 5178 |  | 
|---|
| 5179 | case IDM_ABOUT: | 
|---|
| 5180 | WinDlgBox(HWND_DESKTOP, hwnd, AboutDlgProc, FM3ModHandle, | 
|---|
| 5181 | ABT_FRAME, MPVOID); | 
|---|
| 5182 | break; | 
|---|
| 5183 |  | 
|---|
| 5184 | case IDM_FONTPALETTE: | 
|---|
| 5185 | OpenObject("<WP_FNTPAL>", Default, hwnd); | 
|---|
| 5186 | break; | 
|---|
| 5187 |  | 
|---|
| 5188 | case IDM_HICOLORPALETTE: | 
|---|
| 5189 | case IDM_COLORPALETTE: | 
|---|
| 5190 | { | 
|---|
| 5191 | CHAR *palette = "<WP_CLRPAL>"; | 
|---|
| 5192 | ULONG version[2]; | 
|---|
| 5193 |  | 
|---|
| 5194 | if (!DosQuerySysInfo(QSV_VERSION_MAJOR, QSV_VERSION_MINOR, | 
|---|
| 5195 | (PVOID) & version, (ULONG) sizeof(version))) { | 
|---|
| 5196 | if (version[0] > 20L || (version[0] == 20L && version[1] > 29L)) { | 
|---|
| 5197 | if (SHORT1FROMMP(mp1) == IDM_HICOLORPALETTE) | 
|---|
| 5198 | palette = "<WP_HIRESCLRPAL>"; | 
|---|
| 5199 | else | 
|---|
| 5200 | palette = "<WP_LORESCLRPAL>"; | 
|---|
| 5201 | } | 
|---|
| 5202 | } | 
|---|
| 5203 | OpenObject(palette, Default, hwnd); | 
|---|
| 5204 | } | 
|---|
| 5205 | break; | 
|---|
| 5206 |  | 
|---|
| 5207 | case IDM_SYSTEMSETUP: | 
|---|
| 5208 | OpenObject("<WP_CONFIG>", Default, hwnd); | 
|---|
| 5209 | break; | 
|---|
| 5210 |  | 
|---|
| 5211 | case IDM_SCHEMEPALETTE: | 
|---|
| 5212 | { | 
|---|
| 5213 | HOBJECT hWPSObject; | 
|---|
| 5214 |  | 
|---|
| 5215 | hWPSObject = WinQueryObject("<WP_SCHPAL>"); | 
|---|
| 5216 | if (hWPSObject != NULLHANDLE) | 
|---|
| 5217 | WinSetObjectData(hWPSObject, "SCHEMES=Winter:PM_Winter," | 
|---|
| 5218 | "Spring:PM_Spring,Summer:PM_Summer," | 
|---|
| 5219 | "System:PM_System,Windows:PM_Windows;" | 
|---|
| 5220 | "OPEN=DEFAULT"); | 
|---|
| 5221 | } | 
|---|
| 5222 | break; | 
|---|
| 5223 |  | 
|---|
| 5224 | case IDM_SYSTEMCLOCK: | 
|---|
| 5225 | OpenObject("<WP_CLOCK>", Default, hwnd); | 
|---|
| 5226 | break; | 
|---|
| 5227 |  | 
|---|
| 5228 | #ifdef NEVER | 
|---|
| 5229 | case IDM_SYSINFO: | 
|---|
| 5230 | WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, SysInfoDlgProc, FM3ModHandle, | 
|---|
| 5231 | SYS_FRAME, NULL); | 
|---|
| 5232 | break; | 
|---|
| 5233 | #endif | 
|---|
| 5234 |  | 
|---|
| 5235 | case IDM_INSTANT: | 
|---|
| 5236 | { | 
|---|
| 5237 | CHAR path[CCHMAXPATH]; | 
|---|
| 5238 | PCNRITEM pci = (PCNRITEM) 0; | 
|---|
| 5239 |  | 
|---|
| 5240 | if (hwndTree) | 
|---|
| 5241 | pci = (PCNRITEM) WinSendMsg(hwndTree, CM_QUERYRECORDEMPHASIS, | 
|---|
| 5242 | MPFROMLONG(CMA_FIRST), | 
|---|
| 5243 | MPFROMSHORT(CRA_CURSORED)); | 
|---|
| 5244 | if (pci && (INT) pci != -1) { | 
|---|
| 5245 | strcpy(path, pci->pszFileName); | 
|---|
| 5246 | MakeValidDir(path); | 
|---|
| 5247 | } | 
|---|
| 5248 | else | 
|---|
| 5249 | strcpy(path, pFM2SaveDirectory); | 
|---|
| 5250 | WinDlgBox(HWND_DESKTOP, hwnd, InstantDlgProc, FM3ModHandle, | 
|---|
| 5251 | BAT_FRAME, MPFROMP(path)); | 
|---|
| 5252 | } | 
|---|
| 5253 | break; | 
|---|
| 5254 |  | 
|---|
| 5255 | case IDM_WINFULLSCREEN: | 
|---|
| 5256 | case IDM_DOSCOMMANDLINE: | 
|---|
| 5257 | case IDM_COMMANDLINE: | 
|---|
| 5258 | { | 
|---|
| 5259 | CHAR *env = GetCmdSpec(FALSE), path[CCHMAXPATH]; | 
|---|
| 5260 | INT type = SEPARATE | WINDOWED; | 
|---|
| 5261 |  | 
|---|
| 5262 | *path = 0; | 
|---|
| 5263 | TopWindowName(hwnd, (HWND) 0, path); | 
|---|
| 5264 | if (SHORT1FROMMP(mp1) == IDM_DOSCOMMANDLINE) | 
|---|
| 5265 | env = GetCmdSpec(TRUE); | 
|---|
| 5266 | else if (SHORT1FROMMP(mp1) != IDM_COMMANDLINE) { | 
|---|
| 5267 | env = "WINOS2.COM"; | 
|---|
| 5268 | type = SEPARATE | FULLSCREEN; | 
|---|
| 5269 | } | 
|---|
| 5270 | runemf2(type, hwnd, pszSrcFile, __LINE__, | 
|---|
| 5271 | path, NULL, "%s", env); | 
|---|
| 5272 | } | 
|---|
| 5273 | break; | 
|---|
| 5274 |  | 
|---|
| 5275 | case IDM_KILLPROC: | 
|---|
| 5276 | WinDlgBox(HWND_DESKTOP, hwnd, KillDlgProc, FM3ModHandle, | 
|---|
| 5277 | KILL_FRAME, NULL); | 
|---|
| 5278 | break; | 
|---|
| 5279 |  | 
|---|
| 5280 | case IDM_AUTOVIEWCOMMENTS: | 
|---|
| 5281 | case IDM_AUTOVIEWFILE: | 
|---|
| 5282 | if (SHORT1FROMMP(mp1) == IDM_AUTOVIEWFILE) | 
|---|
| 5283 | fComments = FALSE; | 
|---|
| 5284 | else | 
|---|
| 5285 | fComments = TRUE; | 
|---|
| 5286 | PrfWriteProfileData(fmprof, FM3Str, "Comments", &fComments, sizeof(BOOL)); | 
|---|
| 5287 | WinSetWindowText((fComments) ? hwndAutoview : hwndAutoMLE, NullStr); | 
|---|
| 5288 | goto AutoChange; | 
|---|
| 5289 |  | 
|---|
| 5290 | case IDM_AUTOVIEW: | 
|---|
| 5291 | SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1), | 
|---|
| 5292 | &fAutoView, TRUE, "AutoView"); | 
|---|
| 5293 | AutoChange: | 
|---|
| 5294 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME, | 
|---|
| 5295 | MPFROMLONG(FCF_SIZEBORDER), MPVOID); | 
|---|
| 5296 | if (fAutoView) { | 
|---|
| 5297 |  | 
|---|
| 5298 | CHAR s[CCHMAXPATH]; | 
|---|
| 5299 | HWND hwndDir; | 
|---|
| 5300 | PCNRITEM pci; | 
|---|
| 5301 |  | 
|---|
| 5302 | hwndDir = TopWindowName(hwnd, (HWND) 0, s); | 
|---|
| 5303 | if (hwndDir) { | 
|---|
| 5304 | hwndDir = WinWindowFromID(hwndDir, FID_CLIENT); | 
|---|
| 5305 | if (hwndDir) { | 
|---|
| 5306 | hwndDir = WinWindowFromID(hwndDir, DIR_CNR); | 
|---|
| 5307 | if (hwndDir) { | 
|---|
| 5308 | pci = (PCNRITEM) WinSendMsg(hwndDir, CM_QUERYRECORDEMPHASIS, | 
|---|
| 5309 | MPFROMLONG(CMA_FIRST), | 
|---|
| 5310 | MPFROMSHORT(CRA_CURSORED)); | 
|---|
| 5311 | if (pci && (INT) pci != -1 && | 
|---|
| 5312 | (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW))) | 
|---|
| 5313 | WinSendMsg(hwnd, | 
|---|
| 5314 | UM_LOADFILE, | 
|---|
| 5315 | MPFROMP(pci->pszFileName), | 
|---|
| 5316 | (SHORT1FROMMP(mp1) == IDM_AUTOVIEW) ? | 
|---|
| 5317 | MPVOID : MPFROMLONG(1)); | 
|---|
| 5318 | } | 
|---|
| 5319 | } | 
|---|
| 5320 | } | 
|---|
| 5321 | } | 
|---|
| 5322 | break; | 
|---|
| 5323 |  | 
|---|
| 5324 | case IDM_TEXTTOOLS: | 
|---|
| 5325 | SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1), | 
|---|
| 5326 | &fTextTools, TRUE, "TextTools"); | 
|---|
| 5327 | PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID); | 
|---|
| 5328 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME, | 
|---|
| 5329 | MPFROMLONG(FCF_SIZEBORDER), MPVOID); | 
|---|
| 5330 | break; | 
|---|
| 5331 |  | 
|---|
| 5332 | case IDM_TOOLTITLES: | 
|---|
| 5333 | SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1), | 
|---|
| 5334 | &fToolTitles, TRUE, "ToolTitles"); | 
|---|
| 5335 | PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID); | 
|---|
| 5336 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME, | 
|---|
| 5337 | MPFROMLONG(FCF_SIZEBORDER), MPVOID); | 
|---|
| 5338 | break; | 
|---|
| 5339 |  | 
|---|
| 5340 | case IDM_HIDEMENU: | 
|---|
| 5341 | { | 
|---|
| 5342 | HWND hwndMenu = WinQueryWindowULong(hwnd, QWL_USER); | 
|---|
| 5343 | MenuInvisible = MenuInvisible ? FALSE : TRUE; | 
|---|
| 5344 | if (MenuInvisible) { | 
|---|
| 5345 | WinSetParent(hwndMenu, HWND_OBJECT, FALSE); | 
|---|
| 5346 | WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 5347 | FID_SYSMENU), IDM_HIDEMENU, | 
|---|
| 5348 | GetPString(IDS_UNHIDEMENUTEXT)); | 
|---|
| 5349 | } | 
|---|
| 5350 | else { | 
|---|
| 5351 | WinSetParent(hwndMenu, WinQueryWindow(hwnd, QW_PARENT), FALSE); | 
|---|
| 5352 | WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 5353 | FID_SYSMENU), IDM_HIDEMENU, | 
|---|
| 5354 | GetPString(IDS_HIDEMENUTEXT)); | 
|---|
| 5355 | } | 
|---|
| 5356 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME, | 
|---|
| 5357 | MPFROMLONG(FCF_MENU), MPVOID); | 
|---|
| 5358 | PrfWriteProfileData(fmprof, FM3Str, "MenuInvisible", | 
|---|
| 5359 | &MenuInvisible, sizeof(BOOL)); | 
|---|
| 5360 | } | 
|---|
| 5361 | break; | 
|---|
| 5362 |  | 
|---|
| 5363 | case IDM_SEEALL: | 
|---|
| 5364 | case IDM_GREP: | 
|---|
| 5365 | case IDM_COLLECTOR: | 
|---|
| 5366 | { | 
|---|
| 5367 | HWND hwndC; | 
|---|
| 5368 | SWP swp; | 
|---|
| 5369 | BOOL already = FALSE; | 
|---|
| 5370 |  | 
|---|
| 5371 | if (Collector) | 
|---|
| 5372 | already = TRUE; | 
|---|
| 5373 | if (!already && !fAutoTile && !fExternalCollector) | 
|---|
| 5374 | GetNextWindowPos(hwnd, &swp, NULL, NULL); | 
|---|
| 5375 | hwndC = StartCollector(fExternalCollector ? HWND_DESKTOP : hwnd, 4); | 
|---|
| 5376 | if (hwndC) { | 
|---|
| 5377 | if (!already && !fAutoTile && !fExternalCollector) | 
|---|
| 5378 | WinSetWindowPos(hwndC, HWND_TOP, | 
|---|
| 5379 | swp.x, swp.y, swp.cx, swp.cy, | 
|---|
| 5380 | SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER); | 
|---|
| 5381 | else if (fAutoTile && !already) | 
|---|
| 5382 | TileChildren(hwnd, TRUE); | 
|---|
| 5383 | WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE | | 
|---|
| 5384 | SWP_ACTIVATE); | 
|---|
| 5385 | if (SHORT1FROMMP(mp1) == IDM_GREP) | 
|---|
| 5386 | PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND, | 
|---|
| 5387 | MPFROM2SHORT(IDM_GREP, 0), MPVOID); | 
|---|
| 5388 | if (SHORT1FROMMP(mp1) == IDM_SEEALL) | 
|---|
| 5389 | PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND, | 
|---|
| 5390 | MPFROM2SHORT(IDM_SEEALL, 0), MPVOID); | 
|---|
| 5391 | } | 
|---|
| 5392 | } | 
|---|
| 5393 | break; | 
|---|
| 5394 |  | 
|---|
| 5395 | case IDM_DATABAR: | 
|---|
| 5396 | CreateDataBar(HWND_DESKTOP, 0); | 
|---|
| 5397 | break; | 
|---|
| 5398 |  | 
|---|
| 5399 | case IDM_TOOLLEFT: | 
|---|
| 5400 | case IDM_TOOLRIGHT: | 
|---|
| 5401 | { | 
|---|
| 5402 | TOOL *tool; | 
|---|
| 5403 |  | 
|---|
| 5404 | if (!toolhead || !toolhead->next) { | 
|---|
| 5405 | firsttool = (toolhead) ? toolhead->id : 0; | 
|---|
| 5406 | break; | 
|---|
| 5407 | } | 
|---|
| 5408 | tool = find_tool(firsttool); | 
|---|
| 5409 | if (!tool) | 
|---|
| 5410 | tool = toolhead; | 
|---|
| 5411 | if (SHORT1FROMMP(mp1) == IDM_TOOLRIGHT) { | 
|---|
| 5412 | tool = prev_tool(tool, TRUE); | 
|---|
| 5413 | firsttool = tool->id; | 
|---|
| 5414 | } | 
|---|
| 5415 | else { | 
|---|
| 5416 | tool = next_tool(tool, TRUE); | 
|---|
| 5417 | firsttool = tool->id; | 
|---|
| 5418 | } | 
|---|
| 5419 | ResizeTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 5420 | MAIN_TOOLS)); | 
|---|
| 5421 | } | 
|---|
| 5422 | break; | 
|---|
| 5423 |  | 
|---|
| 5424 | case IDM_CREATETOOL: | 
|---|
| 5425 | PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID); | 
|---|
| 5426 | break; | 
|---|
| 5427 |  | 
|---|
| 5428 | case IDM_TOOLBAR: | 
|---|
| 5429 | SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), | 
|---|
| 5430 | IDM_TOOLSUBMENU, &fToolbar, TRUE, "Toolbar"); | 
|---|
| 5431 | PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID); | 
|---|
| 5432 | WinShowWindow(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 5433 | MAIN_TOOLS), fToolbar); | 
|---|
| 5434 | WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 5435 | WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID); | 
|---|
| 5436 | if (fDrivebar) | 
|---|
| 5437 | WinInvalidateRect(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 5438 | MAIN_DRIVES), NULL, TRUE); | 
|---|
| 5439 | break; | 
|---|
| 5440 |  | 
|---|
| 5441 | case IDM_DRIVEBAR: | 
|---|
| 5442 | SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), | 
|---|
| 5443 | IDM_DRIVEBAR, &fDrivebar, TRUE, "Drivebar"); | 
|---|
| 5444 | WinShowWindow(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 5445 | MAIN_DRIVES), fDrivebar); | 
|---|
| 5446 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 5447 | WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID); | 
|---|
| 5448 | PostMsg(hwnd, UM_BUILDDRIVEBAR, MPVOID, MPVOID); | 
|---|
| 5449 | break; | 
|---|
| 5450 |  | 
|---|
| 5451 | case IDM_USERLIST: | 
|---|
| 5452 | SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), | 
|---|
| 5453 | SHORT1FROMMP(mp1), &fUserComboBox, TRUE, "UserComboBox"); | 
|---|
| 5454 | WinShowWindow(hwndUserlist, fUserComboBox); | 
|---|
| 5455 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 5456 | WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID); | 
|---|
| 5457 | PostMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID); | 
|---|
| 5458 | PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID); | 
|---|
| 5459 | PostMsg(hwnd, UM_FILLCMDLIST, MPVOID, MPVOID); | 
|---|
| 5460 | PostMsg(hwnd, UM_FILLBUTTONLIST, MPVOID, MPVOID); | 
|---|
| 5461 | break; | 
|---|
| 5462 |  | 
|---|
| 5463 | case IDM_MOREBUTTONS: | 
|---|
| 5464 | WinSetWindowText(hwndName, NullStr); | 
|---|
| 5465 | WinSetWindowText(hwndDate, NullStr); | 
|---|
| 5466 | WinSetWindowText(hwndAttr, NullStr); | 
|---|
| 5467 | SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), | 
|---|
| 5468 | SHORT1FROMMP(mp1), &fMoreButtons, TRUE, "MoreButtons"); | 
|---|
| 5469 | if (fMoreButtons) { | 
|---|
| 5470 |  | 
|---|
| 5471 | HWND hwndTemp; | 
|---|
| 5472 |  | 
|---|
| 5473 | hwndTemp = TopWindow(hwnd, (HWND) 0); | 
|---|
| 5474 |  | 
|---|
| 5475 | if (hwndTemp) { | 
|---|
| 5476 | WinSetFocus(HWND_DESKTOP, hwnd); | 
|---|
| 5477 | WinSetFocus(HWND_DESKTOP, hwndTemp); | 
|---|
| 5478 | } | 
|---|
| 5479 | } | 
|---|
| 5480 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 5481 | WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID); | 
|---|
| 5482 | break; | 
|---|
| 5483 |  | 
|---|
| 5484 | // 2014-05-17 SHL | 
|---|
| 5485 | case IDM_CONFIRMDELETE: | 
|---|
| 5486 | SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), | 
|---|
| 5487 | IDM_CONFIRMDELETE, | 
|---|
| 5488 | &fConfirmDelete, | 
|---|
| 5489 | TRUE, | 
|---|
| 5490 | "ConfirmDelete"); | 
|---|
| 5491 | break; | 
|---|
| 5492 |  | 
|---|
| 5493 | case IDM_TOGGLEDRAGDIALOG: | 
|---|
| 5494 | SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), | 
|---|
| 5495 | IDM_TOGGLEDRAGDIALOG, | 
|---|
| 5496 | &fDragndropDlg, | 
|---|
| 5497 | TRUE, | 
|---|
| 5498 | "Drag&DropDlg"); | 
|---|
| 5499 | break; | 
|---|
| 5500 |  | 
|---|
| 5501 | case IDM_SYNCUPDATES: | 
|---|
| 5502 | SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), | 
|---|
| 5503 | IDM_SYNCUPDATES, | 
|---|
| 5504 | &fSyncUpdates, | 
|---|
| 5505 | TRUE, | 
|---|
| 5506 | "SyncUpdates"); | 
|---|
| 5507 | break; | 
|---|
| 5508 |  | 
|---|
| 5509 | case IDM_FREETREE: | 
|---|
| 5510 | if (fFreeTree) { | 
|---|
| 5511 | SWP swp, swpT; | 
|---|
| 5512 |  | 
|---|
| 5513 | WinQueryWindowPos(hwndTree, &swpT); | 
|---|
| 5514 | WinQueryWindowPos(hwnd, &swp); | 
|---|
| 5515 | WinSetWindowPos(hwndTree, HWND_TOP, 0, swp.cy - swpT.cy, 0, 0, | 
|---|
| 5516 | SWP_MOVE); | 
|---|
| 5517 | } | 
|---|
| 5518 | SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1), | 
|---|
| 5519 | &fFreeTree, TRUE, "FreeTree"); | 
|---|
| 5520 | if (fAutoTile) | 
|---|
| 5521 | TileChildren(hwnd, TRUE); | 
|---|
| 5522 | break; | 
|---|
| 5523 |  | 
|---|
| 5524 | case IDM_AUTOTILE: | 
|---|
| 5525 | SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), | 
|---|
| 5526 | SHORT1FROMMP(mp1), &fAutoTile, TRUE, "AutoTile"); | 
|---|
| 5527 | if (fAutoTile) | 
|---|
| 5528 | TileChildren(hwnd, TRUE); | 
|---|
| 5529 | break; | 
|---|
| 5530 |  | 
|---|
| 5531 | case IDM_TILEBACKWARDS: | 
|---|
| 5532 | SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), | 
|---|
| 5533 | SHORT1FROMMP(mp1), &fTileBackwards, TRUE, "TileBackwards"); | 
|---|
| 5534 | if (fAutoTile) | 
|---|
| 5535 | TileChildren(hwnd, TRUE); | 
|---|
| 5536 | break; | 
|---|
| 5537 |  | 
|---|
| 5538 | case IDM_NEXTWINDOW: | 
|---|
| 5539 | case IDM_PREVWINDOW: | 
|---|
| 5540 | NextChild(hwnd, (SHORT1FROMMP(mp1) == IDM_PREVWINDOW)); | 
|---|
| 5541 | break; | 
|---|
| 5542 |  | 
|---|
| 5543 | case IDM_CASCADE: | 
|---|
| 5544 | CascadeChildren(hwnd); | 
|---|
| 5545 | break; | 
|---|
| 5546 |  | 
|---|
| 5547 | case IDM_TILE: | 
|---|
| 5548 | TileChildren(hwnd, TRUE); | 
|---|
| 5549 | break; | 
|---|
| 5550 |  | 
|---|
| 5551 | case IDM_RESTORE: | 
|---|
| 5552 | MinResChildren(hwnd, SWP_RESTORE); | 
|---|
| 5553 | break; | 
|---|
| 5554 |  | 
|---|
| 5555 | case IDM_MINIMIZE: | 
|---|
| 5556 | MinResChildren(hwnd, SWP_MINIMIZE); | 
|---|
| 5557 | break; | 
|---|
| 5558 |  | 
|---|
| 5559 | case IDM_ARRANGEICONS: | 
|---|
| 5560 | ArrangeIcons(hwnd); | 
|---|
| 5561 | break; | 
|---|
| 5562 |  | 
|---|
| 5563 | case IDM_INIVIEWER: | 
|---|
| 5564 | StartIniEditor(hwnd, NULL, 4); | 
|---|
| 5565 | break; | 
|---|
| 5566 |  | 
|---|
| 5567 | case IDM_INIVIEWERSYS: | 
|---|
| 5568 | StartIniEditor(hwnd, "SYS", 4); | 
|---|
| 5569 | break; | 
|---|
| 5570 |  | 
|---|
| 5571 | case IDM_INIVIEWERFM2: | 
|---|
| 5572 | StartIniEditor(hwnd, profile, 4); | 
|---|
| 5573 | break; | 
|---|
| 5574 |  | 
|---|
| 5575 | case IDM_EDITASSOC: | 
|---|
| 5576 | EditAssociations(hwnd); | 
|---|
| 5577 | break; | 
|---|
| 5578 |  | 
|---|
| 5579 | case IDM_EDITCOMMANDS: | 
|---|
| 5580 | EditCommands(hwnd); | 
|---|
| 5581 | PostMsg(hwnd, UM_FILLCMDLIST, MPVOID, MPVOID); | 
|---|
| 5582 | break; | 
|---|
| 5583 |  | 
|---|
| 5584 | default: | 
|---|
| 5585 | if (!SwitchCommand((HWND) WinQueryWindowULong(hwnd, QWL_USER), | 
|---|
| 5586 | SHORT1FROMMP(mp1))) { | 
|---|
| 5587 | if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART && | 
|---|
| 5588 | SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) { | 
|---|
| 5589 |  | 
|---|
| 5590 | INT x; | 
|---|
| 5591 | HWND hwndCnr; | 
|---|
| 5592 |  | 
|---|
| 5593 | if (!cmdloaded) | 
|---|
| 5594 | load_commands(); | 
|---|
| 5595 | hwndCnr = TopWindow(hwnd, (HWND) 0); | 
|---|
| 5596 | hwndCnr = (HWND) WinSendMsg(WinWindowFromID(hwndCnr, FID_CLIENT), | 
|---|
| 5597 | UM_CONTAINERHWND, MPVOID, MPVOID); | 
|---|
| 5598 | if (!hwndCnr) { | 
|---|
| 5599 | Runtime_Error(pszSrcFile, __LINE__, NULL); | 
|---|
| 5600 | break; | 
|---|
| 5601 | } | 
|---|
| 5602 | x = SHORT1FROMMP(mp1);// - IDM_COMMANDSTART; | 
|---|
| 5603 | if (x >= 0) { | 
|---|
| 5604 | //x++; | 
|---|
| 5605 | RunCommand(hwndCnr, x); | 
|---|
| 5606 | if (fUnHilite) { | 
|---|
| 5607 |  | 
|---|
| 5608 | PCNRITEM pci; | 
|---|
| 5609 | DIRCNRDATA *dcd = NULL; | 
|---|
| 5610 |  | 
|---|
| 5611 | // 12 May 07 SHL fixme to understand? backwards maybe? looking for DIR_CNR? | 
|---|
| 5612 | if (WinQueryWindowUShort(hwndCnr, QWS_ID) != TREE_CNR) | 
|---|
| 5613 | dcd = INSTDATA(hwndCnr); | 
|---|
| 5614 | pci = (PCNRITEM) WinSendMsg(hwndCnr, | 
|---|
| 5615 | CM_QUERYRECORDEMPHASIS, | 
|---|
| 5616 | MPFROMLONG(CMA_FIRST), | 
|---|
| 5617 | MPFROMSHORT(CRA_CURSORED)); | 
|---|
| 5618 | if (pci && (INT) pci != -1 && | 
|---|
| 5619 | (pci->rc.flRecordAttr & CRA_SELECTED)) | 
|---|
| 5620 | { | 
|---|
| 5621 | UnHilite(hwnd, | 
|---|
| 5622 | TRUE, | 
|---|
| 5623 | dcd ? &dcd->lastselection : NULL, | 
|---|
| 5624 | dcd ? dcd ->ulItemsToUnHilite : 0); | 
|---|
| 5625 | } | 
|---|
| 5626 | } | 
|---|
| 5627 | } | 
|---|
| 5628 | } | 
|---|
| 5629 | else if (SHORT1FROMMP(mp1) >= IDM_QUICKTOOLSTART && | 
|---|
| 5630 | SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART + 51) { | 
|---|
| 5631 | if (!qtloaded) | 
|---|
| 5632 | load_quicktools(); | 
|---|
| 5633 | if (quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]) { | 
|---|
| 5634 | if (fToolsChanged) | 
|---|
| 5635 | save_tools(NULL); | 
|---|
| 5636 | if (!load_tools(quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1])) | 
|---|
| 5637 | load_tools(NULL); | 
|---|
| 5638 | else { | 
|---|
| 5639 | strcpy(lasttoolbar, | 
|---|
| 5640 | quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]); | 
|---|
| 5641 | PrfWriteProfileString(fmprof, FM3Str, "LastToolbar", lasttoolbar); | 
|---|
| 5642 | } | 
|---|
| 5643 | PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID); | 
|---|
| 5644 | } | 
|---|
| 5645 | } | 
|---|
| 5646 | else { | 
|---|
| 5647 |  | 
|---|
| 5648 | HWND hwndActive; | 
|---|
| 5649 |  | 
|---|
| 5650 | hwndActive = TopWindow(hwnd, (HWND) 0); | 
|---|
| 5651 | if (hwndActive) | 
|---|
| 5652 | PostMsg(WinWindowFromID(hwndActive, FID_CLIENT), | 
|---|
| 5653 | WM_COMMAND, mp1, mp2); | 
|---|
| 5654 | } | 
|---|
| 5655 | } | 
|---|
| 5656 | break;                              // default | 
|---|
| 5657 | } // switch mp1 | 
|---|
| 5658 | return 0; | 
|---|
| 5659 | } | 
|---|
| 5660 |  | 
|---|
| 5661 | static MRESULT EXPENTRY MainWMOnce(HWND hwnd, ULONG msg, MPARAM mp1, | 
|---|
| 5662 | MPARAM mp2) | 
|---|
| 5663 | { | 
|---|
| 5664 | TID tid; | 
|---|
| 5665 | SWP swp; | 
|---|
| 5666 | PFNWP oldproc; | 
|---|
| 5667 | HWND hwndTmp; | 
|---|
| 5668 | HWND hwndFrame; | 
|---|
| 5669 | HWND hwndSysMenu, hwndSysSubMenu, hwndMenu; | 
|---|
| 5670 | USHORT idSysMenu; | 
|---|
| 5671 | MENUITEM mi, mit; | 
|---|
| 5672 | ULONG size; | 
|---|
| 5673 | BOOL temp; | 
|---|
| 5674 |  | 
|---|
| 5675 | static BOOL needTile; | 
|---|
| 5676 |  | 
|---|
| 5677 | switch (msg) { | 
|---|
| 5678 | case WM_CREATE: | 
|---|
| 5679 | WinQueryWindowProcess(hwnd, &mypid, &tid); | 
|---|
| 5680 | hwndMain = hwnd; | 
|---|
| 5681 | WinSetWindowUShort(hwnd, QWL_USER + 8, 0); | 
|---|
| 5682 | WinSetWindowUShort(hwnd, QWL_USER + 10, 0); | 
|---|
| 5683 | WinSetWindowUShort(hwnd, QWL_USER + 12, 0); | 
|---|
| 5684 | WinSetWindowUShort(hwnd, QWL_USER + 16, 0); | 
|---|
| 5685 | if (xbeginthread(MakeMainObjWin, | 
|---|
| 5686 | 245760, | 
|---|
| 5687 | MPVOID, | 
|---|
| 5688 | pszSrcFile, | 
|---|
| 5689 | __LINE__) == -1) | 
|---|
| 5690 | { | 
|---|
| 5691 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID); | 
|---|
| 5692 | return 0; | 
|---|
| 5693 | } | 
|---|
| 5694 | else | 
|---|
| 5695 | DosSleep(32);//05 Aug 07 GKY 64 | 
|---|
| 5696 |  | 
|---|
| 5697 | hwndFrame = WinQueryWindow(hwnd, QW_PARENT); | 
|---|
| 5698 |  | 
|---|
| 5699 | // create frame children (not client children, frame children) | 
|---|
| 5700 | DosSleep(1); | 
|---|
| 5701 | WinQueryWindowPos(hwndFrame, &swp); | 
|---|
| 5702 | oldproc = WinSubclassWindow(hwndFrame, MainFrameWndProc); | 
|---|
| 5703 | WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc); | 
|---|
| 5704 | CommonCreateMainChildren(hwnd, &swp); | 
|---|
| 5705 |  | 
|---|
| 5706 | if (!WinCreateWindow(hwndFrame, | 
|---|
| 5707 | (CHAR *) WC_BUTTON, | 
|---|
| 5708 | "I", | 
|---|
| 5709 | WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS, | 
|---|
| 5710 | ((swp.cx - | 
|---|
| 5711 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5712 | SV_CXMINMAXBUTTON)) - | 
|---|
| 5713 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5714 | SV_CXMINMAXBUTTON) / 2) - | 
|---|
| 5715 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5716 | SV_CXSIZEBORDER), | 
|---|
| 5717 | (swp.cy - WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5718 | SV_CYMINMAXBUTTON)) - | 
|---|
| 5719 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5720 | SV_CYSIZEBORDER), | 
|---|
| 5721 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5722 | SV_CXMINMAXBUTTON) / 2, | 
|---|
| 5723 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5724 | SV_CYMINMAXBUTTON), | 
|---|
| 5725 | hwnd, HWND_TOP, IDM_IDEALSIZE, NULL, NULL)) { | 
|---|
| 5726 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, | 
|---|
| 5727 | PCSZ_WINCREATEWINDOW); | 
|---|
| 5728 | } | 
|---|
| 5729 | else { | 
|---|
| 5730 | WinSubclassWindow(WinWindowFromID(hwndFrame, IDM_IDEALSIZE), | 
|---|
| 5731 | IdealButtonProc); | 
|---|
| 5732 | //fixme to allow user to change presparams 1-10-09 GKY | 
|---|
| 5733 | SetPresParams(WinWindowFromID(hwndFrame, | 
|---|
| 5734 | IDM_IDEALSIZE), | 
|---|
| 5735 | NULL, NULL, NULL, FNT_10SYSTEMVIO); | 
|---|
| 5736 | } | 
|---|
| 5737 |  | 
|---|
| 5738 | hwndTmp = WinCreateWindow(hwndFrame, | 
|---|
| 5739 | (CHAR *) WC_BUTTON, | 
|---|
| 5740 | "#1019", | 
|---|
| 5741 | WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS | | 
|---|
| 5742 | BS_BITMAP, | 
|---|
| 5743 | swp.cx - 46, | 
|---|
| 5744 | swp.y + 2, | 
|---|
| 5745 | 24, | 
|---|
| 5746 | 22, hwnd, HWND_TOP, IDM_OPENWALK, NULL, NULL); | 
|---|
| 5747 | if (!hwndTmp) | 
|---|
| 5748 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, | 
|---|
| 5749 | PCSZ_WINCREATEWINDOW); | 
|---|
| 5750 |  | 
|---|
| 5751 | hwndTmp = WinCreateWindow(hwndFrame, | 
|---|
| 5752 | (CHAR *) WC_BUTTON, | 
|---|
| 5753 | "#3062", | 
|---|
| 5754 | WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS | | 
|---|
| 5755 | BS_BITMAP, | 
|---|
| 5756 | swp.cx - 22, | 
|---|
| 5757 | swp.y + 2, | 
|---|
| 5758 | 24, | 
|---|
| 5759 | 22, hwnd, HWND_TOP, IDM_USERLIST, NULL, NULL); | 
|---|
| 5760 | if (!hwndTmp) | 
|---|
| 5761 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, | 
|---|
| 5762 | PCSZ_WINCREATEWINDOW); | 
|---|
| 5763 |  | 
|---|
| 5764 | hwndUserlist = WinCreateWindow(hwndFrame, | 
|---|
| 5765 | (CHAR *) WC_COMBOBOX, | 
|---|
| 5766 | (PSZ) NULL, | 
|---|
| 5767 | WS_VISIBLE | CBS_DROPDOWN | | 
|---|
| 5768 | LS_HORZSCROLL, | 
|---|
| 5769 | (swp.x + | 
|---|
| 5770 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5771 | SV_CXSIZEBORDER) + 48L), | 
|---|
| 5772 | (swp.cy - | 
|---|
| 5773 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5774 | SV_CYSIZEBORDER)) - 60, | 
|---|
| 5775 | ((swp.cx - | 
|---|
| 5776 | (WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5777 | SV_CXSIZEBORDER) * | 
|---|
| 5778 | 2)) - 64L), 60L, hwndFrame, HWND_TOP, | 
|---|
| 5779 | MAIN_USERLIST, NULL, NULL); | 
|---|
| 5780 | if (!hwndUserlist) | 
|---|
| 5781 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, | 
|---|
| 5782 | PCSZ_WINCREATEWINDOW); | 
|---|
| 5783 | hwndCmdlist = WinCreateWindow(hwndFrame, | 
|---|
| 5784 | (CHAR *) WC_COMBOBOX, | 
|---|
| 5785 | (PSZ) NULL, | 
|---|
| 5786 | WS_VISIBLE | CBS_DROPDOWN | | 
|---|
| 5787 | LS_HORZSCROLL, | 
|---|
| 5788 | (swp.x + | 
|---|
| 5789 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5790 | SV_CXSIZEBORDER) + 48L), | 
|---|
| 5791 | (swp.cy - | 
|---|
| 5792 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5793 | SV_CYSIZEBORDER)) - 60, | 
|---|
| 5794 | ((swp.cx - | 
|---|
| 5795 | (WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5796 | SV_CXSIZEBORDER) * 2)) - | 
|---|
| 5797 | 64L), 60L, hwndFrame, HWND_TOP, | 
|---|
| 5798 | MAIN_CMDLIST, NULL, NULL); | 
|---|
| 5799 | if (!hwndCmdlist) | 
|---|
| 5800 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, | 
|---|
| 5801 | PCSZ_WINCREATEWINDOW); | 
|---|
| 5802 | WinSetWindowText(hwndCmdlist, (CHAR *) GetPString(IDS_COMMANDSTEXT)); | 
|---|
| 5803 | hwndStatelist = WinCreateWindow(hwndFrame, | 
|---|
| 5804 | (CHAR *) WC_COMBOBOX, | 
|---|
| 5805 | (PSZ) NULL, | 
|---|
| 5806 | WS_VISIBLE | CBS_DROPDOWN | | 
|---|
| 5807 | LS_HORZSCROLL, | 
|---|
| 5808 | (swp.x + | 
|---|
| 5809 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5810 | SV_CXSIZEBORDER) + 48L), | 
|---|
| 5811 | (swp.cy - | 
|---|
| 5812 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5813 | SV_CYSIZEBORDER)) - 60, | 
|---|
| 5814 | ((swp.cx - | 
|---|
| 5815 | (WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5816 | SV_CXSIZEBORDER) * | 
|---|
| 5817 | 2)) - 64L), 60L, hwndFrame, HWND_TOP, | 
|---|
| 5818 | MAIN_SETUPLIST, NULL, NULL); | 
|---|
| 5819 | if (!hwndStatelist) | 
|---|
| 5820 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, | 
|---|
| 5821 | PCSZ_WINCREATEWINDOW); | 
|---|
| 5822 |  | 
|---|
| 5823 | hwndDrivelist = WinCreateWindow(hwndFrame, | 
|---|
| 5824 | (CHAR *) WC_COMBOBOX, | 
|---|
| 5825 | (PSZ) NULL, | 
|---|
| 5826 | //WS_VISIBLE | | 
|---|
| 5827 | CBS_DROPDOWN, | 
|---|
| 5828 | (swp.x + | 
|---|
| 5829 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5830 | SV_CXSIZEBORDER)), | 
|---|
| 5831 | (swp.cy - | 
|---|
| 5832 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5833 | SV_CYSIZEBORDER)) - 60, | 
|---|
| 5834 | 48L, | 
|---|
| 5835 | 60L, | 
|---|
| 5836 | hwndFrame, | 
|---|
| 5837 | HWND_TOP, MAIN_DRIVELIST, NULL, NULL); | 
|---|
| 5838 | if (!hwndDrivelist) | 
|---|
| 5839 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, | 
|---|
| 5840 | PCSZ_WINCREATEWINDOW); | 
|---|
| 5841 | //fixme to allow user to change presparams 1-10-09 GKY | 
|---|
| 5842 | SetPresParams(hwndDrivelist, | 
|---|
| 5843 | NULL, NULL, NULL, FNT_10SYSTEMMONOTEXT); | 
|---|
| 5844 | hwndButtonlist = WinCreateWindow(hwndFrame, | 
|---|
| 5845 | (CHAR *) WC_COMBOBOX, | 
|---|
| 5846 | (PSZ) NULL, | 
|---|
| 5847 | WS_VISIBLE | CBS_DROPDOWN | | 
|---|
| 5848 | LS_HORZSCROLL, | 
|---|
| 5849 | (swp.cx - | 
|---|
| 5850 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5851 | SV_CXSIZEBORDER)) - | 
|---|
| 5852 | 164L, | 
|---|
| 5853 | (swp.cy - | 
|---|
| 5854 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5855 | SV_CYSIZEBORDER)) - 60, | 
|---|
| 5856 | 164L, 60L, hwndFrame, HWND_TOP, | 
|---|
| 5857 | MAIN_BUTTONLIST, NULL, NULL); | 
|---|
| 5858 | if (!hwndButtonlist) | 
|---|
| 5859 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, | 
|---|
| 5860 | PCSZ_WINCREATEWINDOW); | 
|---|
| 5861 | WinSendMsg(WinWindowFromID(hwndUserlist, CBID_EDIT), | 
|---|
| 5862 | EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID); | 
|---|
| 5863 | WinSendMsg(WinWindowFromID(hwndStatelist, CBID_EDIT), | 
|---|
| 5864 | EM_SETTEXTLIMIT, MPFROM2SHORT(STATE_NAME_MAX_BYTES, 0), MPVOID); | 
|---|
| 5865 | WinSendMsg(WinWindowFromID(hwndDrivelist, CBID_EDIT), | 
|---|
| 5866 | EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID); | 
|---|
| 5867 | WinSendMsg(WinWindowFromID(hwndButtonlist, CBID_EDIT), | 
|---|
| 5868 | EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID); | 
|---|
| 5869 | WinSendMsg(WinWindowFromID(hwndCmdlist, CBID_EDIT), | 
|---|
| 5870 | EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID); | 
|---|
| 5871 |  | 
|---|
| 5872 | oldproc = WinSubclassWindow(WinWindowFromID(hwndUserlist, CBID_EDIT), | 
|---|
| 5873 | DropDownListProc); | 
|---|
| 5874 | WinSetWindowPtr(WinWindowFromID(hwndUserlist, CBID_EDIT), | 
|---|
| 5875 | QWL_USER, (PVOID) oldproc); | 
|---|
| 5876 | oldproc = WinSubclassWindow(WinWindowFromID(hwndCmdlist, CBID_EDIT), | 
|---|
| 5877 | DropDownListProc); | 
|---|
| 5878 | WinSetWindowPtr(WinWindowFromID(hwndCmdlist, CBID_EDIT), | 
|---|
| 5879 | QWL_USER, (PVOID) oldproc); | 
|---|
| 5880 | oldproc = WinSubclassWindow(WinWindowFromID(hwndButtonlist, CBID_EDIT), | 
|---|
| 5881 | DropDownListProc); | 
|---|
| 5882 | WinSetWindowPtr(WinWindowFromID(hwndButtonlist, CBID_EDIT), | 
|---|
| 5883 | QWL_USER, (PVOID) oldproc); | 
|---|
| 5884 | oldproc = WinSubclassWindow(WinWindowFromID(hwndStatelist, CBID_EDIT), | 
|---|
| 5885 | DropDownListProc); | 
|---|
| 5886 | WinSetWindowPtr(WinWindowFromID(hwndStatelist, CBID_EDIT), | 
|---|
| 5887 | QWL_USER, (PVOID) oldproc); | 
|---|
| 5888 | oldproc = WinSubclassWindow(WinWindowFromID(hwndDrivelist, CBID_EDIT), | 
|---|
| 5889 | DropDownListProc); | 
|---|
| 5890 | WinSetWindowPtr(WinWindowFromID(hwndDrivelist, CBID_EDIT), | 
|---|
| 5891 | QWL_USER, (PVOID) oldproc); | 
|---|
| 5892 | oldproc = WinSubclassWindow(hwndUserlist, DropDownListProc); | 
|---|
| 5893 | WinSetWindowPtr(hwndUserlist, QWL_USER, (PVOID) oldproc); | 
|---|
| 5894 | oldproc = WinSubclassWindow(hwndCmdlist, DropDownListProc); | 
|---|
| 5895 | WinSetWindowPtr(hwndCmdlist, QWL_USER, (PVOID) oldproc); | 
|---|
| 5896 | oldproc = WinSubclassWindow(hwndStatelist, DropDownListProc); | 
|---|
| 5897 | WinSetWindowPtr(hwndStatelist, QWL_USER, (PVOID) oldproc); | 
|---|
| 5898 | oldproc = WinSubclassWindow(hwndDrivelist, DropDownListProc); | 
|---|
| 5899 | WinSetWindowPtr(hwndDrivelist, QWL_USER, (PVOID) oldproc); | 
|---|
| 5900 | oldproc = WinSubclassWindow(hwndButtonlist, DropDownListProc); | 
|---|
| 5901 | WinSetWindowPtr(hwndButtonlist, QWL_USER, (PVOID) oldproc); | 
|---|
| 5902 | oldproc = WinSubclassWindow(WinWindowFromID(hwndFrame, IDM_USERLIST), | 
|---|
| 5903 | ChildFrameButtonProc); | 
|---|
| 5904 | WinSetWindowPtr(WinWindowFromID(hwndFrame, IDM_USERLIST), | 
|---|
| 5905 | QWL_USER, (PVOID) oldproc); | 
|---|
| 5906 | oldproc = WinSubclassWindow(WinWindowFromID(hwndFrame, IDM_OPENWALK), | 
|---|
| 5907 | ChildFrameButtonProc); | 
|---|
| 5908 | WinSetWindowPtr(WinWindowFromID(hwndFrame, IDM_OPENWALK), | 
|---|
| 5909 | QWL_USER, (PVOID) oldproc); | 
|---|
| 5910 | hwndMenu = WinWindowFromID(hwndFrame, FID_MENU); | 
|---|
| 5911 | WinSendMsg(hwnd, UM_ADDTOMENU, MPVOID, MPVOID); | 
|---|
| 5912 | SetToggleChecks(hwndMenu); | 
|---|
| 5913 | CfgMenuInit(hwndMenu, FALSE);        // 14 Feb 08 SHL | 
|---|
| 5914 | SetConditionalCascade(hwndMenu, IDM_COMMANDLINESUBMENU, IDM_COMMANDLINE); | 
|---|
| 5915 | if (fProtectOnly) { | 
|---|
| 5916 | WinEnableMenuItem(hwndMenu, IDM_DOSCOMMANDLINE, FALSE); | 
|---|
| 5917 | WinEnableMenuItem(hwndMenu, IDM_WINFULLSCREEN, FALSE); | 
|---|
| 5918 | } | 
|---|
| 5919 | SetConditionalCascade(hwndMenu, IDM_TOOLSUBMENU, IDM_TOOLBAR); | 
|---|
| 5920 | SetConditionalCascade(hwndMenu, IDM_AUTOVIEWSUBMENU, IDM_AUTOVIEW); | 
|---|
| 5921 | SetConditionalCascade(hwndMenu, IDM_TILEMENU, IDM_TILE); | 
|---|
| 5922 | WinSetWindowULong(hwnd, QWL_USER, hwndMenu); | 
|---|
| 5923 | memset(&mi, 0, sizeof(mi)); | 
|---|
| 5924 | memset(&mit, 0, sizeof(mit)); | 
|---|
| 5925 | hwndSysMenu = WinWindowFromID(hwndFrame, FID_SYSMENU); | 
|---|
| 5926 | idSysMenu = SHORT1FROMMR(WinSendMsg(hwndSysMenu, | 
|---|
| 5927 | MM_ITEMIDFROMPOSITION, | 
|---|
| 5928 | MPVOID, MPVOID)); | 
|---|
| 5929 | WinSendMsg(hwndSysMenu, | 
|---|
| 5930 | MM_QUERYITEM, MPFROM2SHORT(idSysMenu, 0), MPFROMP(&mit)); | 
|---|
| 5931 | hwndSysSubMenu = mit.hwndSubMenu; | 
|---|
| 5932 | mi.iPosition = MIT_END; | 
|---|
| 5933 | mi.afStyle = MIS_SEPARATOR; | 
|---|
| 5934 | mi.id = (USHORT) - 1; | 
|---|
| 5935 | WinSendMsg(hwndSysSubMenu, MM_INSERTITEM, MPFROMP(&mi), MPFROMP(NULL)); | 
|---|
| 5936 | mi.afStyle = MIS_TEXT; | 
|---|
| 5937 | mi.id = IDM_IDEALSIZE; | 
|---|
| 5938 | WinSendMsg(hwndSysSubMenu, | 
|---|
| 5939 | MM_INSERTITEM, | 
|---|
| 5940 | MPFROMP(&mi), MPFROMP(GetPString(IDS_IDEALMENUTEXT))); | 
|---|
| 5941 | mi.afStyle = MIS_TEXT; | 
|---|
| 5942 | mi.id = IDM_HIDEMENU; | 
|---|
| 5943 | WinSendMsg(hwndSysSubMenu, | 
|---|
| 5944 | MM_INSERTITEM, | 
|---|
| 5945 | MPFROMP(&mi), MPFROMP(GetPString(IDS_HIDEMENUTEXT))); | 
|---|
| 5946 | SetSysMenu(hwndSysMenu); | 
|---|
| 5947 |  | 
|---|
| 5948 | size = sizeof(BOOL); | 
|---|
| 5949 | if (PrfQueryProfileData(fmprof, FM3Str, "MenuInvisible", &temp, &size) && | 
|---|
| 5950 | size && temp) | 
|---|
| 5951 | WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_HIDEMENU, 0), MPVOID); | 
|---|
| 5952 | size = sizeof(BOOL); | 
|---|
| 5953 | if (PrfQueryProfileData(fmprof, FM3Str, "FreeTree", &temp, &size) && | 
|---|
| 5954 | size && temp) | 
|---|
| 5955 | WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_FREETREE, 0), MPVOID); | 
|---|
| 5956 | size = sizeof(BOOL); | 
|---|
| 5957 | if (PrfQueryProfileData(fmprof, FM3Str, "AutoTile", &temp, &size) && | 
|---|
| 5958 | size && !temp) | 
|---|
| 5959 | WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_AUTOTILE, 0), MPVOID); | 
|---|
| 5960 | size = sizeof(BOOL); | 
|---|
| 5961 | if (PrfQueryProfileData(fmprof, appname, "Toolbar", &temp, &size) && size && !temp) | 
|---|
| 5962 | WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TOOLBAR, 0), MPVOID); | 
|---|
| 5963 |  | 
|---|
| 5964 | WinSetWindowText(WinWindowFromID(hwndFrame, FID_TITLEBAR), "FM/2"); | 
|---|
| 5965 | FixSwitchList(hwndFrame, NULL); | 
|---|
| 5966 | break;                              // WM_CREATE | 
|---|
| 5967 |  | 
|---|
| 5968 | case UM_SETUP: | 
|---|
| 5969 | // start up some initial children | 
|---|
| 5970 | WinShowWindow(WinQueryWindow(hwnd, QW_PARENT), TRUE); | 
|---|
| 5971 | PostMsg(MainObjectHwnd, UM_SETUP2, mp1, mp2); | 
|---|
| 5972 | return 0; | 
|---|
| 5973 |  | 
|---|
| 5974 | case UM_SETUP2: | 
|---|
| 5975 | { | 
|---|
| 5976 | SWP swp; | 
|---|
| 5977 | ULONG size = sizeof(SWP); | 
|---|
| 5978 |  | 
|---|
| 5979 | WinQueryWindowPos(hwnd, &swp); | 
|---|
| 5980 | hwndTree = StartTreeCnr(hwnd, 4); | 
|---|
| 5981 | if (!hwndTree) | 
|---|
| 5982 | WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT)); | 
|---|
| 5983 | else { | 
|---|
| 5984 | if (!fSaveState || | 
|---|
| 5985 | !PrfQueryProfileData(fmprof, | 
|---|
| 5986 | FM3Str, | 
|---|
| 5987 | "LastTreePos", | 
|---|
| 5988 | &swp, &size) || size != sizeof(SWP)) { | 
|---|
| 5989 |  | 
|---|
| 5990 | INT ratio, height = 0; | 
|---|
| 5991 |  | 
|---|
| 5992 | if (!fNoTreeGap) | 
|---|
| 5993 | height = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2; | 
|---|
| 5994 | size = sizeof(ratio); | 
|---|
| 5995 | if (!PrfQueryProfileData(fmprof, | 
|---|
| 5996 | FM3Str, | 
|---|
| 5997 | "TreeWindowRatio", | 
|---|
| 5998 | (PVOID) & ratio, | 
|---|
| 5999 | &size) || size < sizeof(ratio)) | 
|---|
| 6000 | ratio = 400; | 
|---|
| 6001 | WinSetWindowPos(hwndTree, | 
|---|
| 6002 | HWND_TOP, | 
|---|
| 6003 | 0, | 
|---|
| 6004 | height, | 
|---|
| 6005 | (swp.cx * 100) / ratio, | 
|---|
| 6006 | swp.cy - height, | 
|---|
| 6007 | SWP_SHOW | SWP_SIZE | SWP_MOVE | | 
|---|
| 6008 | SWP_ACTIVATE | SWP_ZORDER); | 
|---|
| 6009 | } | 
|---|
| 6010 | else | 
|---|
| 6011 | WinSetWindowPos(hwndTree, | 
|---|
| 6012 | HWND_TOP, | 
|---|
| 6013 | swp.x, | 
|---|
| 6014 | swp.y, | 
|---|
| 6015 | swp.cx, | 
|---|
| 6016 | swp.cy, | 
|---|
| 6017 | swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW | | 
|---|
| 6018 | SWP_ZORDER | SWP_ACTIVATE); | 
|---|
| 6019 | } | 
|---|
| 6020 | #     if 0 | 
|---|
| 6021 | ResizeTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 6022 | MAIN_TOOLS)); | 
|---|
| 6023 | #     endif | 
|---|
| 6024 | } | 
|---|
| 6025 | PostMsg(MainObjectHwnd, UM_SETUP3, mp1, mp2); | 
|---|
| 6026 | return 0; | 
|---|
| 6027 |  | 
|---|
| 6028 | case UM_SETUP3: | 
|---|
| 6029 | // start remaining child windows | 
|---|
| 6030 | if (!fNoSaveState && fSaveState) { | 
|---|
| 6031 | PCSZ pszStatename = PCSZ_SHUTDOWNSTATE; | 
|---|
| 6032 | PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMP(pszStatename), MPVOID); | 
|---|
| 6033 | if (!add_setup(pszStatename)) | 
|---|
| 6034 | save_setups(); | 
|---|
| 6035 | } | 
|---|
| 6036 | else { | 
|---|
| 6037 | load_tools(NULL); | 
|---|
| 6038 | PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID); | 
|---|
| 6039 | } | 
|---|
| 6040 | PostMsg(MainObjectHwnd, UM_SETUP4, mp1, mp2); | 
|---|
| 6041 | return 0; | 
|---|
| 6042 |  | 
|---|
| 6043 | case UM_SETUP4: | 
|---|
| 6044 | { | 
|---|
| 6045 | INT argc = (INT) mp1, x; | 
|---|
| 6046 | CHAR **argv = (CHAR **) mp2; | 
|---|
| 6047 |  | 
|---|
| 6048 | for (x = 1; x < argc; x++) { | 
|---|
| 6049 | if (*argv[x] == '/' || *argv[x] == ';') | 
|---|
| 6050 | continue; | 
|---|
| 6051 | if (IsFile(argv[x]) == 0 && !FindDirCnrByName(argv[x], FALSE)) { | 
|---|
| 6052 | OpenDirCnr((HWND) 0, hwndMain, hwndTree, TRUE, argv[x]); | 
|---|
| 6053 | needTile = TRUE; // 2011-10-03 SHL | 
|---|
| 6054 | } | 
|---|
| 6055 | } | 
|---|
| 6056 | } | 
|---|
| 6057 | PostMsg(MainObjectHwnd, UM_SETUP5, MPVOID, MPVOID); | 
|---|
| 6058 | return 0; | 
|---|
| 6059 |  | 
|---|
| 6060 | case UM_SETUP5: | 
|---|
| 6061 | #   if 0 | 
|---|
| 6062 | if (fAutoTile) | 
|---|
| 6063 | TileChildren(hwnd, TRUE); | 
|---|
| 6064 | #   endif | 
|---|
| 6065 | PostMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID); | 
|---|
| 6066 | PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID); | 
|---|
| 6067 | PostMsg(hwnd, UM_FILLCMDLIST, MPVOID, MPVOID); | 
|---|
| 6068 | PostMsg(hwnd, UM_FILLBUTTONLIST, MPVOID, MPVOID); | 
|---|
| 6069 | { | 
|---|
| 6070 | HWND hwndActive; | 
|---|
| 6071 |  | 
|---|
| 6072 | hwndActive = TopWindow(hwnd, hwndTree); | 
|---|
| 6073 | if (hwndActive) | 
|---|
| 6074 | WinSetWindowPos(hwndActive, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE); | 
|---|
| 6075 | } | 
|---|
| 6076 | if (fStartMinimized || fReminimize) | 
|---|
| 6077 | PostMsg(hwndTree, UM_MINIMIZE, MPVOID, MPVOID); | 
|---|
| 6078 | else if (fStartMaximized) | 
|---|
| 6079 | PostMsg(hwndTree, UM_MAXIMIZE, MPVOID, MPVOID); | 
|---|
| 6080 | else if (needTile) | 
|---|
| 6081 | WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);      // 2011-10-03 SHL | 
|---|
| 6082 |  | 
|---|
| 6083 | fRunning = TRUE;                    // Allow status window PRESPARM updates | 
|---|
| 6084 |  | 
|---|
| 6085 | if (fWantFirstTimeInit) { | 
|---|
| 6086 | fWantFirstTimeInit = FALSE; | 
|---|
| 6087 | PostMsg(hwnd, WM_COMMAND, MPFROMLONG(IDM_QUICKSETTINGS), MPVOID); | 
|---|
| 6088 | } | 
|---|
| 6089 | return 0; | 
|---|
| 6090 | } // switch | 
|---|
| 6091 |  | 
|---|
| 6092 | return WinDefWindowProc(hwnd, msg, mp1, mp2); | 
|---|
| 6093 | } | 
|---|
| 6094 |  | 
|---|
| 6095 | MRESULT EXPENTRY MainWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 6096 | { | 
|---|
| 6097 | switch (msg) { | 
|---|
| 6098 | case WM_CREATE: | 
|---|
| 6099 | #   ifdef FORTIFY | 
|---|
| 6100 | Fortify_EnterScope(); | 
|---|
| 6101 | #   endif | 
|---|
| 6102 | case UM_SETUP: | 
|---|
| 6103 | case UM_SETUP2: | 
|---|
| 6104 | case UM_SETUP3: | 
|---|
| 6105 | case UM_SETUP4: | 
|---|
| 6106 | case UM_SETUP5: | 
|---|
| 6107 | return MainWMOnce(hwnd, msg, mp1, mp2); | 
|---|
| 6108 |  | 
|---|
| 6109 | case WM_CONTROLPOINTER: | 
|---|
| 6110 | if (!fNoFinger && | 
|---|
| 6111 | (SHORT1FROMMP(mp1) == IDM_OPENWALK || | 
|---|
| 6112 | SHORT1FROMMP(mp1) == IDM_USERLIST)) | 
|---|
| 6113 | return MRFROMLONG(hptrFinger); | 
|---|
| 6114 | break; | 
|---|
| 6115 |  | 
|---|
| 6116 | case UM_LOADFILE: | 
|---|
| 6117 | case UM_THREADUSE: | 
|---|
| 6118 | case UM_BUILDDRIVEBAR: | 
|---|
| 6119 | case WM_TIMER: | 
|---|
| 6120 | return CommonMainWndProc(hwnd, msg, mp1, mp2); | 
|---|
| 6121 |  | 
|---|
| 6122 | case WM_BUTTON1UP: | 
|---|
| 6123 | case WM_BUTTON2UP: | 
|---|
| 6124 | case WM_BUTTON3UP: | 
|---|
| 6125 | case WM_MOUSEMOVE: | 
|---|
| 6126 | shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); | 
|---|
| 6127 | break; | 
|---|
| 6128 |  | 
|---|
| 6129 | case WM_CHAR: | 
|---|
| 6130 | shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL)); | 
|---|
| 6131 | break; | 
|---|
| 6132 |  | 
|---|
| 6133 | case WM_MENUEND: | 
|---|
| 6134 | if ((HWND) mp2 == MainPopupMenu) { | 
|---|
| 6135 | WinDestroyWindow(MainPopupMenu); | 
|---|
| 6136 | MainPopupMenu = (HWND) 0; | 
|---|
| 6137 | } | 
|---|
| 6138 | break; | 
|---|
| 6139 |  | 
|---|
| 6140 | case UM_CONTEXTMENU: | 
|---|
| 6141 | case WM_CONTEXTMENU: | 
|---|
| 6142 | if (CheckMenu(hwndMainMenu, &MainPopupMenu, MAIN_POPUP)) { | 
|---|
| 6143 | SetToggleChecks(MainPopupMenu); | 
|---|
| 6144 | PopupMenu(hwnd, hwnd, MainPopupMenu); | 
|---|
| 6145 | } | 
|---|
| 6146 | if (msg == UM_CONTEXTMENU) | 
|---|
| 6147 | return 0; | 
|---|
| 6148 | return MRFROMSHORT(TRUE); | 
|---|
| 6149 |  | 
|---|
| 6150 | case UM_SETUSERLISTNAME: | 
|---|
| 6151 | if (mp1) { | 
|---|
| 6152 | if (fUserComboBox) | 
|---|
| 6153 | WinSetWindowText(WinWindowFromID(hwndUserlist, CBID_EDIT), | 
|---|
| 6154 | (CHAR *)mp1); | 
|---|
| 6155 | if (add_udir(FALSE, (CHAR *)mp1)) { | 
|---|
| 6156 | if (fUserComboBox && fAutoAddDirs) { | 
|---|
| 6157 | WinSendMsg(hwndUserlist, LM_INSERTITEM, | 
|---|
| 6158 | MPFROM2SHORT(LIT_SORTASCENDING, 0), | 
|---|
| 6159 | MPFROMP((CHAR *)mp1)); | 
|---|
| 6160 | } | 
|---|
| 6161 | } | 
|---|
| 6162 | } | 
|---|
| 6163 | return 0; | 
|---|
| 6164 |  | 
|---|
| 6165 | case UM_ARRANGEICONS: | 
|---|
| 6166 | ArrangeIcons(hwnd); | 
|---|
| 6167 | return 0; | 
|---|
| 6168 |  | 
|---|
| 6169 | case WM_CHORD: | 
|---|
| 6170 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID); | 
|---|
| 6171 | break; | 
|---|
| 6172 |  | 
|---|
| 6173 | case WM_SETFOCUS: | 
|---|
| 6174 | if (mp2) | 
|---|
| 6175 | PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID); | 
|---|
| 6176 | break; | 
|---|
| 6177 |  | 
|---|
| 6178 | case UM_FOCUSME: | 
|---|
| 6179 | WinSetFocus(hwndTree, 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((CHAR *) FM2Str, | 
|---|
| 6193 | "MainWindowPos", WinQueryWindow(hwnd, QW_PARENT)); | 
|---|
| 6194 | if (!fNoSaveState && fSaveState) | 
|---|
| 6195 | SaveDirCnrState(hwnd, PCSZ_SHUTDOWNSTATE); | 
|---|
| 6196 | } | 
|---|
| 6197 | } | 
|---|
| 6198 | break; | 
|---|
| 6199 |  | 
|---|
| 6200 | case MM_PORTHOLEINIT: | 
|---|
| 6201 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 6202 | case 0: | 
|---|
| 6203 | case 1: | 
|---|
| 6204 | { | 
|---|
| 6205 | HWND hwndCurrent; | 
|---|
| 6206 | ULONG wmsg; | 
|---|
| 6207 |  | 
|---|
| 6208 | wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU; | 
|---|
| 6209 | hwndCurrent = TopWindow(hwnd, (HWND) 0); | 
|---|
| 6210 | PortholeInit((HWND) WinSendMsg(WinWindowFromID(hwndCurrent, | 
|---|
| 6211 | FID_CLIENT), wmsg, | 
|---|
| 6212 | MPVOID, MPVOID), mp1, mp2); | 
|---|
| 6213 | } | 
|---|
| 6214 | break; | 
|---|
| 6215 | } | 
|---|
| 6216 | break; | 
|---|
| 6217 |  | 
|---|
| 6218 | case WM_INITMENU: | 
|---|
| 6219 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 6220 | case IDM_CONFIGMENU: | 
|---|
| 6221 | SetToggleChecks((HWND) WinQueryWindowULong(hwnd, QWL_USER)); | 
|---|
| 6222 | break; | 
|---|
| 6223 |  | 
|---|
| 6224 | case IDM_WINDOWSMENU: | 
|---|
| 6225 | /** | 
|---|
| 6226 | * add child windows of client | 
|---|
| 6227 | * and switchlist entries to end of pulldown menu | 
|---|
| 6228 | */ | 
|---|
| 6229 | { | 
|---|
| 6230 | HWND hwndMenu, hwndSubMenu; | 
|---|
| 6231 | MENUITEM mi; | 
|---|
| 6232 |  | 
|---|
| 6233 | hwndMenu = WinQueryWindowULong(hwnd, QWL_USER); | 
|---|
| 6234 | memset(&mi, 0, sizeof(mi)); | 
|---|
| 6235 | mi.iPosition = MIT_END; | 
|---|
| 6236 | mi.afStyle = MIS_TEXT; | 
|---|
| 6237 | if (!WinSendMsg(hwndMenu, MM_QUERYITEM, | 
|---|
| 6238 | MPFROM2SHORT(IDM_WINDOWSMENU, TRUE), MPFROMP(&mi))) | 
|---|
| 6239 | break; | 
|---|
| 6240 | hwndSubMenu = mi.hwndSubMenu; | 
|---|
| 6241 | SetupWinList(hwndSubMenu, hwnd, WinQueryWindow(hwnd, QW_PARENT)); | 
|---|
| 6242 | } | 
|---|
| 6243 | break; | 
|---|
| 6244 |  | 
|---|
| 6245 | default: | 
|---|
| 6246 | { | 
|---|
| 6247 | HWND hwndCurrent; | 
|---|
| 6248 |  | 
|---|
| 6249 | hwndCurrent = TopWindow(hwnd, (HWND) 0); | 
|---|
| 6250 | if (hwndCurrent) | 
|---|
| 6251 | WinSendMsg(hwndCurrent, UM_INITMENU, mp1, mp2); | 
|---|
| 6252 | } | 
|---|
| 6253 | break; | 
|---|
| 6254 | } | 
|---|
| 6255 | break; | 
|---|
| 6256 |  | 
|---|
| 6257 | case UM_ADDTOMENU: | 
|---|
| 6258 | AddToMenu(( | 
|---|
| 6259 | CHAR *)mp1, WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 6260 | FID_MENU)); | 
|---|
| 6261 | return 0; | 
|---|
| 6262 |  | 
|---|
| 6263 | case UM_FILLCMDLIST: | 
|---|
| 6264 | WinSendMsg(hwndCmdlist, LM_DELETEALL, MPVOID, MPVOID); | 
|---|
| 6265 | if (!cmdloaded) | 
|---|
| 6266 | load_commands(); | 
|---|
| 6267 | if (cmdhead) { | 
|---|
| 6268 |  | 
|---|
| 6269 | LINKCMDS *info; | 
|---|
| 6270 | CHAR s[120]; | 
|---|
| 6271 |  | 
|---|
| 6272 | info = cmdhead; | 
|---|
| 6273 | while (info) { | 
|---|
| 6274 | sprintf(s, "%s    {%i}", info->title, info->ID); | 
|---|
| 6275 | WinSendMsg(hwndCmdlist, LM_INSERTITEM, | 
|---|
| 6276 | MPFROM2SHORT(LIT_END, 0), MPFROMP(s)); | 
|---|
| 6277 | info = info->next; | 
|---|
| 6278 | } | 
|---|
| 6279 | } | 
|---|
| 6280 | return 0; | 
|---|
| 6281 |  | 
|---|
| 6282 | case UM_FILLSETUPLIST: | 
|---|
| 6283 | fill_setups_list(); | 
|---|
| 6284 | return 0; | 
|---|
| 6285 |  | 
|---|
| 6286 | case UM_FILLBUTTONLIST: | 
|---|
| 6287 | WinSendMsg(hwndButtonlist, LM_DELETEALL, MPVOID, MPVOID); | 
|---|
| 6288 | if (fUserComboBox) { | 
|---|
| 6289 |  | 
|---|
| 6290 | BOOL foundit = FALSE, thisone; | 
|---|
| 6291 | ULONG ulSearchCount; | 
|---|
| 6292 | SHORT sSelect; | 
|---|
| 6293 | FILEFINDBUF3 findbuf; | 
|---|
| 6294 | HDIR hDir; | 
|---|
| 6295 | CHAR *p; | 
|---|
| 6296 |  | 
|---|
| 6297 | DosError(FERR_DISABLEHARDERR); | 
|---|
| 6298 | hDir = HDIR_CREATE; | 
|---|
| 6299 | ulSearchCount = 1; | 
|---|
| 6300 | if (!DosFindFirst("*.TLS", &hDir, FILE_READONLY | FILE_ARCHIVED, | 
|---|
| 6301 | &findbuf, sizeof(FILEFINDBUF3), | 
|---|
| 6302 | &ulSearchCount, FIL_STANDARD)) { | 
|---|
| 6303 | do { | 
|---|
| 6304 | priority_bumped(); | 
|---|
| 6305 | if (!foundit) { | 
|---|
| 6306 | thisone = FALSE; | 
|---|
| 6307 | p = strrchr(lasttoolbar, '\\'); | 
|---|
| 6308 | if (!p) | 
|---|
| 6309 | p = lasttoolbar; | 
|---|
| 6310 | else | 
|---|
| 6311 | p++; | 
|---|
| 6312 | if (!stricmp(findbuf.achName, p)) | 
|---|
| 6313 | thisone = TRUE; | 
|---|
| 6314 | } | 
|---|
| 6315 | p = strrchr(findbuf.achName, '.'); | 
|---|
| 6316 | if (p) | 
|---|
| 6317 | *p = 0; | 
|---|
| 6318 | sSelect = (SHORT) WinSendMsg(hwndButtonlist, LM_INSERTITEM, | 
|---|
| 6319 | MPFROM2SHORT(LIT_SORTASCENDING, 0), | 
|---|
| 6320 | MPFROMP(findbuf.achName)); | 
|---|
| 6321 | if (!foundit && thisone && sSelect >= 0) { | 
|---|
| 6322 | WinSendMsg(hwndButtonlist, LM_SELECTITEM, | 
|---|
| 6323 | MPFROM2SHORT(sSelect, 0), MPFROMLONG(TRUE)); | 
|---|
| 6324 | foundit = TRUE; | 
|---|
| 6325 | } | 
|---|
| 6326 | } | 
|---|
| 6327 | while (!DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3), | 
|---|
| 6328 | &ulSearchCount)); | 
|---|
| 6329 | DosFindClose(hDir); | 
|---|
| 6330 | priority_bumped(); | 
|---|
| 6331 | } | 
|---|
| 6332 | WinSetWindowText(hwndButtonlist, (CHAR *) GetPString(IDS_TOOLBARTEXT)); | 
|---|
| 6333 | } | 
|---|
| 6334 | return 0; | 
|---|
| 6335 |  | 
|---|
| 6336 | case UM_FILLUSERLIST: | 
|---|
| 6337 | WinSendMsg(hwndUserlist, LM_DELETEALL, MPVOID, MPVOID); | 
|---|
| 6338 | if (fUserComboBox) { | 
|---|
| 6339 | ULONG ulDriveNum; | 
|---|
| 6340 | ULONG ulDriveMap; | 
|---|
| 6341 | ULONG ulSearchCount; | 
|---|
| 6342 | FILEFINDBUF3 findbuf; | 
|---|
| 6343 | HDIR hDir; | 
|---|
| 6344 | APIRET rc; | 
|---|
| 6345 | LINKDIRS *info; | 
|---|
| 6346 | LINKDIRS *temp; | 
|---|
| 6347 |  | 
|---|
| 6348 | if (!loadedudirs) | 
|---|
| 6349 | load_udirs(); | 
|---|
| 6350 | DosError(FERR_DISABLEHARDERR); | 
|---|
| 6351 | DosQCurDisk(&ulDriveNum, &ulDriveMap); | 
|---|
| 6352 | info = udirhead; | 
|---|
| 6353 | while (info) { | 
|---|
| 6354 | if (IsFullName(info->path) && | 
|---|
| 6355 | !(driveflags[toupper(*info->path) - 'A'] & | 
|---|
| 6356 | (DRIVE_IGNORE | DRIVE_INVALID))) { | 
|---|
| 6357 | DosError(FERR_DISABLEHARDERR); | 
|---|
| 6358 | hDir = HDIR_CREATE; | 
|---|
| 6359 | ulSearchCount = 1; | 
|---|
| 6360 | if (!IsRoot(info->path)) | 
|---|
| 6361 | rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY | | 
|---|
| 6362 | MUST_HAVE_DIRECTORY | FILE_READONLY | | 
|---|
| 6363 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN, | 
|---|
| 6364 | &findbuf, sizeof(FILEFINDBUF3), | 
|---|
| 6365 | &ulSearchCount, FIL_STANDARD); | 
|---|
| 6366 | else { | 
|---|
| 6367 | rc = 0; | 
|---|
| 6368 | findbuf.attrFile = FILE_DIRECTORY; | 
|---|
| 6369 | } | 
|---|
| 6370 | priority_bumped(); | 
|---|
| 6371 | if (!rc) { | 
|---|
| 6372 | if (!IsRoot(info->path)) | 
|---|
| 6373 | DosFindClose(hDir); | 
|---|
| 6374 | if (findbuf.attrFile & FILE_DIRECTORY) | 
|---|
| 6375 | WinSendMsg(hwndUserlist, LM_INSERTITEM, | 
|---|
| 6376 | MPFROM2SHORT(LIT_SORTASCENDING, 0), | 
|---|
| 6377 | MPFROMP(info->path)); | 
|---|
| 6378 | else { | 
|---|
| 6379 | temp = info->next; | 
|---|
| 6380 | remove_udir(info->path); | 
|---|
| 6381 | info = temp; | 
|---|
| 6382 | continue; | 
|---|
| 6383 | } | 
|---|
| 6384 | } | 
|---|
| 6385 | else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) { | 
|---|
| 6386 | temp = info->next; | 
|---|
| 6387 | remove_udir(info->path); | 
|---|
| 6388 | info = temp; | 
|---|
| 6389 | continue; | 
|---|
| 6390 | } | 
|---|
| 6391 | } | 
|---|
| 6392 | info = info->next; | 
|---|
| 6393 | } | 
|---|
| 6394 | info = ldirhead; | 
|---|
| 6395 | while (info) { | 
|---|
| 6396 | if (IsFullName(info->path) && | 
|---|
| 6397 | !(driveflags[toupper(*info->path) - 'A'] & | 
|---|
| 6398 | (DRIVE_IGNORE | DRIVE_INVALID))) { | 
|---|
| 6399 | DosError(FERR_DISABLEHARDERR); | 
|---|
| 6400 | hDir = HDIR_CREATE; | 
|---|
| 6401 | ulSearchCount = 1; | 
|---|
| 6402 | if (!IsRoot(info->path)) | 
|---|
| 6403 | rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY | | 
|---|
| 6404 | MUST_HAVE_DIRECTORY | FILE_READONLY | | 
|---|
| 6405 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN, | 
|---|
| 6406 | &findbuf, sizeof(FILEFINDBUF3), | 
|---|
| 6407 | &ulSearchCount, FIL_STANDARD); | 
|---|
| 6408 | else { | 
|---|
| 6409 | rc = 0; | 
|---|
| 6410 | findbuf.attrFile = FILE_DIRECTORY; | 
|---|
| 6411 | } | 
|---|
| 6412 | priority_bumped(); | 
|---|
| 6413 | if (!rc) { | 
|---|
| 6414 | if (!IsRoot(info->path)) | 
|---|
| 6415 | DosFindClose(hDir); | 
|---|
| 6416 | if (findbuf.attrFile & FILE_DIRECTORY) | 
|---|
| 6417 | WinSendMsg(hwndUserlist, LM_INSERTITEM, | 
|---|
| 6418 | MPFROM2SHORT(LIT_SORTASCENDING, 0), | 
|---|
| 6419 | MPFROMP(info->path)); | 
|---|
| 6420 | else { | 
|---|
| 6421 | temp = info->next; | 
|---|
| 6422 | remove_udir(info->path); | 
|---|
| 6423 | info = temp; | 
|---|
| 6424 | continue; | 
|---|
| 6425 | } | 
|---|
| 6426 | } | 
|---|
| 6427 | else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) { | 
|---|
| 6428 | temp = info->next; | 
|---|
| 6429 | remove_udir(info->path); | 
|---|
| 6430 | info = temp; | 
|---|
| 6431 | continue; | 
|---|
| 6432 | } | 
|---|
| 6433 | } | 
|---|
| 6434 | info = info->next; | 
|---|
| 6435 | } | 
|---|
| 6436 | WinSendMsg(hwndUserlist, LM_INSERTITEM, | 
|---|
| 6437 | MPFROM2SHORT(0, 0), | 
|---|
| 6438 | MPFROMP(GetPString(IDS_NEWDIRECTORYTEXT))); | 
|---|
| 6439 | WinSetWindowText(hwndUserlist, (CHAR *) GetPString(IDS_COMMONDIRTEXT)); | 
|---|
| 6440 | } | 
|---|
| 6441 | return 0; | 
|---|
| 6442 |  | 
|---|
| 6443 | case UM_SIZE: | 
|---|
| 6444 | if (fAutoTile) | 
|---|
| 6445 | TileChildren(hwnd, FALSE); | 
|---|
| 6446 | else | 
|---|
| 6447 | MoveChildrenAwayFromTree(hwnd); | 
|---|
| 6448 | return 0; | 
|---|
| 6449 |  | 
|---|
| 6450 | case WM_SIZE: | 
|---|
| 6451 | ResizeChildren(hwnd, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1), | 
|---|
| 6452 | SHORT1FROMMP(mp2), SHORT2FROMMP(mp2)); | 
|---|
| 6453 | break; | 
|---|
| 6454 |  | 
|---|
| 6455 | case WM_ERASEBACKGROUND: | 
|---|
| 6456 | WinFillRect((HPS) mp1, (PRECTL) mp2, 0x00d0d0d0); | 
|---|
| 6457 | return 0; | 
|---|
| 6458 |  | 
|---|
| 6459 | case WM_PAINT: | 
|---|
| 6460 | { | 
|---|
| 6461 | HPS hps; | 
|---|
| 6462 | RECTL rcl; | 
|---|
| 6463 |  | 
|---|
| 6464 | hps = WinBeginPaint(hwnd, (HPS) 0, NULL); | 
|---|
| 6465 | if (hps) { | 
|---|
| 6466 | WinQueryWindowRect(hwnd, &rcl); | 
|---|
| 6467 | WinFillRect(hps, &rcl, CLR_PALEGRAY); | 
|---|
| 6468 | WinEndPaint(hps); | 
|---|
| 6469 | } | 
|---|
| 6470 | } | 
|---|
| 6471 | break; | 
|---|
| 6472 |  | 
|---|
| 6473 | case UM_CONTROL: | 
|---|
| 6474 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 6475 | case MAIN_CMDLIST: | 
|---|
| 6476 | case MAIN_SETUPLIST: | 
|---|
| 6477 | case MAIN_DRIVELIST: | 
|---|
| 6478 | case MAIN_USERLIST: | 
|---|
| 6479 | case MAIN_BUTTONLIST: | 
|---|
| 6480 | switch (SHORT2FROMMP(mp1)) { | 
|---|
| 6481 | case CBN_ENTER: | 
|---|
| 6482 | { | 
|---|
| 6483 | HWND hwndUL = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 6484 | SHORT1FROMMP(mp1)); | 
|---|
| 6485 | CHAR path[CCHMAXPATH]; | 
|---|
| 6486 | ULONG ul; | 
|---|
| 6487 |  | 
|---|
| 6488 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 6489 | case MAIN_USERLIST: | 
|---|
| 6490 | ul = CCHMAXPATH; | 
|---|
| 6491 | break; | 
|---|
| 6492 | case MAIN_SETUPLIST: | 
|---|
| 6493 | ul = STATE_NAME_MAX_BYTES; | 
|---|
| 6494 | break; | 
|---|
| 6495 | default: | 
|---|
| 6496 | ul = 13;                    // fixme to not be hardcoded | 
|---|
| 6497 | } | 
|---|
| 6498 |  | 
|---|
| 6499 | SetShiftState(); | 
|---|
| 6500 | WinQueryWindowText(WinWindowFromID(hwndUL, CBID_EDIT), ul, path); | 
|---|
| 6501 | bstrip(path); | 
|---|
| 6502 | if (*path) { | 
|---|
| 6503 | if (SHORT1FROMMP(mp1) == MAIN_USERLIST) { | 
|---|
| 6504 | // 06 Oct 09 SHL Ctrl-select selects, but suppresses open | 
|---|
| 6505 | if ((shiftstate & (KC_CTRL | KC_SHIFT | KC_ALT)) == KC_CTRL) | 
|---|
| 6506 | break; | 
|---|
| 6507 | if (!strcmp(path, GetPString(IDS_NEWDIRECTORYTEXT))) { | 
|---|
| 6508 | if (!LastDir || | 
|---|
| 6509 | !WinSendMsg(WinQueryWindow(LastDir, QW_PARENT), | 
|---|
| 6510 | UM_CONTAINERDIR, MPFROMP(path), MPVOID)) | 
|---|
| 6511 | strcpy(path, pFM2SaveDirectory); | 
|---|
| 6512 | if (!PMMkDir(hwnd, path, TRUE)) { | 
|---|
| 6513 | WinSetWindowText(hwndUL, (CHAR *) GetPString(IDS_COMMONDIRTEXT)); | 
|---|
| 6514 | break; | 
|---|
| 6515 | } | 
|---|
| 6516 | } | 
|---|
| 6517 | if (!IsFile(path) && !FindDirCnrByName(path, TRUE)) { | 
|---|
| 6518 |  | 
|---|
| 6519 | HWND hwndDir; | 
|---|
| 6520 |  | 
|---|
| 6521 | if ((fUserListSwitches && | 
|---|
| 6522 | !(shiftstate & KC_SHIFT)) || | 
|---|
| 6523 | (!fUserListSwitches && (shiftstate & KC_SHIFT))) { | 
|---|
| 6524 | hwndDir = FindDirCnr(hwnd); | 
|---|
| 6525 | if (hwndDir) { | 
|---|
| 6526 | WinSendMsg(LastDir, UM_SETDIR, MPFROMP(path), MPVOID); | 
|---|
| 6527 | break; | 
|---|
| 6528 | } | 
|---|
| 6529 | } | 
|---|
| 6530 | OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, path); | 
|---|
| 6531 | } | 
|---|
| 6532 | } | 
|---|
| 6533 | else if (SHORT1FROMMP(mp1) == MAIN_DRIVELIST) { | 
|---|
| 6534 | ShowTreeRec(WinWindowFromID(WinWindowFromID(hwndTree, | 
|---|
| 6535 | FID_CLIENT), | 
|---|
| 6536 | TREE_CNR), path, FALSE, TRUE); | 
|---|
| 6537 | WinSetFocus(HWND_DESKTOP, hwndTree); | 
|---|
| 6538 | } | 
|---|
| 6539 | else if (SHORT1FROMMP(mp1) == MAIN_BUTTONLIST) { | 
|---|
| 6540 | strcat(path, PCSZ_DOTTLS); | 
|---|
| 6541 | load_tools(path); | 
|---|
| 6542 | PrfWriteProfileString(fmprof, | 
|---|
| 6543 | FM3Str, "LastToolbar", lasttoolbar); | 
|---|
| 6544 | PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID); | 
|---|
| 6545 | WinSetWindowText(hwndButtonlist, (CHAR *) GetPString(IDS_TOOLBARTEXT)); | 
|---|
| 6546 | } | 
|---|
| 6547 | else if (SHORT1FROMMP(mp1) == MAIN_SETUPLIST) { | 
|---|
| 6548 | CHAR szKey[80]; | 
|---|
| 6549 | ULONG numsaves = 0; | 
|---|
| 6550 | ULONG size = sizeof(ULONG); | 
|---|
| 6551 | // 06 Oct 09 SHL Ctrl-select selects, but suppresses open | 
|---|
| 6552 | if ((shiftstate & (KC_CTRL | KC_SHIFT | KC_ALT)) == KC_CTRL) | 
|---|
| 6553 | break; | 
|---|
| 6554 | sprintf(szKey, "%s.NumDirsLastTime", path);       // path is state name | 
|---|
| 6555 | if (!PrfQueryProfileData(fmprof, | 
|---|
| 6556 | FM3Str, | 
|---|
| 6557 | szKey, | 
|---|
| 6558 | (PVOID)&numsaves, | 
|---|
| 6559 | &size)) | 
|---|
| 6560 | { | 
|---|
| 6561 | if ((WinGetLastError(WinQueryAnchorBlock(hwnd)) & 0xffff) == PMERR_NOT_IN_IDX) { | 
|---|
| 6562 | saymsg(MB_ENTER | MB_ICONASTERISK, hwnd, | 
|---|
| 6563 | GetPString(IDS_WARNINGTEXT), | 
|---|
| 6564 | GetPString(IDS_DOESNTEXISTTEXT), path); | 
|---|
| 6565 | } | 
|---|
| 6566 | else { | 
|---|
| 6567 | Win_Error(hwnd, hwnd, __FILE__, __LINE__, | 
|---|
| 6568 | PCSZ_INIQUERYPRFTEXT); | 
|---|
| 6569 | } | 
|---|
| 6570 | } | 
|---|
| 6571 | else { | 
|---|
| 6572 | char *pszStateName; | 
|---|
| 6573 | if ((shiftstate & KC_SHIFT) == 0) | 
|---|
| 6574 | PostMsg(MainObjectHwnd, UM_RESTORE, MPVOID, MPFROMLONG(2)); | 
|---|
| 6575 | pszStateName = xstrdup(path, pszSrcFile, __LINE__); | 
|---|
| 6576 | if (!pszStateName) { | 
|---|
| 6577 | // Fall back if out of memory - already complained | 
|---|
| 6578 | if ((shiftstate & KC_SHIFT) != 0 || fAutoTile) { | 
|---|
| 6579 | // Autotile requested or forced | 
|---|
| 6580 | PostMsg(MainObjectHwnd, | 
|---|
| 6581 | UM_RESTORE, | 
|---|
| 6582 | MPVOID, | 
|---|
| 6583 | MPFROMLONG(1));                // Autotile | 
|---|
| 6584 | } | 
|---|
| 6585 | } | 
|---|
| 6586 | else if (!PostMsg(MainObjectHwnd, | 
|---|
| 6587 | UM_RESTORE, | 
|---|
| 6588 | MPFROMP(pszStateName), | 
|---|
| 6589 | MPVOID)) { | 
|---|
| 6590 | free(pszStateName); | 
|---|
| 6591 | } | 
|---|
| 6592 | } | 
|---|
| 6593 | } | 
|---|
| 6594 | else if (SHORT1FROMMP(mp1) == MAIN_CMDLIST) { | 
|---|
| 6595 |  | 
|---|
| 6596 | SHORT sSelect = (SHORT) WinSendMsg(hwndCmdlist, | 
|---|
| 6597 | LM_QUERYSELECTION, | 
|---|
| 6598 | MPFROMSHORT(LIT_FIRST), MPVOID); | 
|---|
| 6599 | if (sSelect >= 0) { | 
|---|
| 6600 | CHAR s[CCHMAXPATH]; | 
|---|
| 6601 | CHAR *p; | 
|---|
| 6602 |  | 
|---|
| 6603 | WinSendMsg(hwndCmdlist, LM_QUERYITEMTEXT, | 
|---|
| 6604 | MPFROM2SHORT(sSelect, CCHMAXPATH), MPFROMP(s)); | 
|---|
| 6605 | p = strrchr(s, '}'); | 
|---|
| 6606 | p = 0; | 
|---|
| 6607 | p = strrchr(s, '{'); | 
|---|
| 6608 | p++; | 
|---|
| 6609 | WinPostMsg(hwnd, | 
|---|
| 6610 | WM_COMMAND, | 
|---|
| 6611 | MPFROM2SHORT(atol(p), 0), //fixme GKY this traps in atol the {} probably don't exist | 
|---|
| 6612 | //IDM_COMMANDSTART + sSelect, 0), | 
|---|
| 6613 | MPVOID); | 
|---|
| 6614 | } | 
|---|
| 6615 | WinSetWindowText(hwndCmdlist, (CHAR *) GetPString(IDS_COMMANDSTEXT)); | 
|---|
| 6616 | } | 
|---|
| 6617 | } | 
|---|
| 6618 | } // CBN_ENTER | 
|---|
| 6619 | break; | 
|---|
| 6620 |  | 
|---|
| 6621 | default: | 
|---|
| 6622 | break; | 
|---|
| 6623 | } | 
|---|
| 6624 | break; | 
|---|
| 6625 |  | 
|---|
| 6626 | default: | 
|---|
| 6627 | break; | 
|---|
| 6628 | } | 
|---|
| 6629 | return 0; | 
|---|
| 6630 |  | 
|---|
| 6631 | case WM_HELP: | 
|---|
| 6632 | if (hwndHelp) | 
|---|
| 6633 | PostMsg(hwndHelp, HM_DISPLAY_HELP, MPFROMSHORT(1), MPFROMSHORT(HM_RESOURCEID)); | 
|---|
| 6634 | break; | 
|---|
| 6635 |  | 
|---|
| 6636 | case UM_COMMAND: | 
|---|
| 6637 | case WM_COMMAND: | 
|---|
| 6638 |  | 
|---|
| 6639 | return MainWMCommand(hwnd, msg, mp1, mp2); | 
|---|
| 6640 |  | 
|---|
| 6641 | case WM_CLOSE: | 
|---|
| 6642 | WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 6643 | WM_SYSCOMMAND, MPFROM2SHORT(SC_RESTORE, 0), MPVOID); | 
|---|
| 6644 | WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID); | 
|---|
| 6645 | fAmClosing = TRUE; | 
|---|
| 6646 | WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 6647 | WM_SYSCOMMAND, MPFROM2SHORT(SC_MINIMIZE, 0), MPVOID); | 
|---|
| 6648 | if (CloseChildren(hwnd)) { | 
|---|
| 6649 | fAmClosing = FALSE; | 
|---|
| 6650 | if (fAutoTile) | 
|---|
| 6651 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TILE, 0), MPVOID); | 
|---|
| 6652 | return 0; | 
|---|
| 6653 | } | 
|---|
| 6654 | if (hwndTree) { | 
|---|
| 6655 | if (!PostMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID)) | 
|---|
| 6656 | WinSendMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID); | 
|---|
| 6657 | } | 
|---|
| 6658 | DosSleep(1); | 
|---|
| 6659 | return 0;           // Suppress WinDefWindowProc WM_QUIT message generation | 
|---|
| 6660 |  | 
|---|
| 6661 | case UM_CLOSE: | 
|---|
| 6662 | HideNote(); | 
|---|
| 6663 | WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT)); | 
|---|
| 6664 | return 0; | 
|---|
| 6665 |  | 
|---|
| 6666 | case UM_RESTORE: | 
|---|
| 6667 | { | 
|---|
| 6668 | // Try to restore saved shutdown state | 
|---|
| 6669 | char *pszDefaultStateName = xstrdup(PCSZ_SHUTDOWNSTATE, pszSrcFile, __LINE__); | 
|---|
| 6670 | if (pszDefaultStateName) { | 
|---|
| 6671 | if (!PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMP(pszDefaultStateName), MPVOID)) | 
|---|
| 6672 | // 05 Feb 08 SHL fixme to complain? | 
|---|
| 6673 | free(pszDefaultStateName); | 
|---|
| 6674 | } | 
|---|
| 6675 | } | 
|---|
| 6676 | return 0; | 
|---|
| 6677 |  | 
|---|
| 6678 | case UM_SETDIR: | 
|---|
| 6679 | // mp1 == name of directory to open | 
|---|
| 6680 | if (mp1) | 
|---|
| 6681 | return MRFROMLONG(OpenDirCnr((HWND) 0, | 
|---|
| 6682 | hwndMain, | 
|---|
| 6683 | hwndTree, (BOOL) mp2, (char *)mp1)); | 
|---|
| 6684 | return 0; | 
|---|
| 6685 |  | 
|---|
| 6686 | case WM_DESTROY: | 
|---|
| 6687 | #   ifdef FORTIFY | 
|---|
| 6688 | DbgMsg(pszSrcFile, __LINE__, "WM_DESTROY hwnd %p TID %u", hwnd, GetTidForThread()); // 22 Jul 08 SHL fixme | 
|---|
| 6689 | #   endif | 
|---|
| 6690 | hwndMain = (HWND) 0; | 
|---|
| 6691 | if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID)) | 
|---|
| 6692 | WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID); | 
|---|
| 6693 | #   ifdef FORTIFY | 
|---|
| 6694 | free_commands(); | 
|---|
| 6695 | free_associations(); | 
|---|
| 6696 | free_udirs(); | 
|---|
| 6697 | free_ldir(); | 
|---|
| 6698 | free_archivers(); | 
|---|
| 6699 | free_tools(); | 
|---|
| 6700 | free_setups(); | 
|---|
| 6701 | Fortify_LeaveScope(); | 
|---|
| 6702 | #   endif | 
|---|
| 6703 | break; | 
|---|
| 6704 | } | 
|---|
| 6705 | return WinDefWindowProc(hwnd, msg, mp1, mp2); | 
|---|
| 6706 | } | 
|---|
| 6707 |  | 
|---|
| 6708 | #pragma alloc_text(MISC8,SetToggleChecks,FindDirCnrByName,TopWindow) | 
|---|
| 6709 | #pragma alloc_text(MISC8,TopWindowName,CountDirCnrs) | 
|---|
| 6710 | #pragma alloc_text(MAINWND,AdjustSizeOfClient,FillClient,ChildButtonProc) | 
|---|
| 6711 | #pragma alloc_text(MAINWND,ToolBackProc,StatusProc) | 
|---|
| 6712 | #pragma alloc_text(MAINWND,MoveChildrenAwayFromTree,ArrangeIcons,NextChild) | 
|---|
| 6713 | #pragma alloc_text(MAINWND,ChildFrameButtonProc) | 
|---|
| 6714 | #pragma alloc_text(MAINWND2,CloseChildren,CountChildren,GetNextWindowPos) | 
|---|
| 6715 | #pragma alloc_text(MAINWND2,CascadeChildren,TileChildren,ResizeChildren) | 
|---|
| 6716 | #pragma alloc_text(MAINWND2,MinResChildren,MainFrameWndProc,MainWndProc) | 
|---|
| 6717 | #pragma alloc_text(MAINWND2,DropDownListProc) | 
|---|
| 6718 | #pragma alloc_text(MAINWND3,RestoreDirCnrState,SaveDirCnrState) | 
|---|
| 6719 | #pragma alloc_text(MAINWND3,CloseDirCnrChildren,TransformSwp) | 
|---|
| 6720 | #pragma alloc_text(MAINWND3,ResizeTools,BuildTools,CommandLineProc) | 
|---|
| 6721 | #pragma alloc_text(MAINWND4,DriveProc,DriveBackProc,BuildDriveBarButtons,ResizeDrives) | 
|---|
| 6722 | #pragma alloc_text(MAINWND4,LEDProc,IdealButtonProc) | 
|---|
| 6723 | #pragma alloc_text(MAINWND5,MainWMOnce) | 
|---|
| 6724 | #pragma alloc_text(MAINWND6,MainWMCommand) | 
|---|
| 6725 | #pragma alloc_text(BUBBLE,MakeBubble,BubbleProc,BubbleHelp) | 
|---|
| 6726 | #pragma alloc_text(MAINOBJ,MainObjectWndProc,MakeMainObjWin) | 
|---|
| 6727 |  | 
|---|