1 |
|
---|
2 | /*
|
---|
3 | *@@sourcefile desktop.c:
|
---|
4 | * XFldDesktop implementation code. Note that more
|
---|
5 | * Desktop-related code resides in filesys\archives.c
|
---|
6 | * and filesys\shutdown.c.
|
---|
7 | *
|
---|
8 | * This file is ALL new with V0.9.0.
|
---|
9 | *
|
---|
10 | * Function prefix for this file:
|
---|
11 | * -- dtp*
|
---|
12 | *
|
---|
13 | *@@added V0.9.0 [umoeller]
|
---|
14 | *@@header "filesys\desktop.h"
|
---|
15 | */
|
---|
16 |
|
---|
17 | /*
|
---|
18 | * Copyright (C) 1997-2014 Ulrich Mller.
|
---|
19 | * This file is part of the XWorkplace source package.
|
---|
20 | * XWorkplace is free software; you can redistribute it and/or modify
|
---|
21 | * it under the terms of the GNU General Public License as published
|
---|
22 | * by the Free Software Foundation, in version 2 as it comes in the
|
---|
23 | * "COPYING" file of the XWorkplace main distribution.
|
---|
24 | * This program is distributed in the hope that it will be useful,
|
---|
25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
27 | * GNU General Public License for more details.
|
---|
28 | */
|
---|
29 |
|
---|
30 | #pragma strings(readonly)
|
---|
31 |
|
---|
32 | /*
|
---|
33 | * Suggested #include order:
|
---|
34 | * 1) os2.h
|
---|
35 | * 2) C library headers
|
---|
36 | * 3) setup.h (code generation and debugging options)
|
---|
37 | * 4) headers in helpers\
|
---|
38 | * 5) at least one SOM implementation header (*.ih)
|
---|
39 | * 6) dlgids.h, headers in shared\ (as needed)
|
---|
40 | * 7) headers in implementation dirs (e.g. filesys\, as needed)
|
---|
41 | * 8) #pragma hdrstop and then more SOM headers which crash with precompiled headers
|
---|
42 | */
|
---|
43 |
|
---|
44 | #define INCL_DOSPROCESS
|
---|
45 | #define INCL_DOSSEMAPHORES
|
---|
46 | #define INCL_DOSEXCEPTIONS
|
---|
47 | #define INCL_DOSERRORS
|
---|
48 | #define INCL_DOSMISC
|
---|
49 |
|
---|
50 | #define INCL_WINWINDOWMGR
|
---|
51 | #define INCL_WINFRAMEMGR
|
---|
52 | #define INCL_WINPOINTERS
|
---|
53 | #define INCL_WINMENUS
|
---|
54 | #define INCL_WINDIALOGS
|
---|
55 | #define INCL_WINSTATICS
|
---|
56 | #define INCL_WINBUTTONS
|
---|
57 | #define INCL_WINENTRYFIELDS
|
---|
58 | #define INCL_WINLISTBOXES
|
---|
59 | #define INCL_WINSTDCNR
|
---|
60 | #define INCL_WINSTDSPIN
|
---|
61 | #define INCL_WINSHELLDATA // Prf* functions
|
---|
62 | #define INCL_WINSTDFILE
|
---|
63 | #define INCL_WINSYS
|
---|
64 |
|
---|
65 | #define INCL_GPIBITMAPS
|
---|
66 | #include <os2.h>
|
---|
67 |
|
---|
68 | // C library headers
|
---|
69 | #include <stdio.h>
|
---|
70 | #include <io.h>
|
---|
71 | #include <math.h>
|
---|
72 |
|
---|
73 | // generic headers
|
---|
74 | #include "setup.h" // code generation and debugging options
|
---|
75 |
|
---|
76 | // headers in /helpers
|
---|
77 | #include "helpers\animate.h" // icon and other animations
|
---|
78 | #include "helpers\comctl.h" // common controls (window procs)
|
---|
79 | #include "helpers\dialog.h" // dialog helpers
|
---|
80 | #include "helpers\gpih.h" // GPI helper routines
|
---|
81 | #include "helpers\nls.h" // National Language Support helpers
|
---|
82 | #include "helpers\prfh.h" // INI file helper routines
|
---|
83 | #include "helpers\shapewin.h" // shaped windows helper functions
|
---|
84 | #include "helpers\standards.h" // some standard macros
|
---|
85 | #include "helpers\stringh.h" // string helper routines
|
---|
86 | #include "helpers\syssound.h" // system sound helper routines
|
---|
87 | #include "helpers\threads.h" // thread helpers
|
---|
88 | #include "helpers\winh.h" // PM helper routines
|
---|
89 | #include "helpers\wphandle.h" // file-system object handles
|
---|
90 |
|
---|
91 | // SOM headers which don't crash with prec. header files
|
---|
92 | #include "xfdesk.ih"
|
---|
93 |
|
---|
94 | // XWorkplace implementation headers
|
---|
95 | #include "dlgids.h" // all the IDs that are shared with NLS
|
---|
96 | #include "shared\common.h" // the majestic XWorkplace include file
|
---|
97 | #include "shared\kernel.h" // XWorkplace Kernel
|
---|
98 | #include "shared\notebook.h" // generic XWorkplace notebook handling
|
---|
99 |
|
---|
100 | #include "filesys\desktop.h" // XFldDesktop implementation
|
---|
101 | #include "filesys\fdrmenus.h" // shared folder menu logic
|
---|
102 | #include "filesys\xthreads.h" // extra XWorkplace threads
|
---|
103 |
|
---|
104 | #include "startshut\shutdown.h" // XWorkplace eXtended Shutdown
|
---|
105 |
|
---|
106 | // other SOM headers
|
---|
107 | #pragma hdrstop
|
---|
108 |
|
---|
109 | /* ******************************************************************
|
---|
110 | *
|
---|
111 | * Query setup strings
|
---|
112 | *
|
---|
113 | ********************************************************************/
|
---|
114 |
|
---|
115 | /*
|
---|
116 | *@@ dtpSetup:
|
---|
117 | * implementation of XFldDesktop::wpSetup.
|
---|
118 | *
|
---|
119 | * This parses the XSHUTDOWNNOW setup string to
|
---|
120 | * start XShutdown now, if needed.
|
---|
121 | *
|
---|
122 | *@@added V0.9.7 (2001-01-25) [umoeller]
|
---|
123 | *@@changed V0.9.14 (2001-07-28) [umoeller]: added SHOWRUNDLG
|
---|
124 | *@@changed V0.9.20 (2002-07-03) [umoeller]: added POSTSHUTDOWN
|
---|
125 | *@@changed V0.9.20 (2002-07-12) [umoeller]: added SHOWHELPPANEL
|
---|
126 | */
|
---|
127 |
|
---|
128 | BOOL dtpSetup(WPDesktop *somSelf,
|
---|
129 | PCSZ pcszSetupString)
|
---|
130 | {
|
---|
131 | BOOL brc = TRUE;
|
---|
132 |
|
---|
133 | CHAR szValue[500];
|
---|
134 | ULONG cbValue = sizeof(szValue);
|
---|
135 | if (_wpScanSetupString(somSelf,
|
---|
136 | (PSZ)pcszSetupString,
|
---|
137 | "XSHUTDOWNNOW",
|
---|
138 | szValue,
|
---|
139 | &cbValue))
|
---|
140 | {
|
---|
141 | // XSHUTDOWNNOW setup string present:
|
---|
142 | // well, start shutdown now.
|
---|
143 | // This is a bit tricky, because we want to support
|
---|
144 | // overriding the default shutdown settings for this
|
---|
145 | // one time... as a result, we fill a SHUTDOWNPARAMS
|
---|
146 | // structure with the current settings and override
|
---|
147 | // them when parsing szValue now.
|
---|
148 |
|
---|
149 | SHUTDOWNPARAMS xsd;
|
---|
150 | PSZ pszToken;
|
---|
151 | xsdQueryShutdownSettings(&xsd);
|
---|
152 |
|
---|
153 | // convert params to upper case
|
---|
154 | nlsUpper(szValue);
|
---|
155 |
|
---|
156 | pszToken = strtok(szValue, ", ");
|
---|
157 | if (pszToken)
|
---|
158 | do
|
---|
159 | {
|
---|
160 | if (!strcmp(pszToken, "HALT"))
|
---|
161 | {
|
---|
162 | // xsd.ulRestartWPS = 0; // shutdown
|
---|
163 | xsd.ulCloseMode = SHUT_SHUTDOWN;
|
---|
164 | xsd.optReboot = FALSE;
|
---|
165 | xsd.optPowerOff = FALSE; // V1.0.5 (2006-06-26) [pr]
|
---|
166 | }
|
---|
167 | else if (!strcmp(pszToken, "REBOOT"))
|
---|
168 | {
|
---|
169 | // xsd.ulRestartWPS = 0; // shutdown
|
---|
170 | xsd.ulCloseMode = SHUT_SHUTDOWN;
|
---|
171 | xsd.optReboot = TRUE;
|
---|
172 | xsd.optPowerOff = FALSE; // V1.0.5 (2006-06-26) [pr]
|
---|
173 | }
|
---|
174 | else if (!strncmp(pszToken, "USERREBOOT(", 11))
|
---|
175 | {
|
---|
176 | PSZ p = strchr(pszToken, ')');
|
---|
177 | if (p)
|
---|
178 | {
|
---|
179 | PSZ pszCmd = strhSubstr(pszToken + 11,
|
---|
180 | p);
|
---|
181 | if (pszCmd)
|
---|
182 | {
|
---|
183 | strhncpy0(xsd.szRebootCommand,
|
---|
184 | pszCmd,
|
---|
185 | sizeof(xsd.szRebootCommand));
|
---|
186 | free(pszCmd);
|
---|
187 | }
|
---|
188 | }
|
---|
189 | // xsd.ulRestartWPS = 0; // shutdown
|
---|
190 | xsd.ulCloseMode = SHUT_SHUTDOWN;
|
---|
191 | xsd.optReboot = TRUE;
|
---|
192 | xsd.optPowerOff = FALSE; // V1.0.5 (2006-06-26) [pr]
|
---|
193 | }
|
---|
194 | else if (!strcmp(pszToken, "POWEROFF"))
|
---|
195 | {
|
---|
196 | // xsd.ulRestartWPS = 0; // shutdown
|
---|
197 | xsd.ulCloseMode = SHUT_SHUTDOWN;
|
---|
198 | xsd.optReboot = FALSE;
|
---|
199 | xsd.optPowerOff = TRUE; // V1.0.5 (2006-06-26) [pr]
|
---|
200 | }
|
---|
201 | else if (!strcmp(pszToken, "RESTARTWPS"))
|
---|
202 | {
|
---|
203 | // xsd.ulRestartWPS = 1; // restart Desktop
|
---|
204 | xsd.ulCloseMode = SHUT_RESTARTWPS;
|
---|
205 | xsd.optWPSCloseWindows = FALSE;
|
---|
206 | xsd.optWPSReuseStartupFolder = FALSE;
|
---|
207 | }
|
---|
208 | else if (!strcmp(pszToken, "FULLRESTARTWPS"))
|
---|
209 | {
|
---|
210 | // xsd.ulRestartWPS = 1; // restart Desktop
|
---|
211 | xsd.ulCloseMode = SHUT_RESTARTWPS;
|
---|
212 | xsd.optWPSCloseWindows = TRUE;
|
---|
213 | xsd.optWPSReuseStartupFolder = TRUE;
|
---|
214 | }
|
---|
215 | else if (!strcmp(pszToken, "NOAUTOCLOSEVIO"))
|
---|
216 | xsd.optAutoCloseVIO = FALSE;
|
---|
217 | else if (!strcmp(pszToken, "AUTOCLOSEVIO"))
|
---|
218 | xsd.optAutoCloseVIO = TRUE;
|
---|
219 | else if (!strcmp(pszToken, "NOLOG"))
|
---|
220 | xsd.optLog = FALSE;
|
---|
221 | else if (!strcmp(pszToken, "LOG"))
|
---|
222 | xsd.optLog = TRUE;
|
---|
223 | /* else if (!strcmp(pszToken, "NOANIMATE"))
|
---|
224 | xsd.optAnimate = FALSE;
|
---|
225 | else if (!strcmp(pszToken, "ANIMATE"))
|
---|
226 | xsd.optAnimate = TRUE; */
|
---|
227 | else if (!strcmp(pszToken, "NOCONFIRM"))
|
---|
228 | {
|
---|
229 | xsd.optConfirmShut = FALSE;
|
---|
230 | xsd.optConfirmWPS = FALSE;
|
---|
231 | }
|
---|
232 | else if (!strcmp(pszToken, "CONFIRM"))
|
---|
233 | {
|
---|
234 | xsd.optConfirmShut = TRUE;
|
---|
235 | xsd.optConfirmWPS = TRUE;
|
---|
236 | }
|
---|
237 |
|
---|
238 | } while (pszToken = strtok(NULL, ", "));
|
---|
239 |
|
---|
240 | brc = xsdInitiateShutdownExt(&xsd);
|
---|
241 | }
|
---|
242 | // added POSTSHUTDOWN string to support eStylerLite
|
---|
243 | // shutdown; if we use MENUITEMSELECTED=704, it cannot
|
---|
244 | // intercept the shutdown, so we have to post a WM_COMMAND
|
---|
245 | // instead
|
---|
246 | // V0.9.20 (2002-07-03) [umoeller]
|
---|
247 | else if (_wpScanSetupString(somSelf,
|
---|
248 | (PSZ)pcszSetupString,
|
---|
249 | "POSTSHUTDOWN",
|
---|
250 | szValue,
|
---|
251 | &cbValue))
|
---|
252 | {
|
---|
253 | WinPostMsg(cmnQueryActiveDesktopHWND(),
|
---|
254 | WM_COMMAND,
|
---|
255 | MPFROMSHORT(WPMENUID_SHUTDOWN),
|
---|
256 | MPFROM2SHORT(CMDSRC_MENU,
|
---|
257 | FALSE));
|
---|
258 | }
|
---|
259 |
|
---|
260 | // V0.9.14 (2001-07-28) [umoeller]
|
---|
261 | cbValue = sizeof(szValue);
|
---|
262 | if (_wpScanSetupString(somSelf,
|
---|
263 | (PSZ)pcszSetupString,
|
---|
264 | "SHOWRUNDLG",
|
---|
265 | szValue,
|
---|
266 | &cbValue))
|
---|
267 | {
|
---|
268 | PSZ pszStartup = NULL;
|
---|
269 | if (strcmp(szValue, "DEFAULT")) // boot drive
|
---|
270 | pszStartup = szValue;
|
---|
271 | brc = (cmnRunCommandLine(NULLHANDLE, // active desktop
|
---|
272 | pszStartup)
|
---|
273 | != NULLHANDLE);
|
---|
274 | }
|
---|
275 |
|
---|
276 | if (_wpScanSetupString(somSelf,
|
---|
277 | (PSZ)pcszSetupString,
|
---|
278 | "TESTFILEDLG",
|
---|
279 | szValue,
|
---|
280 | &cbValue))
|
---|
281 | {
|
---|
282 | CHAR szFullFile[CCHMAXPATH] = "";
|
---|
283 | strcpy(szFullFile, szValue);
|
---|
284 | if (cmnFileDlg2(cmnQueryActiveDesktopHWND(),
|
---|
285 | szFullFile,
|
---|
286 | 0,
|
---|
287 | NULLHANDLE,
|
---|
288 | NULL,
|
---|
289 | NULL,
|
---|
290 | TRUE)) // force use of new file dlg
|
---|
291 | winhDebugBox(NULLHANDLE,
|
---|
292 | "Test file dlg",
|
---|
293 | szFullFile);
|
---|
294 | }
|
---|
295 |
|
---|
296 | // SHOWHELPPANEL=[XWP|filename,]panelid
|
---|
297 | // V0.9.20 (2002-07-12) [umoeller]
|
---|
298 | if (_wpScanSetupString(somSelf,
|
---|
299 | (PSZ)pcszSetupString,
|
---|
300 | "SHOWHELPPANEL",
|
---|
301 | szValue,
|
---|
302 | &cbValue))
|
---|
303 | {
|
---|
304 | PSZ p;
|
---|
305 | PCSZ pcszHelpLibrary = NULL, // null means WPHELP.HLP
|
---|
306 | pcszPanelId = szValue;
|
---|
307 | ULONG ulPanelId;
|
---|
308 | if (p = strchr(szValue, ','))
|
---|
309 | {
|
---|
310 | *p = '\0';
|
---|
311 | if (!strcmp(szValue, "XWP"))
|
---|
312 | pcszHelpLibrary = cmnQueryHelpLibrary();
|
---|
313 | else
|
---|
314 | pcszHelpLibrary = szValue;
|
---|
315 | pcszPanelId = p + 1;
|
---|
316 | }
|
---|
317 |
|
---|
318 | if (ulPanelId = atoi(pcszPanelId))
|
---|
319 | {
|
---|
320 | brc = _wpDisplayHelp(somSelf,
|
---|
321 | ulPanelId,
|
---|
322 | (PSZ)pcszHelpLibrary); // can be NULL for WPHELP.HLP
|
---|
323 | }
|
---|
324 | }
|
---|
325 |
|
---|
326 | return brc;
|
---|
327 | }
|
---|
328 |
|
---|
329 | /*
|
---|
330 | *@@ dtpQuerySetup:
|
---|
331 | * implementation of XFldDesktop::xwpQuerySetup2.
|
---|
332 | * See remarks there.
|
---|
333 | *
|
---|
334 | * This returns the length of the XFldDesktop
|
---|
335 | * setup string part only.
|
---|
336 | *
|
---|
337 | *@@added V0.9.1 (2000-01-20) [umoeller]
|
---|
338 | *@@todo warp4 setup strings
|
---|
339 | */
|
---|
340 |
|
---|
341 | BOOL dtpQuerySetup(WPDesktop *somSelf,
|
---|
342 | PVOID pstrSetup)
|
---|
343 | {
|
---|
344 | // PSZ pszTemp = NULL;
|
---|
345 | // ULONG ulValue = 0;
|
---|
346 | // ulDefaultValue = 0;
|
---|
347 |
|
---|
348 | /*
|
---|
349 |
|
---|
350 | @@todo This is the complete list of all WPDesktop setup
|
---|
351 | strings, as documented by WPSREF. However, method
|
---|
352 | implementations only exist for Warp 4.
|
---|
353 |
|
---|
354 | We'd need to manually decode what all the settings
|
---|
355 | in PM_Lockup in OS2.INI are good for.
|
---|
356 |
|
---|
357 | */
|
---|
358 |
|
---|
359 |
|
---|
360 | // AUTOLOCKUP=YES/NO
|
---|
361 | /* if (_wpQueryAutoLockup(somSelf))
|
---|
362 | xstrcat(&pszTemp, "AUTOLOCKUP=YES");
|
---|
363 |
|
---|
364 | // LOCKUPAUTODIM=YES/NO
|
---|
365 | if (_wpQueryLockupAutoDim(somSelf) == FALSE)
|
---|
366 | xstrcat(&pszTemp, "LOCKUPAUTODIM=NO");
|
---|
367 |
|
---|
368 | // LOCKUPBACKGROUND
|
---|
369 |
|
---|
370 | // LOCKUPFULLSCREEN
|
---|
371 | if (_wpQueryLockupFullScreen(somSelf) == FALSE)
|
---|
372 | xstrcat(&pszTemp, "LOCKUPFULLSCREEN=NO");
|
---|
373 |
|
---|
374 | // LOCKUPONSTARTUP
|
---|
375 | if (_wpQueryLockupOnStart(somSelf))
|
---|
376 | xstrcat(&pszTemp, "LOCKUPONSTARTUP=YES");
|
---|
377 |
|
---|
378 | _wpQueryLockupBackground();
|
---|
379 |
|
---|
380 | // LOCKUPTIMEOUT
|
---|
381 | ulValue = _wpQueryLockupTimeout(somSelf);
|
---|
382 | if (ulValue != 3)
|
---|
383 | {
|
---|
384 | CHAR szTemp[300];
|
---|
385 | sprintf(szTemp, "LOCKUPTIMEOUT=%d", ulValue);
|
---|
386 | xstrcat(&pszTemp, szTemp);
|
---|
387 | } */
|
---|
388 |
|
---|
389 | /*
|
---|
390 | * append string
|
---|
391 | *
|
---|
392 | */
|
---|
393 |
|
---|
394 | /* if (pszTemp)
|
---|
395 | {
|
---|
396 | // return string if buffer is given
|
---|
397 | if ( (pszSetupString) && (cbSetupString) )
|
---|
398 | strhncpy0(pszSetupString, // target
|
---|
399 | pszTemp, // source
|
---|
400 | cbSetupString); // buffer size
|
---|
401 |
|
---|
402 | // always return length of string
|
---|
403 | ulReturn = strlen(pszTemp);
|
---|
404 | free(pszTemp);
|
---|
405 | } */
|
---|
406 |
|
---|
407 | return TRUE;
|
---|
408 | }
|
---|
409 |
|
---|
410 | /* ******************************************************************
|
---|
411 | *
|
---|
412 | * Desktop menus
|
---|
413 | *
|
---|
414 | ********************************************************************/
|
---|
415 |
|
---|
416 | /*
|
---|
417 | *@@ dtpModifyPopupMenu:
|
---|
418 | * implementation for XFldDesktop::wpModifyPopupMenu.
|
---|
419 | *
|
---|
420 | *@@added V0.9.0 [umoeller]
|
---|
421 | *@@changed V0.9.3 (2000-04-26) [umoeller]: changed shutdown menu IDs for launchpad
|
---|
422 | *@@changed V0.9.7 (2000-12-13) [umoeller]: changed shutdown menu items
|
---|
423 | *@@changed V0.9.7 (2000-12-13) [umoeller]: added "logoff network now"
|
---|
424 | *@@changed V0.9.9 (2001-03-09) [umoeller]: "shutdown" wasn't always disabled if running
|
---|
425 | */
|
---|
426 |
|
---|
427 | VOID dtpModifyPopupMenu(WPDesktop *somSelf,
|
---|
428 | HWND hwndMenu)
|
---|
429 | {
|
---|
430 | HWND hwndMenuInsert = hwndMenu;
|
---|
431 | PCKERNELGLOBALS pKernelGlobals = krnQueryGlobals();
|
---|
432 |
|
---|
433 | // position of original "Shutdown" menu item in context menu
|
---|
434 | SHORT sOrigShutdownPos = (SHORT)WinSendMsg(hwndMenu,
|
---|
435 | MM_ITEMPOSITIONFROMID,
|
---|
436 | MPFROM2SHORT(WPMENUID_SHUTDOWN, FALSE),
|
---|
437 | MPNULL);
|
---|
438 |
|
---|
439 | BOOL fShutdownRunning = xsdQueryShutdownState() != XSD_IDLE;
|
---|
440 | ULONG ulShutdownAttr = 0;
|
---|
441 |
|
---|
442 | ULONG ulOfs = cmnQuerySetting(sulVarMenuOfs);
|
---|
443 | ULONG fl = cmnQuerySetting(mnuQueryMenuXWPSetting(somSelf)); // V1.0.0 (2002-10-11) [pr]
|
---|
444 |
|
---|
445 | if (fShutdownRunning)
|
---|
446 | // disable all those menu items if XShutdown is currently running
|
---|
447 | ulShutdownAttr = MIA_DISABLED;
|
---|
448 |
|
---|
449 | #ifndef __NOXSHUTDOWN__
|
---|
450 | if ( (cmnQuerySetting(sfXShutdown)) // XShutdown enabled?
|
---|
451 | // && (!cmnQuerySetting(sNoWorkerThread)) // Worker thread enabled?
|
---|
452 | // removed this setting V0.9.16 (2002-01-04) [umoeller]
|
---|
453 | )
|
---|
454 | {
|
---|
455 | // V1.0.10 (2014-04-17) [pr]
|
---|
456 | #ifndef __EASYSHUTDOWN__
|
---|
457 | if ((cmnQuerySetting(sflXShutdown) & XSD_NOCONFIRMSHUT))
|
---|
458 | // if XShutdown confirmations have been disabled,
|
---|
459 | // remove "..." from "Shut down" entry
|
---|
460 | winhMenuRemoveEllipse(hwndMenu,
|
---|
461 | WPMENUID_SHUTDOWN);
|
---|
462 | #endif
|
---|
463 | // disable "shutdown" if shutdown is running
|
---|
464 | // V0.9.9 (2001-03-07) [umoeller]
|
---|
465 | if (fShutdownRunning)
|
---|
466 | WinEnableMenuItem(hwndMenu,
|
---|
467 | WPMENUID_SHUTDOWN,
|
---|
468 | FALSE);
|
---|
469 |
|
---|
470 | } // end if (cmnQuerySetting(sfXShutdown)) ...
|
---|
471 |
|
---|
472 | if ( (!(fl & XWPCTXT_RESTARTWPS)) // V1.0.0 (2002-10-11) [pr]
|
---|
473 | && cmnQuerySetting(sfRestartDesktop))
|
---|
474 | {
|
---|
475 | // insert "Restart Desktop"
|
---|
476 | winhInsertMenuItem(hwndMenuInsert, // either main menu or "Shutdown" submenu
|
---|
477 | sOrigShutdownPos, // either MIT_END or position of "Shutdown" item
|
---|
478 | ulOfs + ID_XFMI_OFS_RESTARTWPS,
|
---|
479 | cmnGetString(ID_SDSI_RESTARTWPS), // pszRestartWPS
|
---|
480 | MIS_TEXT,
|
---|
481 | // disable if Shutdown is currently running
|
---|
482 | ulShutdownAttr);
|
---|
483 |
|
---|
484 | if ((cmnQuerySetting(sflXShutdown) & XSD_NOCONFIRMWPS))
|
---|
485 | // if XShutdown confirmations have been disabled,
|
---|
486 | // remove "..." from "Restart Desktop" entry
|
---|
487 | winhMenuRemoveEllipse(hwndMenuInsert,
|
---|
488 | ulOfs + ID_XFMI_OFS_RESTARTWPS);
|
---|
489 | }
|
---|
490 |
|
---|
491 | if (pKernelGlobals->pXWPShellShared)
|
---|
492 | {
|
---|
493 | // XWPShell running:
|
---|
494 | // insert "logoff"
|
---|
495 | winhInsertMenuItem(hwndMenuInsert, // either main menu or "Shutdown" submenu
|
---|
496 | sOrigShutdownPos, // either MIT_END or position of "Shutdown" item
|
---|
497 | ulOfs + ID_XFMI_OFS_LOGOFF,
|
---|
498 | cmnGetString(ID_XSSI_XSD_LOGOFF), // pszXSDLogoff
|
---|
499 | MIS_TEXT,
|
---|
500 | // disable if Shutdown is currently running
|
---|
501 | ulShutdownAttr);
|
---|
502 |
|
---|
503 | #ifndef __EASYSHUTDOWN__
|
---|
504 | if ((cmnQuerySetting(sflXShutdown) & XSD_NOCONFIRMLOGOFF))
|
---|
505 | // if XShutdown confirmations have been disabled,
|
---|
506 | // remove "..." from "Logoff" entry
|
---|
507 | winhMenuRemoveEllipse(hwndMenuInsert,
|
---|
508 | ulOfs + ID_XFMI_OFS_LOGOFF);
|
---|
509 | #endif
|
---|
510 | }
|
---|
511 | #endif
|
---|
512 |
|
---|
513 | // remove other default menu items?
|
---|
514 | {
|
---|
515 | static const ULONG aSuppressFlags[] =
|
---|
516 | {
|
---|
517 | XWPCTXT_SYSTEMSETUP,
|
---|
518 | XWPCTXT_LOGOFF,
|
---|
519 | };
|
---|
520 | mnuRemoveMenuItems(somSelf,
|
---|
521 | hwndMenu,
|
---|
522 | aSuppressFlags,
|
---|
523 | ARRAYITEMCOUNT(aSuppressFlags));
|
---|
524 | }
|
---|
525 |
|
---|
526 | #ifdef __XWPMEMDEBUG__ // setup.h, helpers\memdebug.c
|
---|
527 | // if XWorkplace is compiled with
|
---|
528 | // VAC++ debug memory funcs,
|
---|
529 | // add a menu item for listing all memory objects
|
---|
530 | winhInsertMenuSeparator(hwndMenu,
|
---|
531 | MIT_END,
|
---|
532 | ulOfs + ID_XFMI_OFS_SEPARATOR);
|
---|
533 | winhInsertMenuItem(hwndMenu,
|
---|
534 | MIT_END,
|
---|
535 | DEBUG_MENUID_LISTHEAP,
|
---|
536 | "List VAC++ debug heap",
|
---|
537 | MIS_TEXT, 0);
|
---|
538 | winhInsertMenuItem(hwndMenu,
|
---|
539 | MIT_END,
|
---|
540 | DEBUG_MENUID_RELEASEFREED,
|
---|
541 | "Discard logs for freed memory",
|
---|
542 | MIS_TEXT, 0);
|
---|
543 | #endif
|
---|
544 |
|
---|
545 | #ifdef __DEBUG__
|
---|
546 | // if we have a debug compile,
|
---|
547 | // add "crash" items
|
---|
548 | winhInsertMenuSeparator(hwndMenu,
|
---|
549 | MIT_END,
|
---|
550 | ulOfs + ID_XFMI_OFS_SEPARATOR);
|
---|
551 | hwndMenuInsert = winhInsertSubmenu(hwndMenu,
|
---|
552 | MIT_END,
|
---|
553 | DEBUG_MENUID_CRASH_MENU,
|
---|
554 | "Crash WPS",
|
---|
555 | MIS_TEXT,
|
---|
556 | // first item ID in "Shutdown" menu:
|
---|
557 | // crash thread 1
|
---|
558 | DEBUG_MENUID_CRASH_THR1,
|
---|
559 | "Thread 1",
|
---|
560 | MIS_TEXT, 0);
|
---|
561 | winhInsertMenuItem(hwndMenuInsert,
|
---|
562 | MIT_END,
|
---|
563 | DEBUG_MENUID_CRASH_WORKER,
|
---|
564 | "Worker thread",
|
---|
565 | MIS_TEXT, 0);
|
---|
566 | winhInsertMenuItem(hwndMenuInsert,
|
---|
567 | MIT_END,
|
---|
568 | DEBUG_MENUID_CRASH_QUICK,
|
---|
569 | "Speedy thread",
|
---|
570 | MIS_TEXT, 0);
|
---|
571 | winhInsertMenuItem(hwndMenuInsert,
|
---|
572 | MIT_END,
|
---|
573 | DEBUG_MENUID_CRASH_FILE,
|
---|
574 | "File thread",
|
---|
575 | MIS_TEXT, 0);
|
---|
576 |
|
---|
577 | // add "Dump window list"
|
---|
578 | winhInsertMenuItem(hwndMenu,
|
---|
579 | MIT_END,
|
---|
580 | DEBUG_MENUID_DUMPWINLIST,
|
---|
581 | "Dump window list",
|
---|
582 | MIS_TEXT, 0);
|
---|
583 | #endif
|
---|
584 |
|
---|
585 | // krnUnlockGlobals();
|
---|
586 | }
|
---|
587 |
|
---|
588 | /*
|
---|
589 | *@@ dtpMenuItemSelected:
|
---|
590 | * implementation for XFldDesktop::wpMenuItemSelected.
|
---|
591 | *
|
---|
592 | * This returns TRUE if one of the new items was processed
|
---|
593 | * or FALSE if the parent method should be called. We may
|
---|
594 | * change *pulMenuId and return FALSE.
|
---|
595 | *
|
---|
596 | *@@added V0.9.1 (99-12-04) [umoeller]
|
---|
597 | *@@changed V0.9.3 (2000-04-26) [umoeller]: changed shutdown menu item IDs; changed prototype
|
---|
598 | *@@changed V0.9.5 (2000-08-10) [umoeller]: added logoff support
|
---|
599 | */
|
---|
600 |
|
---|
601 | BOOL dtpMenuItemSelected(XFldDesktop *somSelf,
|
---|
602 | HWND hwndFrame,
|
---|
603 | PULONG pulMenuId) // in/out: menu item ID (can be changed)
|
---|
604 | {
|
---|
605 | if (xsdQueryShutdownState() == XSD_IDLE)
|
---|
606 | {
|
---|
607 | ULONG ulMenuId2 = (*pulMenuId - (cmnQuerySetting(sulVarMenuOfs)));
|
---|
608 |
|
---|
609 | if (ulMenuId2 == ID_XFMI_OFS_RESTARTWPS)
|
---|
610 | {
|
---|
611 | xsdInitiateRestartWPS(FALSE); // restart Desktop, no logoff
|
---|
612 | return TRUE;
|
---|
613 | }
|
---|
614 | else if (ulMenuId2 == ID_XFMI_OFS_LOGOFF)
|
---|
615 | {
|
---|
616 | xsdInitiateRestartWPS(TRUE); // logoff
|
---|
617 | return TRUE;
|
---|
618 | }
|
---|
619 | #ifndef __NOXSHUTDOWN__
|
---|
620 | else if ( (cmnQuerySetting(sfXShutdown))
|
---|
621 | // && (cmnQuerySetting(sNoWorkerThread) == 0)
|
---|
622 | // removed this setting V0.9.16 (2002-01-04) [umoeller]
|
---|
623 | )
|
---|
624 | {
|
---|
625 | // shutdown enabled:
|
---|
626 | if (*pulMenuId == WPMENUID_SHUTDOWN)
|
---|
627 | {
|
---|
628 | xsdInitiateShutdown();
|
---|
629 | return TRUE;
|
---|
630 | }
|
---|
631 | else if (ulMenuId2 == ID_XFMI_OFS_OS2_SHUTDOWN)
|
---|
632 | {
|
---|
633 | // default OS/2 shutdown (in submenu):
|
---|
634 | // have parent method called with default shutdown menu item ID
|
---|
635 | // to start OS/2 shutdown...
|
---|
636 | *pulMenuId = WPMENUID_SHUTDOWN;
|
---|
637 | return FALSE;
|
---|
638 | }
|
---|
639 | }
|
---|
640 | #endif
|
---|
641 | }
|
---|
642 |
|
---|
643 | #ifdef __XWPLITE__
|
---|
644 | if (*pulMenuId == 0x25D) // product info
|
---|
645 | {
|
---|
646 | cmnShowProductInfo(NULLHANDLE, // owner
|
---|
647 | MMSOUND_SYSTEMSTARTUP);
|
---|
648 | return TRUE;
|
---|
649 | }
|
---|
650 | #endif
|
---|
651 |
|
---|
652 | #ifdef __XWPMEMDEBUG__ // setup.h, helpers\memdebug.c
|
---|
653 | // if XWorkplace is compiled with
|
---|
654 | // VAC++ debug memory funcs,
|
---|
655 | // check the menu item for listing all memory objects
|
---|
656 | if (*pulMenuId == DEBUG_MENUID_LISTHEAP)
|
---|
657 | {
|
---|
658 | memdCreateMemDebugWindow();
|
---|
659 | return TRUE;
|
---|
660 | }
|
---|
661 | else if (*pulMenuId == DEBUG_MENUID_RELEASEFREED)
|
---|
662 | {
|
---|
663 | HPOINTER hptrOld = winhSetWaitPointer();
|
---|
664 | memdReleaseFreed();
|
---|
665 | WinSetPointer(HWND_DESKTOP, hptrOld);
|
---|
666 | return TRUE;
|
---|
667 | }
|
---|
668 | #endif
|
---|
669 |
|
---|
670 | #ifdef __DEBUG__
|
---|
671 | switch (*pulMenuId)
|
---|
672 | {
|
---|
673 | case DEBUG_MENUID_CRASH_THR1:
|
---|
674 | krnPostThread1ObjectMsg(XM_CRASH, 0, 0);
|
---|
675 | break;
|
---|
676 |
|
---|
677 | case DEBUG_MENUID_CRASH_WORKER:
|
---|
678 | xthrPostWorkerMsg(XM_CRASH, 0, 0);
|
---|
679 | break;
|
---|
680 |
|
---|
681 | case DEBUG_MENUID_CRASH_QUICK:
|
---|
682 | xthrPostBushMsg(XM_CRASH, 0, 0);
|
---|
683 | break;
|
---|
684 |
|
---|
685 | case DEBUG_MENUID_CRASH_FILE:
|
---|
686 | xthrPostFileMsg(XM_CRASH, 0, 0);
|
---|
687 | break;
|
---|
688 |
|
---|
689 | case DEBUG_MENUID_DUMPWINLIST:
|
---|
690 | winlCreateWinListWindow();
|
---|
691 | break;
|
---|
692 | }
|
---|
693 | #endif
|
---|
694 |
|
---|
695 | return FALSE;
|
---|
696 | }
|
---|
697 |
|
---|
698 | /* ******************************************************************
|
---|
699 | *
|
---|
700 | * XFldDesktop notebook settings pages callbacks (notebook.c)
|
---|
701 | *
|
---|
702 | ********************************************************************/
|
---|
703 |
|
---|
704 | static const CONTROLDEF
|
---|
705 | #ifndef __NOBOOTLOGO__
|
---|
706 | BootLogoGroup = LOADDEF_GROUP(ID_XSDI_DTP_LOGOGROUP, SZL_AUTOSIZE),
|
---|
707 | BootLogoCB = LOADDEF_AUTOCHECKBOX(ID_XSDI_DTP_BOOTLOGO),
|
---|
708 | LogoStyleGroup = LOADDEF_GROUP(ID_XSDI_DTP_LOGOSTYLEGROUP, SZL_AUTOSIZE),
|
---|
709 | LogoTransparentRadio = LOADDEF_FIRST_AUTORADIO(ID_XSDI_DTP_LOGO_TRANSPARENT),
|
---|
710 | LogoBlowUpRadio = LOADDEF_NEXT_AUTORADIO(ID_XSDI_DTP_LOGO_BLOWUP),
|
---|
711 | LogoFrameGroup = CONTROLDEF_GROUP(
|
---|
712 | NULL,
|
---|
713 | ID_XSDI_DTP_LOGOFRAME,
|
---|
714 | -1,
|
---|
715 | -1),
|
---|
716 | LogoBitmap =
|
---|
717 | {
|
---|
718 | WC_STATIC,
|
---|
719 | "",
|
---|
720 | SS_FGNDFRAME | WS_VISIBLE,
|
---|
721 | ID_XSDI_DTP_LOGOBITMAP,
|
---|
722 | CTL_COMMON_FONT,
|
---|
723 | {66, 40},
|
---|
724 | COMMON_SPACING
|
---|
725 | },
|
---|
726 | LogoFileText = LOADDEF_TEXT(ID_XSDI_DTP_LOGOFILETXT),
|
---|
727 | LogoFileEF = CONTROLDEF_ENTRYFIELD(
|
---|
728 | NULL,
|
---|
729 | ID_XSDI_DTP_LOGOFILE,
|
---|
730 | 100,
|
---|
731 | -1),
|
---|
732 | LogoFileBrowseButton = CONTROLDEF_PUSHBUTTON(
|
---|
733 | LOAD_STRING, // "Bro~wse..."
|
---|
734 | DID_BROWSE,
|
---|
735 | -1,
|
---|
736 | STD_BUTTON_HEIGHT),
|
---|
737 | LogoFileTestButton = CONTROLDEF_PUSHBUTTON(
|
---|
738 | LOAD_STRING, // "T~est logo",
|
---|
739 | ID_XSDI_DTP_TESTLOGO,
|
---|
740 | -1,
|
---|
741 | STD_BUTTON_HEIGHT),
|
---|
742 | #endif
|
---|
743 | WriteXWPStartLogCB = LOADDEF_AUTOCHECKBOX(ID_XSDI_DTP_WRITEXWPSTARTLOG),
|
---|
744 | #ifndef __NOBOOTUPSTATUS__
|
---|
745 | BootupStatusCB = LOADDEF_AUTOCHECKBOX(ID_XSDI_DTP_BOOTUPSTATUS),
|
---|
746 | #endif
|
---|
747 | #ifndef __NOXWPSTARTUP__
|
---|
748 | CreateStartupFolderButton = CONTROLDEF_PUSHBUTTON(
|
---|
749 | LOAD_STRING, // "Create ~XWorkplace Startup folder",
|
---|
750 | ID_XSDI_DTP_CREATESTARTUPFLDR,
|
---|
751 | -1,
|
---|
752 | STD_BUTTON_HEIGHT),
|
---|
753 | #endif
|
---|
754 | NumLockOnCB = LOADDEF_AUTOCHECKBOX(ID_XSDI_DTP_NUMLOCKON);
|
---|
755 |
|
---|
756 | static const DLGHITEM dlgDesktopStartup[] =
|
---|
757 | {
|
---|
758 | START_TABLE, // root table, required
|
---|
759 | #ifndef __NOBOOTLOGO__
|
---|
760 | START_ROW(0), // boot logo group
|
---|
761 | START_GROUP_TABLE(&BootLogoGroup),
|
---|
762 | START_ROW(0),
|
---|
763 | CONTROL_DEF(&BootLogoCB),
|
---|
764 | START_ROW(ROW_VALIGN_CENTER),
|
---|
765 | CONTROL_DEF(&LogoFileText),
|
---|
766 | START_ROW(ROW_VALIGN_CENTER),
|
---|
767 | CONTROL_DEF(&LogoFileEF),
|
---|
768 | // START_ROW(0),
|
---|
769 | CONTROL_DEF(&LogoFileBrowseButton),
|
---|
770 | START_ROW(0),
|
---|
771 | START_GROUP_TABLE(&LogoFrameGroup),
|
---|
772 | START_ROW(0),
|
---|
773 | CONTROL_DEF(&LogoBitmap),
|
---|
774 | END_TABLE, // logo frame group
|
---|
775 | START_TABLE,
|
---|
776 | START_ROW(0),
|
---|
777 | START_GROUP_TABLE(&LogoStyleGroup),
|
---|
778 | START_ROW(0),
|
---|
779 | CONTROL_DEF(&LogoTransparentRadio),
|
---|
780 | START_ROW(0),
|
---|
781 | CONTROL_DEF(&LogoBlowUpRadio),
|
---|
782 | END_TABLE, // logo style group
|
---|
783 | START_ROW(0),
|
---|
784 | CONTROL_DEF(&LogoFileTestButton),
|
---|
785 | END_TABLE,
|
---|
786 | END_TABLE, // end of boot logo group
|
---|
787 | #endif
|
---|
788 | START_ROW(0),
|
---|
789 | CONTROL_DEF(&WriteXWPStartLogCB),
|
---|
790 | #ifndef __NOBOOTUPSTATUS__
|
---|
791 | START_ROW(0),
|
---|
792 | CONTROL_DEF(&BootupStatusCB),
|
---|
793 | #endif
|
---|
794 | START_ROW(0),
|
---|
795 | CONTROL_DEF(&NumLockOnCB),
|
---|
796 | #ifndef __NOXWPSTARTUP__
|
---|
797 | START_ROW(0),
|
---|
798 | CONTROL_DEF(&CreateStartupFolderButton),
|
---|
799 | #endif
|
---|
800 | START_ROW(0), // notebook buttons (will be moved)
|
---|
801 | CONTROL_DEF(&G_UndoButton), // common.c
|
---|
802 | CONTROL_DEF(&G_DefaultButton), // common.c
|
---|
803 | CONTROL_DEF(&G_HelpButton), // common.c
|
---|
804 | END_TABLE
|
---|
805 | };
|
---|
806 |
|
---|
807 | static const XWPSETTING G_DtpStartupBackup[] =
|
---|
808 | {
|
---|
809 | sfWriteXWPStartupLog,
|
---|
810 | #ifndef __NOBOOTUPSTATUS__
|
---|
811 | sfShowBootupStatus,
|
---|
812 | #endif
|
---|
813 | #ifndef __NOBOOTLOGO__
|
---|
814 | sfBootLogo,
|
---|
815 | sulBootLogoStyle,
|
---|
816 | #endif
|
---|
817 | sfNumLockStartup
|
---|
818 | };
|
---|
819 |
|
---|
820 | /*
|
---|
821 | * dtpStartupInitPage:
|
---|
822 | * notebook callback function (notebook.c) for the
|
---|
823 | * "Startup" page in the Desktop's settings
|
---|
824 | * notebook.
|
---|
825 | * Sets the controls on the page according to the
|
---|
826 | * Global Settings.
|
---|
827 | *
|
---|
828 | *@@added V0.9.0 [umoeller]
|
---|
829 | *@@changed V0.9.1 (2000-02-09) [umoeller]: added NumLock support to this page
|
---|
830 | *@@changed V0.9.13 (2001-06-14) [umoeller]: fixed Undo for boot logo file
|
---|
831 | *@@changed V0.9.14 (2001-08-21) [umoeller]: added "write startuplog" setting
|
---|
832 | *@@changecd V0.9.16 (2001-09-29) [umoeller]: now using dialog formatter
|
---|
833 | */
|
---|
834 |
|
---|
835 | VOID dtpStartupInitPage(PNOTEBOOKPAGE pnbp, // notebook info struct
|
---|
836 | ULONG flFlags) // CBI_* flags (notebook.h)
|
---|
837 | {
|
---|
838 | if (flFlags & CBI_INIT)
|
---|
839 | {
|
---|
840 | // first call: backup Global Settings for "Undo" button;
|
---|
841 | // this memory will be freed automatically by the
|
---|
842 | // common notebook window function (notebook.c) when
|
---|
843 | // the notebook page is destroyed
|
---|
844 | pnbp->pUser = cmnBackupSettings(G_DtpStartupBackup,
|
---|
845 | ARRAYITEMCOUNT(G_DtpStartupBackup));
|
---|
846 |
|
---|
847 | // insert the controls using the dialog formatter
|
---|
848 | // V0.9.16 (2001-09-29) [umoeller]
|
---|
849 | ntbFormatPage(pnbp->hwndDlgPage,
|
---|
850 | dlgDesktopStartup,
|
---|
851 | ARRAYITEMCOUNT(dlgDesktopStartup));
|
---|
852 |
|
---|
853 | #ifndef __NOBOOTLOGO__
|
---|
854 | // backup old boot logo file
|
---|
855 | pnbp->pUser2 = cmnQueryBootLogoFile(); // malloc'ed
|
---|
856 | // fixed V0.9.13 (2001-06-14) [umoeller]
|
---|
857 |
|
---|
858 | // prepare the control to properly display
|
---|
859 | // stretched bitmaps
|
---|
860 | ctlPrepareStretchedBitmap(WinWindowFromID(pnbp->hwndDlgPage,
|
---|
861 | ID_XSDI_DTP_LOGOBITMAP),
|
---|
862 | TRUE); // preserve proportions
|
---|
863 |
|
---|
864 | // set entry field limit
|
---|
865 | winhSetEntryFieldLimit(WinWindowFromID(pnbp->hwndDlgPage,
|
---|
866 | ID_XSDI_DTP_LOGOFILE),
|
---|
867 | CCHMAXPATH);
|
---|
868 | #endif
|
---|
869 | }
|
---|
870 |
|
---|
871 | if (flFlags & CBI_SET)
|
---|
872 | {
|
---|
873 | #ifndef __NOBOOTLOGO__
|
---|
874 | USHORT usRadioID;
|
---|
875 | HDC hdcMem;
|
---|
876 | HPS hpsMem;
|
---|
877 | HBITMAP hbmBootLogo;
|
---|
878 |
|
---|
879 | HPOINTER hptrOld = winhSetWaitPointer();
|
---|
880 |
|
---|
881 | SIZEL szlPage = {0, 0};
|
---|
882 | PSZ pszBootLogoFile = cmnQueryBootLogoFile();
|
---|
883 |
|
---|
884 | // "boot logo enabled"
|
---|
885 | winhSetDlgItemChecked(pnbp->hwndDlgPage, ID_XSDI_DTP_BOOTLOGO,
|
---|
886 | cmnQuerySetting(sfBootLogo));
|
---|
887 |
|
---|
888 | // "boot logo style"
|
---|
889 | if (cmnQuerySetting(sulBootLogoStyle) == 0)
|
---|
890 | usRadioID = ID_XSDI_DTP_LOGO_TRANSPARENT;
|
---|
891 | else
|
---|
892 | usRadioID = ID_XSDI_DTP_LOGO_BLOWUP;
|
---|
893 | winhSetDlgItemChecked(pnbp->hwndDlgPage, usRadioID,
|
---|
894 | TRUE); // V1.0.6 (2006-08-20) [pr]
|
---|
895 |
|
---|
896 | // set boot logo file entry field
|
---|
897 | WinSetDlgItemText(pnbp->hwndDlgPage,
|
---|
898 | ID_XSDI_DTP_LOGOFILE,
|
---|
899 | pszBootLogoFile);
|
---|
900 |
|
---|
901 | // attempt to display the boot logo
|
---|
902 | if (gpihCreateMemPS(WinQueryAnchorBlock(pnbp->hwndDlgPage),
|
---|
903 | &szlPage,
|
---|
904 | &hdcMem,
|
---|
905 | &hpsMem))
|
---|
906 | {
|
---|
907 | APIRET arc;
|
---|
908 | if (!(arc = gpihLoadBitmapFile(&hbmBootLogo,
|
---|
909 | hpsMem,
|
---|
910 | pszBootLogoFile)))
|
---|
911 | {
|
---|
912 | // and have the subclassed static control display the thing
|
---|
913 | WinSendDlgItemMsg(pnbp->hwndDlgPage, ID_XSDI_DTP_LOGOBITMAP,
|
---|
914 | SM_SETHANDLE,
|
---|
915 | (MPARAM)hbmBootLogo,
|
---|
916 | MPNULL);
|
---|
917 |
|
---|
918 | // delete the bitmap again
|
---|
919 | // (the static control has made a private copy
|
---|
920 | // of the bitmap, so this is safe)
|
---|
921 | GpiDeleteBitmap(hbmBootLogo);
|
---|
922 | }
|
---|
923 | GpiDestroyPS(hpsMem);
|
---|
924 | DevCloseDC(hdcMem);
|
---|
925 | }
|
---|
926 | free(pszBootLogoFile);
|
---|
927 |
|
---|
928 | WinSetPointer(HWND_DESKTOP, hptrOld);
|
---|
929 | #endif
|
---|
930 | // startup log file
|
---|
931 | winhSetDlgItemChecked(pnbp->hwndDlgPage, ID_XSDI_DTP_WRITEXWPSTARTLOG,
|
---|
932 | cmnQuerySetting(sfWriteXWPStartupLog));
|
---|
933 |
|
---|
934 | #ifndef __NOBOOTUPSTATUS__
|
---|
935 | // bootup status
|
---|
936 | winhSetDlgItemChecked(pnbp->hwndDlgPage, ID_XSDI_DTP_BOOTUPSTATUS,
|
---|
937 | cmnQuerySetting(sfShowBootupStatus));
|
---|
938 | #endif
|
---|
939 |
|
---|
940 | // numlock on
|
---|
941 | winhSetDlgItemChecked(pnbp->hwndDlgPage, ID_XSDI_DTP_NUMLOCKON,
|
---|
942 | cmnQuerySetting(sfNumLockStartup));
|
---|
943 | }
|
---|
944 |
|
---|
945 | if (flFlags & CBI_ENABLE)
|
---|
946 | {
|
---|
947 | #ifndef __NOBOOTLOGO__
|
---|
948 | PSZ pszBootLogoFile = cmnQueryBootLogoFile();
|
---|
949 | BOOL fBootLogoFileExists = (access(pszBootLogoFile, 0) == 0);
|
---|
950 | free(pszBootLogoFile);
|
---|
951 |
|
---|
952 | WinEnableControl(pnbp->hwndDlgPage, ID_XSDI_DTP_LOGOBITMAP,
|
---|
953 | cmnQuerySetting(sfBootLogo));
|
---|
954 | WinEnableControl(pnbp->hwndDlgPage, ID_XSDI_DTP_TESTLOGO, fBootLogoFileExists);
|
---|
955 | #endif
|
---|
956 |
|
---|
957 | #ifndef __NOXWPSTARTUP__
|
---|
958 | if (WinQueryObject((PSZ)XFOLDER_STARTUPID))
|
---|
959 | WinEnableControl(pnbp->hwndDlgPage, ID_XSDI_DTP_CREATESTARTUPFLDR, FALSE);
|
---|
960 | #endif
|
---|
961 | }
|
---|
962 | }
|
---|
963 |
|
---|
964 | #ifndef __NOBOOTLOGO__
|
---|
965 |
|
---|
966 | /*
|
---|
967 | *@@ SetBootLogoFile:
|
---|
968 | * changes the boot logo file. Shared between the
|
---|
969 | * entry field handler and "Undo".
|
---|
970 | *
|
---|
971 | *@@added V0.9.13 (2001-06-14) [umoeller]
|
---|
972 | */
|
---|
973 |
|
---|
974 | STATIC VOID SetBootLogoFile(PNOTEBOOKPAGE pnbp,
|
---|
975 | PCSZ pcszNewBootLogoFile,
|
---|
976 | BOOL fWrite) // in: if TRUE, write back to OS2.INI
|
---|
977 | {
|
---|
978 | WinEnableControl(pnbp->hwndDlgPage, ID_XSDI_DTP_TESTLOGO,
|
---|
979 | (access(pcszNewBootLogoFile, 0) == 0));
|
---|
980 |
|
---|
981 | if (fWrite)
|
---|
982 | {
|
---|
983 | // query new file name from entry field
|
---|
984 | PrfWriteProfileString(HINI_USER,
|
---|
985 | (PSZ)INIAPP_XWORKPLACE,
|
---|
986 | (PSZ)INIKEY_BOOTLOGOFILE,
|
---|
987 | (PSZ)pcszNewBootLogoFile);
|
---|
988 | // update the display by calling the INIT callback
|
---|
989 | pnbp->inbp.pfncbInitPage(pnbp, CBI_SET | CBI_ENABLE);
|
---|
990 | }
|
---|
991 | }
|
---|
992 |
|
---|
993 | #endif
|
---|
994 |
|
---|
995 | /*
|
---|
996 | * dtpStartupItemChanged:
|
---|
997 | * notebook callback function (notebook.c) for the
|
---|
998 | * "Startup" page in the Desktop's settings
|
---|
999 | * notebook.
|
---|
1000 | * Reacts to changes of any of the dialog controls.
|
---|
1001 | *
|
---|
1002 | *@@added V0.9.0 [umoeller]
|
---|
1003 | *@@changed V0.9.1 (2000-02-09) [umoeller]: added NumLock support to this page
|
---|
1004 | *@@changed V0.9.3 (2000-04-11) [umoeller]: fixed major resource leak; the bootlogo bitmap was never freed
|
---|
1005 | *@@changed V0.9.9 (2001-04-07) [pr]: fixed Undo
|
---|
1006 | *@@changed V0.9.13 (2001-06-14) [umoeller]: fixed Undo for boot logo file
|
---|
1007 | *@@changed V0.9.14 (2001-08-21) [umoeller]: added "write startuplog" setting
|
---|
1008 | */
|
---|
1009 |
|
---|
1010 | MRESULT dtpStartupItemChanged(PNOTEBOOKPAGE pnbp,
|
---|
1011 | ULONG ulItemID,
|
---|
1012 | USHORT usNotifyCode,
|
---|
1013 | ULONG ulExtra) // for checkboxes: contains new state
|
---|
1014 | {
|
---|
1015 | BOOL fProcessed = TRUE;
|
---|
1016 |
|
---|
1017 | ULONG ulChange = 1;
|
---|
1018 |
|
---|
1019 | {
|
---|
1020 | switch (ulItemID)
|
---|
1021 | {
|
---|
1022 | #ifndef __NOBOOTLOGO__
|
---|
1023 | case ID_XSDI_DTP_BOOTLOGO:
|
---|
1024 | cmnSetSetting(sfBootLogo, ulExtra);
|
---|
1025 | ulChange = 2; // re-enable items
|
---|
1026 | break;
|
---|
1027 |
|
---|
1028 | case ID_XSDI_DTP_LOGO_TRANSPARENT:
|
---|
1029 | cmnSetSetting(sulBootLogoStyle, 0);
|
---|
1030 | break;
|
---|
1031 |
|
---|
1032 | case ID_XSDI_DTP_LOGO_BLOWUP:
|
---|
1033 | cmnSetSetting(sulBootLogoStyle, 1);
|
---|
1034 | break;
|
---|
1035 | #endif
|
---|
1036 |
|
---|
1037 | case ID_XSDI_DTP_WRITEXWPSTARTLOG:
|
---|
1038 | cmnSetSetting(sfWriteXWPStartupLog, ulExtra);
|
---|
1039 | break;
|
---|
1040 |
|
---|
1041 | #ifndef __NOBOOTUPSTATUS__
|
---|
1042 | case ID_XSDI_DTP_BOOTUPSTATUS:
|
---|
1043 | cmnSetSetting(sfShowBootupStatus, ulExtra);
|
---|
1044 | break;
|
---|
1045 | #endif
|
---|
1046 |
|
---|
1047 | case ID_XSDI_DTP_NUMLOCKON:
|
---|
1048 | cmnSetSetting(sfNumLockStartup, ulExtra);
|
---|
1049 | winhSetNumLock(ulExtra);
|
---|
1050 | break;
|
---|
1051 |
|
---|
1052 | case DID_UNDO:
|
---|
1053 | // "Undo" button: get pointer to backed-up Global Settings
|
---|
1054 | cmnRestoreSettings(pnbp->pUser,
|
---|
1055 | ARRAYITEMCOUNT(G_DtpStartupBackup));
|
---|
1056 |
|
---|
1057 | #ifndef __NOBOOTLOGO__
|
---|
1058 | SetBootLogoFile(pnbp,
|
---|
1059 | (PCSZ)pnbp->pUser2,
|
---|
1060 | TRUE); // write
|
---|
1061 | #endif
|
---|
1062 |
|
---|
1063 | // update the display by calling the INIT callback
|
---|
1064 | pnbp->inbp.pfncbInitPage(pnbp, CBI_SET | CBI_ENABLE);
|
---|
1065 | break;
|
---|
1066 |
|
---|
1067 | case DID_DEFAULT:
|
---|
1068 | // set the default settings for this settings page
|
---|
1069 | // (this is in common.c because it's also used at
|
---|
1070 | // Desktop startup)
|
---|
1071 | cmnSetDefaultSettings(pnbp->inbp.ulPageID);
|
---|
1072 | // update the display by calling the INIT callback
|
---|
1073 | pnbp->inbp.pfncbInitPage(pnbp, CBI_SET | CBI_ENABLE);
|
---|
1074 | break;
|
---|
1075 |
|
---|
1076 | default:
|
---|
1077 | ulChange = 0;
|
---|
1078 | fProcessed = FALSE;
|
---|
1079 | }
|
---|
1080 | }
|
---|
1081 |
|
---|
1082 | if (ulChange == 2)
|
---|
1083 | // enable/disable items
|
---|
1084 | pnbp->inbp.pfncbInitPage(pnbp, CBI_ENABLE);
|
---|
1085 |
|
---|
1086 | if (!fProcessed)
|
---|
1087 | {
|
---|
1088 | // not processed above:
|
---|
1089 | // second switch-case with non-global settings stuff
|
---|
1090 |
|
---|
1091 | switch (ulItemID)
|
---|
1092 | {
|
---|
1093 | #ifndef __NOBOOTLOGO__
|
---|
1094 | /*
|
---|
1095 | * ID_XSDI_DTP_LOGOFILE:
|
---|
1096 | * focus leaves "file" entry field:
|
---|
1097 | * update OS2.INI
|
---|
1098 | */
|
---|
1099 |
|
---|
1100 | case ID_XSDI_DTP_LOGOFILE:
|
---|
1101 | {
|
---|
1102 | PSZ pszNewBootLogoFile = winhQueryWindowText(pnbp->hwndControl);
|
---|
1103 | SetBootLogoFile(pnbp,
|
---|
1104 | pszNewBootLogoFile,
|
---|
1105 | (usNotifyCode == EN_KILLFOCUS)); // write?
|
---|
1106 | if (pszNewBootLogoFile)
|
---|
1107 | free(pszNewBootLogoFile);
|
---|
1108 | }
|
---|
1109 | break;
|
---|
1110 |
|
---|
1111 | /*
|
---|
1112 | * DID_BROWSE:
|
---|
1113 | * "Browse" button: open file dialog
|
---|
1114 | */
|
---|
1115 |
|
---|
1116 | case DID_BROWSE:
|
---|
1117 | {
|
---|
1118 | // FILEDLG fd;
|
---|
1119 | CHAR szFile[CCHMAXPATH] = "*.BMP";
|
---|
1120 | PSZ pszNewBootLogoFile = winhQueryWindowText(WinWindowFromID(pnbp->hwndDlgPage,
|
---|
1121 | ID_XSDI_DTP_LOGOFILE));
|
---|
1122 |
|
---|
1123 | /* memset(&fd, 0, sizeof(FILEDLG));
|
---|
1124 | fd.cbSize = sizeof(FILEDLG);
|
---|
1125 | fd.fl = FDS_OPEN_DIALOG
|
---|
1126 | | FDS_CENTER;
|
---|
1127 | */
|
---|
1128 |
|
---|
1129 | if (pszNewBootLogoFile)
|
---|
1130 | {
|
---|
1131 | // get last directory used
|
---|
1132 | PSZ p = strrchr(pszNewBootLogoFile, '\\');
|
---|
1133 | if (p)
|
---|
1134 | {
|
---|
1135 | // contains directory:
|
---|
1136 | PSZ pszDir = strhSubstr(pszNewBootLogoFile, p + 1);
|
---|
1137 | strcpy(szFile, pszDir);
|
---|
1138 | free(pszDir);
|
---|
1139 | }
|
---|
1140 | free(pszNewBootLogoFile);
|
---|
1141 | }
|
---|
1142 | strcat(szFile, "*.bmp");
|
---|
1143 |
|
---|
1144 | /* if ( WinFileDlg(HWND_DESKTOP, // parent
|
---|
1145 | pnbp->hwndFrame, // owner
|
---|
1146 | &fd)
|
---|
1147 | && (fd.lReturn == DID_OK)
|
---|
1148 | ) */
|
---|
1149 | if (cmnFileDlg(pnbp->hwndFrame,
|
---|
1150 | szFile,
|
---|
1151 | 0, // WINH_FOD_INILOADDIR | WINH_FOD_INISAVEDIR,
|
---|
1152 | 0,
|
---|
1153 | 0,
|
---|
1154 | 0))
|
---|
1155 | {
|
---|
1156 | // copy file from FOD to page
|
---|
1157 | WinSetDlgItemText(pnbp->hwndDlgPage,
|
---|
1158 | ID_XSDI_DTP_LOGOFILE,
|
---|
1159 | szFile);
|
---|
1160 | PrfWriteProfileString(HINI_USER,
|
---|
1161 | (PSZ)INIAPP_XWORKPLACE,
|
---|
1162 | (PSZ)INIKEY_BOOTLOGOFILE,
|
---|
1163 | szFile);
|
---|
1164 | // update the display by calling the INIT callback
|
---|
1165 | pnbp->inbp.pfncbInitPage(pnbp, CBI_SET | CBI_ENABLE);
|
---|
1166 | }
|
---|
1167 | }
|
---|
1168 | break;
|
---|
1169 |
|
---|
1170 | /*
|
---|
1171 | * ID_XSDI_DTP_TESTLOGO:
|
---|
1172 | *
|
---|
1173 | */
|
---|
1174 |
|
---|
1175 | case ID_XSDI_DTP_TESTLOGO:
|
---|
1176 | {
|
---|
1177 | HDC hdcMem;
|
---|
1178 | HPS hpsMem;
|
---|
1179 | HBITMAP hbmBootLogo;
|
---|
1180 | ULONG ulError;
|
---|
1181 | SIZEL szlPage = {0, 0};
|
---|
1182 | HPOINTER hptrOld = winhSetWaitPointer();
|
---|
1183 |
|
---|
1184 | PSZ pszBootLogoFile = cmnQueryBootLogoFile();
|
---|
1185 |
|
---|
1186 | // attempt to load the boot logo
|
---|
1187 | if (gpihCreateMemPS(WinQueryAnchorBlock(pnbp->hwndDlgPage),
|
---|
1188 | &szlPage,
|
---|
1189 | &hdcMem,
|
---|
1190 | &hpsMem))
|
---|
1191 | {
|
---|
1192 | if (!gpihLoadBitmapFile(&hbmBootLogo,
|
---|
1193 | hpsMem,
|
---|
1194 | pszBootLogoFile))
|
---|
1195 | {
|
---|
1196 | if (cmnQuerySetting(sulBootLogoStyle) == 1)
|
---|
1197 | {
|
---|
1198 | // blow-up mode:
|
---|
1199 | HPS hpsScreen = WinGetScreenPS(HWND_DESKTOP);
|
---|
1200 | anmBlowUpBitmap(hpsScreen,
|
---|
1201 | hbmBootLogo,
|
---|
1202 | 1000); // total animation time
|
---|
1203 |
|
---|
1204 | DosSleep(2000);
|
---|
1205 |
|
---|
1206 | WinReleasePS(hpsScreen);
|
---|
1207 |
|
---|
1208 | // repaint all windows
|
---|
1209 | winhRepaintWindows(HWND_DESKTOP);
|
---|
1210 | }
|
---|
1211 | else
|
---|
1212 | {
|
---|
1213 | // transparent mode:
|
---|
1214 | SHAPEFRAME sf;
|
---|
1215 | SWP swpScreen;
|
---|
1216 |
|
---|
1217 | sf.hab = WinQueryAnchorBlock(pnbp->hwndDlgPage);
|
---|
1218 | sf.hps = hpsMem;
|
---|
1219 | sf.hbm = hbmBootLogo;
|
---|
1220 | sf.bmi.cbFix = sizeof(sf.bmi);
|
---|
1221 | GpiQueryBitmapInfoHeader(sf.hbm, &sf.bmi);
|
---|
1222 |
|
---|
1223 | // set ptlLowerLeft so that the bitmap
|
---|
1224 | // is centered on the screen
|
---|
1225 | WinQueryWindowPos(HWND_DESKTOP, &swpScreen);
|
---|
1226 | sf.ptlLowerLeft.x = (swpScreen.cx - sf.bmi.cx) / 2;
|
---|
1227 | sf.ptlLowerLeft.y = (swpScreen.cy - sf.bmi.cy) / 2;
|
---|
1228 |
|
---|
1229 | if (shpCreateWindows(&sf)) // this selects the bitmap into the HPS
|
---|
1230 | {
|
---|
1231 | DosSleep(2000);
|
---|
1232 |
|
---|
1233 | GpiSetBitmap(sf.hps, NULLHANDLE); // V0.9.3 (2000-04-11) [umoeller]
|
---|
1234 |
|
---|
1235 | WinDestroyWindow(sf.hwndShapeFrame) ;
|
---|
1236 | WinDestroyWindow(sf.hwndShape);
|
---|
1237 | }
|
---|
1238 | }
|
---|
1239 | // delete the bitmap again
|
---|
1240 | if (!GpiDeleteBitmap(hbmBootLogo))
|
---|
1241 | cmnLog(__FILE__, __LINE__, __FUNCTION__,
|
---|
1242 | "Unable to free bootlogo bitmap.");
|
---|
1243 | }
|
---|
1244 | GpiDestroyPS(hpsMem);
|
---|
1245 | DevCloseDC(hdcMem);
|
---|
1246 | }
|
---|
1247 | free(pszBootLogoFile);
|
---|
1248 |
|
---|
1249 | WinSetPointer(HWND_DESKTOP, hptrOld);
|
---|
1250 | }
|
---|
1251 | break;
|
---|
1252 | #endif
|
---|
1253 |
|
---|
1254 | #ifndef __NOXWPSTARTUP__
|
---|
1255 | /*
|
---|
1256 | *@@ ID_XSDI_DTP_CREATESTARTUPFLDR:
|
---|
1257 | * "Create startup folder"
|
---|
1258 | */
|
---|
1259 |
|
---|
1260 | case ID_XSDI_DTP_CREATESTARTUPFLDR:
|
---|
1261 | {
|
---|
1262 | CHAR szSetup[200];
|
---|
1263 | HOBJECT hObj;
|
---|
1264 | sprintf(szSetup,
|
---|
1265 | "DEFAULTVIEW=ICON;ICONVIEW=NONFLOWED,MINI;"
|
---|
1266 | "OBJECTID=%s;",
|
---|
1267 | XFOLDER_STARTUPID);
|
---|
1268 | if (hObj = WinCreateObject((PSZ)G_pcszXFldStartup,
|
---|
1269 | cmnGetString(ID_XFSI_XWPSTARTUPFDR), // "XWorkplace Startup",
|
---|
1270 | // finally localized V1.0.0 (2002-08-31) [umoeller]
|
---|
1271 | szSetup,
|
---|
1272 | (PSZ)WPOBJID_DESKTOP, // "<WP_DESKTOP>",
|
---|
1273 | CO_UPDATEIFEXISTS))
|
---|
1274 | WinEnableControl(pnbp->hwndDlgPage, ID_XSDI_DTP_CREATESTARTUPFLDR, FALSE);
|
---|
1275 | else
|
---|
1276 | cmnMessageBoxExt(pnbp->hwndFrame,
|
---|
1277 | 104,
|
---|
1278 | NULL, 0,
|
---|
1279 | 105,
|
---|
1280 | MB_OK);
|
---|
1281 | }
|
---|
1282 | break;
|
---|
1283 | #endif
|
---|
1284 |
|
---|
1285 | default:
|
---|
1286 | ;
|
---|
1287 | }
|
---|
1288 | } // end if (!fProcessed)
|
---|
1289 |
|
---|
1290 | return ((MPARAM)0);
|
---|
1291 | }
|
---|
1292 |
|
---|
1293 |
|
---|