home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: WPS_PM / WPS_PM.zip / xfld085s.zip / main / xfsys.c < prev    next >
C/C++ Source or Header  |  1999-03-02  |  207KB  |  5,069 lines

  1.  
  2. /*
  3.  *@@sourcefile xfsys.c:
  4.  *      This file contains the following major XFolder parts
  5.  *      (in this order):
  6.  *
  7.  *      --  XFldWPS notebook callbacks (for notebook.c)
  8.  *      --  XFldWPS SOM stuff
  9.  *      --  XFldSystem notebook callbacks (for notebook.c)
  10.  *      --  XFldSystem SOM stuff
  11.  *
  12.  *      Check the other files starting with xf* for the
  13.  *      other XFolder classes.
  14.  *
  15.  *      These classes implement the "Workplace Shell" and
  16.  *      "OS/2 Kernel" settings objects, respectively.
  17.  *
  18.  *      Installation of these classes is optional, but you
  19.  *      won't be able to change XFolder's settings without
  20.  *      them.
  21.  *
  22.  *      This file has undergone major changes with V0.82, but this
  23.  *      was mainly reorganized and clarified without introducing
  24.  *      new features.
  25.  *
  26.  *@@somclass XFldWPS xfwps_
  27.  *@@somclass M_XFldWPS xfwpsM_
  28.  *@@somclass XFldSystem xfsys_
  29.  *@@somclass M_XFldSystem xfsysM_
  30.  */
  31.  
  32. /*
  33.  *      Copyright (C) 1997-99 Ulrich Möller.
  34.  *      This file is part of the XFolder source package.
  35.  *      XFolder is free software; you can redistribute it and/or modify
  36.  *      it under the terms of the GNU General Public License as published
  37.  *      by the Free Software Foundation, in version 2 as it comes in the
  38.  *      "COPYING" file of the XFolder main distribution.
  39.  *      This program is distributed in the hope that it will be useful,
  40.  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
  41.  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  42.  *      GNU General Public License for more details.
  43.  */
  44.  
  45. /*
  46.  *  This file was generated by the SOM Compiler and Emitter Framework.
  47.  *  Generated using:
  48.  *      SOM Emitter emitctm: 2.41
  49.  */
  50.  
  51. #ifndef SOM_Module_xfsys_Source
  52. #define SOM_Module_xfsys_Source
  53. #endif
  54. #define xfsys_Class_Source
  55. #define M_xfsys_Class_Source
  56.  
  57. /*
  58.  *  Suggested #include order:
  59.  *  1)  os2.h
  60.  *  2)  C library headers
  61.  *  3)  SOM headers which work with precompiled header files
  62.  *  4)  headers in /helpers
  63.  *  5)  headers in /main with dlgids.h and common.h first
  64.  *  6)  #pragma hdrstop to prevent VAC++ crashes
  65.  *  7)  other needed SOM headers
  66.  *  8)  for non-SOM-class files: corresponding header (e.g. classlst.h)
  67.  */
  68.  
  69. #define INCL_DOSFILEMGR
  70. #define INCL_DOSMODULEMGR
  71. #define INCL_DOSPROCESS         // DosSleep, priorities, PIDs etc.
  72. #define INCL_DOSSEMAPHORES      // needed for xthreads.h
  73. #define INCL_DOSEXCEPTIONS
  74. #define INCL_DOSERRORS
  75. #define INCL_DOSDEVICES
  76. #define INCL_DOSDEVIOCTL
  77. #define INCL_DOSMISC            // DosGetMessage etc.
  78.  
  79. #define INCL_WINWINDOWMGR
  80. #define INCL_WINFRAMEMGR        // WM_FORMATFRAME, SC_CLOSE etc.
  81. #define INCL_WINSYS             // presparams, WinQuerySysValue()
  82. #define INCL_WINPOINTERS
  83. #define INCL_WININPUT           // WM_BUTTON1DOWN etc.
  84.  
  85. #define INCL_WINSHELLDATA       // profile funcs
  86. #define INCL_WINPROGRAMLIST     // needed for WPProgram
  87. #define INCL_WINCOUNTRY         // WinCompareStrings, WinUpper
  88. #define INCL_WINTIMER
  89. #define INCL_WINERRORS
  90. #define INCL_WINRECTANGLES      // rcl functions
  91. #define INCL_WINCLIPBOARD
  92. #define INCL_WINMESSAGEMGR      // sophisticated msg funcs
  93.  
  94. #define INCL_WINDIALOGS
  95. #define INCL_WINSTATICS
  96. #define INCL_WINMENUS           // needed for menus.h
  97. #define INCL_WINENTRYFIELDS
  98. #define INCL_WINBUTTONS
  99. #define INCL_WINLISTBOXES
  100.  
  101. #define INCL_WINSTDSPIN         // spin buttons
  102. #define INCL_WINSTDCNR          // needed for winh.h
  103. #define INCL_WINSTDBOOK         // notebooks
  104. #define INCL_WINSTDFILE         // file dialog
  105. #define INCL_WINMLE             // multi-line entry field
  106.  
  107. #define INCL_WINWORKPLACE
  108.  
  109. #include <os2.h>
  110.  
  111. // C library headers
  112. #include <stdio.h>              // needed for except.h
  113. #include <setjmp.h>             // needed for except.h
  114. #include <assert.h>             // needed for except.h
  115. #include <ctype.h>
  116.  
  117. // headers in /helpers
  118. #include "dosh.h"               // Control Program helper routines
  119. #include "winh.h"               // PM helper routines
  120.  
  121. #include "animate.h"            // icon and other animations
  122. #include "linklist.h"           // linked list helper routines
  123. #include "procstat.h"           // DosQProcStat handling
  124. #include "stringh.h"            // string helper routines
  125. #include "undoc.h"              // some undocumented stuff
  126.  
  127. // SOM headers which don't crash with prec. header files
  128. #include "xfsys.ih"
  129. #include "xfdesk.h"
  130. #include "xfldr.h"
  131. #include "xfobj.h"
  132.  
  133. // headers in /main
  134. #include "dlgids.h"             // all the IDs that are shared with NLS
  135. #include "common.h"             // the majestic XFolder include file
  136.  
  137. #include "classlst.h"           // SOM logic for "WPS Classes" page
  138. #include "cnrsort.h"            // container sort comparison functions
  139. #include "module.h"             // XFolder main DLL information
  140. #include "notebook.h"           // generic XFolder notebook handling
  141. #include "statbars.h"           // status bar translation logic
  142. #include "xthreads.h"           // XFolder threads; this includes threads.h
  143.  
  144. // other SOM headers
  145. #pragma hdrstop                 // VAC++ keeps crashing otherwise
  146.  
  147. // we include statbars.h last because we need the
  148. // WPFolder include before
  149.  
  150. // notebook callbacks for "Sort" page in xfldr.c
  151.  
  152. VOID fncbSortInitPage(PVOID pnbi, ULONG ulExtra);
  153.  
  154. MRESULT fncbSortItemChanged(PVOID pnbi,
  155.                 USHORT usItemID, USHORT usNotifyCode,
  156.                 ULONG ulExtra);
  157.  
  158. /* ******************************************************************
  159.  *                                                                  *
  160.  *   here come some notebook helper routines                        *
  161.  *                                                                  *
  162.  ********************************************************************/
  163.  
  164. /*
  165.  *@@ AddResourceDLLToLB:
  166.  *      this loads a given DLL temporarily in order to
  167.  *      find out if it's an XFolder NLS DLL; if so,
  168.  *      its language string is loaded and a descriptive
  169.  *      string is inserted into a given list box
  170.  *      (used for "XFolder Internals" settings page)
  171.  *
  172.  *@@changes 0.85 Language string now initialized to ""
  173.  */
  174.  
  175. VOID AddResourceDLLToLB(HWND hwndDlg, ULONG idLB, PSZ pszFileName)
  176. {
  177.     CHAR    szLBEntry[200] = "",   // changed V0.85
  178.             szResourceModuleName[CCHMAXPATH];
  179.     HMODULE hmodDLL = NULLHANDLE;
  180.     // PVOID   pProc;
  181.     ULONG   ulCopied;
  182.     APIRET  rc;
  183.  
  184.     #ifdef DEBUG_LANGCODES
  185.         _Pmpf(("  Entering AddResourceDLLtoLB: %s", pszFileName));
  186.     #endif
  187.     if (cmnQueryXFolderBasePath(szResourceModuleName))
  188.     {
  189.         strcat(szResourceModuleName, "\\bin\\");
  190.         strcat(szResourceModuleName, pszFileName);
  191.  
  192.         #ifdef DEBUG_LANGCODES
  193.             _Pmpf(("  Loading module '%s'", szResourceModuleName));
  194.         #endif
  195.         rc = DosLoadModule(NULL, 0,
  196.                       szResourceModuleName,
  197.                       &hmodDLL);
  198.         if (rc == NO_ERROR)
  199.         {
  200.             #ifdef DEBUG_LANGCODES
  201.                 _Pmpf(("  Testing for language string"));
  202.             #endif
  203.             if (WinLoadString(WinQueryAnchorBlock(HWND_DESKTOP), hmodDLL,
  204.                 ID_XSSI_DLLLANGUAGE, sizeof(szLBEntry), szLBEntry))
  205.             {
  206.                 #ifdef DEBUG_LANGCODES
  207.                     _Pmpf(("    found %s", szLBEntry));
  208.                 #endif
  209.                 strcat(szLBEntry, " -- ");
  210.                 strcat(szLBEntry, pszFileName);
  211.  
  212.                 WinSendDlgItemMsg(hwndDlg, idLB,
  213.                                 LM_INSERTITEM,
  214.                                 (MPARAM)LIT_SORTASCENDING,
  215.                                 (MPARAM)szLBEntry);
  216.             }
  217.  
  218.             DosFreeModule(hmodDLL);
  219.         }
  220.         #ifdef DEBUG_LANGCODES
  221.             else
  222.                 _Pmpf(("    Error %d", rc));
  223.         #endif
  224.     }
  225. }
  226.  
  227. /*
  228.  *  Folder hotkeys descriptions arrays:
  229.  *      every item these arrays must match exactly one
  230.  *      item in the ulLBCommands array in common.c.
  231.  */
  232.  
  233. CHAR  szLBEntries[FLDRHOTKEYCOUNT][MAXLBENTRYLENGTH];
  234.  
  235. ULONG szLBStringIDs[FLDRHOTKEYCOUNT] = {
  236.          ID_XSSI_LB_REFRESHNOW          ,
  237.          ID_XSSI_LB_SNAPTOGRID          ,
  238.          ID_XSSI_LB_SELECTALL           ,
  239.          ID_XSSI_LB_OPENPARENTFOLDER    ,
  240.  
  241.          ID_XSSI_LB_OPENSETTINGSNOTEBOOK,
  242.          ID_XSSI_LB_OPENNEWDETAILSVIEW  ,
  243.          ID_XSSI_LB_OPENNEWICONVIEW     ,
  244.          ID_XSSI_LB_DESELECTALL         ,
  245.          ID_XSSI_LB_OPENNEWTREEVIEW     ,
  246.  
  247.          ID_XSSI_LB_FIND                ,
  248.  
  249.          ID_XSSI_LB_PICKUP              ,
  250.          ID_XSSI_LB_PICKUPCANCELDRAG    ,
  251.  
  252.          ID_XSSI_LB_SORTBYNAME          ,
  253.          ID_XSSI_LB_SORTBYSIZE          ,
  254.          ID_XSSI_LB_SORTBYTYPE          ,
  255.          ID_XSSI_LB_SORTBYREALNAME      ,
  256.          ID_XSSI_LB_SORTBYWRITEDATE     ,
  257.          ID_XSSI_LB_SORTBYACCESSDATE    ,
  258.          ID_XSSI_LB_SORTBYCREATIONDATE  ,
  259.  
  260.          ID_XSSI_LB_SWITCHTOICONVIEW    ,
  261.          ID_XSSI_LB_SWITCHTODETAILSVIEW ,
  262.          ID_XSSI_LB_SWITCHTOTREEVIEW    ,
  263.  
  264.          ID_XSSI_LB_ARRANGEDEFAULT      ,
  265.          ID_XSSI_LB_ARRANGEFROMTOP      ,
  266.          ID_XSSI_LB_ARRANGEFROMLEFT     ,
  267.          ID_XSSI_LB_ARRANGEFROMRIGHT    ,
  268.          ID_XSSI_LB_ARRANGEFROMBOTTOM   ,
  269.          ID_XSSI_LB_ARRANGEPERIMETER    ,
  270.          ID_XSSI_LB_ARRANGEHORIZONTALLY ,
  271.          ID_XSSI_LB_ARRANGEVERTICALLY   ,
  272.  
  273.          ID_XSSI_LB_INSERT              ,
  274.  
  275.          ID_XSSI_LB_SORTBYEXTENSION     ,
  276.          ID_XSSI_LB_OPENPARENTFOLDERANDCLOSE,
  277.  
  278.          ID_XSSI_LB_CLOSEWINDOW,
  279.          ID_XSSI_LB_SELECTSOME,
  280.          ID_XSSI_LB_SORTFOLDERSFIRST,
  281.          ID_XSSI_LB_SORTBYCLASS,
  282.  
  283.          ID_XSSI_LB_CONTEXTMENU,
  284.          ID_XSSI_LB_TASKLIST,
  285.  
  286.          ID_XSSI_LB_COPYFILENAME_SHORT,
  287.          ID_XSSI_LB_COPYFILENAME_FULL
  288.  
  289.     };
  290.  
  291. ULONG ulLBCommands[FLDRHOTKEYCOUNT] = {
  292.         WPMENUID_REFRESH,
  293.         ID_XFMI_OFS_SNAPTOGRID,
  294.         WPMENUID_SELALL,
  295.         ID_XFMI_OFS_OPENPARENT,
  296.  
  297.         WPMENUID_PROPERTIES,
  298.         WPMENUID_DETAILS,
  299.         WPMENUID_ICON,
  300.         WPMENUID_DESELALL,
  301.         WPMENUID_TREE,
  302.  
  303.         WPMENUID_FIND,
  304.  
  305.         WPMENUID_PICKUP,
  306.         WPMENUID_PUTDOWN_CANCEL,
  307.  
  308.         ID_WPMI_SORTBYNAME,
  309.         ID_WPMI_SORTBYSIZE,
  310.         ID_WPMI_SORTBYTYPE,
  311.         ID_WPMI_SORTBYREALNAME,
  312.         ID_WPMI_SORTBYWRITEDATE,
  313.         ID_WPMI_SORTBYACCESSDATE,
  314.         ID_WPMI_SORTBYCREATIONDATE,
  315.  
  316.         ID_WPMI_SHOWICONVIEW,
  317.         ID_WPMI_SHOWDETAILSVIEW,
  318.         ID_WPMI_SHOWTREEVIEW,
  319.  
  320.         WPMENUID_ARRANGE,
  321.         ID_WPMI_ARRANGEFROMTOP,
  322.         ID_WPMI_ARRANGEFROMLEFT,
  323.         ID_WPMI_ARRANGEFROMRIGHT,
  324.         ID_WPMI_ARRANGEFROMBOTTOM,
  325.         ID_WPMI_ARRANGEPERIMETER,
  326.         ID_WPMI_ARRANGEHORIZONTALLY,
  327.         ID_WPMI_ARRANGEVERTICALLY,
  328.  
  329.         ID_WPMI_PASTE,
  330.  
  331.         ID_XFMI_OFS_SORTBYEXT,
  332.         ID_XFMI_OFS_OPENPARENTANDCLOSE,
  333.  
  334.         ID_XFMI_OFS_CLOSE,
  335.         ID_XFMI_OFS_SELECTSOME,
  336.         ID_XFMI_OFS_SORTFOLDERSFIRST,
  337.         ID_XFMI_OFS_SORTBYCLASS,
  338.  
  339.         ID_XFMI_OFS_CONTEXTMENU,
  340.         0x8011,                     // show task list (sysmenu)
  341.  
  342.         ID_XFMI_OFS_COPYFILENAME_SHORT,
  343.         ID_XFMI_OFS_COPYFILENAME_FULL
  344.     };
  345.  
  346. /*
  347.  *@@ FindHotkeyFromLBSel:
  348.  *      this subroutine finds an index to the global
  349.  *      FolderHotkeys[] array according to the currently
  350.  *      selected list box item. This is used on the
  351.  *      "Folder hotkeys" notebook page.
  352.  *      This returns:
  353.  *        NULL  if no accelerator has been defined yet
  354.  *          -1  if LB entries do not match array strings
  355.  *              (should not happen)
  356.  *       other: means that an accelerator has been defined.
  357.  *              We then return the pointer to the hotkey.
  358.  *      If pusCommand is != NULL, it will then contain the
  359.  *      menu "command" of the selected LB item, such that
  360.  *      a new accelerator can be created.
  361.  */
  362.  
  363. PXFLDHOTKEY FindHotkeyFromLBSel(HWND hwndDlg, USHORT *pusCommand)
  364. {
  365.     SHORT               i, i2 = 0;
  366.     CHAR                szTemp[MAXLBENTRYLENGTH];
  367.     SHORT               sItem;
  368.     SHORT               LBIndex = -1;
  369.     PXFLDHOTKEY         pHotkey = cmnQueryFldrHotkeys(),
  370.                         pHotkeyFound = NULL;
  371.  
  372.     sItem = (SHORT)WinSendDlgItemMsg(hwndDlg, ID_XSDI_LISTBOX,
  373.                             LM_QUERYSELECTION,
  374.                             (MPARAM)LIT_CURSOR,
  375.                             MPNULL);
  376.  
  377.     WinSendDlgItemMsg(hwndDlg, ID_XSDI_LISTBOX,
  378.                             LM_QUERYITEMTEXT,
  379.                             MPFROM2SHORT(sItem, sizeof(szTemp)),
  380.                             (MPARAM)szTemp);
  381.     // szTemp now contains the selected list box entry's text
  382.  
  383.     for (i = 0; i < FLDRHOTKEYCOUNT; i++)
  384.     {
  385.         if (strcmp(szTemp, szLBEntries[i]) == 0)
  386.         {
  387.             LBIndex = i;
  388.             break;
  389.         }
  390.     }
  391.     // i now contains the index in the listbox arrays:
  392.     // -- szLBEntries[] for the strings,
  393.     // -- ulLBCommands[] for the corresponding commands
  394.     // or -1 if not found.
  395.  
  396.     // item found?
  397.     if (LBIndex != -1)
  398.     {
  399.         // yes:
  400.         // loop thru the hotkeys array
  401.         while (pHotkey->usCommand)
  402.         {
  403.             if (pHotkey->usCommand == ulLBCommands[i])
  404.             {
  405.                 // hotkey defined for this listbox item already:
  406.                 pHotkeyFound = pHotkey;
  407.                 break;
  408.             }
  409.             // else: go for next item
  410.             pHotkey++;
  411.             i2++;
  412.         }
  413.  
  414.         if ( (pHotkeyFound == NULL) && (pusCommand) )
  415.             // hotkey not yet defined: store the command
  416.             // which corresponds to the selected item, so
  417.             // a new hotkey can be added
  418.             *pusCommand = ulLBCommands[i];
  419.  
  420.         return (pHotkeyFound);
  421.     }
  422.     else
  423.         return (PXFLDHOTKEY)-1;     // LB entry not found
  424. }
  425.  
  426. /*
  427.  *@@ fnwpHotkeyEntryField:
  428.  *      this is the window proc for the subclassed entry
  429.  *      field on the "Folder Hotkeys" notebook page. We will
  430.  *      intercept all WM_CHAR messages and set the entry field
  431.  *      display to the key description instead of the character.
  432.  *      Moreover, we will update the global folder hotkey array
  433.  *      according to the currently selected listbox item on that
  434.  *      page.
  435.  */
  436.  
  437. MRESULT EXPENTRY fnwpHotkeyEntryField(HWND hwndEdit, ULONG msg, MPARAM mp1, MPARAM mp2)
  438. {
  439.     // get original wnd proc; this was stored in the
  440.     // window words in xfsys.c
  441.     PFNWP       OldEditProc = (PFNWP)WinQueryWindowULong(hwndEdit, QWL_USER);
  442.  
  443.     MRESULT mrc = (MPARAM)FALSE; // WM_CHAR not-processed flag
  444.  
  445.     switch (msg) {
  446.         case WM_CHAR: {
  447.             int i, i3;
  448.             USHORT usCommand;
  449.             USHORT usKeyCode;
  450.             USHORT usFlags    = SHORT1FROMMP(mp1);
  451.             USHORT usch       = SHORT1FROMMP(mp2);
  452.             USHORT usvk       = SHORT2FROMMP(mp2);
  453.  
  454.             if (    ((usFlags & KC_KEYUP) == 0)
  455.                 &&  (     ((usFlags & KC_VIRTUALKEY) != 0)
  456.                        || ((usFlags & KC_CTRL) != 0)
  457.                        || ((usFlags & KC_ALT) != 0)
  458.                        || (   ((usFlags & KC_VIRTUALKEY) == 0)
  459.                            && (     (usch == 0xEC00)
  460.                                 ||  (usch == 0xED00)
  461.                                 ||  (usch == 0xEE00)
  462.                               )
  463.                           )
  464.                     )
  465.                )
  466.             {
  467.                 PXFLDHOTKEY pHotkeyFound = NULL;
  468.  
  469.                 usFlags &= (KC_VIRTUALKEY | KC_CTRL | KC_ALT | KC_SHIFT);
  470.                 if (usFlags & KC_VIRTUALKEY)
  471.                     usKeyCode = usvk;
  472.                 else
  473.                     usKeyCode = usch;
  474.  
  475.                 pHotkeyFound = FindHotkeyFromLBSel(WinQueryWindow(hwndEdit, QW_PARENT),
  476.                                              &usCommand);
  477.  
  478.                 #ifdef DEBUG_KEYS
  479.                     _Pmpf(("List box index: %d", i));
  480.                 #endif
  481.  
  482.                 if (pHotkeyFound == NULL)
  483.                 {
  484.                     // no hotkey defined yet: append a new one
  485.                     pHotkeyFound = cmnQueryFldrHotkeys();
  486.  
  487.                     // go to the end of the list
  488.                     while (pHotkeyFound->usCommand)
  489.                         pHotkeyFound++;
  490.  
  491.                     pHotkeyFound->usCommand = usCommand;
  492.                     // set a new list terminator
  493.                     (*(pHotkeyFound+1)).usCommand = 0;
  494.  
  495.                 }
  496.  
  497.                 if ((ULONG)pHotkeyFound != -1)
  498.                 {
  499.                     // no error: set hotkey data
  500.                     CHAR szKeyName[200];
  501.                     pHotkeyFound->usFlags      = usFlags;
  502.                     pHotkeyFound->usKeyCode    = usKeyCode;
  503.                     #ifdef DEBUG_KEYS
  504.                         _Pmpf(("Stored usFlags = 0x%lX, usKeyCode = 0x%lX", usFlags, usKeyCode));
  505.                     #endif
  506.  
  507.                     // show description
  508.                     cmnDescribeKey(szKeyName, usFlags, usKeyCode);
  509.                     WinSetWindowText(hwndEdit, szKeyName);
  510.                     winhEnableDlgItem(WinQueryWindow(hwndEdit, QW_PARENT),
  511.                             ID_XSDI_CLEARACCEL, TRUE);
  512.  
  513.                     // save hotkeys to INIs
  514.                     cmnStoreFldrHotkeys();
  515.  
  516.                     mrc = (MPARAM)TRUE; // WM_CHAR processed flag;
  517.                 }
  518.             }
  519.         break; }
  520.  
  521.         default:
  522.             mrc = OldEditProc(hwndEdit, msg, mp1, mp2);
  523.     }
  524.     return (mrc);
  525. }
  526.  
  527. /* ******************************************************************
  528.  *                                                                  *
  529.  *   "Workplace Shell" notebook callbacks                           *
  530.  *                                                                  *
  531.  ********************************************************************/
  532.  
  533. /*
  534.  *  All the following functions starting with fncbWPS* are callbacks
  535.  *  for the common notebook dlg function in notebook.c. There are
  536.  *  two callbacks for each notebook page in "Workplace Shell", one
  537.  *  for (re)initializing the page's controls and one for reacting
  538.  *  to controls being changed by the user.
  539.  *  These callbacks are specified in xfwps::xfAddXFldWPSPages.
  540.  *  These callbacks are all new with V0.82 and replace the awful
  541.  *  dialog procedures which were previously used, because these
  542.  *  became hard to maintain over time.
  543.  */
  544.  
  545. /*
  546.  *@@ fncbWPSXFolder1InitPage:
  547.  *      notebook callback function (notebook.c) for the
  548.  *      first "XFolder" page in "Workplace Shell" object.
  549.  *      Sets the controls on the page according to the
  550.  *      Global Settings.
  551.  */
  552.  
  553. VOID fncbWPSXFolder1InitPage(PVOID pnbi,   // notebook info struct
  554.                          ULONG ulExtra)        // INIT_* flags (notebook.h)
  555. {
  556.     PCREATENOTEBOOKPAGE pcnbp = (PCREATENOTEBOOKPAGE)pnbi;
  557.     PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  558.  
  559.     if (ulExtra & CBI_INIT)
  560.     {
  561.         if (pcnbp->pBackup == NULL)
  562.         {
  563.             // first call: backup Global Settings for "Undo" button;
  564.             // this memory will be freed automatically by the
  565.             // common notebook window function (notebook.c) when
  566.             // the notebook page is destroyed
  567.             pcnbp->pBackup = malloc(sizeof(GLOBALSETTINGS));
  568.             memcpy(pcnbp->pBackup, pGlobalSettings, sizeof(GLOBALSETTINGS));
  569.         }
  570.     }
  571.  
  572.     if (ulExtra & CBI_SET)
  573.     {
  574.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_ADDINTERNALS,
  575.                 pGlobalSettings->ShowInternals);
  576.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_REPLICONS,
  577.                 pGlobalSettings->ReplIcons);
  578.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_FULLPATH,
  579.                 pGlobalSettings->FullPath);
  580.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_KEEPTITLE,
  581.                 pGlobalSettings->KeepTitle);
  582.         // maximum path chars spin button
  583.         winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_MAXPATHCHARS,
  584.                 11, 200,        // limits
  585.                 pGlobalSettings->MaxPathChars);  // data
  586.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_TREEVIEWAUTOSCROLL,
  587.                 pGlobalSettings->TreeViewAutoScroll);
  588.     }
  589.  
  590.     if (ulExtra & CBI_ENABLE)
  591.     {
  592.         winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_TREEVIEWAUTOSCROLL,
  593.                 (    (pGlobalSettings->NoWorkerThread == FALSE)
  594.                   && (pGlobalSettings->NoSubclassing == FALSE)
  595.                 ));
  596.     }
  597. }
  598.  
  599. /*
  600.  *@@ fncbWPSXFolder1ItemChanged:
  601.  *      notebook callback function (notebook.c) for the
  602.  *      first "XFolder" page in "Workplace Shell" object.
  603.  *      Reacts to changes of any of the dialog controls.
  604.  */
  605.  
  606. MRESULT fncbWPSXFolder1ItemChanged(PVOID pnbi,
  607.                 USHORT usItemID, USHORT usNotifyCode,
  608.                 ULONG ulExtra)      // for checkboxes: contains new state
  609. {
  610.     PCREATENOTEBOOKPAGE pcnbp = (PCREATENOTEBOOKPAGE)pnbi;
  611.     PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  612.     BOOL fSave = TRUE,
  613.          fUpdate = FALSE;
  614.  
  615.     LONG lTemp;
  616.  
  617.     switch (usItemID) {
  618.         case ID_XSDI_ADDINTERNALS:
  619.             pGlobalSettings->ShowInternals = ulExtra;
  620.         break;
  621.  
  622.         case ID_XSDI_REPLICONS:
  623.             pGlobalSettings->ReplIcons = ulExtra;
  624.         break;
  625.  
  626.         case ID_XSDI_FULLPATH:
  627.             pGlobalSettings->FullPath  = ulExtra;
  628.             fUpdate = TRUE;
  629.         break;
  630.  
  631.         case ID_XSDI_KEEPTITLE:
  632.             pGlobalSettings->KeepTitle = ulExtra;
  633.             fUpdate = TRUE;
  634.         break;
  635.  
  636.         case ID_XSDI_TREEVIEWAUTOSCROLL:
  637.             pGlobalSettings->TreeViewAutoScroll = ulExtra;
  638.         break;
  639.  
  640.         case ID_XSDI_MAXPATHCHARS:  // spinbutton
  641.             pGlobalSettings->MaxPathChars = ulExtra;
  642.             fUpdate = TRUE;
  643.         break;
  644.  
  645.         case DID_UNDO: {
  646.             // "Undo" button: get pointer to backed-up Global Settings
  647.             PGLOBALSETTINGS pGSBackup = (PGLOBALSETTINGS)(pcnbp->pBackup);
  648.  
  649.             // and restore the settings for this page
  650.             pGlobalSettings->ShowInternals = pGSBackup->ShowInternals;
  651.             pGlobalSettings->ReplIcons = pGSBackup->ReplIcons;
  652.             pGlobalSettings->FullPath  = pGSBackup->FullPath ;
  653.             pGlobalSettings->KeepTitle = pGSBackup->KeepTitle;
  654.             pGlobalSettings->TreeViewAutoScroll = pGSBackup->TreeViewAutoScroll;
  655.             pGlobalSettings->MaxPathChars = pGSBackup->MaxPathChars;
  656.  
  657.             // update the display by calling the INIT callback
  658.             (*(pcnbp->pfncbInitPage))(pnbi, CBI_SET | CBI_ENABLE);
  659.             fUpdate = TRUE;
  660.         break; }
  661.  
  662.         case DID_DEFAULT: {
  663.             // set the default settings for this settings page
  664.             // (this is in common.c because it's also used at
  665.             // WPS startup)
  666.             cmnSetDefaultSettings(pcnbp->ulPageID);
  667.             // update the display by calling the INIT callback
  668.             (*(pcnbp->pfncbInitPage))(pnbi, CBI_SET | CBI_ENABLE);
  669.             fUpdate = TRUE;
  670.         break; }
  671.  
  672.         default:
  673.             fSave = FALSE;
  674.     }
  675.  
  676.     if (fSave)
  677.         cmnStoreGlobalSettings();
  678.  
  679.     if (fUpdate)
  680.         // have Worker thread update all open folder windows
  681.         // with the full-path-in-title settings
  682.         xthrPostWorkerMsg(WOM_REFRESHFOLDERVIEWS,
  683.                 (MPARAM)NULL, // update all, not just children
  684.                 MPNULL);
  685.  
  686.     return ((MPARAM)-1);
  687. }
  688.  
  689. /*
  690.  *@@ fncbWPSXFolder2InitPage:
  691.  *      notebook callback function (notebook.c) for the
  692.  *      second "XFolder" page in "Workplace Shell" object.
  693.  *      Sets the controls on the page according to the
  694.  *      Global Settings.
  695.  */
  696.  
  697. VOID fncbWPSXFolder2InitPage(PVOID pnbi,   // notebook info struct
  698.                          ULONG ulExtra)        // INIT_* flags (notebook.h)
  699. {
  700.     PCREATENOTEBOOKPAGE pcnbp = (PCREATENOTEBOOKPAGE)pnbi;
  701.     PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  702.  
  703.     if (ulExtra & CBI_INIT)
  704.     {
  705.         if (pcnbp->pBackup == NULL)
  706.         {
  707.             // first call: backup Global Settings for "Undo" button;
  708.             // this memory will be freed automatically by the
  709.             // common notebook window function (notebook.c) when
  710.             // the notebook page is destroyed
  711.             pcnbp->pBackup = malloc(sizeof(GLOBALSETTINGS));
  712.             memcpy(pcnbp->pBackup, pGlobalSettings, sizeof(GLOBALSETTINGS));
  713.             pcnbp->pBackup2 = malloc(DEFAULTTITLELENGTH);
  714.             strcpy(pcnbp->pBackup2, _wpclsQueryTitle(_WPFolder));
  715.         }
  716.     }
  717.  
  718.     if (ulExtra & CBI_SET)
  719.     {
  720.         CHAR          szSearchMask[CCHMAXPATH];
  721.         HDIR          hdirFindHandle = HDIR_SYSTEM;
  722.         FILEFINDBUF3  FindBuffer     = {0};      // Returned from FindFirst/Next
  723.         ULONG         ulResultBufLen = sizeof(FILEFINDBUF3);
  724.         ULONG         ulFindCount    = 1;        // Look for 1 file at a time
  725.         APIRET        rc             = NO_ERROR; // Return code
  726.         ULONG         ulCopied;
  727.  
  728.         // variable menu ID offset spin button
  729.         winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_VARMENUOFFSET, 100, 2000, pGlobalSettings->VarMenuOffset);
  730.  
  731.         // default class title entry field
  732.         WinSetDlgItemText(pcnbp->hwndPage, ID_XSDI_DEFAULTTITLE,
  733.                          _wpclsQueryTitle(_WPFolder));
  734.  
  735.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_NOWORKERTHREAD, pGlobalSettings->NoWorkerThread);
  736.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_NOSUBCLASSING,  pGlobalSettings->NoSubclassing);
  737.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_XFOLDERANIMATION,  pGlobalSettings->ShowXFolderAnim);
  738.  
  739.         // language drop-down box
  740.         WinSendDlgItemMsg(pcnbp->hwndPage, ID_XSDI_LANGUAGE, LM_DELETEALL, 0, 0);
  741.  
  742.         if (cmnQueryXFolderBasePath(szSearchMask))
  743.         {
  744.             strcat(szSearchMask, "\\bin\\xfldr*.dll");
  745.  
  746.             #ifdef DEBUG_LANGCODES
  747.                 _Pmpf(("  szSearchMask: %s", szSearchMask));
  748.                 _Pmpf(("  DosFindFirst"));
  749.             #endif
  750.             rc = DosFindFirst( szSearchMask,          // File pattern
  751.                                 &hdirFindHandle,      // Directory search handle
  752.                                 FILE_NORMAL,          // Search attribute
  753.                                 &FindBuffer,          // Result buffer
  754.                                 ulResultBufLen,       // Result buffer length
  755.                                 &ulFindCount,         // Number of entries to find
  756.                                 FIL_STANDARD);        // Return level 1 file info
  757.  
  758.             if (rc != NO_ERROR) {
  759.                 DebugBox("XFolder", "XFolder was unable to find any National Language Support DLLs. You need to re-install XFolder.");
  760.             } else {
  761.                 // no error:
  762.                 #ifdef DEBUG_LANGCODES
  763.                     _Pmpf(("  Found file: %s", FindBuffer.achName));
  764.                 #endif
  765.                 AddResourceDLLToLB(pcnbp->hwndPage, ID_XSDI_LANGUAGE, FindBuffer.achName);
  766.  
  767.                 // Keep finding the next file until there are no more files
  768.                 while (rc != ERROR_NO_MORE_FILES) {
  769.                     ulFindCount = 1;                      // Reset find count.
  770.  
  771.                     rc = DosFindNext(hdirFindHandle,      // Directory handle
  772.                                      &FindBuffer,         // Result buffer
  773.                                      ulResultBufLen,      // Result buffer length
  774.                                      &ulFindCount);       // Number of entries to find
  775.  
  776.                     if (rc == NO_ERROR) {
  777.                         AddResourceDLLToLB(pcnbp->hwndPage, ID_XSDI_LANGUAGE, FindBuffer.achName);
  778.                         #ifdef DEBUG_LANGCODES
  779.                             _Pmpf(("  Found next: %s", FindBuffer.achName));
  780.                         #endif
  781.                     }
  782.                 } // endwhile
  783.  
  784.                 rc = DosFindClose(hdirFindHandle);    // close our find handle
  785.                 if (rc != NO_ERROR) {
  786.                     DebugBox("XFolder", "DosFindClose error");
  787.                 }
  788.  
  789.                 #ifdef DEBUG_LANGCODES
  790.                     _Pmpf(("  Selecting: %s", cmnQueryLanguageCode()));
  791.                 #endif
  792.                 WinSendDlgItemMsg(pcnbp->hwndPage, ID_XSDI_LANGUAGE,
  793.                     LM_SELECTITEM,
  794.                     WinSendDlgItemMsg(pcnbp->hwndPage, ID_XSDI_LANGUAGE, // find matching item
  795.                         LM_SEARCHSTRING,
  796.                         MPFROM2SHORT(LSS_SUBSTRING, LIT_FIRST),
  797.                         (MPARAM)cmnQueryLanguageCode()),
  798.                     (MPARAM)TRUE); // select
  799.             }
  800.         }
  801.     }
  802. }
  803.  
  804. /*
  805.  *@@ fncbWPSXFolder2ItemChanged:
  806.  *      notebook callback function (notebook.c) for the
  807.  *      second "XFolder" page in "Workplace Shell" object.
  808.  *      Reacts to changes of any of the dialog controls.
  809.  */
  810.  
  811. MRESULT fncbWPSXFolder2ItemChanged(PVOID pnbi,
  812.                 USHORT usItemID, USHORT usNotifyCode,
  813.                 ULONG ulExtra)      // for checkboxes: contains new state
  814. {
  815.     PCREATENOTEBOOKPAGE pcnbp = (PCREATENOTEBOOKPAGE)pnbi;
  816.     PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  817.     BOOL fSave = TRUE,
  818.          fUpdateOtherPages = FALSE;
  819.     CHAR szTemp[200];
  820.  
  821.     switch (usItemID) {
  822.         case ID_XSDI_XFOLDERANIMATION:
  823.             pGlobalSettings->ShowXFolderAnim = ulExtra;
  824.         break;
  825.  
  826.         case ID_XSDI_NOWORKERTHREAD:
  827.             pGlobalSettings->NoWorkerThread  = ulExtra;
  828.             // set flag to iterate over other notebook pages
  829.             fUpdateOtherPages = TRUE;
  830.         break;
  831.  
  832.         case ID_XSDI_NOSUBCLASSING:
  833.             pGlobalSettings->NoSubclassing   = ulExtra;
  834.             // set flag to iterate over other notebook pages
  835.             fUpdateOtherPages = TRUE;
  836.         break;
  837.  
  838.         // language drop-down box: load/unload resource modules
  839.         case ID_XSDI_LANGUAGE: {
  840.             if (usNotifyCode == LN_SELECT)
  841.             {
  842.                 CHAR   szOldLanguageCode[LANGUAGECODELENGTH];
  843.                 LONG   lTemp2 = 0;
  844.                 CHAR   szTemp2[10];
  845.                 PSZ    p;
  846.  
  847.                 strcpy(szOldLanguageCode, cmnQueryLanguageCode());
  848.  
  849.                 WinQueryDlgItemText(pcnbp->hwndPage, ID_XSDI_LANGUAGE,
  850.                         sizeof(szTemp),
  851.                         szTemp);
  852.                 p = strhistr(szTemp, " -- XFLDR")+9; // my own case-insensitive routine
  853.                 if (p) {
  854.                     strncpy(szTemp2, p, 3);
  855.                     szTemp2[4] = '\0';
  856.                     cmnSetLanguageCode(szTemp2);
  857.                 }
  858.  
  859.                 // did language really change?
  860.                 if (strcmp(szOldLanguageCode, cmnQueryLanguageCode()) != 0)
  861.                 {
  862.                     // enforce reload of resource DLL
  863.                     if (cmnQueryNLSModuleHandle(
  864.                                 TRUE        // reload flag
  865.                        ) == NULLHANDLE)
  866.                     {
  867.                         // error occured loading the module: restore
  868.                         //   old language
  869.                         cmnSetLanguageCode(szOldLanguageCode);
  870.                         // update display
  871.                         (*(pcnbp->pfncbInitPage))(pnbi, CBI_SET | CBI_ENABLE);
  872.                     }
  873.                     else {
  874.                         HWND      hwndSystemFrame,
  875.                                   hwndCurrent = pcnbp->hwndPage;
  876.                         HWND      hwndDesktop = WinQueryDesktopWindow(
  877.                                     WinQueryAnchorBlock(HWND_DESKTOP), NULLHANDLE);
  878.  
  879.                         // "closing system window"
  880.                         cmnMessageBoxMsg(pcnbp->hwndPage,
  881.                                         // set the page as the owner, so the
  882.                                         // user cannot switch pages any more
  883.                                 102, 103,
  884.                                 MB_OK);
  885.  
  886.                         // find frame window handle of "Workplace Shell" window
  887.                         while ((hwndCurrent) && (hwndCurrent != hwndDesktop)) {
  888.                             hwndSystemFrame = hwndCurrent;
  889.                             hwndCurrent = WinQueryWindow(hwndCurrent, QW_PARENT);
  890.                         }
  891.                         if (hwndCurrent)
  892.                             WinPostMsg(hwndSystemFrame,
  893.                                 WM_SYSCOMMAND,
  894.                                 (MPARAM)SC_CLOSE,
  895.                                 MPFROM2SHORT(0, 0));
  896.                     }
  897.                 } // end if (strcmp(szOldLanguageCode, szLanguageCode) != 0)
  898.             } // end if (usNotifyCode == LN_SELECT)
  899.         break; }
  900.  
  901.         case ID_XSDI_VARMENUOFFSET:
  902.             pGlobalSettings->VarMenuOffset = ulExtra;
  903.         break;
  904.  
  905.         case ID_XSDI_DEFAULTTITLE: {
  906.             WinQueryDlgItemText(pcnbp->hwndPage, ID_XSDI_DEFAULTTITLE,
  907.                              sizeof(szTemp),
  908.                              szTemp);
  909.             _xfclsSetDefaultTitle(_XFolder, szTemp);
  910.         break; }
  911.  
  912.         case DID_UNDO: {
  913.             // "Undo" button: get pointer to backed-up Global Settings
  914.             PGLOBALSETTINGS pGSBackup = (PGLOBALSETTINGS)(pcnbp->pBackup);
  915.  
  916.             // and restore the settings for this page
  917.             pGlobalSettings->ShowXFolderAnim = pGSBackup->ShowXFolderAnim;
  918.             pGlobalSettings->NoWorkerThread  = pGSBackup->NoWorkerThread;
  919.             pGlobalSettings->NoSubclassing   = pGSBackup->NoSubclassing;
  920.             pGlobalSettings->VarMenuOffset   = pGSBackup->VarMenuOffset;
  921.             _xfclsSetDefaultTitle(_XFolder, pcnbp->pBackup2);
  922.  
  923.             // update the display by calling the INIT callback
  924.             (*(pcnbp->pfncbInitPage))(pnbi, CBI_SET | CBI_ENABLE);
  925.         break; }
  926.  
  927.         case DID_DEFAULT: {
  928.             // set the default settings for this settings page
  929.             // (this is in common.c because it's also used at
  930.             // WPS startup)
  931.             cmnSetDefaultSettings(pcnbp->ulPageID);
  932.             _xfclsSetDefaultTitle(_XFolder, "XFolder");
  933.             // update the display by calling the INIT callback
  934.             (*(pcnbp->pfncbInitPage))(pnbi, CBI_SET | CBI_ENABLE);
  935.         break; }
  936.  
  937.         default:
  938.             fSave = FALSE;
  939.     }
  940.  
  941.     if (fSave)
  942.         cmnStoreGlobalSettings();
  943.  
  944.     if (fUpdateOtherPages) {
  945.         PCREATENOTEBOOKPAGE pcnbp = NULL;
  946.         // iterate over all currently open notebook pages
  947.         while (pcnbp = ntbQueryOpenPages(pcnbp)) {
  948.             if (pcnbp->fPageVisible)
  949.                 if (pcnbp->pfncbInitPage)
  950.                     // enable/disable items on visible page
  951.                     (*(pcnbp->pfncbInitPage))(pcnbp, CBI_ENABLE);
  952.         }
  953.     }
  954.  
  955.     return ((MPARAM)-1);
  956. }
  957.  
  958. /*
  959.  *@@ fncbWPSFileOpsInitPage:
  960.  *      notebook callback function (notebook.c) for the
  961.  *      "File operations" page in "Workplace Shell"
  962.  *      object.
  963.  *      Sets the controls on the page according to the
  964.  *      Global Settings.
  965.  */
  966.  
  967. VOID fncbWPSFileOpsInitPage(PVOID pnbi,   // notebook info struct
  968.                          ULONG ulExtra)        // INIT_* flags (notebook.h)
  969. {
  970.     PCREATENOTEBOOKPAGE pcnbp = (PCREATENOTEBOOKPAGE)pnbi;
  971.     PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  972.  
  973.     if (ulExtra & CBI_INIT)
  974.     {
  975.         if (pcnbp->pBackup == NULL)
  976.         {
  977.             // first call: backup Global Settings for "Undo" button;
  978.             // this memory will be freed automatically by the
  979.             // common notebook window function (notebook.c) when
  980.             // the notebook page is destroyed
  981.             pcnbp->pBackup = malloc(sizeof(GLOBALSETTINGS));
  982.             memcpy(pcnbp->pBackup, pGlobalSettings, sizeof(GLOBALSETTINGS));
  983.         }
  984.     }
  985.  
  986.     if (ulExtra & CBI_SET)
  987.     {
  988.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_CLEANUPINIS,
  989.                 pGlobalSettings->CleanupINIs);
  990.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_REPLCONFIRMS,
  991.                 pGlobalSettings->ReplConfirms);
  992.     }
  993.  
  994.     if (ulExtra & CBI_ENABLE)
  995.     {
  996.         winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_CLEANUPINIS,
  997.                 !(pGlobalSettings->NoWorkerThread));
  998.     }
  999. }
  1000.  
  1001. /*
  1002.  *@@ fncbWPSFileOpsChanged:
  1003.  *      notebook callback function (notebook.c) for the
  1004.  *      "File operations" page in "Workplace Shell"
  1005.  *      object.
  1006.  *      Reacts to changes of any of the dialog controls.
  1007.  */
  1008.  
  1009. MRESULT fncbWPSFileOpsItemChanged(PVOID pnbi,
  1010.                 USHORT usItemID, USHORT usNotifyCode,
  1011.                 ULONG ulExtra)      // for checkboxes: contains new state
  1012. {
  1013.     PCREATENOTEBOOKPAGE pcnbp = (PCREATENOTEBOOKPAGE)pnbi;
  1014.     PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  1015.     BOOL fSave = TRUE;
  1016.  
  1017.     switch (usItemID) {
  1018.         case ID_XSDI_REPLCONFIRMS:
  1019.             pGlobalSettings->ReplConfirms = ulExtra;
  1020.         break;
  1021.  
  1022.         case ID_XSDI_CLEANUPINIS:
  1023.             pGlobalSettings->CleanupINIs = ulExtra;
  1024.         break;
  1025.  
  1026.         case DID_UNDO: {
  1027.             // "Undo" button: get pointer to backed-up Global Settings
  1028.             PGLOBALSETTINGS pGSBackup = (PGLOBALSETTINGS)(pcnbp->pBackup);
  1029.  
  1030.             // and restore the settings for this page
  1031.             pGlobalSettings->ReplConfirms = pGSBackup->ReplConfirms;
  1032.             pGlobalSettings->CleanupINIs = pGSBackup->CleanupINIs;
  1033.  
  1034.             // update the display by calling the INIT callback
  1035.             (*(pcnbp->pfncbInitPage))(pnbi, CBI_SET | CBI_ENABLE);
  1036.         break; }
  1037.  
  1038.         case DID_DEFAULT: {
  1039.             // set the default settings for this settings page
  1040.             // (this is in common.c because it's also used at
  1041.             // WPS startup)
  1042.             cmnSetDefaultSettings(pcnbp->ulPageID);
  1043.             // update the display by calling the INIT callback
  1044.             (*(pcnbp->pfncbInitPage))(pnbi, CBI_SET | CBI_ENABLE);
  1045.         break; }
  1046.  
  1047.         default:
  1048.             fSave = FALSE;
  1049.     }
  1050.  
  1051.     if (fSave)
  1052.         cmnStoreGlobalSettings();
  1053.  
  1054.     return ((MPARAM)-1);
  1055. }
  1056.  
  1057. /*
  1058.  *@@ fncbWPSAddMenusInitPage:
  1059.  *      notebook callback function (notebook.c) for the
  1060.  *      first "Context Menus" page in "Workplace Shell"
  1061.  *      object ("Add menu items").
  1062.  *      Sets the controls on the page according to the
  1063.  *      Global Settings.
  1064.  */
  1065.  
  1066. VOID fncbWPSAddMenusInitPage(PVOID pnbi,   // notebook info struct
  1067.                          ULONG ulExtra)        // INIT_* flags (notebook.h)
  1068. {
  1069.     PCREATENOTEBOOKPAGE pcnbp = (PCREATENOTEBOOKPAGE)pnbi;
  1070.     PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  1071.  
  1072.     if (ulExtra & CBI_INIT)
  1073.     {
  1074.         if (pcnbp->pBackup == NULL)
  1075.         {
  1076.             // first call: backup Global Settings for "Undo" button;
  1077.             // this memory will be freed automatically by the
  1078.             // common notebook window function (notebook.c) when
  1079.             // the notebook page is destroyed
  1080.             pcnbp->pBackup = malloc(sizeof(GLOBALSETTINGS));
  1081.             memcpy(pcnbp->pBackup, pGlobalSettings, sizeof(GLOBALSETTINGS));
  1082.         }
  1083.     }
  1084.  
  1085.     if (ulExtra & CBI_SET)
  1086.     {
  1087.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_FILEATTRIBS,
  1088.                 pGlobalSettings->FileAttribs);
  1089.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_COPYFILENAME,
  1090.                 pGlobalSettings->AddCopyFilenameItem);
  1091.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_FLDRVIEWS,
  1092.                 pGlobalSettings->ExtendFldrViewMenu);
  1093.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_MOVE4REFRESH,
  1094.                 pGlobalSettings->MoveRefreshNow);
  1095.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_SELECTSOME,
  1096.                 pGlobalSettings->AddSelectSomeItem);
  1097.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_FOLDERCONTENT,
  1098.                 pGlobalSettings->AddFolderContentItem);
  1099.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_FC_SHOWICONS,
  1100.                 pGlobalSettings->FCShowIcons);
  1101.     }
  1102.  
  1103.     if (ulExtra & CBI_ENABLE)
  1104.     {
  1105.         BOOL fIsWarp4 = doshIsWarp4();
  1106.         BOOL fViewVisible =
  1107.                (    ( (fIsWarp4)  && (pGlobalSettings->RemoveViewMenu == 0) )
  1108.                  || ( (!fIsWarp4) && ((pGlobalSettings->DefaultMenuItems & CTXT_SELECT) == 0)
  1109.                ));
  1110.         winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_FOLDERCONTENT,
  1111.                 !(pGlobalSettings->NoSubclassing));
  1112.         winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_FC_SHOWICONS,
  1113.                 !(pGlobalSettings->NoSubclassing));
  1114.         winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_SELECTSOME, fViewVisible);
  1115.         winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_FLDRVIEWS, fViewVisible);
  1116.     }
  1117. }
  1118.  
  1119. /*
  1120.  *@@ fncbWPSAddMenusItemChanged:
  1121.  *      notebook callback function (notebook.c) for the
  1122.  *      first "Context Menus" page in "Workplace Shell"
  1123.  *      object ("Add menu items").
  1124.  *      Reacts to changes of any of the dialog controls.
  1125.  */
  1126.  
  1127. MRESULT fncbWPSAddMenusItemChanged(PVOID pnbi,
  1128.                 USHORT usItemID, USHORT usNotifyCode,
  1129.                 ULONG ulExtra)      // for checkboxes: contains new state
  1130. {
  1131.     PCREATENOTEBOOKPAGE pcnbp = (PCREATENOTEBOOKPAGE)pnbi;
  1132.     PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  1133.     BOOL fSave = TRUE;
  1134.  
  1135.     switch (usItemID) {
  1136.         case ID_XSDI_FILEATTRIBS:
  1137.             pGlobalSettings->FileAttribs = ulExtra;
  1138.         break;
  1139.  
  1140.         case ID_XSDI_COPYFILENAME:
  1141.             pGlobalSettings->AddCopyFilenameItem = ulExtra;
  1142.         break;
  1143.  
  1144.         case ID_XSDI_FLDRVIEWS:
  1145.             pGlobalSettings->ExtendFldrViewMenu = ulExtra;
  1146.         break;
  1147.  
  1148.         case ID_XSDI_MOVE4REFRESH:
  1149.             pGlobalSettings->MoveRefreshNow = ulExtra;
  1150.         break;
  1151.  
  1152.         case ID_XSDI_SELECTSOME:
  1153.             pGlobalSettings->AddSelectSomeItem = ulExtra;
  1154.         break;
  1155.  
  1156.         case ID_XSDI_FOLDERCONTENT:
  1157.             pGlobalSettings->AddFolderContentItem = ulExtra;
  1158.         break;
  1159.  
  1160.         case ID_XSDI_FC_SHOWICONS:
  1161.             pGlobalSettings->FCShowIcons = ulExtra;
  1162.             if (ulExtra)
  1163.                 // enabled: show warning msg box (video driver bugs)
  1164.                 cmnMessageBoxMsg(pcnbp->hwndPage, 116, 117, MB_OK);
  1165.         break;
  1166.  
  1167.         case DID_UNDO: {
  1168.             // "Undo" button: get pointer to backed-up Global Settings
  1169.             PGLOBALSETTINGS pGSBackup = (PGLOBALSETTINGS)(pcnbp->pBackup);
  1170.  
  1171.             // and restore the settings for this page
  1172.             pGlobalSettings->FileAttribs = pGSBackup->FileAttribs;
  1173.             pGlobalSettings->AddCopyFilenameItem = pGSBackup->AddCopyFilenameItem;
  1174.             pGlobalSettings->ExtendFldrViewMenu = pGSBackup->ExtendFldrViewMenu;
  1175.             pGlobalSettings->MoveRefreshNow = pGSBackup->MoveRefreshNow;
  1176.             pGlobalSettings->AddSelectSomeItem = pGSBackup->AddSelectSomeItem;
  1177.             pGlobalSettings->AddFolderContentItem = pGSBackup->AddFolderContentItem;
  1178.             pGlobalSettings->FCShowIcons = pGSBackup->FCShowIcons;
  1179.  
  1180.             // update the display by calling the INIT callback
  1181.             (*(pcnbp->pfncbInitPage))(pnbi, CBI_SET | CBI_ENABLE);
  1182.         break; }
  1183.  
  1184.         case DID_DEFAULT: {
  1185.             // set the default settings for this settings page
  1186.             // (this is in common.c because it's also used at
  1187.             // WPS startup)
  1188.             cmnSetDefaultSettings(pcnbp->ulPageID);
  1189.             // update the display by calling the INIT callback
  1190.             (*(pcnbp->pfncbInitPage))(pnbi, CBI_SET | CBI_ENABLE);
  1191.         break; }
  1192.  
  1193.         default:
  1194.             fSave = FALSE;
  1195.     }
  1196.  
  1197.     if (fSave)
  1198.         cmnStoreGlobalSettings();
  1199.  
  1200.     return ((MPARAM)-1);
  1201. }
  1202.  
  1203. /*
  1204.  *@@ fncbWPSConfigFolderMenusInitPage:
  1205.  *      notebook callback function (notebook.c) for the
  1206.  *      second "Context Menus" page in "Workplace Shell"
  1207.  *      object ("Config folder items").
  1208.  *      Sets the controls on the page according to the
  1209.  *      Global Settings.
  1210.  */
  1211.  
  1212. VOID fncbWPSConfigFolderMenusInitPage(PVOID pnbi,   // notebook info struct
  1213.                          ULONG ulExtra)        // INIT_* flags (notebook.h)
  1214. {
  1215.     PCREATENOTEBOOKPAGE pcnbp = (PCREATENOTEBOOKPAGE)pnbi;
  1216.     PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  1217.  
  1218.     if (ulExtra & CBI_INIT)
  1219.     {
  1220.         if (pcnbp->pBackup == NULL)
  1221.         {
  1222.             // first call: backup Global Settings for "Undo" button;
  1223.             // this memory will be freed automatically by the
  1224.             // common notebook window function (notebook.c) when
  1225.             // the notebook page is destroyed
  1226.             pcnbp->pBackup = malloc(sizeof(GLOBALSETTINGS));
  1227.             memcpy(pcnbp->pBackup, pGlobalSettings, sizeof(GLOBALSETTINGS));
  1228.         }
  1229.     }
  1230.  
  1231.     if (ulExtra & CBI_SET)
  1232.     {
  1233.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_CASCADE,
  1234.                     pGlobalSettings->MenuCascadeMode);
  1235.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_REMOVEX,
  1236.                     pGlobalSettings->RemoveX);
  1237.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_APPDPARAM,
  1238.                     pGlobalSettings->AppdParam);
  1239.  
  1240.         switch (pGlobalSettings->TemplatesOpenSettings)
  1241.         {
  1242.             case 0:  winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_TPL_DONOTHING, 1); break;
  1243.             case 1:  winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_TPL_OPENSETTINGS, 1); break;
  1244.             default:  winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_TPL_EDITTITLE, 1); break;
  1245.         }
  1246.  
  1247.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_TPL_POSITION,
  1248.                     pGlobalSettings->TemplatesReposition);
  1249.     }
  1250. }
  1251.  
  1252. /*
  1253.  *@@ fncbWPSConfigFolderMenusItemChanged:
  1254.  *      notebook callback function (notebook.c) for the
  1255.  *      second "Context Menus" page in "Workplace Shell"
  1256.  *      object ("Config folder items").
  1257.  *      Reacts to changes of any of the dialog controls.
  1258.  */
  1259.  
  1260. MRESULT fncbWPSConfigFolderMenusItemChanged(PVOID pnbi,
  1261.                 USHORT usItemID, USHORT usNotifyCode,
  1262.                 ULONG ulExtra)      // for checkboxes: contains new state
  1263. {
  1264.     PCREATENOTEBOOKPAGE pcnbp = (PCREATENOTEBOOKPAGE)pnbi;
  1265.     PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  1266.     BOOL fSave = TRUE;
  1267.  
  1268.     switch (usItemID) {
  1269.         case ID_XSDI_CASCADE:
  1270.             pGlobalSettings->MenuCascadeMode   = ulExtra;
  1271.         break;
  1272.  
  1273.         case ID_XSDI_REMOVEX:
  1274.             pGlobalSettings->RemoveX   = ulExtra;
  1275.         break;
  1276.  
  1277.         case ID_XSDI_APPDPARAM:
  1278.             pGlobalSettings->AppdParam = ulExtra;
  1279.         break;
  1280.  
  1281.         // "create from templates" settings
  1282.         case ID_XSDI_TPL_DONOTHING:
  1283.             pGlobalSettings->TemplatesOpenSettings = 0;
  1284.         break;
  1285.  
  1286.         case ID_XSDI_TPL_EDITTITLE:
  1287.             pGlobalSettings->TemplatesOpenSettings = BM_INDETERMINATE;
  1288.         break;
  1289.  
  1290.         case ID_XSDI_TPL_OPENSETTINGS:
  1291.             pGlobalSettings->TemplatesOpenSettings = BM_CHECKED;
  1292.         break;
  1293.  
  1294.         case ID_XSDI_TPL_POSITION:
  1295.             pGlobalSettings->TemplatesReposition = ulExtra;
  1296.         break;
  1297.  
  1298.         case DID_UNDO: {
  1299.             // "Undo" button: get pointer to backed-up Global Settings
  1300.             PGLOBALSETTINGS pGSBackup = (PGLOBALSETTINGS)(pcnbp->pBackup);
  1301.  
  1302.             // and restore the settings for this page
  1303.             pGlobalSettings->MenuCascadeMode   = pGSBackup->MenuCascadeMode;
  1304.             pGlobalSettings->RemoveX   = pGSBackup->RemoveX;
  1305.             pGlobalSettings->AppdParam = pGSBackup->AppdParam;
  1306.             pGlobalSettings->TemplatesOpenSettings = pGSBackup->TemplatesOpenSettings;
  1307.             pGlobalSettings->TemplatesReposition = pGSBackup->TemplatesReposition;
  1308.  
  1309.             // update the display by calling the INIT callback
  1310.             (*(pcnbp->pfncbInitPage))(pnbi, CBI_SET | CBI_ENABLE);
  1311.         break; }
  1312.  
  1313.         case DID_DEFAULT: {
  1314.             // set the default settings for this settings page
  1315.             // (this is in common.c because it's also used at
  1316.             // WPS startup)
  1317.             cmnSetDefaultSettings(pcnbp->ulPageID);
  1318.             // update the display by calling the INIT callback
  1319.             (*(pcnbp->pfncbInitPage))(pnbi, CBI_SET | CBI_ENABLE);
  1320.         break; }
  1321.  
  1322.         default:
  1323.             fSave = FALSE;
  1324.     }
  1325.  
  1326.     if (fSave)
  1327.         cmnStoreGlobalSettings();
  1328.  
  1329.     return ((MPARAM)-1);
  1330. }
  1331.  
  1332. /*
  1333.  *@@ fncbWPSRemoveItemsInitPage:
  1334.  *      notebook callback function (notebook.c) for the
  1335.  *      third "Context Menus" page in "Workplace Shell"
  1336.  *      object ("Remove menu items").
  1337.  *      Sets the controls on the page according to the
  1338.  *      Global Settings.
  1339.  */
  1340.  
  1341. VOID fncbWPSRemoveItemsInitPage(PVOID pnbi,   // notebook info struct
  1342.                          ULONG ulExtra)        // INIT_* flags (notebook.h)
  1343. {
  1344.     PCREATENOTEBOOKPAGE pcnbp = (PCREATENOTEBOOKPAGE)pnbi;
  1345.     PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  1346.  
  1347.     if (ulExtra & CBI_INIT)
  1348.     {
  1349.         if (pcnbp->pBackup == NULL)
  1350.         {
  1351.             // first call: backup Global Settings for "Undo" button;
  1352.             // this memory will be freed automatically by the
  1353.             // common notebook window function (notebook.c) when
  1354.             // the notebook page is destroyed
  1355.             pcnbp->pBackup = malloc(sizeof(GLOBALSETTINGS));
  1356.             memcpy(pcnbp->pBackup, pGlobalSettings, sizeof(GLOBALSETTINGS));
  1357.         }
  1358.     }
  1359.  
  1360.     if (ulExtra & CBI_SET)
  1361.     {
  1362.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_HELP  ,
  1363.                 (pGlobalSettings->DefaultMenuItems & CTXT_HELP) == 0);
  1364.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_CRANOTHER,
  1365.                 (pGlobalSettings->DefaultMenuItems & CTXT_CRANOTHER) == 0);
  1366.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_COPY  ,
  1367.                 (pGlobalSettings->DefaultMenuItems & CTXT_COPY     ) == 0);
  1368.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_MOVE  ,
  1369.                 (pGlobalSettings->DefaultMenuItems & CTXT_MOVE     ) == 0);
  1370.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_SHADOW,
  1371.                 (pGlobalSettings->DefaultMenuItems & CTXT_SHADOW   ) == 0);
  1372.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_DELETE,
  1373.                 (pGlobalSettings->DefaultMenuItems & CTXT_DELETE   ) == 0);
  1374.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_PICKUP,
  1375.                 (pGlobalSettings->DefaultMenuItems & CTXT_PICKUP   ) == 0);
  1376.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_FIND  ,
  1377.                 (pGlobalSettings->DefaultMenuItems & CTXT_FIND     ) == 0);
  1378.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_SELECT,
  1379.                 (pGlobalSettings->DefaultMenuItems & CTXT_SELECT   ) == 0);
  1380.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_SORT  ,
  1381.                 (pGlobalSettings->DefaultMenuItems & CTXT_SORT     ) == 0);
  1382.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_ARRANGE,
  1383.                 (pGlobalSettings->DefaultMenuItems & CTXT_ARRANGE ) == 0);
  1384.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_PRINT  ,
  1385.                 (pGlobalSettings->DefaultMenuItems & CTXT_PRINT   ) == 0);
  1386.  
  1387.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_WARP4DISPLAY,
  1388.                 !pGlobalSettings->RemoveViewMenu);
  1389.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_INSERT,
  1390.                 !pGlobalSettings->RemovePasteItem);
  1391.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_LOCKINPLACE,
  1392.                 !pGlobalSettings->RemoveLockInPlaceItem);
  1393.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_CHECKDISK,
  1394.                 !pGlobalSettings->RemoveCheckDiskItem);
  1395.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_FORMATDISK,
  1396.                 !pGlobalSettings->RemoveFormatDiskItem);
  1397.     }
  1398.  
  1399.     if (ulExtra & CBI_INIT)
  1400.     {
  1401.         // disable items for Warp 3/4
  1402.         if (doshIsWarp4()) {
  1403.             winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_SELECT, FALSE);
  1404.         } else {
  1405.             winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_LOCKINPLACE, FALSE);
  1406.             winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_WARP4DISPLAY, FALSE);
  1407.             winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_INSERT, FALSE);
  1408.         }
  1409.     }
  1410. }
  1411.  
  1412. /*
  1413.  *@@ fncbWPSRemoveItemsItemChanged:
  1414.  *      notebook callback function (notebook.c) for the
  1415.  *      third "Context Menus" page in "Workplace Shell"
  1416.  *      object ("Remove menu items").
  1417.  *      Reacts to changes of any of the dialog controls.
  1418.  */
  1419.  
  1420. MRESULT fncbWPSRemoveItemsItemChanged(PVOID pnbi,
  1421.                 USHORT usItemID, USHORT usNotifyCode,
  1422.                 ULONG ulExtra)      // for checkboxes: contains new state
  1423. {
  1424.     PCREATENOTEBOOKPAGE pcnbp = (PCREATENOTEBOOKPAGE)pnbi;
  1425.     PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  1426.     BOOL fSave = TRUE;
  1427.  
  1428.     LONG lTemp;
  1429.  
  1430.     switch (usItemID) {
  1431.         case ID_XSDI_HELP:
  1432.             if (ulExtra)
  1433.                 pGlobalSettings->DefaultMenuItems &= ~CTXT_HELP;
  1434.             else
  1435.                 pGlobalSettings->DefaultMenuItems |= CTXT_HELP;
  1436.         break;
  1437.  
  1438.         case ID_XSDI_CRANOTHER:
  1439.             if (ulExtra)
  1440.                 pGlobalSettings->DefaultMenuItems &= ~CTXT_CRANOTHER;
  1441.             else
  1442.                 pGlobalSettings->DefaultMenuItems |= CTXT_CRANOTHER;
  1443.         break;
  1444.  
  1445.         case ID_XSDI_COPY:
  1446.             if (ulExtra)
  1447.                 pGlobalSettings->DefaultMenuItems &= ~CTXT_COPY;
  1448.             else
  1449.                 pGlobalSettings->DefaultMenuItems |= CTXT_COPY;
  1450.         break;
  1451.  
  1452.         case ID_XSDI_MOVE:
  1453.             if (ulExtra)
  1454.                 pGlobalSettings->DefaultMenuItems &= ~CTXT_MOVE;
  1455.             else
  1456.                 pGlobalSettings->DefaultMenuItems |= CTXT_MOVE;
  1457.         break;
  1458.  
  1459.         case ID_XSDI_SHADOW:
  1460.             if (ulExtra)
  1461.                 pGlobalSettings->DefaultMenuItems &= ~CTXT_SHADOW;
  1462.             else
  1463.                 pGlobalSettings->DefaultMenuItems |= CTXT_SHADOW;
  1464.         break;
  1465.  
  1466.         case ID_XSDI_DELETE:
  1467.             if (ulExtra)
  1468.                 pGlobalSettings->DefaultMenuItems &= ~CTXT_DELETE;
  1469.             else
  1470.                 pGlobalSettings->DefaultMenuItems |= CTXT_DELETE;
  1471.         break;
  1472.  
  1473.         case ID_XSDI_PICKUP:
  1474.             if (ulExtra)
  1475.                 pGlobalSettings->DefaultMenuItems &= ~CTXT_PICKUP;
  1476.             else
  1477.                 pGlobalSettings->DefaultMenuItems |= CTXT_PICKUP;
  1478.         break;
  1479.  
  1480.         case ID_XSDI_FIND:
  1481.             if (ulExtra)
  1482.                 pGlobalSettings->DefaultMenuItems &= ~CTXT_FIND;
  1483.             else
  1484.                 pGlobalSettings->DefaultMenuItems |= CTXT_FIND;
  1485.         break;
  1486.  
  1487.         case ID_XSDI_SELECT:
  1488.             if (ulExtra)
  1489.                 pGlobalSettings->DefaultMenuItems &= ~CTXT_SELECT;
  1490.             else
  1491.                 pGlobalSettings->DefaultMenuItems |= CTXT_SELECT;
  1492.         break;
  1493.  
  1494.         case ID_XSDI_SORT:
  1495.             if (ulExtra)
  1496.                 pGlobalSettings->DefaultMenuItems &= ~CTXT_SORT;
  1497.             else
  1498.                 pGlobalSettings->DefaultMenuItems |= CTXT_SORT;
  1499.         break;
  1500.  
  1501.         case ID_XSDI_ARRANGE:
  1502.             if (ulExtra)
  1503.                 pGlobalSettings->DefaultMenuItems &= ~CTXT_ARRANGE;
  1504.             else
  1505.                 pGlobalSettings->DefaultMenuItems |= CTXT_ARRANGE;
  1506.         break;
  1507.  
  1508.         case ID_XSDI_PRINT:
  1509.             if (ulExtra)
  1510.                 pGlobalSettings->DefaultMenuItems &= ~CTXT_PRINT;
  1511.             else
  1512.                 pGlobalSettings->DefaultMenuItems |= CTXT_PRINT;
  1513.         break;
  1514.  
  1515.         case ID_XSDI_WARP4DISPLAY:
  1516.             pGlobalSettings->RemoveViewMenu = 1-ulExtra;
  1517.         break;
  1518.  
  1519.         case ID_XSDI_INSERT:
  1520.             pGlobalSettings->RemovePasteItem = 1-ulExtra;
  1521.         break;
  1522.  
  1523.         case ID_XSDI_LOCKINPLACE:
  1524.             pGlobalSettings->RemoveLockInPlaceItem = 1-ulExtra;
  1525.         break;
  1526.  
  1527.         case ID_XSDI_CHECKDISK:
  1528.             pGlobalSettings->RemoveCheckDiskItem = 1-ulExtra;
  1529.         break;
  1530.  
  1531.         case ID_XSDI_FORMATDISK:
  1532.             pGlobalSettings->RemoveFormatDiskItem = 1-ulExtra;
  1533.         break;
  1534.  
  1535.         case DID_UNDO: {
  1536.             // "Undo" button: get pointer to backed-up Global Settings
  1537.             PGLOBALSETTINGS pGSBackup = (PGLOBALSETTINGS)(pcnbp->pBackup);
  1538.  
  1539.             // and restore the settings for this page
  1540.             pGlobalSettings->DefaultMenuItems = pGSBackup->DefaultMenuItems;
  1541.             pGlobalSettings->RemoveViewMenu = pGSBackup->RemoveViewMenu;
  1542.             pGlobalSettings->RemovePasteItem = pGSBackup->RemovePasteItem;
  1543.             pGlobalSettings->RemoveLockInPlaceItem = pGSBackup->RemoveLockInPlaceItem;
  1544.             pGlobalSettings->RemoveCheckDiskItem = pGSBackup->RemoveCheckDiskItem;
  1545.             pGlobalSettings->RemoveFormatDiskItem = pGSBackup->RemoveFormatDiskItem;
  1546.  
  1547.             // update the display by calling the INIT callback
  1548.             (*(pcnbp->pfncbInitPage))(pnbi, CBI_SET | CBI_ENABLE);
  1549.         break; }
  1550.  
  1551.         case DID_DEFAULT: {
  1552.             // set the default settings for this settings page
  1553.             // (this is in common.c because it's also used at
  1554.             // WPS startup)
  1555.             cmnSetDefaultSettings(pcnbp->ulPageID);
  1556.             // update the display by calling the INIT callback
  1557.             (*(pcnbp->pfncbInitPage))(pnbi, CBI_SET | CBI_ENABLE);
  1558.         break; }
  1559.  
  1560.         default:
  1561.             fSave = FALSE;
  1562.     }
  1563.  
  1564.     if (fSave)
  1565.         cmnStoreGlobalSettings();
  1566.  
  1567.     return ((MPARAM)-1);
  1568. }
  1569.  
  1570. /*
  1571.  *@@ fncbWPSStatusBar1InitPage:
  1572.  *      notebook callback function (notebook.c) for the
  1573.  *      first "Status bars" page in "Workplace Shell" object.
  1574.  *      Sets the controls on the page according to the
  1575.  *      Global Settings.
  1576.  */
  1577.  
  1578. VOID fncbWPSStatusBar1InitPage(PVOID pnbi,   // notebook info struct
  1579.                          ULONG ulExtra)        // INIT_* flags (notebook.h)
  1580. {
  1581.     PCREATENOTEBOOKPAGE pcnbp = (PCREATENOTEBOOKPAGE)pnbi;
  1582.     PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  1583.  
  1584.     if (ulExtra & CBI_INIT)
  1585.     {
  1586.         if (pcnbp->pBackup == NULL)
  1587.         {
  1588.             // first call: backup Global Settings for "Undo" button;
  1589.             // this memory will be freed automatically by the
  1590.             // common notebook window function (notebook.c) when
  1591.             // the notebook page is destroyed
  1592.             pcnbp->pBackup = malloc(sizeof(GLOBALSETTINGS));
  1593.             memcpy(pcnbp->pBackup, pGlobalSettings, sizeof(GLOBALSETTINGS));
  1594.         }
  1595.     }
  1596.  
  1597.     if (ulExtra & CBI_SET)
  1598.     {
  1599.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_ENABLESTATUSBAR,
  1600.                         pGlobalSettings->StatusBar);
  1601.  
  1602.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_SBFORICONVIEWS,
  1603.                         (pGlobalSettings->SBForViews & SBV_ICON) != 0);
  1604.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_SBFORTREEVIEWS,
  1605.                         (pGlobalSettings->SBForViews & SBV_TREE) != 0);
  1606.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_SBFORDETAILSVIEWS,
  1607.                         (pGlobalSettings->SBForViews & SBV_DETAILS) != 0);
  1608.  
  1609.         if (pGlobalSettings->SBStyle == SBSTYLE_WARP3RAISED)
  1610.             winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_SBSTYLE_3RAISED, TRUE);
  1611.         else if (pGlobalSettings->SBStyle == SBSTYLE_WARP3SUNKEN)
  1612.             winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_SBSTYLE_3SUNKEN, TRUE);
  1613.         else if (pGlobalSettings->SBStyle == SBSTYLE_WARP4RECT)
  1614.             winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_SBSTYLE_4RECT, TRUE);
  1615.         else
  1616.             winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_SBSTYLE_4MENU, TRUE);
  1617.     }
  1618.  
  1619.     if (ulExtra & CBI_ENABLE)
  1620.     {
  1621.         BOOL fEnable = !(pGlobalSettings->NoSubclassing);
  1622.         winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_ENABLESTATUSBAR, fEnable);
  1623.         winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_SBSTYLE_3RAISED, fEnable);
  1624.         winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_SBSTYLE_3SUNKEN, fEnable);
  1625.         winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_SBSTYLE_4MENU,   fEnable);
  1626.         winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_SBSTYLE_4RECT,   fEnable);
  1627.  
  1628.         winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_SBFORICONVIEWS,   fEnable);
  1629.         winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_SBFORTREEVIEWS,   fEnable);
  1630.         winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_SBFORDETAILSVIEWS,   fEnable);
  1631.     }
  1632. }
  1633.  
  1634. /*
  1635.  *@@ fncbWPSStatusBar1ItemChanged:
  1636.  *      notebook callback function (notebook.c) for the
  1637.  *      second "Status bars" page in "Workplace Shell" object.
  1638.  *      Reacts to changes of any of the dialog controls.
  1639.  */
  1640.  
  1641. MRESULT fncbWPSStatusBar1ItemChanged(PVOID pnbi,
  1642.                 USHORT usItemID, USHORT usNotifyCode,
  1643.                 ULONG ulExtra)      // for checkboxes: contains new state
  1644. {
  1645.     PCREATENOTEBOOKPAGE pcnbp = (PCREATENOTEBOOKPAGE)pnbi;
  1646.     PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  1647.     BOOL fSave = TRUE,
  1648.          fShowStatusBars = FALSE,
  1649.          fRefreshStatusBars = FALSE;
  1650.  
  1651.     switch (usItemID) {
  1652.         case ID_XSDI_ENABLESTATUSBAR:
  1653.             pGlobalSettings->StatusBar = ulExtra;
  1654.             fShowStatusBars = TRUE;
  1655.         break;
  1656.  
  1657.         case ID_XSDI_SBFORICONVIEWS:
  1658.             if (ulExtra)
  1659.                 pGlobalSettings->SBForViews |= SBV_ICON;
  1660.             else
  1661.                 pGlobalSettings->SBForViews &= ~SBV_ICON;
  1662.             fShowStatusBars = TRUE;
  1663.         break;
  1664.  
  1665.         case ID_XSDI_SBFORTREEVIEWS:
  1666.             if (ulExtra)
  1667.                 pGlobalSettings->SBForViews |= SBV_TREE;
  1668.             else
  1669.                 pGlobalSettings->SBForViews &= ~SBV_TREE;
  1670.             fShowStatusBars = TRUE;
  1671.         break;
  1672.  
  1673.         case ID_XSDI_SBFORDETAILSVIEWS:
  1674.             if (ulExtra)
  1675.                 pGlobalSettings->SBForViews |= SBV_DETAILS;
  1676.             else
  1677.                 pGlobalSettings->SBForViews &= ~SBV_DETAILS;
  1678.             fShowStatusBars = TRUE;
  1679.         break;
  1680.  
  1681.         case ID_XSDI_SBSTYLE_3RAISED:
  1682.             pGlobalSettings->SBStyle = SBSTYLE_WARP3RAISED;
  1683.             fRefreshStatusBars = TRUE;
  1684.         break;
  1685.  
  1686.         case ID_XSDI_SBSTYLE_3SUNKEN:
  1687.             pGlobalSettings->SBStyle = SBSTYLE_WARP3SUNKEN;
  1688.             fRefreshStatusBars = TRUE;
  1689.         break;
  1690.  
  1691.         case ID_XSDI_SBSTYLE_4RECT:
  1692.             pGlobalSettings->SBStyle = SBSTYLE_WARP4RECT;
  1693.             fRefreshStatusBars = TRUE;
  1694.         break;
  1695.  
  1696.         case ID_XSDI_SBSTYLE_4MENU:
  1697.             pGlobalSettings->SBStyle = SBSTYLE_WARP4MENU;
  1698.             fRefreshStatusBars = TRUE;
  1699.         break;
  1700.  
  1701.         case DID_UNDO: {
  1702.             // "Undo" button: get pointer to backed-up Global Settings
  1703.             PGLOBALSETTINGS pGSBackup = (PGLOBALSETTINGS)(pcnbp->pBackup);
  1704.  
  1705.             // and restore the settings for this page
  1706.             pGlobalSettings->StatusBar  = pGSBackup->StatusBar;
  1707.             pGlobalSettings->SBForViews = pGSBackup->SBForViews;
  1708.             pGlobalSettings->SBStyle = pGSBackup->SBStyle;
  1709.  
  1710.             // update the display by calling the INIT callback
  1711.             (*(pcnbp->pfncbInitPage))(pnbi, CBI_SET | CBI_ENABLE);
  1712.             fRefreshStatusBars = TRUE;
  1713.             fShowStatusBars = TRUE;
  1714.         break; }
  1715.  
  1716.         case DID_DEFAULT: {
  1717.             // set the default settings for this settings page
  1718.             // (this is in common.c because it's also used at
  1719.             // WPS startup)
  1720.             cmnSetDefaultSettings(pcnbp->ulPageID);
  1721.             // update the display by calling the INIT callback
  1722.             (*(pcnbp->pfncbInitPage))(pnbi, CBI_SET | CBI_ENABLE);
  1723.             fRefreshStatusBars = TRUE;
  1724.             fShowStatusBars = TRUE;
  1725.         break; }
  1726.  
  1727.         default:
  1728.             fSave = FALSE;
  1729.     }
  1730.  
  1731.     if (fSave) {
  1732.         cmnStoreGlobalSettings();
  1733.     }
  1734.  
  1735.     // have the Worker thread update the
  1736.     // status bars for all currently open
  1737.     // folders
  1738.     if (fRefreshStatusBars)
  1739.         xthrPostWorkerMsg(WOM_UPDATEALLSTATUSBARS,
  1740.                 (MPARAM)2,
  1741.                 MPNULL);
  1742.  
  1743.     if (fShowStatusBars) {
  1744.         xthrPostWorkerMsg(WOM_UPDATEALLSTATUSBARS,
  1745.                 (MPARAM)1,
  1746.                 MPNULL);
  1747.         ntbUpdateVisiblePage(NULL,   // all somSelf's
  1748.                 SP_XFOLDER_FLDR);
  1749.     }
  1750.  
  1751.     return ((MPARAM)-1);
  1752. }
  1753.  
  1754. /*
  1755.  *@@ fncbWPSStatusBar2InitPage:
  1756.  *      notebook callback function (notebook.c) for the
  1757.  *      second "Status bars" page in "Workplace Shell" object.
  1758.  *      Sets the controls on the page according to the
  1759.  *      Global Settings.
  1760.  */
  1761.  
  1762. CHAR                    szSBTextNoneSelBackup[CCHMAXMNEMONICS],
  1763.                         szSBText1SelBackup[CCHMAXMNEMONICS],
  1764.                         szSBTextMultiSelBackup[CCHMAXMNEMONICS],
  1765.                         szSBClassSelected[256];
  1766. SOMClass                *pSBClassObjectSelected = NULL;
  1767. somId                   somidClassSelected;
  1768.  
  1769. // definitions for "Select Class" dialog for status bars
  1770. MRESULT EXPENTRY fncbStatusBarReturnClassAttr(HWND hwndCnr, ULONG ulscd,
  1771.                     MPARAM mpwps, MPARAM mpreccParent);
  1772.  
  1773. MRESULT EXPENTRY fncbStatusBarClassSelected(HWND hwndCnr,  ULONG ulNLSStrings,
  1774.                     MPARAM mpwps, MPARAM mphwndInfo);
  1775.  
  1776. // struct passed to callbacks
  1777. typedef struct _STATUSBARSELECTCLASS {
  1778.     HWND            hwndOKButton;
  1779.     PNLSSTRINGS     pNLSStrings;
  1780. } STATUSBARSELECTCLASS, *PSTATUSBARSELECTCLASS;
  1781.  
  1782. VOID fncbWPSStatusBar2InitPage(PVOID pnbi,   // notebook info struct
  1783.                          ULONG ulExtra)        // INIT_* flags (notebook.h)
  1784. {
  1785.     PCREATENOTEBOOKPAGE pcnbp = (PCREATENOTEBOOKPAGE)pnbi;
  1786.     PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  1787.  
  1788.     if (ulExtra & CBI_INIT)
  1789.     {
  1790.         if (pcnbp->pBackup == NULL)
  1791.         {
  1792.             // first call: backup Global Settings for "Undo" button;
  1793.             // this memory will be freed automatically by the
  1794.             // common notebook window function (notebook.c) when
  1795.             // the notebook page is destroyed
  1796.             pcnbp->pBackup = malloc(sizeof(GLOBALSETTINGS));
  1797.             memcpy(pcnbp->pBackup, pGlobalSettings, sizeof(GLOBALSETTINGS));
  1798.         }
  1799.  
  1800.         strcpy(szSBTextNoneSelBackup,
  1801.                     cmnQueryStatusBarSetting(SBS_TEXTNONESEL));
  1802.         strcpy(szSBTextMultiSelBackup,
  1803.                     cmnQueryStatusBarSetting(SBS_TEXTMULTISEL));
  1804.         // status bar settings page: get last selected
  1805.         // class from INIs (for single-object mode)
  1806.         // and query the SOM class object from this string
  1807.         PrfQueryProfileString(HINI_USER, INIAPP_XFOLDER,
  1808.                 INIKEY_SB_LASTCLASS, "XFldObject",
  1809.                 szSBClassSelected, sizeof(szSBClassSelected));
  1810.         if (pSBClassObjectSelected == NULL) {
  1811.             somidClassSelected = somIdFromString(szSBClassSelected);
  1812.             if (somidClassSelected) {
  1813.                 // get pointer to class object (e.g. M_WPObject)
  1814.                 pSBClassObjectSelected = _somFindClass(SOMClassMgrObject, somidClassSelected, 0, 0);
  1815.             }
  1816.         }
  1817.         if (pSBClassObjectSelected) {
  1818.             stbQueryClassMnemonics(pSBClassObjectSelected,
  1819.                     szSBText1SelBackup,
  1820.                     sizeof(szSBText1SelBackup));
  1821.         }
  1822.     }
  1823.  
  1824.     if (ulExtra & CBI_SET)
  1825.     {
  1826.         CHAR    szTemp[CCHMAXMNEMONICS];
  1827.  
  1828.         WinSetDlgItemText(pcnbp->hwndPage, ID_XSDI_SBCURCLASS, szSBClassSelected);
  1829.  
  1830.         // descriptive status bar strings
  1831.         WinSendDlgItemMsg(pcnbp->hwndPage, ID_XSDI_SBTEXTNONESEL, EM_SETTEXTLIMIT,
  1832.             (MPARAM)(CCHMAXMNEMONICS-1), MPNULL);
  1833.         WinSetDlgItemText(pcnbp->hwndPage, ID_XSDI_SBTEXTNONESEL ,
  1834.             cmnQueryStatusBarSetting(SBS_TEXTNONESEL));
  1835.  
  1836.         WinSendDlgItemMsg(pcnbp->hwndPage, ID_XSDI_SBTEXT1SEL, EM_SETTEXTLIMIT,
  1837.             (MPARAM)(CCHMAXMNEMONICS-1), MPNULL);
  1838.         if (pSBClassObjectSelected == NULL) {
  1839.             somidClassSelected = somIdFromString(szSBClassSelected);
  1840.             if (somidClassSelected) {
  1841.                 // get pointer to class object (e.g. M_WPObject)
  1842.                 pSBClassObjectSelected = _somFindClass(SOMClassMgrObject, somidClassSelected, 0, 0);
  1843.             }
  1844.         }
  1845.  
  1846.         if (pSBClassObjectSelected) {
  1847.             stbQueryClassMnemonics(pSBClassObjectSelected,
  1848.                     szTemp,
  1849.                     sizeof(szTemp));
  1850.             WinSetDlgItemText(pcnbp->hwndPage, ID_XSDI_SBTEXT1SEL, szTemp);
  1851.         }
  1852.  
  1853.         WinSendDlgItemMsg(pcnbp->hwndPage, ID_XSDI_SBTEXTMULTISEL, EM_SETTEXTLIMIT,
  1854.             (MPARAM)(CCHMAXMNEMONICS-1), MPNULL);
  1855.         WinSetDlgItemText(pcnbp->hwndPage, ID_XSDI_SBTEXTMULTISEL,
  1856.             cmnQueryStatusBarSetting(SBS_TEXTMULTISEL));
  1857.     }
  1858.  
  1859.     if (ulExtra & CBI_ENABLE)
  1860.     {
  1861.         BOOL fEnable = !(pGlobalSettings->NoSubclassing);
  1862.         winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_SBTEXTNONESEL,   fEnable);
  1863.         winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_SBTEXT1SEL,      fEnable);
  1864.         winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_SBTEXTMULTISEL,  fEnable);
  1865.     }
  1866.  
  1867.     if (ulExtra & CBI_DESTROY)
  1868.         if (pSBClassObjectSelected) {
  1869.             SOMFree(somidClassSelected);
  1870.             pSBClassObjectSelected = NULL;
  1871.         }
  1872. }
  1873.  
  1874. /*
  1875.  *@@ fncbWPSStatusBar2ItemChanged:
  1876.  *      notebook callback function (notebook.c) for the
  1877.  *      second "Status bars" page in "Workplace Shell" object.
  1878.  *      Reacts to changes of any of the dialog controls.
  1879.  */
  1880.  
  1881. MRESULT fncbWPSStatusBar2ItemChanged(PVOID pnbi,
  1882.                 USHORT usItemID, USHORT usNotifyCode,
  1883.                 ULONG ulExtra)      // for checkboxes: contains new state
  1884. {
  1885.     PCREATENOTEBOOKPAGE pcnbp = (PCREATENOTEBOOKPAGE)pnbi;
  1886.     PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  1887.     BOOL fSave = TRUE;
  1888.     CHAR szDummy[CCHMAXMNEMONICS];
  1889.  
  1890.     switch (usItemID) {
  1891.         case ID_XSDI_SBTEXTNONESEL:
  1892.             WinQueryDlgItemText(pcnbp->hwndPage, ID_XSDI_SBTEXTNONESEL,
  1893.                             sizeof(szDummy)-1, szDummy);
  1894.             cmnSetStatusBarSetting(SBS_TEXTNONESEL, szDummy);
  1895.  
  1896.             if (pSBClassObjectSelected == NULL) {
  1897.                 somidClassSelected = somIdFromString(szSBClassSelected);
  1898.                 if (somidClassSelected) {
  1899.                     // get pointer to class object (e.g. M_WPObject)
  1900.                     pSBClassObjectSelected = _somFindClass(SOMClassMgrObject, somidClassSelected, 0, 0);
  1901.                 }
  1902.             }
  1903.         break;
  1904.  
  1905.         case ID_XSDI_SBTEXT1SEL:
  1906.             if (pSBClassObjectSelected) {
  1907.                 WinQueryDlgItemText(pcnbp->hwndPage, ID_XSDI_SBTEXT1SEL,
  1908.                                 sizeof(szDummy)-1, szDummy);
  1909.                 stbSetClassMnemonics(pSBClassObjectSelected,
  1910.                                 szDummy);
  1911.             }
  1912.         break;
  1913.  
  1914.         case ID_XSDI_SBTEXTMULTISEL:
  1915.             WinQueryDlgItemText(pcnbp->hwndPage, ID_XSDI_SBTEXTMULTISEL,
  1916.                             sizeof(szDummy)-1, szDummy);
  1917.             cmnSetStatusBarSetting(SBS_TEXTMULTISEL, szDummy);
  1918.         break;
  1919.  
  1920.         // "Select class" on "Status Bars" page:
  1921.         // set up WPS classes dialog
  1922.         case ID_XSDI_SBSELECTCLASS: {
  1923.             SELECTCLASSDATA         scd;
  1924.             STATUSBARSELECTCLASS    sbsc;
  1925.  
  1926.             CHAR szTitle[100] = "title";
  1927.             CHAR szIntroText[2000] = "intro";
  1928.  
  1929.             cmnGetMessage(NULL, 0, szTitle, sizeof(szTitle), 112);
  1930.             cmnGetMessage(NULL, 0, szIntroText, sizeof(szIntroText), 113);
  1931.             scd.pszDlgTitle = szTitle;
  1932.             scd.pszIntroText = szIntroText;
  1933.             scd.pszRootClass = "WPObject";
  1934.             scd.pszOrphans = NULL;
  1935.             strcpy(scd.szClassSelected, szSBClassSelected);
  1936.  
  1937.             // these callback funcs are defined way more below
  1938.             scd.pfnwpReturnAttrForClass = fncbStatusBarReturnClassAttr;
  1939.             scd.pfnwpClassSelected = fncbStatusBarClassSelected;
  1940.             // the folllowing data will be passed to the callbacks
  1941.             // so the callback can display NLS messages
  1942.             sbsc.pNLSStrings = cmnQueryNLSStrings();
  1943.             scd.ulUserClassSelected = (ULONG)&sbsc;
  1944.  
  1945.             scd.pszHelpLibrary = cmnQueryHelpLibrary();
  1946.             scd.ulHelpPanel = ID_XFH_SELECTCLASS;
  1947.  
  1948.             if (clsSelectWpsClassDlg(pcnbp->hwndPage,
  1949.                     NLS_MODULE, ID_XSD_SELECTCLASS,
  1950.                     &scd) == DID_OK)
  1951.             {
  1952.                 strcpy(szSBClassSelected, scd.szClassSelected);
  1953.                 WinSetDlgItemText(pcnbp->hwndPage, ID_XSDI_SBCURCLASS, szSBClassSelected);
  1954.                 PrfWriteProfileString(HINI_USER, INIAPP_XFOLDER, INIKEY_SB_LASTCLASS,
  1955.                             szSBClassSelected);
  1956.                 if (pSBClassObjectSelected) {
  1957.                     SOMFree(somidClassSelected);
  1958.                     pSBClassObjectSelected = NULL;
  1959.                     // this will provoke the following func to re-read
  1960.                     // the class's status bar mnemonics
  1961.                 }
  1962.  
  1963.                 // update the display by calling the INIT callback
  1964.                 (*(pcnbp->pfncbInitPage))(pnbi, CBI_SET | CBI_ENABLE);
  1965.  
  1966.                 // refresh the "Undo" data for this
  1967.                 stbQueryClassMnemonics(pSBClassObjectSelected,
  1968.                         szSBText1SelBackup,
  1969.                         sizeof(szSBText1SelBackup));
  1970.  
  1971.             }
  1972.         break; }
  1973.  
  1974.         case DID_UNDO: {
  1975.             // "Undo" button: get pointer to backed-up Global Settings
  1976.             PGLOBALSETTINGS pGSBackup = (PGLOBALSETTINGS)(pcnbp->pBackup);
  1977.  
  1978.             // and restore the settings for this page
  1979.             cmnSetStatusBarSetting(SBS_TEXTNONESEL,
  1980.                     szSBTextNoneSelBackup);
  1981.             cmnSetStatusBarSetting(SBS_TEXTMULTISEL,
  1982.                     szSBTextMultiSelBackup);
  1983.  
  1984.             if (pSBClassObjectSelected == NULL) {
  1985.                 somidClassSelected = somIdFromString(szSBClassSelected);
  1986.                 if (somidClassSelected) {
  1987.                     // get pointer to class object (e.g. M_WPObject)
  1988.                     pSBClassObjectSelected = _somFindClass(SOMClassMgrObject, somidClassSelected, 0, 0);
  1989.                 }
  1990.             }
  1991.             if (pSBClassObjectSelected) {
  1992.                 stbSetClassMnemonics(pSBClassObjectSelected,
  1993.                                 szSBText1SelBackup);
  1994.             }
  1995.  
  1996.             // update the display by calling the INIT callback
  1997.             (*(pcnbp->pfncbInitPage))(pnbi, CBI_SET | CBI_ENABLE);
  1998.         break; }
  1999.  
  2000.         case DID_DEFAULT: {
  2001.             // set the default settings for this settings page
  2002.             // (this is in common.c because it's also used at
  2003.             // WPS startup)
  2004.             cmnSetStatusBarSetting(SBS_TEXTNONESEL, NULL);  // load default
  2005.             cmnSetStatusBarSetting(SBS_TEXTMULTISEL, NULL); // load default
  2006.  
  2007.             if (pSBClassObjectSelected == NULL) {
  2008.                 somidClassSelected = somIdFromString(szSBClassSelected);
  2009.                 if (somidClassSelected) {
  2010.                     // get pointer to class object (e.g. M_WPObject)
  2011.                     pSBClassObjectSelected = _somFindClass(SOMClassMgrObject, somidClassSelected, 0, 0);
  2012.                 }
  2013.             }
  2014.             if (pSBClassObjectSelected) {
  2015.                 stbSetClassMnemonics(pSBClassObjectSelected,
  2016.                                 NULL);  // load default
  2017.             }
  2018.             // update the display by calling the INIT callback
  2019.             (*(pcnbp->pfncbInitPage))(pnbi, CBI_SET | CBI_ENABLE);
  2020.         break; }
  2021.  
  2022.         default:
  2023.             fSave = FALSE;
  2024.     }
  2025.  
  2026.     if (fSave) {
  2027.         cmnStoreGlobalSettings();
  2028.         // have the Worker thread update the
  2029.         // status bars for all currently open
  2030.         // folders
  2031.         xthrPostWorkerMsg(WOM_UPDATEALLSTATUSBARS,
  2032.                 (MPARAM)2, // update display
  2033.                 MPNULL);
  2034.     }
  2035.  
  2036.     return ((MPARAM)-1);
  2037. }
  2038.  
  2039. /*
  2040.  *@@ fncbWPSSnap2GridInitPage:
  2041.  *      notebook callback function (notebook.c) for the
  2042.  *      "Snap to grid" page in "Workplace Shell" object.
  2043.  *      Sets the controls on the page according to the
  2044.  *      Global Settings.
  2045.  */
  2046.  
  2047. VOID fncbWPSSnap2GridInitPage(PVOID pnbi,   // notebook info struct
  2048.                          ULONG ulExtra)        // INIT_* flags (notebook.h)
  2049. {
  2050.     PCREATENOTEBOOKPAGE pcnbp = (PCREATENOTEBOOKPAGE)pnbi;
  2051.     PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  2052.  
  2053.     if (ulExtra & CBI_INIT)
  2054.     {
  2055.         if (pcnbp->pBackup == NULL)
  2056.         {
  2057.             // first call: backup Global Settings for "Undo" button;
  2058.             // this memory will be freed automatically by the
  2059.             // common notebook window function (notebook.c) when
  2060.             // the notebook page is destroyed
  2061.             pcnbp->pBackup = malloc(sizeof(GLOBALSETTINGS));
  2062.             memcpy(pcnbp->pBackup, pGlobalSettings, sizeof(GLOBALSETTINGS));
  2063.         }
  2064.     }
  2065.  
  2066.     if (ulExtra & CBI_SET)
  2067.     {
  2068.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_SNAPTOGRID, pGlobalSettings->AddSnapToGridItem);
  2069.         winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_GRID_X, 0, 500, pGlobalSettings->GridX);
  2070.         winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_GRID_Y, 0, 500, pGlobalSettings->GridY);
  2071.         winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_GRID_CX, 1, 500, pGlobalSettings->GridCX);
  2072.         winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_GRID_CY, 1, 500, pGlobalSettings->GridCY);
  2073.     }
  2074. }
  2075.  
  2076. /*
  2077.  *@@ fncbWPSSnap2GridItemChanged:
  2078.  *      notebook callback function (notebook.c) for the
  2079.  *      "Snap to grid" page in "Workplace Shell" object.
  2080.  *      Reacts to changes of any of the dialog controls.
  2081.  */
  2082.  
  2083. MRESULT fncbWPSSnap2GridItemChanged(PVOID pnbi,
  2084.                 USHORT usItemID, USHORT usNotifyCode,
  2085.                 ULONG ulExtra)      // for checkboxes: contains new state
  2086. {
  2087.     PCREATENOTEBOOKPAGE pcnbp = (PCREATENOTEBOOKPAGE)pnbi;
  2088.     PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  2089.     BOOL fSave = TRUE;
  2090.  
  2091.     switch (usItemID) {
  2092.         case ID_XSDI_SNAPTOGRID:
  2093.             pGlobalSettings->AddSnapToGridItem = ulExtra;
  2094.         break;
  2095.  
  2096.         case ID_XSDI_GRID_X:
  2097.             pGlobalSettings->GridX = ulExtra;
  2098.         break;
  2099.  
  2100.         case ID_XSDI_GRID_Y:
  2101.             pGlobalSettings->GridY = ulExtra;
  2102.         break;
  2103.  
  2104.         case ID_XSDI_GRID_CX:
  2105.             pGlobalSettings->GridCX = ulExtra;
  2106.         break;
  2107.  
  2108.         case ID_XSDI_GRID_CY:
  2109.             pGlobalSettings->GridCY = ulExtra;
  2110.         break;
  2111.  
  2112.         case DID_UNDO: {
  2113.             // "Undo" button: get pointer to backed-up Global Settings
  2114.             PGLOBALSETTINGS pGSBackup = (PGLOBALSETTINGS)(pcnbp->pBackup);
  2115.  
  2116.             // and restore the settings for this page
  2117.             pGlobalSettings->AddSnapToGridItem = pGSBackup->AddSnapToGridItem;
  2118.             pGlobalSettings->GridX = pGSBackup->GridX;
  2119.             pGlobalSettings->GridY = pGSBackup->GridY;
  2120.             pGlobalSettings->GridCX = pGSBackup->GridCX;
  2121.             pGlobalSettings->GridCY = pGSBackup->GridCY;
  2122.  
  2123.             // update the display by calling the INIT callback
  2124.             (*(pcnbp->pfncbInitPage))(pnbi, CBI_SET | CBI_ENABLE);
  2125.         break; }
  2126.  
  2127.         case DID_DEFAULT: {
  2128.             // set the default settings for this settings page
  2129.             // (this is in common.c because it's also used at
  2130.             // WPS startup)
  2131.             cmnSetDefaultSettings(pcnbp->ulPageID);
  2132.             // update the display by calling the INIT callback
  2133.             (*(pcnbp->pfncbInitPage))(pnbi, CBI_SET | CBI_ENABLE);
  2134.         break; }
  2135.  
  2136.         default:
  2137.             fSave = FALSE;
  2138.     }
  2139.  
  2140.     if (fSave)
  2141.         cmnStoreGlobalSettings();
  2142.  
  2143.     return ((MPARAM)-1);
  2144. }
  2145.  
  2146. /*
  2147.  *@@ fncbWPSFldrHotkeysInitPage:
  2148.  *      notebook callback function (notebook.c) for the
  2149.  *      "Folder hotkeys" page in "Workplace Shell" object.
  2150.  *      Sets the controls on the page according to the
  2151.  *      Global Settings.
  2152.  */
  2153.  
  2154. VOID fncbWPSFldrHotkeysInitPage(PVOID pnbi,   // notebook info struct
  2155.                          ULONG ulExtra)        // INIT_* flags (notebook.h)
  2156. {
  2157.     PCREATENOTEBOOKPAGE pcnbp = (PCREATENOTEBOOKPAGE)pnbi;
  2158.     PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  2159.  
  2160.     HWND    hwndEditField = WinWindowFromID(pcnbp->hwndPage, ID_XSDI_DESCRIPTION);
  2161.     HWND    hwndListbox = WinWindowFromID(pcnbp->hwndPage, ID_XSDI_LISTBOX);
  2162.  
  2163.     SHORT i;
  2164.  
  2165.     if (ulExtra & CBI_INIT)
  2166.     {
  2167.         HAB     hab = WinQueryAnchorBlock(pcnbp->hwndPage);
  2168.         HMODULE hmod = NLS_MODULE;
  2169.         PFNWP   OldEditProc;
  2170.  
  2171.         if (pcnbp->pBackup == NULL)
  2172.         {
  2173.             // first call: backup Global Settings for "Undo" button;
  2174.             // this memory will be freed automatically by the
  2175.             // common notebook window function (notebook.c) when
  2176.             // the notebook page is destroyed
  2177.             pcnbp->pBackup = malloc(sizeof(GLOBALSETTINGS));
  2178.             memcpy(pcnbp->pBackup, pGlobalSettings, sizeof(GLOBALSETTINGS));
  2179.             // and also backup the Folder Hotkeys array in the
  2180.             // second pointer
  2181.             pcnbp->pBackup2 = malloc(FLDRHOTKEYSSIZE);
  2182.             memcpy(pcnbp->pBackup2,
  2183.                         cmnQueryFldrHotkeys(),
  2184.                         FLDRHOTKEYSSIZE);
  2185.         }
  2186.  
  2187.         for (i = 0; i < FLDRHOTKEYCOUNT; i++)
  2188.         {
  2189.             if (WinLoadString(hab, hmod,
  2190.                     szLBStringIDs[i],
  2191.                     sizeof(szLBEntries[i]),
  2192.                     szLBEntries[i])
  2193.                == 0)
  2194.             {
  2195.                 DebugBox("XFolder", "Unable to load strings.");
  2196.                 break;
  2197.             }
  2198.         }
  2199.  
  2200.         OldEditProc = WinSubclassWindow(hwndEditField, fnwpHotkeyEntryField);
  2201.         WinSetWindowULong(hwndEditField, QWL_USER, (ULONG)OldEditProc);
  2202.     }
  2203.  
  2204.     if (ulExtra & CBI_SET)
  2205.     {
  2206.         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_ACCELERATORS, pGlobalSettings->Accelerators);
  2207.  
  2208.         WinSendMsg(hwndListbox, LM_DELETEALL, 0, 0);
  2209.         WinSetWindowText(hwndEditField, "");
  2210.  
  2211.         for (i = 0; i < FLDRHOTKEYCOUNT; i++)
  2212.         {
  2213.             if (szLBEntries[i])
  2214.             {
  2215.                 WinSendMsg(hwndListbox,
  2216.                         LM_INSERTITEM,
  2217.                         (MPARAM)LIT_SORTASCENDING,
  2218.                         (MPARAM)szLBEntries[i]);
  2219.             }
  2220.             else break;
  2221.         }
  2222.     }
  2223.  
  2224.     if (ulExtra & CBI_ENABLE)
  2225.     {
  2226.         BOOL fEnable = !(pGlobalSettings->NoSubclassing);
  2227.         winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_ACCELERATORS, fEnable);
  2228.         winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_LISTBOX, fEnable);
  2229.         winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_CLEARACCEL, fEnable);
  2230.     }
  2231. }
  2232.  
  2233. /*
  2234.  *@@ fncbWPSFldrHotkeysItemChanged:
  2235.  *      notebook callback function (notebook.c) for the
  2236.  *      "Snap to grid" page in "Workplace Shell" object.
  2237.  *      Reacts to changes of any of the dialog controls.
  2238.  */
  2239.  
  2240. MRESULT fncbWPSFldrHotkeysItemChanged(PVOID pnbi,
  2241.                 USHORT usItemID, USHORT usNotifyCode,
  2242.                 ULONG ulExtra)      // for checkboxes: contains new state
  2243. {
  2244.     PCREATENOTEBOOKPAGE pcnbp = (PCREATENOTEBOOKPAGE)pnbi;
  2245.     PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  2246.  
  2247.     switch (usItemID) {
  2248.         case ID_XSDI_ACCELERATORS:
  2249.             pGlobalSettings->Accelerators = ulExtra;
  2250.             cmnStoreGlobalSettings();
  2251.         break;
  2252.  
  2253.         case ID_XSDI_LISTBOX: {
  2254.             if (usNotifyCode == LN_SELECT)
  2255.             {
  2256.                 // new hotkey description from listbox selected:
  2257.                 CHAR            szKeyName[200];
  2258.                 PXFLDHOTKEY     pHotkeyFound;
  2259.  
  2260.                 // update the Edit field with new
  2261.                 // key description, but do NOT save settings yet
  2262.                 pHotkeyFound = FindHotkeyFromLBSel(pcnbp->hwndPage, NULL);
  2263.                 if ( (pHotkeyFound) && ((ULONG)pHotkeyFound != -1) )
  2264.                 {
  2265.                     cmnDescribeKey(szKeyName, pHotkeyFound->usFlags,
  2266.                                               pHotkeyFound->usKeyCode);
  2267.                     winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_CLEARACCEL, TRUE);
  2268.                 }
  2269.                 else { // not found: set to "not defined"
  2270.                     strcpy(szKeyName,
  2271.                         (cmnQueryNLSStrings())->pszNotDefined);
  2272.  
  2273.                     winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_CLEARACCEL, FALSE);
  2274.                 }
  2275.  
  2276.                 // set edit field to description text
  2277.                 WinSetDlgItemText(pcnbp->hwndPage, ID_XSDI_DESCRIPTION,
  2278.                             szKeyName);
  2279.                 // enable previously disabled items
  2280.                 winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_DESCRIPTION, TRUE);
  2281.                 winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_DESCRIPTION_TX1, TRUE);
  2282.             }
  2283.         break; }
  2284.  
  2285.         // we need not handle the entry field, because the
  2286.         // subclassed window procedure for that is smart
  2287.         // enough to update the hotkeys data itself
  2288.  
  2289.         case ID_XSDI_CLEARACCEL: {
  2290.             // "Clear" button:
  2291.             USHORT      usCommand;
  2292.             PXFLDHOTKEY pHotkeyFound;
  2293.  
  2294.             pHotkeyFound = FindHotkeyFromLBSel(pcnbp->hwndPage, &usCommand);
  2295.  
  2296.             if ( (pHotkeyFound) && ((ULONG)pHotkeyFound != -1) )
  2297.             {
  2298.                 // accelerator defined:
  2299.                 PXFLDHOTKEY pHotkey = pHotkeyFound;
  2300.  
  2301.                 // in order to delete the marked accelerator,
  2302.                 // move all following hotkeys in the global
  2303.                 // hotkeys table one position ahead
  2304.                 while (pHotkey->usCommand)
  2305.                 {
  2306.                     memcpy(pHotkey, pHotkey+1, sizeof(XFLDHOTKEY));
  2307.                     pHotkey++;
  2308.                 }
  2309.  
  2310.                 WinSetDlgItemText(pcnbp->hwndPage, ID_XSDI_DESCRIPTION,
  2311.                             (cmnQueryNLSStrings())->pszNotDefined);
  2312.                 winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_CLEARACCEL, FALSE);
  2313.                 cmnStoreFldrHotkeys();
  2314.             }
  2315.         break; }
  2316.  
  2317.         case DID_UNDO: {
  2318.             // "Undo" button: get pointer to backed-up Global Settings
  2319.             PGLOBALSETTINGS pGSBackup = (PGLOBALSETTINGS)(pcnbp->pBackup);
  2320.  
  2321.             // and restore the settings for this page
  2322.             pGlobalSettings->Accelerators = pGSBackup->Accelerators;
  2323.  
  2324.             // here, also restore the backed-up FolderHotkeys array
  2325.             // second pointer
  2326.             memcpy(cmnQueryFldrHotkeys(), pcnbp->pBackup2, FLDRHOTKEYSSIZE);
  2327.  
  2328.             // update the display by calling the INIT callback
  2329.             (*(pcnbp->pfncbInitPage))(pnbi, CBI_SET | CBI_ENABLE);
  2330.             cmnStoreFldrHotkeys();
  2331.         break; }
  2332.  
  2333.         case DID_DEFAULT: {
  2334.             // set the default settings for this settings page
  2335.             // (this is in common.c because it's also used at
  2336.             // WPS startup)
  2337.             cmnSetDefaultSettings(pcnbp->ulPageID);
  2338.             cmnLoadDefaultFldrHotkeys();
  2339.             // update the display by calling the INIT callback
  2340.             (*(pcnbp->pfncbInitPage))(pnbi, CBI_SET | CBI_ENABLE);
  2341.             cmnStoreGlobalSettings();
  2342.             cmnStoreFldrHotkeys();
  2343.         break; }
  2344.     }
  2345.  
  2346.     return ((MPARAM)-1);
  2347. }
  2348.  
  2349. /* ******************************************************************
  2350.  *                                                                  *
  2351.  *   callback funcs for "Select Statusbar Class" dlg                *
  2352.  *                                                                  *
  2353.  ********************************************************************/
  2354.  
  2355. /*
  2356.  * All these funcs are called from the dialog funcs in
  2357.  * classlst.c, which are in turn called when the "Select class"
  2358.  * button is pressed on the "Status bars" settings page.
  2359.  *
  2360.  */
  2361.  
  2362. /*
  2363.  *@@ fncbStatusBarReturnClassAttr:
  2364.  *      this callback function is called for every single
  2365.  *      record core which represents a WPS class; we need
  2366.  *      to return the record core attributes
  2367.  */
  2368.  
  2369. MRESULT EXPENTRY fncbStatusBarReturnClassAttr(HWND hwndCnr,
  2370.                     ULONG ulscd,   // SELECTCLASSDATA struct
  2371.                     MPARAM mpwps,  // current WPSLISTITEM struct
  2372.                     MPARAM mpreccParent) // parent record core
  2373. {
  2374.     USHORT          usAttr = CRA_RECORDREADONLY | CRA_COLLAPSED | CRA_DISABLED;
  2375.     PWPSLISTITEM     pwps = (PWPSLISTITEM)mpwps;
  2376.     PSELECTCLASSDATA pscd = (PSELECTCLASSDATA)ulscd;
  2377.     PRECORDCORE     preccParent = NULL;
  2378.  
  2379.     if (pwps) {
  2380.         #ifdef DEBUG_SETTINGS
  2381.             _Pmpf(("Checking %s", pwps->pszClassName));
  2382.         #endif
  2383.         if (pwps->pClassObject) {
  2384.  
  2385.             // now check if the class supports new sort mnemonics
  2386.             // if (somResolveByName(pwps->pClassObject, "xfclsAddsNewStatusBarMnemonics"))
  2387.             if (    (stbClassAddsNewMnemonics(pwps->pClassObject))
  2388.                  // && (strlen(pwps->szReplacedByClass) == 0)
  2389.                )
  2390.             {
  2391.                 // class _does_ support mnemonics: give the
  2392.                 // new recc attr the "in use" flag
  2393.                 usAttr = CRA_RECORDREADONLY | CRA_COLLAPSED | CRA_INUSE;
  2394.  
  2395.                 // and select it if the settings notebook wants it
  2396.                 if (strcmp(pwps->pszClassName, pscd->szClassSelected) == 0)
  2397.                     usAttr |= CRA_SELECTED;
  2398.  
  2399.                 // expand all the parent records of the new record
  2400.                 // so that classes with status bar mnemonics are
  2401.                 // all initially visible in the container
  2402.                 preccParent = (PRECORDCORE)mpreccParent;
  2403.                 while (preccParent)
  2404.                 {
  2405.                     WinSendMsg(hwndCnr, CM_EXPANDTREE, (MPARAM)preccParent, MPNULL);
  2406.  
  2407.                     preccParent = WinSendMsg(hwndCnr, CM_QUERYRECORD,
  2408.                             preccParent,
  2409.                             MPFROM2SHORT(CMA_PARENT, CMA_ITEMORDER));
  2410.  
  2411.                     if (preccParent == (PRECORDCORE)-1) {
  2412.                         preccParent = NULL;
  2413.                     }
  2414.                 }
  2415.             }
  2416.  
  2417.         } // end if if (pwps->pClassObject)
  2418.         else {
  2419.             // invalid class: hide in cnr
  2420.             usAttr = CRA_FILTERED;
  2421.         }
  2422.     }
  2423.     return (MPARAM)(usAttr);
  2424. }
  2425.  
  2426. /*
  2427.  *@@ fncbStatusBarClassSelected:
  2428.  *      callback func for class selected;
  2429.  *      mphwndInfo has been set to the static control hwnd.
  2430.  *      Returns TRUE if the selection is valid; the dlg func
  2431.  *      will then enable the OK button.
  2432.  */
  2433.  
  2434. MRESULT EXPENTRY fncbStatusBarClassSelected(HWND hwndCnr, ULONG ulpsbsc,
  2435.                     MPARAM mpwps, MPARAM mphwndInfo)
  2436. {
  2437.     PWPSLISTITEM pwps = (PWPSLISTITEM)mpwps;
  2438.     PSTATUSBARSELECTCLASS psbsc = (PSTATUSBARSELECTCLASS)ulpsbsc;
  2439.     CHAR szInfo[2000];
  2440.     MRESULT mrc = (MPARAM)FALSE;
  2441.     PSZ pszClassTitle;
  2442.  
  2443.     strcpy(szInfo, pwps->pszClassName);
  2444.  
  2445.     if (pwps->pClassObject) {
  2446.         pszClassTitle = _wpclsQueryTitle(pwps->pClassObject);
  2447.         if (pszClassTitle)
  2448.             sprintf(szInfo, "%s (\"%s\")\n",
  2449.                     pwps->pszClassName,
  2450.                     pszClassTitle);
  2451.     }
  2452.  
  2453.     if (pwps->pRecord->flRecordAttr & CRA_INUSE) {
  2454.         strcat(szInfo, (psbsc->pNLSStrings)->pszSBClassMnemonics );
  2455.         strcat(szInfo, "\n");
  2456.         stbQueryClassMnemonics(pwps->pClassObject,
  2457.                 &(szInfo[strlen(szInfo)]), 256);
  2458.         mrc = (MPARAM)TRUE;
  2459.     } else {
  2460.         strcat(szInfo,
  2461.                 psbsc->pNLSStrings->pszSBClassNotSupported);
  2462.     }
  2463.  
  2464.     WinSetWindowText((HWND)mphwndInfo, szInfo);
  2465.  
  2466.     return (mrc);
  2467. }
  2468.  
  2469. /* ******************************************************************
  2470.  *                                                                  *
  2471.  *   "WPS Classes" notebook page functions                          *
  2472.  *                                                                  *
  2473.  ********************************************************************/
  2474.  
  2475. /*
  2476.  *  The "WPS Classes" notebook page in "Workplace Shell" does not
  2477.  *  use the callbacks, but a regular notebook dlg function because
  2478.  *  it needs to handle lots of container messages, which the function
  2479.  *  in notebook.c does not handle.
  2480.  */
  2481.  
  2482. /*
  2483.  *@@ strParseDescription:
  2484.  *      searches pszBuf for pszSrch0 ; if found, the line containing
  2485.  *      pszSrch is parsed as follows:
  2486.  *          <pszSrch0 > <ulFlags> <RestOfLine>
  2487.  *             PSZ       hex str     PSZ
  2488.  *      Returns length of what was copied to pszDescription or
  2489.  *      zero on errors.
  2490.  *      This is used for explaing a certain WPS class when it is
  2491.  *      being selected in the "WPS classes" notebook page.
  2492.  *      This returns TRUE if pszSrch0 was found.
  2493.  */
  2494.  
  2495. BOOL strParseDescription(PSZ pszBuf, PSZ pszSrch0, PULONG pulFlags, PSZ pszDescription)
  2496. {
  2497.     BOOL brc = FALSE;
  2498.     PSZ p1, p2;
  2499.  
  2500.     // create search string for beginning of line
  2501.     PSZ pszSrch2 = malloc(strlen(pszSrch0) + 4);
  2502.     strcpy(pszSrch2, "\r\n");
  2503.     strcat(pszSrch2, pszSrch0);
  2504.  
  2505.     p1 = strstr(pszBuf, pszSrch2);
  2506.     if (p1) {
  2507.         p1 += 2; // skip \r\n
  2508.         p1 = strchr(p1, ' ');
  2509.         if (p1) {
  2510.             // p1 now has ulFlags
  2511.             sscanf(p1, "%lX ", pulFlags);
  2512.             p1 = strchr(p1+1, ' ');
  2513.             if (p1) {
  2514.                 brc = TRUE;
  2515.                 // p1 now has beginning of description
  2516.                 p2 = strstr(p1, "\r\n");
  2517.                 if (p2) {
  2518.                     // p2 now has end of description
  2519.                     strncpy(pszDescription, p1+1, (p2-p1-1));
  2520.                 } else
  2521.                     strncat(pszDescription, p1+1, 200);
  2522.             }
  2523.         }
  2524.     }
  2525.     return (brc);
  2526. }
  2527.  
  2528. PSZ pszClassInfo = NULL;
  2529. HWND hwndClassInfo = NULLHANDLE;
  2530.  
  2531. /*
  2532.  *@@ UpdateClassInfo:
  2533.  *      this is called every time a new class gets selected
  2534.  *      in the "WPS classes" page: update the infos
  2535.  */
  2536.  
  2537. VOID UpdateClassInfo(HWND hwndDlg, PCLASSRECORDCORE pRecordSelected)
  2538. {
  2539.     PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  2540.     HWND hwndIcon = NULLHANDLE;
  2541.     HPOINTER hClassIcon = NULLHANDLE;
  2542.  
  2543.     if (pGlobalSettings->WpsShowClassInfo) {
  2544.         PWPSLISTITEM pwps = pRecordSelected->pwps;
  2545.         CHAR szInfo[1000] = "", szInfo2[256] = "";
  2546.         BOOL fCreate = FALSE;
  2547.         PNLSSTRINGS pNLSStrings = cmnQueryNLSStrings();
  2548.  
  2549.         if (hwndClassInfo)
  2550.             fCreate = !(WinIsWindow(
  2551.                     WinQueryAnchorBlock(HWND_DESKTOP),
  2552.                     hwndClassInfo));
  2553.         if (    (hwndClassInfo == NULLHANDLE)
  2554.              || (fCreate)
  2555.            )
  2556.         {
  2557.             hwndClassInfo = WinLoadDlg(HWND_DESKTOP, hwndDlg,
  2558.                               fnwpDlgGeneric,
  2559.                               NLS_MODULE, ID_XSD_SETTINGS_WPSCL_INFO,
  2560.                               NULL);
  2561.             hwndIcon = WinWindowFromID(hwndClassInfo, ID_XSDI_SC_ICON);
  2562.             anmPrepareStaticIcon(hwndIcon, 1);
  2563.         }
  2564.  
  2565.         if (pwps) {
  2566.                 /* WinSendDlgItemMsg(hwndDlg, ID_XSDI_SC_CLASSICON,
  2567.                         SM_SETHANDLE,
  2568.                         (MPARAM)_ wpclsQueryIcon(pwps->pClassObject),
  2569.                         MPNULL); */
  2570.             // dll name
  2571.             WinSetDlgItemText(hwndClassInfo, ID_XSDI_SC_CLASSMODULE, pwps->pszModName);
  2572.  
  2573.             // class name
  2574.             strcpy(szInfo, pwps->pszClassName);
  2575.             WinSetDlgItemText(hwndClassInfo, ID_XSDI_SC_CLASSNAME, szInfo);
  2576.  
  2577.             // "replaced by"
  2578.             WinSetDlgItemText(hwndClassInfo, ID_XSDI_SC_REPLACEDBY,
  2579.                     (pwps->pszReplacedWithClasses)
  2580.                         ? pwps->pszReplacedWithClasses
  2581.                         : "");
  2582.  
  2583.             // class icon
  2584.             hwndIcon = WinWindowFromID(hwndClassInfo, ID_XSDI_SC_ICON);
  2585.             if (pwps->pClassObject)
  2586.                 hClassIcon = _wpclsQueryIcon(pwps->pClassObject);
  2587.             WinSendMsg(hwndIcon,
  2588.                        SM_SETHANDLE,
  2589.                        (MPARAM)hClassIcon,  // NULLHANDLE if error -> hide
  2590.                        MPNULL);
  2591.  
  2592.             // class title
  2593.             if (pwps->pClassObject) {
  2594.                 PSZ pszClassTitle = _wpclsQueryTitle(
  2595.                                 pwps->pClassObject);
  2596.                 if (pszClassTitle)
  2597.                     sprintf(szInfo2,
  2598.                         "\"%s\"",
  2599.                         pszClassTitle);
  2600.                 else
  2601.                     strcpy(szInfo2, "?");
  2602.             } else
  2603.                 strcpy(szInfo2, pNLSStrings->pszWpsClassLoadingFailed);
  2604.             WinSetDlgItemText(hwndClassInfo, ID_XSDI_SC_CLASSTITLE, szInfo2);
  2605.  
  2606.             // class information
  2607.             if (pszClassInfo) {
  2608.                 ULONG ulFlags;
  2609.                 if (!strParseDescription(pszClassInfo,
  2610.                             pwps->pszClassName,
  2611.                             &ulFlags,
  2612.                             szInfo))
  2613.                 {
  2614.                     // not found: search for "UnknownClass"
  2615.                     strParseDescription(pszClassInfo,
  2616.                             "UnknownClass",
  2617.                             &ulFlags,
  2618.                             szInfo);
  2619.                 }
  2620.             }
  2621.         } // end if (pwps)
  2622.         else {
  2623.             // if (pwps == NULL), the "Orphans" item has been
  2624.             // selected: give info for this
  2625.             strcpy(szInfo, pNLSStrings->pszWpsClassOrphansInfo);
  2626.             WinSetDlgItemText(hwndClassInfo, ID_XSDI_SC_CLASSMODULE, "");
  2627.             WinSetDlgItemText(hwndClassInfo, ID_XSDI_SC_CLASSNAME, "");
  2628.             WinSetDlgItemText(hwndClassInfo, ID_XSDI_SC_REPLACEDBY, "");
  2629.             WinSetDlgItemText(hwndClassInfo, ID_XSDI_SC_CLASSTITLE, "");
  2630.  
  2631.             hwndIcon = WinWindowFromID(hwndClassInfo, ID_XSDI_SC_ICON);
  2632.             WinSendMsg(hwndIcon,
  2633.                        SM_SETHANDLE,
  2634.                        (MPARAM)NULLHANDLE,  // hide icon
  2635.                        MPNULL);
  2636.         }
  2637.  
  2638.         // give MLE new text
  2639.         WinSetDlgItemText(hwndClassInfo, ID_XSDI_SC_TEXT2, szInfo);
  2640.         // scroll MLE to top
  2641.         WinSendDlgItemMsg(hwndClassInfo, ID_XSDI_SC_TEXT2,
  2642.                 MLM_SETFIRSTCHAR,
  2643.                 (MPARAM)0,
  2644.                 MPNULL);
  2645.  
  2646.         WinShowWindow(hwndClassInfo, TRUE);
  2647.     } // end if (pGlobalSettings->WpsShowClassInfo)
  2648.     else {
  2649.         if (hwndClassInfo)
  2650.             if (WinIsWindow(
  2651.                     WinQueryAnchorBlock(HWND_DESKTOP),
  2652.                     hwndClassInfo))
  2653.                 WinShowWindow(hwndClassInfo, FALSE);
  2654.     }
  2655. }
  2656.  
  2657. /*
  2658.  *@@ fncbReturnWPSClassAttr:
  2659.  *      this callback function is called for every single
  2660.  *      record core which represents a WPS class; we need
  2661.  *      to return the record core attributes
  2662.  */
  2663.  
  2664. MRESULT EXPENTRY fncbReturnWPSClassAttr(HWND hwndCnr,
  2665.                     ULONG ulscd,   // SELECTCLASSDATA struct
  2666.                     MPARAM mpwps,  // current WPSLISTITEM struct
  2667.                     MPARAM mpreccParent) // parent record core
  2668. {
  2669.     USHORT          usAttr = CRA_RECORDREADONLY | CRA_COLLAPSED;
  2670.     PWPSLISTITEM     pwps = (PWPSLISTITEM)mpwps;
  2671.     PSELECTCLASSDATA pscd = (PSELECTCLASSDATA)ulscd;
  2672.     PRECORDCORE     preccParent = NULL;
  2673.  
  2674.     if (pwps) {
  2675.         #ifdef DEBUG_SETTINGS
  2676.             _Pmpf(("Checking %s\n", pwps->pszClassName));
  2677.         #endif
  2678.         // if the class is one of the following,
  2679.         // expand all the parent records of the new record
  2680.         // so that these classes are initially visible
  2681.         if (    (strcmp(pwps->pszClassName, "WPAbstract") == 0)
  2682.              || (strcmp(pwps->pszClassName, "XFldDataFile") == 0)
  2683.              || (strcmp(pwps->pszClassName, "XFolder") == 0)
  2684.            )
  2685.         {
  2686.             preccParent = (PRECORDCORE)mpreccParent;
  2687.             while (preccParent)
  2688.             {
  2689.                 WinSendMsg(hwndCnr, CM_EXPANDTREE, (MPARAM)preccParent, MPNULL);
  2690.  
  2691.                 preccParent = WinSendMsg(hwndCnr, CM_QUERYRECORD,
  2692.                         preccParent,
  2693.                         MPFROM2SHORT(CMA_PARENT, CMA_ITEMORDER));
  2694.  
  2695.                 if (preccParent == (PRECORDCORE)-1) {
  2696.                     preccParent = NULL;
  2697.                 }
  2698.             }
  2699.         }
  2700.     }
  2701.     return (MPARAM)(usAttr);
  2702. }
  2703.  
  2704. /*
  2705.  *@@ fncbReplaceClassSelected:
  2706.  *      callback func for class selected in the "Replace
  2707.  *      with subclass" dlg;
  2708.  *      mphwndInfo has been set to the static control hwnd.
  2709.  *      Returns TRUE if the selection is valid; the dlg func
  2710.  *      will then enable the OK button.
  2711.  */
  2712.  
  2713. MRESULT EXPENTRY fncbReplaceClassSelected(HWND hwndCnr, ULONG ulpsbsc,
  2714.                     MPARAM mpwps, MPARAM mphwndInfo)
  2715. {
  2716.     PWPSLISTITEM pwps = (PWPSLISTITEM)mpwps;
  2717.     PSTATUSBARSELECTCLASS psbsc = (PSTATUSBARSELECTCLASS)ulpsbsc;
  2718.     PSZ pszClassTitle;
  2719.     CHAR szInfo[2000] = "";
  2720.  
  2721.     if (pwps->pClassObject) {
  2722.         if (pszClassInfo) {
  2723.             ULONG ulFlags;
  2724.             if (!strParseDescription(pszClassInfo,
  2725.                         pwps->pszClassName,
  2726.                         &ulFlags,
  2727.                         szInfo))
  2728.             {
  2729.                 // not found: search for "UnknownClass"
  2730.                 strParseDescription(pszClassInfo,
  2731.                         "UnknownClass",
  2732.                         &ulFlags,
  2733.                         szInfo);
  2734.             }
  2735.         }
  2736.     }
  2737.  
  2738.     WinSetWindowText((HWND)mphwndInfo, szInfo);
  2739.  
  2740.     return (MRESULT)TRUE;
  2741. }
  2742.  
  2743. /*
  2744.  *@@ fnwpSettingsWpsClasses:
  2745.  *      dlg func for "WPS Classes" notebook page; this does
  2746.  *      _not_ use the common notebook funcs, because it needs
  2747.  *      to handle too many different (cnr) messages
  2748.  */
  2749.  
  2750. BOOL fFillingCnr = FALSE;
  2751.  
  2752. MRESULT EXPENTRY fnwpSettingsWpsClasses(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  2753. {
  2754.     MRESULT mrc = MPNULL;
  2755.     PSELECTCLASSDATA pscd = (PSELECTCLASSDATA)WinQueryWindowULong(hwndDlg, QWL_USER);
  2756.  
  2757.     switch(msg) {
  2758.  
  2759.         /*
  2760.          * WM_INITDLG:
  2761.          *      set up the container data and colors
  2762.          */
  2763.  
  2764.         case WM_INITDLG: {
  2765.             CNRINFO CnrInfo;
  2766.  
  2767.             mrc = WinDefDlgProc(hwndDlg, msg, mp1, mp2);
  2768.  
  2769.             pscd = (PSELECTCLASSDATA)malloc(sizeof(SELECTCLASSDATA));
  2770.             memset(pscd, 0, sizeof(SELECTCLASSDATA));
  2771.             WinSetWindowULong(hwndDlg, QWL_USER, (ULONG)pscd);
  2772.  
  2773.             // make Warp 4 notebook buttons and move controls
  2774.             winhAssertWarp4Notebook(hwndDlg,
  2775.                     100,         // ID threshold
  2776.                     WARP4_NOTEBOOK_OFFSET);   // move other controls offset (common.h)
  2777.  
  2778.             // setup container
  2779.             pscd->hwndCnr = WinWindowFromID(hwndDlg, ID_XSDI_SC_CNR);
  2780.             WinSendMsg(pscd->hwndCnr, CM_QUERYCNRINFO, &CnrInfo, (MPARAM)sizeof(CnrInfo));
  2781.             CnrInfo.pSortRecord = (PVOID)fnCompareName;
  2782.             CnrInfo.flWindowAttr =
  2783.                     CV_TREE | CA_TREELINE | CV_TEXT;
  2784.             CnrInfo.cxTreeIndent = 30;
  2785.             WinSendMsg(pscd->hwndCnr, CM_SETCNRINFO,
  2786.                     &CnrInfo,
  2787.                     (MPARAM)(CMA_PSORTRECORD | CMA_FLWINDOWATTR | CMA_CXTREEINDENT));
  2788.  
  2789.             WinPostMsg(hwndDlg, WM_SETTINGS2DLG, MPNULL, MPNULL);
  2790.  
  2791.             // fill container later
  2792.             fFillingCnr = FALSE;
  2793.             WinSendMsg(hwndDlg, WM_FILLCNR, MPNULL, MPNULL);
  2794.         break; }
  2795.  
  2796.         /*
  2797.          * WM_FILLCNR:
  2798.          *      this fills the cnr with all the WPS classes
  2799.          */
  2800.  
  2801.         case WM_FILLCNR: {
  2802.             HPOINTER hptrOld = WinQueryPointer(HWND_DESKTOP);
  2803.             CHAR szClassInfoFile[CCHMAXPATH];
  2804.             ULONG ulCopied;
  2805.             PNLSSTRINGS pNLSStrings = cmnQueryNLSStrings();
  2806.  
  2807.             WinSetPointer(HWND_DESKTOP,
  2808.                     WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE));
  2809.             fFillingCnr = TRUE;
  2810.  
  2811.             pscd->pszRootClass = "WPObject";
  2812.             strcpy(pscd->szClassSelected, "WPObject");
  2813.  
  2814.             pscd->pfnwpReturnAttrForClass = fncbReturnWPSClassAttr;
  2815.             pscd->pfnwpClassSelected = NULL; // fncbStatusBarClassSelected;
  2816.             // scd.ulUserClassSelected = (ULONG)&sbsc;
  2817.  
  2818.             if (cmnQueryXFolderBasePath(szClassInfoFile))
  2819.             {
  2820.                 sprintf(szClassInfoFile+strlen(szClassInfoFile),
  2821.                         "\\help\\xfcls%s.txt",
  2822.                         cmnQueryLanguageCode());
  2823.                 // _Pmpf(("Class info file: %s", szClassInfoFile));
  2824.                 pszClassInfo = doshReadTextFile(szClassInfoFile, 100);
  2825.             } else
  2826.                 return (NULL);
  2827.  
  2828.             // add orphans; this is done by setting the title
  2829.             // for the "Orphans" recc tree
  2830.             pscd->pszOrphans = pNLSStrings->pszWpsClassOrphans;
  2831.  
  2832.             // fill container with WPS data (classlst.c)
  2833.             pscd->pwpsc = clsWpsClasses2Cnr(pscd->hwndCnr, pscd->pszRootClass,
  2834.                     pscd);  // also contains callback
  2835.  
  2836.             fFillingCnr = FALSE;
  2837.             WinSetPointer(HWND_DESKTOP, hptrOld);
  2838.         break; }
  2839.  
  2840.         case WM_SETTINGS2DLG: {
  2841.             PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  2842.             winhSetDlgItemChecked(hwndDlg, ID_XSDI_SC_BOOTUPSTATUS, pGlobalSettings->ShowBootupStatus);
  2843.         break; }
  2844.  
  2845.         case WM_DLG2SETTINGS: {
  2846.             PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  2847.             pGlobalSettings->ShowBootupStatus = winhIsDlgItemChecked(hwndDlg, ID_XSDI_SC_BOOTUPSTATUS);
  2848.             cmnStoreGlobalSettings(); // update INI
  2849.         break; }
  2850.  
  2851.         /*
  2852.          * WM_TIMER:
  2853.          *      timer for tree view auto-scroll (we don't
  2854.          *      use the Worker thread here)
  2855.          */
  2856.  
  2857.         case WM_TIMER: {
  2858.             if ( ( pscd->preccExpanded->flRecordAttr & CRA_EXPANDED) != 0 ) {
  2859.                 PRECORDCORE     preccLastChild;
  2860.                 WinStopTimer(WinQueryAnchorBlock(hwndDlg),
  2861.                         hwndDlg,
  2862.                         1);
  2863.                 // scroll the tree view properly
  2864.                 preccLastChild = WinSendMsg(pscd->hwndCnr,
  2865.                         CM_QUERYRECORD,
  2866.                         pscd->preccExpanded,   // expanded PRECORDCORE from CN_EXPANDTREE
  2867.                     MPFROM2SHORT(CMA_LASTCHILD, CMA_ITEMORDER));
  2868.                 if (preccLastChild) {
  2869.                     // ULONG ulrc;
  2870.                     winhCnrScrollToRecord(pscd->hwndCnr,
  2871.                             (PRECORDCORE)preccLastChild,
  2872.                             CMA_TEXT,   // record text rectangle only
  2873.                             TRUE);      // keep parent visible
  2874.                 }
  2875.             }
  2876.         }
  2877.  
  2878.         /*
  2879.          * WM_CONTROL:
  2880.          *      capture cnr notifications
  2881.          */
  2882.  
  2883.         case WM_CONTROL: {
  2884.             if (SHORT1FROMMP(mp1) == ID_XSDI_SC_BOOTUPSTATUS) {
  2885.                 WinPostMsg(hwndDlg, WM_DLG2SETTINGS, MPNULL, MPNULL);
  2886.             } else if (SHORT1FROMMP(mp1) == ID_XSDI_SC_CNR) {
  2887.  
  2888.                 switch (SHORT2FROMMP(mp1)) { // notify code
  2889.  
  2890.                     /*
  2891.                      * CN_EXPANDTREE:
  2892.                      *      tree view has been expanded:
  2893.                      *      do cnr auto-scroll if we're
  2894.                      *      not initially filling the cnr
  2895.                      */
  2896.  
  2897.                     case CN_EXPANDTREE: {
  2898.                         if (!fFillingCnr) {
  2899.                             PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  2900.                             if (pGlobalSettings->TreeViewAutoScroll) {
  2901.                                 pscd->preccExpanded = (PRECORDCORE)mp2;
  2902.                                 WinStartTimer(WinQueryAnchorBlock(hwndDlg),
  2903.                                         hwndDlg,
  2904.                                         1,
  2905.                                         100);
  2906.                             }
  2907.                         }
  2908.                         mrc = MPNULL;
  2909.                     break; }
  2910.  
  2911.                     /*
  2912.                      * CN_CONTEXTMENU:
  2913.                      *      context menu requested
  2914.                      */
  2915.  
  2916.                     case CN_CONTEXTMENU: {
  2917.                         POINTL ptl;
  2918.                         HWND   hPopupMenu;
  2919.                         PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  2920.                         ULONG ulFlagsSelected = 0;
  2921.                         CHAR szDummy[2000];
  2922.  
  2923.                         pscd->preccSource = (PCLASSRECORDCORE)mp2;
  2924.                         if (pscd->preccSource) {
  2925.                             QUERYRECORDRECT qRect;
  2926.                             RECTL rclRecc;
  2927.  
  2928.                             // we have a selection
  2929.                             LONG lrc2;
  2930.                             hPopupMenu = WinLoadMenu(hwndDlg, NLS_MODULE,
  2931.                                     ID_XSM_WPSCLASSES_SEL);
  2932.  
  2933.                             // give the marked item source emphasis
  2934.                             WinSendMsg(pscd->hwndCnr,
  2935.                                         CM_SETRECORDEMPHASIS,
  2936.                                         (MPARAM)pscd->preccSource,
  2937.                                         MPFROM2SHORT(TRUE,  // set emphasis
  2938.                                                 CRA_SOURCE));
  2939.  
  2940.                             // allow deregistering?
  2941.                             if (pscd->preccSource->pwps) {
  2942.                                 BOOL fAllowDeregister = TRUE;
  2943.                                 if (pscd->preccSource->pwps->pszModName == NULL)
  2944.                                     // DLL == NULL: not in WPS class list,
  2945.                                     // so we better not allow touching this
  2946.                                     fAllowDeregister = FALSE;
  2947.                                 else  if (pszClassInfo)
  2948.                                     // parse class info text whether this
  2949.                                     // class may be deregistered
  2950.                                     if (strParseDescription(pszClassInfo,
  2951.                                             pscd->preccSource->pwps->pszClassName,
  2952.                                             &ulFlagsSelected,
  2953.                                             szDummy))
  2954.                                         if (ulFlagsSelected == 0)
  2955.                                             fAllowDeregister = FALSE;
  2956.                                 if (!fAllowDeregister)
  2957.                                     // disable "Deregister" menu item
  2958.                                     WinEnableMenuItem(hPopupMenu,
  2959.                                             ID_XSMI_WPS_DEREGISTER, FALSE);
  2960.  
  2961.                                 // allow replacements only if the
  2962.                                 // class has subclasses
  2963.                                 lrc2 = (LONG)WinSendMsg(
  2964.                                         pscd->hwndCnr, CM_QUERYRECORD,
  2965.                                         (MPARAM)pscd->preccSource,
  2966.                                         MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
  2967.                                 if ((lrc2 == 0) || (lrc2 == -1))
  2968.                                     WinEnableMenuItem(hPopupMenu,
  2969.                                         ID_XSMI_WPS_REPLACE, FALSE);
  2970.                                 // allow de-replacement only if the
  2971.                                 // replaces another class
  2972.                                 if (pscd->preccSource->pwps->pszReplacesThisClass == NULL)
  2973.                                     WinEnableMenuItem(hPopupMenu,
  2974.                                         ID_XSMI_WPS_UNREPLACE, FALSE);
  2975.  
  2976.                             } else {
  2977.                                 WinEnableMenuItem(hPopupMenu,
  2978.                                     ID_XSMI_WPS_DEREGISTER, FALSE);
  2979.                                 WinEnableMenuItem(hPopupMenu,
  2980.                                     ID_XSMI_WPS_REPLACE, FALSE);
  2981.                                 WinEnableMenuItem(hPopupMenu,
  2982.                                     ID_XSMI_WPS_UNREPLACE, FALSE);
  2983.                             }
  2984.  
  2985.                             // calculate the point where to show the context
  2986.                             // menu; we use the lower-right corner of the
  2987.                             // source record core
  2988.                             qRect.cb = sizeof(qRect);
  2989.                             qRect.pRecord = (PRECORDCORE)pscd->preccSource;
  2990.                             qRect.fsExtent = CMA_TEXT;
  2991.                             WinSendMsg(pscd->hwndCnr,
  2992.                                        CM_QUERYRECORDRECT,
  2993.                                        &rclRecc,
  2994.                                        &qRect);
  2995.                             ptl.x = rclRecc.xRight;
  2996.                             ptl.y = rclRecc.yBottom;
  2997.                             // convert this to screen coordinates
  2998.                             WinMapWindowPoints(pscd->hwndCnr,
  2999.                                        HWND_DESKTOP,
  3000.                                        &ptl,
  3001.                                        1);
  3002.                         } else {
  3003.                             // no selection: different menu
  3004.                             hPopupMenu = WinLoadMenu(hwndDlg, NLS_MODULE,
  3005.                                     ID_XSM_WPSCLASSES_NOSEL);
  3006.                             WinSendMsg(pscd->hwndCnr,
  3007.                                         CM_SETRECORDEMPHASIS,
  3008.                                         (MPARAM)NULL,   // undocumented: if precc == NULL,
  3009.                                                         // the whole cnr is given emphasis
  3010.                                         MPFROM2SHORT(TRUE,  // set emphasis
  3011.                                                 CRA_SOURCE));
  3012.                             // use mouse coordinates for context menu
  3013.                             WinQueryPointerPos(HWND_DESKTOP, &ptl);
  3014.                         }
  3015.  
  3016.                         if (hwndClassInfo) {
  3017.                             if (!WinIsWindow(
  3018.                                     WinQueryAnchorBlock(hwndDlg),
  3019.                                     hwndClassInfo))
  3020.                                 pGlobalSettings->WpsShowClassInfo = FALSE;
  3021.                         } else
  3022.                             pGlobalSettings->WpsShowClassInfo = FALSE;
  3023.  
  3024.                         // check "info" menu item?
  3025.                         winhSetMenuItemChecked(hPopupMenu,
  3026.                                 ID_XSMI_WPS_INFO,
  3027.                                 (pGlobalSettings->WpsShowClassInfo));
  3028.  
  3029.                         _Pmpf(("ptl.x: %d, ptl.y: %d", ptl.x, ptl.y));
  3030.  
  3031.                         // finally, show context menu
  3032.                         WinPopupMenu(HWND_DESKTOP, hwndDlg,
  3033.                                 hPopupMenu,
  3034.                                 (SHORT)ptl.x,
  3035.                                 (SHORT)ptl.y,
  3036.                                 0,
  3037.                                 PU_NONE | PU_MOUSEBUTTON1 | PU_KEYBOARD
  3038.                                 | PU_HCONSTRAIN | PU_VCONSTRAIN);
  3039.                     break; }
  3040.  
  3041.                     /*
  3042.                      * CN_EMPHASIS:
  3043.                      *      selection changed: call UpdateClassInfo
  3044.                      */
  3045.  
  3046.                     case CN_EMPHASIS: {
  3047.                         // get cnr notification struct
  3048.                         PNOTIFYRECORDEMPHASIS pnre = (PNOTIFYRECORDEMPHASIS)mp2;
  3049.  
  3050.                         if (pnre)
  3051.                             if (    (pnre->fEmphasisMask & CRA_SELECTED)
  3052.                                  && (pnre->pRecord)
  3053.                                )
  3054.                             {
  3055.                                 pscd->preccSelection = (PCLASSRECORDCORE)(pnre->pRecord);
  3056.                                 UpdateClassInfo(hwndDlg, pscd->preccSelection);
  3057.                             }
  3058.                     break; }
  3059.                 }
  3060.             } // end if (SHORT1FROMMP(mp1) == ID_XSDI_SC_CNR) {
  3061.         break; }
  3062.  
  3063.         /*
  3064.          * WM_COMMAND:
  3065.          *
  3066.          */
  3067.  
  3068.         case WM_COMMAND: {
  3069.             PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  3070.  
  3071.             switch (SHORT1FROMMP(mp1)) {
  3072.  
  3073.                 // "Information" menu command
  3074.                 case ID_XSMI_WPS_INFO: {
  3075.                     if (pGlobalSettings->WpsShowClassInfo) {
  3076.                         pGlobalSettings->WpsShowClassInfo = FALSE;
  3077.                     } else {
  3078.                         pGlobalSettings->WpsShowClassInfo = TRUE;
  3079.                     }
  3080.                     cmnStoreGlobalSettings();
  3081.                     UpdateClassInfo(hwndDlg, pscd->preccSelection);
  3082.                 break; }
  3083.  
  3084.                 // "Register" menu command
  3085.                 case ID_XSMI_WPS_REGISTER: {
  3086.                     REGISTERCLASSDATA rcd;
  3087.                     rcd.pszHelpLibrary = cmnQueryHelpLibrary();
  3088.                     rcd.ulHelpPanel = ID_XFH_REGISTERCLASS;
  3089.                     if (WinDlgBox(HWND_DESKTOP, hwndDlg,
  3090.                                              fnwpRegisterClass,
  3091.                                              NLS_MODULE, ID_XSD_SETTINGS_WPSCL_REGISTER,
  3092.                                              &rcd) == DID_OK)
  3093.                     {
  3094.                         PSZ pTable[1];
  3095.                         HPOINTER hptrOld = WinQueryPointer(HWND_DESKTOP);
  3096.                         pTable[0] = rcd.szClassName;
  3097.                         WinSetPointer(HWND_DESKTOP,
  3098.                                 WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE));
  3099.                         WinSendMsg(pscd->hwndCnr,
  3100.                                     CM_REMOVERECORD,
  3101.                                     (MPARAM)NULL,
  3102.                                     MPFROM2SHORT(0, // remove all records
  3103.                                             CMA_FREE | CMA_INVALIDATE));
  3104.                         clsCleanupWpsClasses(pscd->pwpsc);
  3105.                         WinSetPointer(HWND_DESKTOP, hptrOld);
  3106.                         free(pszClassInfo);
  3107.                         pszClassInfo = NULL;
  3108.  
  3109.                         if (WinRegisterObjectClass(rcd.szClassName, rcd.szModName))
  3110.                             // success
  3111.                             cmnMessageBoxMsgExt(hwndDlg,
  3112.                                     121,
  3113.                                     pTable, 1, 131,
  3114.                                     MB_OK);
  3115.                         else
  3116.                             // error
  3117.                             cmnMessageBoxMsgExt(hwndDlg,
  3118.                                     104,
  3119.                                     pTable, 1, 132,
  3120.                                     MB_OK);
  3121.  
  3122.                         // fill cnr again
  3123.                         WinPostMsg(hwndDlg, WM_FILLCNR, MPNULL, MPNULL);
  3124.                     }
  3125.                 break; }
  3126.  
  3127.                 // "Deregister" menu command
  3128.                 case ID_XSMI_WPS_DEREGISTER: {
  3129.                     if (pscd->preccSource)
  3130.                         if (pscd->preccSource->pwps) {
  3131.                             BOOL fAllow = FALSE;
  3132.                             CHAR szTemp[CCHMAXPATH];
  3133.                             PSZ pTable[2];
  3134.                             pTable[0] = szTemp;
  3135.                             pTable[1] = pscd->preccSource->pwps->pszReplacedWithClasses;
  3136.  
  3137.                             strcpy(szTemp, pscd->preccSource->pwps->pszClassName);
  3138.                                 // save for later
  3139.  
  3140.                             // do not allow deregistering if the class is currently
  3141.                             // replaced by another class
  3142.                             if ( pscd->preccSource->pwps->pszReplacedWithClasses)
  3143.                             {
  3144.                                 // show warning
  3145.                                 cmnMessageBoxMsgExt(hwndDlg,
  3146.                                             116,
  3147.                                             pTable, 2, 139,
  3148.                                             MB_OK);
  3149.                                 // and stop
  3150.                                 break;
  3151.                             }
  3152.  
  3153.                             if (strncmp(pscd->preccSource->pwps->pszClassName,
  3154.                                             "XFld", 4) == 0) {
  3155.                                 // XFolder class
  3156.                                 if (cmnMessageBoxMsgExt(hwndDlg,
  3157.                                             116,
  3158.                                             pTable, 1, 120,
  3159.                                             MB_YESNO | MB_DEFBUTTON2)
  3160.                                         == MBID_YES)
  3161.                                     fAllow = TRUE;
  3162.                             } else
  3163.                                 if (cmnMessageBoxMsgExt(hwndDlg,
  3164.                                             116,
  3165.                                             pTable, 1, 118,
  3166.                                             MB_YESNO | MB_DEFBUTTON2)
  3167.                                         == MBID_YES)
  3168.                                     fAllow = TRUE;
  3169.  
  3170.                             if (fAllow) {
  3171.                                 if (WinDeregisterObjectClass(pscd->preccSource->pwps->pszClassName))
  3172.                                 {
  3173.                                     // success
  3174.                                     lstRemoveItem((PLISTITEM*)(&(pscd->pwpsc->pwpsClassList)),
  3175.                                             NULL,
  3176.                                             (PLISTITEM)pscd->preccSource->pwps);
  3177.                                                     // remove item from list
  3178.  
  3179.                                     // free(pscd->pRecordSelected->pwps);
  3180.  
  3181.                                     WinSendMsg(pscd->hwndCnr,
  3182.                                                 CM_REMOVERECORD,
  3183.                                                 (MPARAM)&(pscd->preccSource),
  3184.                                                 MPFROM2SHORT(1, // remove one record
  3185.                                                         CMA_FREE | CMA_INVALIDATE));
  3186.  
  3187.                                     cmnMessageBoxMsgExt(hwndDlg,
  3188.                                             121,
  3189.                                             pTable, 1, 122,
  3190.                                             MB_OK);
  3191.                                 } else
  3192.                                     // error
  3193.                                     cmnMessageBoxMsgExt(hwndDlg,
  3194.                                             104,
  3195.                                             pTable, 1, 119,
  3196.                                             MB_OK);
  3197.                             }
  3198.                         }
  3199.                 break; }
  3200.  
  3201.                 // "Replace class" menu command:
  3202.                 // show yet another WPS classes dlg
  3203.                 case ID_XSMI_WPS_REPLACE: {
  3204.                     if (pscd->preccSource)
  3205.                         if (pscd->preccSource)
  3206.                         {
  3207.                             SELECTCLASSDATA         scd;
  3208.                             STATUSBARSELECTCLASS    sbsc;
  3209.                             PSZ                     pszClassName =
  3210.                                         pscd->preccSource->pwps->pszClassName;
  3211.  
  3212.                             CHAR szTitle[CCHMAXPATH] = "title";
  3213.                             CHAR szIntroText[2000] = "intro";
  3214.  
  3215.                             cmnGetMessage(NULL, 0,
  3216.                                     szTitle, sizeof(szTitle), 112);
  3217.                             // replace "%1" by class name which is to be
  3218.                             // replaced
  3219.                             cmnGetMessage(&pszClassName, 1,
  3220.                                     szIntroText, sizeof(szIntroText), 123);
  3221.                             scd.pszDlgTitle = szTitle;
  3222.                             scd.pszIntroText = szIntroText;
  3223.                             scd.pszRootClass = pszClassName;
  3224.                             scd.pszOrphans = NULL;
  3225.                             strcpy(scd.szClassSelected, scd.pszRootClass);
  3226.  
  3227.                             scd.pfnwpReturnAttrForClass = NULL; // fncbStatusBarReturnClassAttr;
  3228.                             scd.pfnwpClassSelected = fncbReplaceClassSelected;
  3229.                             // the folllowing data will be passed to the callbacks
  3230.                             // so the callback can display NLS messages
  3231.                             sbsc.pNLSStrings = cmnQueryNLSStrings();
  3232.                             scd.ulUserClassSelected = (ULONG)&sbsc;
  3233.  
  3234.                             scd.pszHelpLibrary = cmnQueryHelpLibrary();
  3235.                             scd.ulHelpPanel = 0;
  3236.  
  3237.                             if (clsSelectWpsClassDlg(hwndDlg,
  3238.                                     NLS_MODULE, ID_XSD_SELECTCLASS,
  3239.                                     &scd) == DID_OK)
  3240.                             {
  3241.                                 PSZ pTable[2];
  3242.                                 pTable[0] = pscd->preccSource->pwps->pszClassName;
  3243.                                 pTable[1] = scd.szClassSelected;
  3244.                                 if (cmnMessageBoxMsgExt(hwndDlg,
  3245.                                             116,
  3246.                                             pTable, 2, 124,
  3247.                                             MB_YESNO | MB_DEFBUTTON2)
  3248.                                         == MBID_YES)
  3249.                                     if (WinReplaceObjectClass(
  3250.                                             pscd->preccSource->pwps->pszClassName,
  3251.                                             scd.szClassSelected,
  3252.                                             TRUE))
  3253.                                         // success
  3254.                                         cmnMessageBoxMsgExt(hwndDlg,
  3255.                                                 121,
  3256.                                                 pTable, 2, 129,
  3257.                                                 MB_OK);
  3258.                                     else
  3259.                                         // error
  3260.                                         cmnMessageBoxMsgExt(hwndDlg,
  3261.                                                 104,
  3262.                                                 pTable, 2, 130,
  3263.                                                 MB_OK);
  3264.                             }
  3265.                         }
  3266.                 break; }
  3267.  
  3268.                 // "Unreplace class" menu command
  3269.                 case ID_XSMI_WPS_UNREPLACE: {
  3270.                     if (pscd->preccSource)
  3271.                         if (pscd->preccSource->pwps) {
  3272.                             BOOL fAllow = FALSE;
  3273.                             PSZ pTable[2];
  3274.                             pTable[0] = pscd->preccSource->pwps->pszReplacesThisClass;
  3275.                             pTable[1] = pscd->preccSource->pwps->pszClassName;
  3276.  
  3277.                             if (strncmp(pscd->preccSource->pwps->pszClassName,
  3278.                                             "XFld", 4) == 0) {
  3279.                                 // XFolder class
  3280.                                 if (cmnMessageBoxMsgExt(hwndDlg,
  3281.                                             116,
  3282.                                             pTable, 2, 125,
  3283.                                             MB_YESNO | MB_DEFBUTTON2)
  3284.                                         == MBID_YES)
  3285.                                     fAllow = TRUE;
  3286.                             } else
  3287.                                 if (cmnMessageBoxMsgExt(hwndDlg,
  3288.                                             116,
  3289.                                             pTable, 2, 126,
  3290.                                             MB_YESNO | MB_DEFBUTTON2)
  3291.                                         == MBID_YES)
  3292.                                     fAllow = TRUE;
  3293.  
  3294.                             if (fAllow) {
  3295.                                 if (WinReplaceObjectClass(
  3296.                                         pscd->preccSource->pwps->pszReplacesThisClass,
  3297.                                         pscd->preccSource->pwps->pszClassName,
  3298.                                         FALSE))
  3299.                                     // success
  3300.                                     cmnMessageBoxMsgExt(hwndDlg,
  3301.                                             121,
  3302.                                             pTable, 2, 127,
  3303.                                             MB_OK);
  3304.                                 else
  3305.                                     // error
  3306.                                     cmnMessageBoxMsgExt(hwndDlg,
  3307.                                             104,
  3308.                                             pTable, 2, 128,
  3309.                                             MB_OK);
  3310.                             }
  3311.                         }
  3312.                 break; }
  3313.             } // end switch (SHORT1FROMMP(mp1))
  3314.             pscd->preccSource = NULL;
  3315.         break; }
  3316.  
  3317.         /*
  3318.          * WM_MENUEND:
  3319.          *      if the context menu is dismissed, we'll need
  3320.          *      to remove the cnr source emphasis which we
  3321.          *      set above
  3322.          */
  3323.  
  3324.         case WM_MENUEND: {
  3325.             WinSendMsg(pscd->hwndCnr,
  3326.                         CM_SETRECORDEMPHASIS,
  3327.                         (MPARAM)pscd->preccSource,
  3328.                         MPFROM2SHORT(FALSE,  // remove emphasis
  3329.                                 CRA_SOURCE));
  3330.         break; }
  3331.  
  3332.         /*
  3333.          * WM_WINDOWPOSCHANGED:
  3334.          *      cheap trick: this msg is posted when
  3335.          *      the user switches to a different notebook
  3336.          *      page. Since every notebook page is really
  3337.          *      a separate dialog window, PM simulates
  3338.          *      switching notebook pages by showing or
  3339.          *      hiding the various dialog windows.
  3340.          *      We also show or hide the "Information"
  3341.          *      window then.
  3342.          */
  3343.  
  3344.         case WM_WINDOWPOSCHANGED: {
  3345.             PGLOBALSETTINGS pGlobalSettings = cmnQueryGlobalSettings();
  3346.             PSWP pswp = (PSWP)mp1;
  3347.  
  3348.             // call default
  3349.             mrc = WinDefDlgProc(hwndDlg, msg, mp1, mp2);
  3350.  
  3351.             if (pswp->fl & SWP_SHOW) {
  3352.                 // notebook page is shown:
  3353.                 // also show "Info" window
  3354.                 if ( pGlobalSettings->WpsShowClassInfo)
  3355.                     WinShowWindow(hwndClassInfo, TRUE);
  3356.             } else if (pswp->fl & SWP_HIDE)
  3357.                 // notebook page is hidden:
  3358.                 // hide "Info" window
  3359.                 WinShowWindow(hwndClassInfo, FALSE);
  3360.         break; }
  3361.  
  3362.         /*
  3363.          * WM_DESTROY:
  3364.          *      clean up big time
  3365.          */
  3366.  
  3367.         case WM_DESTROY: {
  3368.             HPOINTER hptrOld = WinQueryPointer(HWND_DESKTOP);
  3369.             WinSetPointer(HWND_DESKTOP,
  3370.                     WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE));
  3371.             if (hwndClassInfo) {
  3372.                 WinDestroyWindow(hwndClassInfo);
  3373.                 hwndClassInfo = NULLHANDLE;
  3374.             }
  3375.             // free cnr records
  3376.             WinSendMsg(pscd->hwndCnr,
  3377.                         CM_REMOVERECORD,
  3378.                         (MPARAM)NULL,
  3379.                         MPFROM2SHORT(0, // remove all records
  3380.                                 CMA_FREE | CMA_INVALIDATE));
  3381.  
  3382.             // cleanup allocated WPS data (classlst.c)
  3383.             clsCleanupWpsClasses(pscd->pwpsc);
  3384.             free(pscd);
  3385.             free(pszClassInfo);
  3386.             pszClassInfo = NULL;
  3387.             mrc = WinDefDlgProc(hwndDlg, msg, mp1, mp2);
  3388.             WinSetPointer(HWND_DESKTOP, hptrOld);
  3389.         break; }
  3390.  
  3391.         default:
  3392.             mrc = WinDefDlgProc(hwndDlg, msg, mp1, mp2);
  3393.     }
  3394.     return (mrc);
  3395. }
  3396.  
  3397. /* ******************************************************************
  3398.  *                                                                  *
  3399.  *   here come the XFldWPS instance methods                         *
  3400.  *                                                                  *
  3401.  ********************************************************************/
  3402.  
  3403. /*
  3404.  *@@ xfAddXFldWPSPages:
  3405.  *           this actually adds the XFolder pages into the "Workplace Shell" notebook
  3406.  */
  3407.  
  3408. SOM_Scope ULONG  SOMLINK xfwps_xfAddXFldWPSPages(XFldWPS *somSelf,
  3409.                                                    HWND hwndDlg)
  3410. {
  3411.     PAGEINFO        pi;
  3412.     PCREATENOTEBOOKPAGE pcnbp;
  3413.     HMODULE         savehmod = NLS_MODULE;
  3414.     CHAR            szXFolderVersion[100];
  3415.     PNLSSTRINGS pNLSStrings = cmnQueryNLSStrings();
  3416.     PSZ pszHelpLibrary = cmnQueryHelpLibrary();
  3417.     /* XFldWPSData *somThis = XFldWPSGetData(somSelf); */
  3418.     XFldWPSMethodDebug("XFldWPS","xfwps_xfAddXFldWPSPages");
  3419.  
  3420.     strcpy(szXFolderVersion, "~XFolder ");
  3421.     strcat(szXFolderVersion, XFOLDER_VERSION);
  3422.     memset((PCH)&pi, 0, sizeof(PAGEINFO));
  3423.  
  3424.     // insert "WPS Classes" page
  3425.     pi.cb                  = sizeof(PAGEINFO);
  3426.     pi.hwndPage            = NULLHANDLE;
  3427.     pi.pfnwp               = fnwpSettingsWpsClasses;
  3428.     pi.resid               = savehmod;
  3429.     pi.pCreateParams       = somSelf;
  3430.     pi.dlgid               = ID_XSD_SETTINGS_WPSCLASSES;
  3431.     pi.usPageStyleFlags    = BKA_STATUSTEXTON | BKA_MAJOR;   // major tab;
  3432.     pi.usPageInsertFlags   = BKA_FIRST;
  3433.     pi.usSettingsFlags     = 0; // don't enumerate in status line
  3434.     pi.pszName             = pNLSStrings->pszWpsClasses;
  3435.  
  3436.     pi.pszHelpLibraryName  = pszHelpLibrary;
  3437.     pi.idDefaultHelpPanel  = ID_XSH_SETTINGS_WPSCLASSES;
  3438.  
  3439.     _wpInsertSettingsPage(somSelf, hwndDlg, &pi);
  3440.  
  3441.     // insert "Sort" page
  3442.     pcnbp = malloc(sizeof(CREATENOTEBOOKPAGE));
  3443.     memset(pcnbp, 0, sizeof(CREATENOTEBOOKPAGE));
  3444.     pcnbp->somSelf = somSelf;
  3445.     pcnbp->hwndNotebook = hwndDlg;
  3446.     pcnbp->hmod = savehmod;
  3447.     pcnbp->ulDlgID = ID_XSD_SETTINGS_FLDRSORT;
  3448.     pcnbp->fMajorTab = TRUE;
  3449.     pcnbp->pszName = pNLSStrings->pszSort;
  3450.     pcnbp->ulDefaultHelpPanel  = ID_XSH_SETTINGS_FLDRSORT;
  3451.     // mark this page as "global", because both
  3452.     // the instance settings notebook and the
  3453.     // "Workplace Shell" object use the same
  3454.     // callbacks
  3455.     pcnbp->ulPageID = SP_FLDRSORT_GLOBAL;
  3456.     pcnbp->pfncbInitPage    = fncbSortInitPage;
  3457.     pcnbp->pfncbItemChanged = fncbSortItemChanged;
  3458.     ntbInsertPage(pcnbp);
  3459.  
  3460.     // insert "Hotkeys" page
  3461.     pcnbp = malloc(sizeof(CREATENOTEBOOKPAGE));
  3462.     memset(pcnbp, 0, sizeof(CREATENOTEBOOKPAGE));
  3463.     pcnbp->somSelf = somSelf;
  3464.     pcnbp->hwndNotebook = hwndDlg;
  3465.     pcnbp->hmod = savehmod;
  3466.     pcnbp->ulDlgID = ID_XSD_SET4ACCELS;
  3467.     pcnbp->fMajorTab = TRUE;
  3468.     pcnbp->pszName = pNLSStrings->psz4Accelerators;
  3469.     pcnbp->ulDefaultHelpPanel  = ID_XSH_SETTINGS1+5;
  3470.     pcnbp->ulPageID = SP_4ACCELERATORS;
  3471.     pcnbp->pfncbInitPage    = fncbWPSFldrHotkeysInitPage;
  3472.     pcnbp->pfncbItemChanged = fncbWPSFldrHotkeysItemChanged;
  3473.     ntbInsertPage(pcnbp);
  3474.  
  3475.     // insert "Snap to grid" page
  3476.     pcnbp = malloc(sizeof(CREATENOTEBOOKPAGE));
  3477.     memset(pcnbp, 0, sizeof(CREATENOTEBOOKPAGE));
  3478.     pcnbp->somSelf = somSelf;
  3479.     pcnbp->hwndNotebook = hwndDlg;
  3480.     pcnbp->hmod = savehmod;
  3481.     pcnbp->fMajorTab = TRUE;
  3482.     pcnbp->pszName = pNLSStrings->psz3SnapToGrid;
  3483.     pcnbp->ulDlgID = ID_XSD_SET3SNAPTOGRID;
  3484.     pcnbp->ulDefaultHelpPanel  = ID_XSH_SETTINGS1+4;
  3485.     pcnbp->ulPageID = SP_3SNAPTOGRID;
  3486.     pcnbp->pfncbInitPage    = fncbWPSSnap2GridInitPage;
  3487.     pcnbp->pfncbItemChanged = fncbWPSSnap2GridItemChanged;
  3488.     ntbInsertPage(pcnbp);
  3489.  
  3490.     /*
  3491.      * "Status bar" pages
  3492.      */
  3493.  
  3494.     // insert "Status bar" page 2
  3495.     pcnbp = malloc(sizeof(CREATENOTEBOOKPAGE));
  3496.     memset(pcnbp, 0, sizeof(CREATENOTEBOOKPAGE));
  3497.     pcnbp->somSelf = somSelf;
  3498.     pcnbp->hwndNotebook = hwndDlg;
  3499.     pcnbp->hmod = savehmod;
  3500.     pcnbp->fEnumerate = TRUE;
  3501.     pcnbp->pszName = pNLSStrings->psz27StatusBar;
  3502.     pcnbp->ulDlgID = ID_XSD_SET28STATUSBARS2;
  3503.     pcnbp->ulDefaultHelpPanel  = ID_XSH_SETTINGS_SB2;
  3504.     pcnbp->ulPageID = SP_28STATUSBAR2;
  3505.     pcnbp->pfncbInitPage    = fncbWPSStatusBar2InitPage;
  3506.     pcnbp->pfncbItemChanged = fncbWPSStatusBar2ItemChanged;
  3507.     ntbInsertPage(pcnbp);
  3508.  
  3509.     // insert "Status bar" page 1
  3510.     pcnbp = malloc(sizeof(CREATENOTEBOOKPAGE));
  3511.     memset(pcnbp, 0, sizeof(CREATENOTEBOOKPAGE));
  3512.     pcnbp->somSelf = somSelf;
  3513.     pcnbp->hwndNotebook = hwndDlg;
  3514.     pcnbp->hmod = savehmod;
  3515.     pcnbp->fMajorTab = TRUE;
  3516.     pcnbp->fEnumerate = TRUE;
  3517.     pcnbp->pszName = pNLSStrings->psz27StatusBar;
  3518.     pcnbp->ulDlgID = ID_XSD_SET27STATUSBARS;
  3519.     pcnbp->ulDefaultHelpPanel  = ID_XSH_SETTINGS1+3;
  3520.     pcnbp->ulPageID = SP_27STATUSBAR;
  3521.     pcnbp->pfncbInitPage    = fncbWPSStatusBar1InitPage;
  3522.     pcnbp->pfncbItemChanged = fncbWPSStatusBar1ItemChanged;
  3523.     ntbInsertPage(pcnbp);
  3524.  
  3525.     /*
  3526.      * "Menu items" pages
  3527.      */
  3528.  
  3529.     pcnbp = malloc(sizeof(CREATENOTEBOOKPAGE));
  3530.     memset(pcnbp, 0, sizeof(CREATENOTEBOOKPAGE));
  3531.     pcnbp->somSelf = somSelf;
  3532.     pcnbp->hwndNotebook = hwndDlg;
  3533.     pcnbp->hmod = savehmod;
  3534.     pcnbp->fEnumerate = TRUE;
  3535.     pcnbp->pszName = pNLSStrings->psz2RemoveItems;
  3536.     pcnbp->ulDlgID = ID_XSD_SET2REMOVEMENUS;
  3537.     pcnbp->ulDefaultHelpPanel  = ID_XSH_SETTINGS1+1;
  3538.     pcnbp->ulPageID = SP_2REMOVEITEMS;
  3539.     pcnbp->pfncbInitPage    = fncbWPSRemoveItemsInitPage;
  3540.     pcnbp->pfncbItemChanged = fncbWPSRemoveItemsItemChanged;
  3541.     ntbInsertPage(pcnbp);
  3542.  
  3543.     // insert "Config folder menu items" page
  3544.     pcnbp = malloc(sizeof(CREATENOTEBOOKPAGE));
  3545.     memset(pcnbp, 0, sizeof(CREATENOTEBOOKPAGE));
  3546.     pcnbp->somSelf = somSelf;
  3547.     pcnbp->hwndNotebook = hwndDlg;
  3548.     pcnbp->hmod = savehmod;
  3549.     pcnbp->fEnumerate = TRUE;
  3550.     pcnbp->pszName = pNLSStrings->psz26ConfigFolderMenus;
  3551.     pcnbp->ulDlgID = ID_XSD_SET26CONFIGMENUS;
  3552.     pcnbp->ulDefaultHelpPanel  = ID_XSH_SETTINGS_CFGM;
  3553.     pcnbp->ulPageID = SP_26CONFIGITEMS;
  3554.     pcnbp->pfncbInitPage    = fncbWPSConfigFolderMenusInitPage;
  3555.     pcnbp->pfncbItemChanged = fncbWPSConfigFolderMenusItemChanged;
  3556.     ntbInsertPage(pcnbp);
  3557.  
  3558.     // insert "Add Menu Items" page
  3559.     pcnbp = malloc(sizeof(CREATENOTEBOOKPAGE));
  3560.     memset(pcnbp, 0, sizeof(CREATENOTEBOOKPAGE));
  3561.     pcnbp->somSelf = somSelf;
  3562.     pcnbp->hwndNotebook = hwndDlg;
  3563.     pcnbp->hmod = savehmod;
  3564.     pcnbp->fMajorTab = TRUE;
  3565.     pcnbp->fEnumerate = TRUE;
  3566.     pcnbp->pszName = pNLSStrings->psz25AddItems;
  3567.     pcnbp->ulDlgID = ID_XSD_SET25ADDMENUS;
  3568.     pcnbp->ulDefaultHelpPanel  = ID_XSH_SETTINGS1+2;
  3569.     pcnbp->ulPageID = SP_25ADDITEMS;
  3570.     pcnbp->pfncbInitPage    = fncbWPSAddMenusInitPage;
  3571.     pcnbp->pfncbItemChanged = fncbWPSAddMenusItemChanged;
  3572.     ntbInsertPage(pcnbp);
  3573.  
  3574.     /*
  3575.      * "File Operations" page
  3576.      */
  3577.  
  3578.     pcnbp = malloc(sizeof(CREATENOTEBOOKPAGE));
  3579.     memset(pcnbp, 0, sizeof(CREATENOTEBOOKPAGE));
  3580.     pcnbp->somSelf = somSelf;
  3581.     pcnbp->hwndNotebook = hwndDlg;
  3582.     pcnbp->hmod = savehmod;
  3583.     pcnbp->fMajorTab = TRUE;
  3584.     pcnbp->pszName = pNLSStrings->pszFileOps;
  3585.     pcnbp->ulDlgID = ID_XSD_SETTINGS_FILEOPS;
  3586.     pcnbp->ulDefaultHelpPanel  = ID_XSH_SETTINGS_FILEOPS;
  3587.     pcnbp->ulPageID = SP_FILEOPS;
  3588.     pcnbp->pfncbInitPage    = fncbWPSFileOpsInitPage;
  3589.     pcnbp->pfncbItemChanged = fncbWPSFileOpsItemChanged;
  3590.     ntbInsertPage(pcnbp);
  3591.  
  3592.     /*
  3593.      * "XFolder" pages
  3594.      */
  3595.  
  3596.     // insert "XFolder" settings page 2 ("Internals")
  3597.     pcnbp = malloc(sizeof(CREATENOTEBOOKPAGE));
  3598.     memset(pcnbp, 0, sizeof(CREATENOTEBOOKPAGE));
  3599.     pcnbp->somSelf = somSelf;
  3600.     pcnbp->hwndNotebook = hwndDlg;
  3601.     pcnbp->hmod = savehmod;
  3602.     pcnbp->fEnumerate = TRUE;
  3603.     pcnbp->pszName = pNLSStrings->psz5Internals;
  3604.     pcnbp->ulDlgID = ID_XSD_SET5INTERNALS;
  3605.     pcnbp->ulDefaultHelpPanel  = ID_XSH_SETTINGS1+6;
  3606.     pcnbp->ulPageID = SP_5INTERNALS;
  3607.     pcnbp->pfncbInitPage    = fncbWPSXFolder2InitPage;
  3608.     pcnbp->pfncbItemChanged = fncbWPSXFolder2ItemChanged;
  3609.     ntbInsertPage(pcnbp);
  3610.  
  3611.     /* memset((PCH)&pi, 0, sizeof(PAGEINFO));
  3612.     pi.cb                  = sizeof(PAGEINFO);
  3613.     pi.hwndPage            = NULLHANDLE;
  3614.     pi.pfnwp               = fnwpSettingsXFolderInternals;
  3615.     pi.resid               = savehmod;
  3616.     pi.pCreateParams       = somSelf;
  3617.     pi.dlgid               = ;
  3618.     pi.usPageStyleFlags    = BKA_STATUSTEXTON | BKA_MINOR;                // no major tabs
  3619.     pi.usPageInsertFlags   = BKA_FIRST;
  3620.     pi.usSettingsFlags     = SETTINGS_PAGE_NUMBERS;          // auto enumerate in status line
  3621.     pi.pszName             = ;
  3622.  
  3623.     pi.pszHelpLibraryName  = pszHelpLibrary;
  3624.     pi.idDefaultHelpPanel  = ;
  3625.  
  3626.     _wpInsertSettingsPage(somSelf, hwndDlg, &pi); */
  3627.  
  3628.     // insert "XFolder" settings page 1
  3629.     pcnbp = malloc(sizeof(CREATENOTEBOOKPAGE));
  3630.     memset(pcnbp, 0, sizeof(CREATENOTEBOOKPAGE));
  3631.     pcnbp->somSelf = somSelf;
  3632.     pcnbp->hwndNotebook = hwndDlg;
  3633.     pcnbp->hmod = savehmod;
  3634.     pcnbp->fMajorTab = TRUE;
  3635.     pcnbp->fEnumerate = TRUE;
  3636.     pcnbp->pszName = szXFolderVersion;
  3637.     pcnbp->ulDlgID = ID_XSD_SET1XFOLDER;
  3638.     pcnbp->ulDefaultHelpPanel  = ID_XSH_SETTINGS1;
  3639.     pcnbp->ulPageID = SP_1GENERIC;
  3640.     pcnbp->pfncbInitPage    = fncbWPSXFolder1InitPage;
  3641.     pcnbp->pfncbItemChanged = fncbWPSXFolder1ItemChanged;
  3642.     return (ntbInsertPage(pcnbp));
  3643. }
  3644.  
  3645. /*
  3646.  *@@ wpAddSystemScreenPage:
  3647.  *           this WPSystem instance method is overridden in order
  3648.  *           to suppress the "Screen" page in the "Workplace Shell"
  3649.  *           object, because we want that page in "OS/2 Kernel"
  3650.  *           only.
  3651.  */
  3652.  
  3653. SOM_Scope ULONG  SOMLINK xfwps_wpAddSystemScreenPage(XFldWPS *somSelf,
  3654.                                                      HWND hwndNotebook)
  3655. {
  3656.     /* XFldWPSData *somThis = XFldWPSGetData(somSelf); */
  3657.     XFldWPSMethodDebug("XFldWPS","xfwps_wpAddSystemScreenPage");
  3658.  
  3659.     return (SETTINGS_PAGE_REMOVED);
  3660. }
  3661.  
  3662. /*
  3663.  *@@ wpAddDMQSDisplayTypePage:
  3664.  *           this WPSystem instance method is overridden in order
  3665.  *           to suppress the second "Screen" page in the "Workplace
  3666.  *           Shell" object. Depending on the installed video driver,
  3667.  *           this page may or may not be displayed in the "System"
  3668.  *           notebook, but we never want this in "Workplace Shell",
  3669.  *           but in "OS/2 Kernel" instead.
  3670.  */
  3671.  
  3672. SOM_Scope ULONG  SOMLINK xfwps_wpAddDMQSDisplayTypePage(XFldWPS *somSelf,
  3673.                                                         HWND hwndNotebook)
  3674. {
  3675.     /* XFldWPSData *somThis = XFldWPSGetData(somSelf); */
  3676.     XFldWPSMethodDebug("XFldWPS","xfwps_wpAddDMQSDisplayTypePage");
  3677.  
  3678.     return (SETTINGS_PAGE_REMOVED);
  3679. }
  3680.  
  3681. /*
  3682.  *@@ wpAddSettingsPages:
  3683.  *           this instance method is overridden in order
  3684.  *           to add the new XFolder pages on top of
  3685.  *           the other WPS settings pages from the old "System"
  3686.  *           notebook.
  3687.  */
  3688.  
  3689. SOM_Scope BOOL  SOMLINK xfwps_wpAddSettingsPages(XFldWPS *somSelf,
  3690.                                                    HWND hwndNotebook)
  3691. {
  3692.     /* XFldWPSData *somThis = XFldWPSGetData(somSelf); */
  3693.     XFldWPSMethodDebug("XFldWPS","xfwps_wpAddSettingsPages");
  3694.  
  3695.     XFldWPS_parent_WPSystem_wpAddSettingsPages(somSelf,
  3696.                                                        hwndNotebook);
  3697.  
  3698.     // add XFolder pages on top
  3699.     _xfAddXFldWPSPages(somSelf, hwndNotebook);
  3700.  
  3701.     return (TRUE);
  3702. }
  3703.  
  3704. /* ******************************************************************
  3705.  *                                                                  *
  3706.  *   here come the XFldWPS class methods                            *
  3707.  *                                                                  *
  3708.  ********************************************************************/
  3709.  
  3710. /*
  3711.  *@@ wpclsSetSetting:
  3712.  *           this WPAbstract method sets the class object
  3713.  *           settings in the settings notebook via setup
  3714.  *           strings. WPSystem defines the WPS-wide system
  3715.  *           setting strings here, and XFolder needs to
  3716.  *           introduce its own settings here also.
  3717.  */
  3718.  
  3719. SOM_Scope BOOL  SOMLINK xfwpsM_wpclsSetSetting(M_XFldWPS *somSelf,
  3720.                                                  PSZ pszSetting,
  3721.                                                  PVOID pValue)
  3722. {
  3723.     // M_XFldWPSData *somThis = M_XFldWPSGetData(somSelf);
  3724.     M_XFldWPSMethodDebug("M_XFldWPS","xfwpsM_wpclsSetSetting");
  3725.  
  3726.     return (M_XFldWPS_parent_M_WPSystem_wpclsSetSetting(somSelf,
  3727.                                                         pszSetting,
  3728.                                                         pValue));
  3729. }
  3730.  
  3731. /*
  3732.  *@@ wpclsQuerySettingsPageSize:
  3733.  *           this WPObject class method should return the
  3734.  *           size of the largest settings page in dialog
  3735.  *           units; if a settings notebook is initially
  3736.  *           opened, i.e. no window pos has been stored
  3737.  *           yet, the WPS will use this size, to avoid
  3738.  *           truncated settings pages.
  3739.  */
  3740.  
  3741. SOM_Scope BOOL  SOMLINK xfwpsM_wpclsQuerySettingsPageSize(M_XFldWPS *somSelf,
  3742.                                                           PSIZEL pSizl)
  3743. {
  3744.     BOOL brc;
  3745.     /* M_XFldWPSData *somThis = M_XFldWPSGetData(somSelf); */
  3746.     M_XFldWPSMethodDebug("M_XFldWPS","xfwpsM_wpclsQuerySettingsPageSize");
  3747.  
  3748.     brc = M_XFldWPS_parent_M_WPSystem_wpclsQuerySettingsPageSize(somSelf,
  3749.                                                                    pSizl);
  3750.     if (brc) {
  3751.         pSizl->cy = 170;        // this is the height of the "WPS Classes" page,
  3752.                                 // which seems to be the largest in the "Workplace
  3753.                                 // Shell" object
  3754.         if (doshIsWarp4())
  3755.             // on Warp 4, reduce again, because we're moving
  3756.             // the notebook buttons to the bottom
  3757.             pSizl->cy -= WARP4_NOTEBOOK_OFFSET;
  3758.     }
  3759.     return (brc);
  3760. }
  3761.  
  3762. /*
  3763.  *@@ wpclsQueryIconData:
  3764.  *           give the WPS object a new icon
  3765.  */
  3766.  
  3767. SOM_Scope ULONG  SOMLINK xfwpsM_wpclsQueryIconData(M_XFldWPS *somSelf,
  3768.                                                    PICONINFO pIconInfo)
  3769. {
  3770.     // M_XFldWPSData *somThis = M_XFldWPSGetData(somSelf);
  3771.     M_XFldWPSMethodDebug("M_XFldWPS","xfwpsM_wpclsQueryIconData");
  3772.  
  3773.     if (pIconInfo) {
  3774.        pIconInfo->fFormat = ICON_RESOURCE;
  3775.        pIconInfo->resid   = ID_ICONWPS;
  3776.        pIconInfo->hmod    = modQueryHandle();
  3777.     }
  3778.  
  3779.     return (sizeof(ICONINFO));
  3780.  
  3781.     /* return (M_XFldWPS_parent_M_WPSystem_wpclsQueryIconData(somSelf,
  3782.                                                            pIconInfo)); */
  3783. }
  3784.  
  3785. /*
  3786.  *@@ wpclsQueryTitle:
  3787.  *           tell the WPS the new class name: "Workplace Shell"
  3788.  */
  3789.  
  3790. SOM_Scope PSZ  SOMLINK xfwpsM_wpclsQueryTitle(M_XFldWPS *somSelf)
  3791. {
  3792.     // M_XFldWPSData *somThis = M_XFldWPSGetData(somSelf);
  3793.     M_XFldWPSMethodDebug("M_XFldWPS","xfwpsM_wpclsQueryTitle");
  3794.  
  3795.     return ("Workplace Shell");
  3796. }
  3797.  
  3798. /*
  3799.  *@@ wpclsInitData:
  3800.  *           initialize XFldWPS class data
  3801.  */
  3802.  
  3803. SOM_Scope void  SOMLINK xfwpsM_wpclsInitData(M_XFldWPS *somSelf)
  3804. {
  3805.     // M_XFldWPSData *somThis = M_XFldWPSGetData(somSelf);
  3806.     M_XFldWPSMethodDebug("M_XFldWPS","xfwpsM_wpclsInitData");
  3807.  
  3808.     M_XFldWPS_parent_M_WPSystem_wpclsInitData(somSelf);
  3809.  
  3810.     // _hmodXFldWPS = NULLHANDLE;
  3811. }
  3812.  
  3813. /* ******************************************************************
  3814.  *                                                                  *
  3815.  *   "OS/2 Kernel" notebook callbacks                               *
  3816.  *                                                                  *
  3817.  ********************************************************************/
  3818.  
  3819. /*
  3820.  *  All the following functions starting with fncbConfig* are callbacks
  3821.  *  for the common notebook dlg function in notebook.c. There are
  3822.  *  two callbacks for each notebook page in "OS/2 Kernel", one
  3823.  *  for (re)initializing the page's controls and one for reacting
  3824.  *  to controls being changed by the user.
  3825.  *  These callbacks are specified in xfsys::xfAddXFldSystemPages.
  3826.  *  These callbacks are all new with V0.82 and replace the awful
  3827.  *  dialog procedures which were previously used, because these
  3828.  *  became hard to maintain over time.
  3829.  */
  3830.  
  3831. CHAR    szOrigSwapPath[CCHMAXPATH] = "";
  3832. CHAR    szConfigSys[CCHMAXPATH];
  3833. CHAR    aszAllDrives[30][5];  // 30 strings with 5 chars each for spin button
  3834. PSZ     apszAllDrives[30];    // 30 pointers to the buffers
  3835. LONG    lDriveCount = 0;
  3836.  
  3837. /*
  3838.  *@@ fncbConfigInitPage:
  3839.  *      common notebook callback function (notebook.c) for
  3840.  *      all the notebook pages dealing with CONFIG.SYS settings.
  3841.  *      Sets the controls on the page according to the CONFIG.SYS
  3842.  *      statements.
  3843.  *      Since this callback is shared among all the CONFIG.SYS
  3844.  *      pages, pcnbp->ulPageID is used for telling them apart by
  3845.  *      using the SP_* identifiers.
  3846.  */
  3847.  
  3848. VOID fncbConfigInitPage(PVOID pnbi, ULONG ulExtra)  // notebook info struct
  3849. {
  3850.     PCREATENOTEBOOKPAGE pcnbp = (PCREATENOTEBOOKPAGE)pnbi;
  3851.     // CHAR    szConfigSys[CCHMAXPATH];
  3852.     PSZ     pszConfigSys;
  3853.  
  3854.     if (ulExtra & CBI_INIT)
  3855.     {
  3856.         HPOINTER hptrOld = WinQueryPointer(HWND_DESKTOP);
  3857.         HPOINTER hptrWait = WinQuerySysPointer(HWND_DESKTOP,
  3858.                     SPTR_WAIT, FALSE);
  3859.         WinSetPointer(HWND_DESKTOP, hptrWait);
  3860.  
  3861.         sprintf(szConfigSys, "%c:\\config.sys", doshQueryBootDrive());
  3862.  
  3863.         WinSetPointer(HWND_DESKTOP, hptrOld);
  3864.  
  3865.         winhEnableDlgItem(pcnbp->hwndPage, DID_APPLY, TRUE);
  3866.  
  3867.         // on the "HPFS" page:
  3868.         // if the system has any HPFS drives,
  3869.         // we disable the "HPFS installed" item
  3870.         if (pcnbp->ulPageID == SP_HPFS) {
  3871.             CHAR szHPFSDrives[30];
  3872.             doshEnumDrives(szHPFSDrives, "HPFS");
  3873.             if (strlen(szHPFSDrives) > 0)
  3874.                 winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_OS_FSINSTALLED, FALSE);
  3875.         }
  3876.         else if (pcnbp->ulPageID == SP_ERRORS) {
  3877.             CHAR szAllDrives[30];
  3878.             PSZ p = szAllDrives;
  3879.             ULONG ul = 0;
  3880.             doshEnumDrives(szAllDrives, NULL); // all drives
  3881.  
  3882.             while (*p) {
  3883.                 aszAllDrives[ul][0] = szAllDrives[ul];
  3884.                 aszAllDrives[ul][1] = '\0';
  3885.                 apszAllDrives[ul] = &(aszAllDrives[ul][0]);
  3886.                 p++;
  3887.                 ul++;
  3888.             }
  3889.             aszAllDrives[ul][0] = '0';
  3890.             aszAllDrives[ul][1] = 0;
  3891.             apszAllDrives[ul] = &(aszAllDrives[ul][0]);
  3892.             lDriveCount = ul;
  3893.             ul++;
  3894.             WinSendDlgItemMsg(pcnbp->hwndPage, ID_XSDI_OS_SUPRESSP_DRIVE,
  3895.                     SPBM_SETARRAY,
  3896.                     (MPARAM)apszAllDrives,
  3897.                     (MPARAM)ul);
  3898.         }
  3899.  
  3900.         pszConfigSys = doshReadTextFile(szConfigSys, 1000);
  3901.         if (pszConfigSys == NULL)
  3902.             DebugBox(szConfigSys, "XFolder was unable to open the CONFIG.SYS file.");
  3903.         else
  3904.         {
  3905.             PSZ     p;
  3906.             ULONG   ul;
  3907.  
  3908.             switch (pcnbp->ulPageID) {
  3909.                 case SP_SCHEDULER: {
  3910.                     if (p = strhGetParameter(pszConfigSys, "THREADS=", NULL, 0)) {
  3911.                         sscanf(p, "%d", &ul);
  3912.                     } else // default
  3913.                         ul = 64;
  3914.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_MAXTHREADS, 128, 4096, ul);
  3915.  
  3916.                     if (p = strhGetParameter(pszConfigSys, "MAXWAIT=", NULL, 0)) {
  3917.                         sscanf(p, "%d", &ul);
  3918.                     } else // default
  3919.                         ul = 3;
  3920.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_MAXWAIT, 1, 10, ul);
  3921.  
  3922.                     if (p = strhGetParameter(pszConfigSys, "PRIORITY_DISK_IO=", NULL, 0)) {
  3923.                         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_PRIORITYDISKIO,
  3924.                             (strncmp(p, "YES", 3) == 0));
  3925.                     } else // default
  3926.                         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_PRIORITYDISKIO,
  3927.                             TRUE);
  3928.                 break; }
  3929.  
  3930.                 case SP_MEMORY: {
  3931.                     // installed physical memory
  3932.                     CHAR szMemory[30];
  3933.                     ULONG   aulSysInfo[QSV_MAX] = {0};
  3934.                     DosQuerySysInfo(1L, QSV_MAX,
  3935.                                         (PVOID)aulSysInfo, sizeof(ULONG)*QSV_MAX);
  3936.                     sprintf(szMemory, "%d",
  3937.                                (aulSysInfo[QSV_TOTPHYSMEM-1] + (512*1000)) / 1024 / 1024);
  3938.                     WinSetDlgItemText(pcnbp->hwndPage, ID_XSDI_OS_PHYSICALMEMORY, szMemory);
  3939.  
  3940.                     // parse SWAPPATH command
  3941.                     if (p = strhGetParameter(pszConfigSys, "SWAPPATH=", NULL, 0)) {
  3942.                         CHAR    szSwapPath[CCHMAXPATH] = "Error";
  3943.                         ULONG   ulMinFree = 2048, ulMinSize = 2048;
  3944.                         // int     iScanned;
  3945.                         sscanf(p, "%s %d %d",
  3946.                                     &szSwapPath, &ulMinFree, &ulMinSize);
  3947.  
  3948.                         WinSetDlgItemText(pcnbp->hwndPage, ID_XSDI_OS_SWAPPATH, szSwapPath);
  3949.                         winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_MINSWAPSIZE,
  3950.                                 2, 100, (ulMinSize / 1024));
  3951.                         winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_MINSWAPFREE,
  3952.                                 2, 1000, (ulMinFree / 1024));
  3953.  
  3954.                         if (strlen(szOrigSwapPath) == 0) {
  3955.                             if (szSwapPath[strlen(szSwapPath)-1] != '\\')
  3956.                                 sprintf(szOrigSwapPath, "%s\\swapper.dat", szSwapPath);
  3957.                             else
  3958.                                 sprintf(szOrigSwapPath, "%sswapper.dat", szSwapPath);
  3959.                         }
  3960.                     }
  3961.                 break; }
  3962.  
  3963.                 case SP_HPFS: {
  3964.                     CHAR    szParameter[300] = "",
  3965.                             // szTemp[300] = "",
  3966.                             szSearchKey[100],
  3967.                             szAutoCheck[200] = "";
  3968.                     ULONG   ulCacheSize = 0,
  3969.                             ulThreshold = 4,
  3970.                             ulMaxAge = 5000,
  3971.                             ulDiskIdle = 1000,
  3972.                             ulBufferIdle = 500;
  3973.                     BOOL    fLazyWrite = TRUE;
  3974.  
  3975.                     szAutoCheck[0] = doshQueryBootDrive();  // default value
  3976.  
  3977.                     // evaluate IFS=...\HPFS.IFS
  3978.                     sprintf(szSearchKey, "IFS=%c:\\OS2\\HPFS.IFS ", doshQueryBootDrive());
  3979.                     p = strhGetParameter(pszConfigSys, szSearchKey,
  3980.                             szParameter, sizeof(szParameter));
  3981.  
  3982.                     if (p) {
  3983.                         PSZ p2;
  3984.                         if (p2 = strhistr(szParameter, "/CACHE:"))
  3985.                             sscanf(p2+7, "%d", &ulCacheSize);
  3986.                         if (p2 = strhistr(szParameter, "/CRECL:"))
  3987.                             sscanf(p2+7, "%d", &ulThreshold);
  3988.                         if (p2 = strhistr(szParameter, "/AUTOCHECK:"))
  3989.                             sscanf(p2+11, "%s", &szAutoCheck);
  3990.                     }
  3991.  
  3992.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_FSINSTALLED,
  3993.                                 (p != 0));
  3994.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_CACHESIZE_AUTO,
  3995.                                 (ulCacheSize == 0));
  3996.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_CACHESIZE,
  3997.                                 0, 2048, ulCacheSize);
  3998.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_CACHE_THRESHOLD,
  3999.                                 4, 64, ulThreshold);
  4000.                     WinSetDlgItemText(pcnbp->hwndPage, ID_XSDI_OS_AUTOCHECK, szAutoCheck);
  4001.  
  4002.                     // evaluate
  4003.                     // RUN=...\CACHE.EXE /MAXAGE:60000 /DISKIDLE:1000 /BUFFERIDLE:40000
  4004.                     sprintf(szSearchKey, "RUN=%c:\\OS2\\CACHE.EXE ", doshQueryBootDrive());
  4005.                     p = strhGetParameter(pszConfigSys, szSearchKey,
  4006.                                 szParameter, sizeof(szParameter));
  4007.  
  4008.                     if (p) {
  4009.                         PSZ p2;
  4010.                         if (p2 = strhistr(szParameter, "/MAXAGE:"))
  4011.                             sscanf(p2+8,  "%d", &ulMaxAge);
  4012.                         if (p2 = strhistr(szParameter, "/DISKIDLE:"))
  4013.                             sscanf(p2+10, "%d", &ulDiskIdle);
  4014.                         if (p2 = strhistr(szParameter, "/BUFFERIDLE:"))
  4015.                             sscanf(p2+12, "%d", &ulBufferIdle);
  4016.                         if (strhistr(szParameter, "/LAZY:OFF"))
  4017.                             fLazyWrite = FALSE;
  4018.                     }
  4019.  
  4020.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_CACHE_LAZYWRITE,
  4021.                                 fLazyWrite);
  4022.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_CACHE_MAXAGE,
  4023.                                 500, 100*1000, ulMaxAge);
  4024.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_CACHE_BUFFERIDLE,
  4025.                                 500, 100*1000, ulBufferIdle);
  4026.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_CACHE_DISKIDLE,
  4027.                                 500, 100*1000, ulDiskIdle);
  4028.  
  4029.                 break; }
  4030.  
  4031.                 case SP_FAT: {
  4032.                     CHAR    szParameter[300] = "",
  4033.                             // szTemp[300] = "",
  4034.                             szAutoCheck[200] = "";
  4035.                     ULONG   ulCacheSize = 512,
  4036.                             ulThreshold = 4;
  4037.                     PSZ     p2;
  4038.  
  4039.                     // evaluate DISKCACHE
  4040.                     p = strhGetParameter(pszConfigSys, "DISKCACHE=",
  4041.                             szParameter, sizeof(szParameter));
  4042.  
  4043.                     // enable "Cache installed" item if DISKCACHE= found
  4044.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_FSINSTALLED,
  4045.                                 (p != NULL));
  4046.  
  4047.                     // now set the other items according to the DISKCACHE
  4048.                     // parameters; if that was not found, the default values
  4049.                     // above will be used
  4050.                     if (szParameter[0] == 'D')
  4051.                         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_CACHESIZE_AUTO,
  4052.                                     TRUE);
  4053.                     else
  4054.                         sscanf(szParameter, "%d", &ulCacheSize);
  4055.  
  4056.                     p2 = strchr(szParameter, ','); // get next parameter
  4057.                     // optional "LW" parameter (lazy write)
  4058.                     if (p2) {
  4059.                         if (strncmp(p2+1, "LW", 2) == 0) {
  4060.                             winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_CACHE_LAZYWRITE,
  4061.                                         TRUE);
  4062.                             p2 = strchr(p2+1, ','); // get next parameter
  4063.                         }
  4064.                     }
  4065.                     // optional threshold parameter
  4066.                     if (p2) {
  4067.                         sscanf(p2+1, "%d", &ulThreshold);
  4068.                         p2 = strchr(p2+1, ','); // get next parameter
  4069.                     }
  4070.                     // optional "autocheck" parameter
  4071.                     if (p2) {
  4072.                         if (strncmp(p2+1, "AC:", 3) == 0)
  4073.                             strcpy(szAutoCheck, p2+4);
  4074.                     }
  4075.  
  4076.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_CACHESIZE,
  4077.                                 0, 14400, ulCacheSize);
  4078.                     // the threshold param is in sectors of 512 bytes
  4079.                     // each, so for getting KB, we need to divide by 2
  4080.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_CACHE_THRESHOLD,
  4081.                                 4, 64, ulThreshold / 2);
  4082.                     WinSetDlgItemText(pcnbp->hwndPage, ID_XSDI_OS_AUTOCHECK, szAutoCheck);
  4083.  
  4084.                 break; }
  4085.  
  4086.                 case SP_WPS: {
  4087.                     CHAR    szParameter[300] = "";
  4088.                     PSZ p = strhGetParameter(pszConfigSys, "SET AUTOSTART=",
  4089.                             szParameter, sizeof(szParameter));
  4090.                     BOOL fAutoRefreshFolders = TRUE;
  4091.                     if (p) {
  4092.                         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_AUTO_PROGRAMS,
  4093.                             (strhistr(szParameter, "PROGRAMS") != NULL));
  4094.                         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_AUTO_TASKLIST,
  4095.                             (strhistr(szParameter, "TASKLIST") != NULL));
  4096.                         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_AUTO_CONNECTIONS,
  4097.                             (strhistr(szParameter, "CONNECTIONS") != NULL));
  4098.                         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_AUTO_LAUNCHPAD,
  4099.                             (strhistr(szParameter, "LAUNCHPAD") != NULL));
  4100.                         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_AUTO_WARPCENTER,
  4101.                             (strhistr(szParameter, "WARPCENTER") != NULL));
  4102.                     }
  4103.  
  4104.                     p = strhGetParameter(pszConfigSys, "SET RESTARTOBJECTS=",
  4105.                             szParameter, sizeof(szParameter));
  4106.                     if ( (p == NULL) || (strhistr(szParameter, "YES")) )
  4107.                         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_RESTART_YES, TRUE);
  4108.                     else if (strhistr(szParameter, "NO"))
  4109.                         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_RESTART_NO, TRUE);
  4110.                     else if (strhistr(szParameter, "STARTUPFOLDERSONLY"))
  4111.                         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_RESTART_FOLDERS, TRUE);
  4112.  
  4113.                     if (strhistr(szParameter, "REBOOTONLY"))
  4114.                         winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_RESTART_REBOOT, TRUE);
  4115.  
  4116.                     // auto-refresh folders: cannot be disabled on Warp 3
  4117.                     p = strhGetParameter(pszConfigSys, "SET AUTOREFRESHFOLDERS=",
  4118.                             szParameter, sizeof(szParameter));
  4119.                     if (p)
  4120.                         if (strhistr(szParameter, "NO"))
  4121.                             fAutoRefreshFolders = FALSE;
  4122.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_AUTOREFRESHFOLDERS,
  4123.                                 fAutoRefreshFolders);
  4124.                 break; }
  4125.  
  4126.                 case SP_ERRORS: {
  4127.                     CHAR    szParameter[300] = "";
  4128.                     BOOL fAutoFail = FALSE,
  4129.                          fReIPL = FALSE;
  4130.                     PSZ p = strhGetParameter(pszConfigSys, "AUTOFAIL=",
  4131.                             szParameter, sizeof(szParameter));
  4132.                     if (p)
  4133.                         if (strhistr(szParameter, "YES"))
  4134.                             fAutoFail = TRUE;
  4135.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_AUTOFAIL, fAutoFail);
  4136.  
  4137.                     p = strhGetParameter(pszConfigSys, "REIPL=",
  4138.                             szParameter, sizeof(szParameter));
  4139.                     if (p)
  4140.                         if (strhistr(szParameter, "ON"))
  4141.                             fReIPL = TRUE;
  4142.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_REIPL, fReIPL);
  4143.  
  4144.                     p = strhGetParameter(pszConfigSys, "SUPPRESSPOPUPS=",
  4145.                             szParameter, sizeof(szParameter));
  4146.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_SUPRESSPOPUPS,
  4147.                             (p != NULL));
  4148.                     if (p) {
  4149.                         LONG lIndex = 0;           // default for "0" param
  4150.                         if (*p != '0') {
  4151.                             CHAR c = toupper(*p);
  4152.                             lIndex = c-'C'; // 0 for C, 1 for D etc.
  4153.                         } else {
  4154.                             // "0" character:
  4155.                             lIndex = lDriveCount;
  4156.                         }
  4157.  
  4158.                         WinSendDlgItemMsg(pcnbp->hwndPage, ID_XSDI_OS_SUPRESSP_DRIVE,
  4159.                                 SPBM_SETCURRENTVALUE,
  4160.                                 (MPARAM)lIndex,
  4161.                                 (MPARAM)NULL);
  4162.                     }
  4163.  
  4164.                 break; }
  4165.             } // end switch
  4166.  
  4167.             free(pszConfigSys);
  4168.             pszConfigSys = NULL;
  4169.         }
  4170.     }
  4171.  
  4172.     if (ulExtra & CBI_ENABLE)
  4173.     {
  4174.         // enable items
  4175.         if (pcnbp->ulPageID == SP_HPFS)
  4176.         {
  4177.             BOOL fLazyWrite = winhIsDlgItemChecked(pcnbp->hwndPage,
  4178.                             ID_XSDI_OS_CACHE_LAZYWRITE);
  4179.             winhEnableDlgItem(pcnbp->hwndPage,
  4180.                         ID_XSDI_OS_CACHE_MAXAGE, fLazyWrite);
  4181.             winhEnableDlgItem(pcnbp->hwndPage,
  4182.                         ID_XSDI_OS_CACHE_BUFFERIDLE, fLazyWrite);
  4183.             winhEnableDlgItem(pcnbp->hwndPage,
  4184.                         ID_XSDI_OS_CACHE_DISKIDLE, fLazyWrite);
  4185.         }
  4186.  
  4187.         if (    (pcnbp->ulPageID == SP_HPFS)
  4188.             ||  (pcnbp->ulPageID == SP_FAT)
  4189.            )
  4190.         {
  4191.             winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_OS_CACHESIZE,
  4192.                         !winhIsDlgItemChecked(pcnbp->hwndPage,
  4193.                             ID_XSDI_OS_CACHESIZE_AUTO));
  4194.         }
  4195.         else if (pcnbp->ulPageID == SP_WPS)
  4196.         {
  4197.             winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_OS_AUTO_WARPCENTER, (doshIsWarp4()));
  4198.             winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_OS_AUTOREFRESHFOLDERS, (doshIsWarp4()));
  4199.         }
  4200.         else if (pcnbp->ulPageID == SP_ERRORS)
  4201.             winhEnableDlgItem(pcnbp->hwndPage, ID_XSDI_OS_SUPRESSP_DRIVE,
  4202.                 winhIsDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_SUPRESSPOPUPS));
  4203.     }
  4204. }
  4205.  
  4206. /*
  4207.  *@@ fncbConfigItemChanged:
  4208.  *      common notebook callback function (notebook.c) for
  4209.  *      all the notebook pages dealing with CONFIG.SYS settings.
  4210.  *      This monster function reacts to changes of any of the
  4211.  *      dialog controls and reads/writes CONFIG.SYS settings.
  4212.  *      Since this callback is shared among all the CONFIG.SYS
  4213.  *      pages, pcnbp->ulPageID is used for telling them apart by
  4214.  *      using the SP_* identifiers.
  4215.  */
  4216.  
  4217. MRESULT fncbConfigItemChanged(PVOID pnbi,
  4218.                 USHORT usItemID, USHORT usNotifyCode,
  4219.                 ULONG ulExtra)      // for checkboxes: contains new state
  4220. {
  4221.     PCREATENOTEBOOKPAGE pcnbp = (PCREATENOTEBOOKPAGE)pnbi;
  4222.     LONG    lGrid = 0;
  4223.  
  4224.     switch (usItemID)
  4225.     {
  4226.  
  4227.         case ID_XSDI_OS_MAXTHREADS:
  4228.             // "Scheduler" page; 64 steps
  4229.             lGrid = 64;
  4230.             goto adjustspin;
  4231.  
  4232.         case ID_XSDI_OS_MINSWAPSIZE:
  4233.         case ID_XSDI_OS_MINSWAPFREE:
  4234.             lGrid = 2;
  4235.             goto adjustspin;
  4236.  
  4237.         case ID_XSDI_OS_CACHESIZE:
  4238.             // HPFS and FAT pages; 64 KB steps
  4239.             lGrid = 64;
  4240.             goto adjustspin;
  4241.  
  4242.         case ID_XSDI_OS_CACHE_THRESHOLD:
  4243.             // HPFS and FAT pages; 4 KB steps
  4244.             lGrid = 4;
  4245.             goto adjustspin;
  4246.  
  4247.         case ID_XSDI_OS_CACHE_MAXAGE:
  4248.         case ID_XSDI_OS_CACHE_BUFFERIDLE:
  4249.         case ID_XSDI_OS_CACHE_DISKIDLE:
  4250.             // HPFS page; 1000 ms steps
  4251.             lGrid = 1000;
  4252.  
  4253.             adjustspin:
  4254.             if (   (usNotifyCode == SPBN_UPARROW)
  4255.                 || (usNotifyCode == SPBN_DOWNARROW)
  4256.                )
  4257.             {
  4258.                 winhAdjustDlgItemSpinData(pcnbp->hwndPage, usItemID,
  4259.                             lGrid, usNotifyCode);
  4260.             }
  4261.         break;
  4262.  
  4263.         /*
  4264.          * DID_APPLY:
  4265.          *      "Apply" button
  4266.          */
  4267.  
  4268.         case DID_APPLY: {
  4269.  
  4270.             if (cmnMessageBoxMsg(pcnbp->hwndPage,
  4271.                     100, 101,
  4272.                     MB_YESNO | MB_DEFBUTTON2)
  4273.                  == MBID_YES)
  4274.             {
  4275.                 PSZ     pszConfigSys = NULL;
  4276.                 if (pszConfigSys == NULL) {
  4277.                     pszConfigSys = doshReadTextFile(szConfigSys, 1000);
  4278.                     if (pszConfigSys == NULL)
  4279.                         DebugBox(szConfigSys, "XFolder was unable to open the CONFIG.SYS file.");
  4280.                 }
  4281.  
  4282.                 if (pszConfigSys) {
  4283.                     // PSZ     p;
  4284.                     ULONG   ul = 0, ulMinFree = 0, ulMinSize = 0;
  4285.                     CHAR    szTemp[CCHMAXPATH];
  4286.                     CHAR    szSwapPath[CCHMAXPATH];
  4287.  
  4288.                     switch (pcnbp->ulPageID) {
  4289.                         case SP_SCHEDULER: {
  4290.                             WinSendDlgItemMsg(pcnbp->hwndPage, ID_XSDI_OS_MAXTHREADS,
  4291.                                   SPBM_QUERYVALUE,
  4292.                                   (MPARAM)&ul,
  4293.                                   MPFROM2SHORT(0, SPBQ_UPDATEIFVALID));
  4294.                             sprintf(szTemp, "%d", ul);
  4295.                             strhSetParameter(pszConfigSys, "THREADS=", szTemp, TRUE);
  4296.  
  4297.                             WinSendDlgItemMsg(pcnbp->hwndPage, ID_XSDI_OS_MAXWAIT,
  4298.                                   SPBM_QUERYVALUE,
  4299.                                   (MPARAM)&ul,
  4300.                                   MPFROM2SHORT(0, SPBQ_UPDATEIFVALID));
  4301.                             sprintf(szTemp, "%d", ul);
  4302.                             strhSetParameter(pszConfigSys, "MAXWAIT=", szTemp, TRUE);
  4303.  
  4304.                             strhSetParameter(pszConfigSys, "PRIORITY_DISK_IO=",
  4305.                                     (winhIsDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_PRIORITYDISKIO)
  4306.                                             ? "yes" : "no"),
  4307.                                     TRUE);
  4308.                         break; }
  4309.  
  4310.                         case SP_MEMORY: {
  4311.                             WinQueryDlgItemText(pcnbp->hwndPage, ID_XSDI_OS_SWAPPATH,
  4312.                                             sizeof(szSwapPath)-1, szSwapPath);
  4313.                             WinSendDlgItemMsg(pcnbp->hwndPage, ID_XSDI_OS_MINSWAPSIZE,
  4314.                                   SPBM_QUERYVALUE,
  4315.                                   (MPARAM)&ulMinSize,
  4316.                                   MPFROM2SHORT(0, SPBQ_UPDATEIFVALID));
  4317.                             WinSendDlgItemMsg(pcnbp->hwndPage, ID_XSDI_OS_MINSWAPFREE,
  4318.                                   SPBM_QUERYVALUE,
  4319.                                   (MPARAM)&ulMinFree,
  4320.                                   MPFROM2SHORT(0, SPBQ_UPDATEIFVALID));
  4321.                             sprintf(szTemp, "%s %d %d", szSwapPath, ulMinFree*1024, ulMinSize*1024);
  4322.                             strhSetParameter(pszConfigSys, "SWAPPATH=", szTemp, TRUE);
  4323.                         break; }
  4324.  
  4325.                         case SP_HPFS: {
  4326.                             CHAR    szTemp[300] = "",
  4327.                                     szAutoCheck[200] = "",
  4328.                                     szSearchKey[100] = "";
  4329.                             ULONG   ulCacheSize = 0,
  4330.                                     ulThreshold = 4,
  4331.                                     ulMaxAge = 5000,
  4332.                                     ulDiskIdle = 1000,
  4333.                                     ulBufferIdle = 500;
  4334.                             // BOOL    fLazyWrite = TRUE;
  4335.  
  4336.                             WinSendDlgItemMsg(pcnbp->hwndPage, ID_XSDI_OS_CACHE_THRESHOLD,
  4337.                                   SPBM_QUERYVALUE,
  4338.                                   (MPARAM)&ulThreshold,
  4339.                                   MPFROM2SHORT(0, SPBQ_UPDATEIFVALID));
  4340.                             WinQueryDlgItemText(pcnbp->hwndPage, ID_XSDI_OS_AUTOCHECK,
  4341.                                             sizeof(szAutoCheck)-1, szAutoCheck);
  4342.  
  4343.                             if (winhIsDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_CACHESIZE_AUTO)) {
  4344.                                 // auto-size cache: leave out /CACHE
  4345.                                 sprintf(szTemp,
  4346.                                         "/crecl:%d /autocheck:%s",
  4347.                                         doshQueryBootDrive(),
  4348.                                         ulThreshold,
  4349.                                         szAutoCheck);
  4350.                             } else {
  4351.                                 // no auto-size cache
  4352.                                 WinSendDlgItemMsg(pcnbp->hwndPage, ID_XSDI_OS_CACHESIZE,
  4353.                                       SPBM_QUERYVALUE,
  4354.                                       (MPARAM)&ulCacheSize,
  4355.                                       MPFROM2SHORT(0, SPBQ_UPDATEIFVALID));
  4356.                                 sprintf(szTemp,
  4357.                                         "/cache:%d /crecl:%d /autocheck:%s",
  4358.                                         ulCacheSize,
  4359.                                         ulThreshold,
  4360.                                         szAutoCheck);
  4361.                             }
  4362.                             sprintf(szSearchKey, "IFS=%c:\\OS2\\HPFS.IFS ",
  4363.                                         doshQueryBootDrive());
  4364.                             strhSetParameter(pszConfigSys, szSearchKey, szTemp, TRUE);
  4365.  
  4366.                             if (winhIsDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_CACHE_LAZYWRITE)) {
  4367.                                 WinSendDlgItemMsg(pcnbp->hwndPage, ID_XSDI_OS_CACHE_MAXAGE,
  4368.                                       SPBM_QUERYVALUE,
  4369.                                       (MPARAM)&ulMaxAge,
  4370.                                       MPFROM2SHORT(0, SPBQ_UPDATEIFVALID));
  4371.                                 WinSendDlgItemMsg(pcnbp->hwndPage, ID_XSDI_OS_CACHE_DISKIDLE,
  4372.                                       SPBM_QUERYVALUE,
  4373.                                       (MPARAM)&ulDiskIdle,
  4374.                                       MPFROM2SHORT(0, SPBQ_UPDATEIFVALID));
  4375.                                 WinSendDlgItemMsg(pcnbp->hwndPage, ID_XSDI_OS_CACHE_BUFFERIDLE,
  4376.                                       SPBM_QUERYVALUE,
  4377.                                       (MPARAM)&ulBufferIdle,
  4378.                                       MPFROM2SHORT(0, SPBQ_UPDATEIFVALID));
  4379.                                 sprintf(szTemp,
  4380.                                         "/maxage:%d /diskidle:%d /bufferidle:%d "
  4381.                                         "/readahead:on /lazy:1",
  4382.                                         ulMaxAge,
  4383.                                         ulDiskIdle,
  4384.                                         ulBufferIdle);
  4385.                             } else {
  4386.                                 strcpy(szTemp, "/lazy:off");
  4387.                             }
  4388.                             // compose the key with CACHE;
  4389.                             sprintf(szSearchKey, "RUN=%c:\\OS2\\CACHE.EXE ",
  4390.                                         doshQueryBootDrive());
  4391.                             strhSetParameter(pszConfigSys, szSearchKey, szTemp, TRUE);
  4392.  
  4393.                         break; }
  4394.  
  4395.                         case SP_FAT: {
  4396.                             // "Cache installed" checked?
  4397.                             if (winhIsDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_FSINSTALLED)) {
  4398.                                 CHAR    // szParameter[300] = "",
  4399.                                         szTemp[300] = "",
  4400.                                         szAutoCheck[200] = "";
  4401.                                 ULONG   ulCacheSize = 512,
  4402.                                         ulThreshold = 4;
  4403.                                 // PSZ     p2;
  4404.  
  4405.                                 if (winhIsDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_CACHESIZE_AUTO))
  4406.                                     strcpy(szTemp, "d");
  4407.                                 else {
  4408.                                     // no auto-size cache
  4409.                                     WinSendDlgItemMsg(pcnbp->hwndPage, ID_XSDI_OS_CACHESIZE,
  4410.                                           SPBM_QUERYVALUE,
  4411.                                           (MPARAM)&ulCacheSize,
  4412.                                           MPFROM2SHORT(0, SPBQ_UPDATEIFVALID));
  4413.                                     sprintf(szTemp, "%d", ulCacheSize);
  4414.                                 }
  4415.  
  4416.                                 if (winhIsDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_CACHE_LAZYWRITE))
  4417.                                     strcat(szTemp, ",lw");
  4418.  
  4419.                                 WinSendDlgItemMsg(pcnbp->hwndPage, ID_XSDI_OS_CACHE_THRESHOLD,
  4420.                                       SPBM_QUERYVALUE,
  4421.                                       (MPARAM)&ulThreshold,
  4422.                                       MPFROM2SHORT(0, SPBQ_UPDATEIFVALID));
  4423.                                 // again, convert KB to sectors for the threshold
  4424.                                 sprintf(szTemp+strlen(szTemp), ",%d", ulThreshold*2);
  4425.  
  4426.                                 WinQueryDlgItemText(pcnbp->hwndPage, ID_XSDI_OS_AUTOCHECK,
  4427.                                                 sizeof(szAutoCheck)-1, szAutoCheck);
  4428.                                 if (strlen(szAutoCheck))
  4429.                                     sprintf(szTemp+strlen(szTemp), ",ac:%s", szAutoCheck, TRUE);
  4430.  
  4431.                                 strhSetParameter(pszConfigSys, "DISKCACHE=", szTemp, TRUE);
  4432.  
  4433.                             } else {
  4434.                                 // no "Cache installed":
  4435.                                 strhDeleteLine(pszConfigSys, "DISKCACHE=");
  4436.                             }
  4437.                         break; }
  4438.  
  4439.                         case SP_WPS: {
  4440.                             CHAR   szTemp[300] = "";
  4441.                             BOOL   fCopied = FALSE;
  4442.                             if (winhIsDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_AUTO_PROGRAMS)) {
  4443.                                 strcpy(szTemp, "programs");
  4444.                                 fCopied = TRUE;
  4445.                             }
  4446.                             if (winhIsDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_AUTO_TASKLIST)) {
  4447.                                 if (fCopied)
  4448.                                     strcat(szTemp, ",");
  4449.                                 strcat(szTemp, "tasklist");
  4450.                                 fCopied = TRUE;
  4451.                             }
  4452.                             if (fCopied)
  4453.                                 strcat(szTemp, ",");
  4454.                             strcat(szTemp, "folders");
  4455.                             if (winhIsDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_AUTO_CONNECTIONS)) {
  4456.                                 strcat(szTemp, ",connections");
  4457.                             }
  4458.                             if (winhIsDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_AUTO_LAUNCHPAD)) {
  4459.                                 strcat(szTemp, ",launchpad");
  4460.                             }
  4461.                             if (winhIsDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_AUTO_WARPCENTER)) {
  4462.                                 strcat(szTemp, ",warpcenter");
  4463.                             }
  4464.                             strhSetParameter(pszConfigSys, "SET AUTOSTART=", szTemp, TRUE);
  4465.  
  4466.                             if (winhIsDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_RESTART_FOLDERS))
  4467.                                 strcpy(szTemp, "STARTUPFOLDERSONLY");
  4468.                             else if (winhIsDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_RESTART_NO))
  4469.                                 strcpy(szTemp, "no");
  4470.                             else
  4471.                                 strcpy(szTemp, "yes");
  4472.                             if (winhIsDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_RESTART_REBOOT))
  4473.                                 strcat(szTemp, ",rebootonly");
  4474.                             strhSetParameter(pszConfigSys, "SET RESTARTOBJECTS=", szTemp, TRUE);
  4475.  
  4476.                             if (doshIsWarp4())
  4477.                                 if (winhIsDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_AUTOREFRESHFOLDERS))
  4478.                                     strhDeleteLine(pszConfigSys, "SET AUTOREFRESHFOLDERS=");
  4479.                                 else
  4480.                                     strhSetParameter(pszConfigSys, "SET AUTOREFRESHFOLDERS=",
  4481.                                             "no", TRUE);
  4482.                         break; }
  4483.  
  4484.                         case SP_ERRORS: {
  4485.                             if (winhIsDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_AUTOFAIL))
  4486.                                 strhSetParameter(pszConfigSys, "AUTOFAIL=", "yes", TRUE);
  4487.                             else
  4488.                                 strhDeleteLine(pszConfigSys, "AUTOFAIL=");
  4489.  
  4490.                             if (winhIsDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_REIPL))
  4491.                                 strhSetParameter(pszConfigSys, "REIPL=", "on", TRUE);
  4492.                             else
  4493.                                 strhDeleteLine(pszConfigSys, "REIPL=");
  4494.  
  4495.                             if (winhIsDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_SUPRESSPOPUPS)) {
  4496.                                 CHAR szSpinButtonValue[5];
  4497.                                 WinSendDlgItemMsg(pcnbp->hwndPage, ID_XSDI_OS_SUPRESSP_DRIVE,
  4498.                                         SPBM_QUERYVALUE,
  4499.                                         (MPARAM)szSpinButtonValue,
  4500.                                         MPFROM2SHORT(sizeof(szSpinButtonValue)-1,
  4501.                                             SPBQ_UPDATEIFVALID));
  4502.                                 strhSetParameter(pszConfigSys, "SUPPRESSPOPUPS=",
  4503.                                         szSpinButtonValue, TRUE);
  4504.                             } else
  4505.                                 strhDeleteLine(pszConfigSys, "SUPPRESSPOPUPS=");
  4506.  
  4507.  
  4508.                         break; }
  4509.                     } // end switch
  4510.  
  4511.                     sprintf(szConfigSys, "%c:\\config.sys", doshQueryBootDrive());
  4512.                     doshWriteTextFile(szConfigSys, pszConfigSys, TRUE);
  4513.  
  4514.                     cmnMessageBoxMsg(pcnbp->hwndPage, 100, 136, MB_OK);
  4515.  
  4516.                     if (pszConfigSys) {
  4517.                         free(pszConfigSys);
  4518.                         pszConfigSys = NULL;
  4519.                     }
  4520.                 }
  4521.             }
  4522.         break; }
  4523.  
  4524.         /*
  4525.          * DID_OPTIMIZE:
  4526.          *      "Optimize" button
  4527.          */
  4528.  
  4529.         case DID_OPTIMIZE: {
  4530.  
  4531.             switch (pcnbp->ulPageID) {
  4532.                 case SP_SCHEDULER: {
  4533.                     // THREADS=
  4534.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_MAXTHREADS,
  4535.                             128, 4096,
  4536.                             // get current thread count, add 50% for safety,
  4537.                             // and round up to the next multiple of 128
  4538.                             (( (    (prcQueryThreadCount(0)  // whole system
  4539.                                   * 3) / 2) + 127 ) / 128) * 128
  4540.                     );
  4541.  
  4542.                     // MAXWAIT=2
  4543.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_MAXWAIT, 1, 10,
  4544.                         2);
  4545.  
  4546.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_PRIORITYDISKIO,
  4547.                         TRUE);
  4548.                 break; }
  4549.  
  4550.                 case SP_MEMORY: {
  4551.                     // minsize: get current size, add 50% and
  4552.                     // round up to the next multiple of 2 MB
  4553.                     if (strlen(szOrigSwapPath) != 0) {
  4554.                         ULONG ulSize = doshQueryPathSize(szOrigSwapPath)/1024/1024;
  4555.                         winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_MINSWAPSIZE,
  4556.                                 2, 100,
  4557.                                 ( (((ulSize*3)/2)+1) / 2 ) * 2
  4558.                         );
  4559.                     }
  4560.  
  4561.                     // minfree = 2
  4562.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_MINSWAPFREE,
  4563.                             2, 1000,
  4564.                             2);
  4565.                 break; }
  4566.  
  4567.                 case SP_HPFS: {
  4568.                     ULONG   aulSysInfo[QSV_MAX] = {0},
  4569.                             ulInstalledMB;
  4570.                     CHAR szHPFSDrives[30];
  4571.                     DosQuerySysInfo(1L, QSV_MAX,
  4572.                                         (PVOID)aulSysInfo, sizeof(ULONG)*QSV_MAX);
  4573.                     ulInstalledMB =
  4574.                                (aulSysInfo[QSV_TOTPHYSMEM-1] + (512*1000)) / 1024 / 1024;
  4575.                     doshEnumDrives(szHPFSDrives, "HPFS");
  4576.  
  4577.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_FSINSTALLED,
  4578.                                 (strlen(szHPFSDrives) > 0));
  4579.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_CACHESIZE_AUTO,
  4580.                                 FALSE);
  4581.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_CACHESIZE,
  4582.                                 0, 2048,
  4583.                                 (ulInstalledMB > 16) ? 2048 : 1024);
  4584.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_CACHE_THRESHOLD,
  4585.                                 4, 64, 64);
  4586.                     WinSetDlgItemText(pcnbp->hwndPage, ID_XSDI_OS_AUTOCHECK, szHPFSDrives);
  4587.  
  4588.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_CACHE_LAZYWRITE,
  4589.                                 TRUE);
  4590.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_CACHE_MAXAGE,
  4591.                                 500, 100*1000, 60*1000);
  4592.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_CACHE_BUFFERIDLE,
  4593.                                 500, 100*1000, 30*1000);
  4594.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_CACHE_DISKIDLE,
  4595.                                 500, 100*1000, 60*1000);
  4596.  
  4597.                 break; }
  4598.  
  4599.                 case SP_FAT: {
  4600.                     ULONG   aulSysInfo[QSV_MAX] = {0},
  4601.                             ulInstalledMB;
  4602.                     CHAR szFATDrives[30];
  4603.                     DosQuerySysInfo(1L, QSV_MAX,
  4604.                                         (PVOID)aulSysInfo, sizeof(ULONG)*QSV_MAX);
  4605.                     ulInstalledMB =
  4606.                                (aulSysInfo[QSV_TOTPHYSMEM-1] + (512*1000)) / 1024 / 1024;
  4607.                     doshEnumDrives(szFATDrives, "FAT");
  4608.  
  4609.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_FSINSTALLED,
  4610.                                 (strlen(szFATDrives) > 0));
  4611.  
  4612.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_CACHESIZE_AUTO, FALSE);
  4613.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_CACHE_LAZYWRITE, TRUE);
  4614.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_CACHESIZE,
  4615.                                 0, 14400,
  4616.                                 (ulInstalledMB > 16) ? 2048 : 1024);
  4617.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_CACHE_THRESHOLD,
  4618.                                 4, 64, 64);
  4619.                     // do not auto-check FAT drives
  4620.                     WinSetDlgItemText(pcnbp->hwndPage, ID_XSDI_OS_AUTOCHECK, "");
  4621.  
  4622.                 break; }
  4623.  
  4624.                 case SP_WPS: {
  4625.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_AUTO_PROGRAMS, TRUE);
  4626.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_AUTO_TASKLIST, TRUE);
  4627.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_AUTO_CONNECTIONS, TRUE);
  4628.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_AUTO_LAUNCHPAD, FALSE);
  4629.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_AUTO_WARPCENTER, FALSE);
  4630.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_RESTART_FOLDERS, TRUE);
  4631.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_RESTART_REBOOT, FALSE);
  4632.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_AUTOREFRESHFOLDERS,
  4633.                                 FALSE);
  4634.                 break; }
  4635.  
  4636.                 case SP_ERRORS: {
  4637.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_AUTOFAIL, TRUE);
  4638.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_REIPL, FALSE);
  4639.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_SUPRESSPOPUPS, FALSE);
  4640.                 break; }
  4641.             } // end switch
  4642.  
  4643.             fncbConfigInitPage(pnbi, 100); // re-enable items
  4644.         break; }
  4645.  
  4646.         /*
  4647.          * DID_DEFAULT:
  4648.          *      "Default" button
  4649.          */
  4650.  
  4651.         case DID_DEFAULT: {
  4652.             switch (pcnbp->ulPageID) {
  4653.                 case SP_SCHEDULER: {
  4654.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_MAXTHREADS,
  4655.                             128, 4096, (doshIsWarp4()) ? 512 : 256);
  4656.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_MAXWAIT, 1, 10,
  4657.                         3);
  4658.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_PRIORITYDISKIO,
  4659.                         TRUE);
  4660.                 break; }
  4661.  
  4662.                 case SP_MEMORY: {
  4663.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_MINSWAPSIZE,
  4664.                             2, 100, 2);
  4665.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_MINSWAPFREE,
  4666.                             2, 1000, 2);
  4667.                 break; }
  4668.  
  4669.                 case SP_HPFS: {
  4670.                     CHAR szHPFSDrives[30];
  4671.                     doshEnumDrives(szHPFSDrives, "HPFS");
  4672.  
  4673.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_FSINSTALLED, TRUE);
  4674.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_CACHESIZE_AUTO, FALSE);
  4675.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_CACHESIZE,
  4676.                                 0, 2048, 1024);
  4677.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_CACHE_THRESHOLD,
  4678.                                 4, 64, 4);
  4679.                     WinSetDlgItemText(pcnbp->hwndPage, ID_XSDI_OS_AUTOCHECK, szHPFSDrives);
  4680.  
  4681.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_CACHE_LAZYWRITE,
  4682.                                 TRUE);
  4683.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_CACHE_MAXAGE,
  4684.                                 500, 100*1000, 5*1000);
  4685.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_CACHE_BUFFERIDLE,
  4686.                                 500, 100*1000, 500);
  4687.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_CACHE_DISKIDLE,
  4688.                                 500, 100*1000, 1000);
  4689.  
  4690.                 break; }
  4691.  
  4692.                 case SP_FAT: {
  4693.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_FSINSTALLED, TRUE);
  4694.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_CACHESIZE_AUTO, TRUE);
  4695.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_CACHE_LAZYWRITE, TRUE);
  4696.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_CACHESIZE,
  4697.                                 0, 14400, 1024);
  4698.                     winhSetDlgItemSpinData(pcnbp->hwndPage, ID_XSDI_OS_CACHE_THRESHOLD,
  4699.                                 4, 64, 4);
  4700.                     WinSetDlgItemText(pcnbp->hwndPage, ID_XSDI_OS_AUTOCHECK, "");
  4701.                 break; }
  4702.  
  4703.                 case SP_WPS: {
  4704.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_AUTO_PROGRAMS, TRUE);
  4705.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_AUTO_TASKLIST, TRUE);
  4706.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_AUTO_CONNECTIONS, TRUE);
  4707.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_AUTO_LAUNCHPAD, TRUE);
  4708.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_AUTO_WARPCENTER,
  4709.                                     (doshIsWarp4()));
  4710.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_RESTART_YES, TRUE);
  4711.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_RESTART_REBOOT, FALSE);
  4712.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_AUTOREFRESHFOLDERS,
  4713.                                     (doshIsWarp4()));
  4714.                 break; }
  4715.  
  4716.                 case SP_ERRORS: {
  4717.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_AUTOFAIL, FALSE);
  4718.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_REIPL, FALSE);
  4719.                     winhSetDlgItemChecked(pcnbp->hwndPage, ID_XSDI_OS_SUPRESSPOPUPS, FALSE);
  4720.                 break; }
  4721.             } // end switch
  4722.  
  4723.             fncbConfigInitPage(pnbi, 100); // re-enable items
  4724.         break; }
  4725.  
  4726.         case ID_XSDI_OS_AUTOCHECK_PROPOSE: {
  4727.             // "Propose" button for auto-chkdsk (HPFS/FAT pages):
  4728.             // enumerate all HPFS or FAT drives on the system
  4729.             CHAR szHPFSDrives[30];
  4730.             doshEnumDrives(szHPFSDrives,
  4731.                     (pcnbp->ulPageID == SP_HPFS) ? "HPFS" : "FAT");
  4732.             WinSetDlgItemText(pcnbp->hwndPage, ID_XSDI_OS_AUTOCHECK, szHPFSDrives);
  4733.         break; }
  4734.     }
  4735.  
  4736.     if (    (usNotifyCode == SPBN_CHANGE)
  4737.          || (usNotifyCode == BN_CLICKED)
  4738.        )
  4739.        // if we had any changes, we might need to
  4740.        // re-enable controls
  4741.        fncbConfigInitPage(pnbi, 100);
  4742.  
  4743.     return ((MPARAM)-1);
  4744. }
  4745.  
  4746. /*
  4747.  *@@ fncbConfigTimer:
  4748.  *      common callback func for the "Memory" and "Scheduler"
  4749.  *      pages, which have a 2-sec timer set for updating the
  4750.  *      display
  4751.  */
  4752.  
  4753. VOID fncbConfigTimer(PVOID pnbi, ULONG ulTimer)
  4754. {
  4755.     PCREATENOTEBOOKPAGE pcnbp = (PCREATENOTEBOOKPAGE)pnbi;
  4756.     CHAR szTemp[50];
  4757.  
  4758.     switch (pcnbp->ulPageID)
  4759.     {
  4760.         case SP_SCHEDULER: {
  4761.             sprintf(szTemp, "%d", prcQueryThreadCount(0));
  4762.             WinSetDlgItemText(pcnbp->hwndPage, ID_XSDI_OS_CURRENTTHREADS, szTemp);
  4763.         break; }
  4764.  
  4765.         case SP_MEMORY: {
  4766.             if (strlen(szOrigSwapPath) != 0) {
  4767.                 ULONG ulSize = doshQueryPathSize(szOrigSwapPath)/1024/1024;
  4768.                 if (ulSize) {
  4769.                     sprintf(szTemp, "%d", ulSize);
  4770.                     WinSetDlgItemText(pcnbp->hwndPage, ID_XSDI_OS_CURRENTSWAPSIZE,
  4771.                         (szTemp));
  4772.                 } else
  4773.                     WinSetDlgItemText(pcnbp->hwndPage, ID_XSDI_OS_CURRENTSWAPSIZE, "???");
  4774.             }
  4775.         break; }
  4776.     }
  4777. }
  4778.  
  4779. /* ******************************************************************
  4780.  *                                                                  *
  4781.  *   here come the XFldSystem instance methods                      *
  4782.  *                                                                  *
  4783.  ********************************************************************/
  4784.  
  4785. /*
  4786.  *@@ xfAddXFldSystemPages:
  4787.  *           this actually adds the "XFolder" pages into the System notebook
  4788.  */
  4789.  
  4790. SOM_Scope ULONG  SOMLINK xfsys_xfAddXFldSystemPages(XFldSystem *somSelf,
  4791.                                                  HWND hwndDlg)
  4792. {
  4793.     PCREATENOTEBOOKPAGE pcnbp;
  4794.     PAGEINFO        pi;
  4795.     HMODULE         savehmod;
  4796.     // CHAR            szXFolderVersion[100];
  4797.     PNLSSTRINGS pNLSStrings = cmnQueryNLSStrings();
  4798.     PSZ pszHelpLibrary = cmnQueryHelpLibrary();
  4799.  
  4800.     // XFldSystemData *somThis = XFldSystemGetData(somSelf);
  4801.     XFldSystemMethodDebug("XFldSystem","xfsys_xfAddXFldSystemPages");
  4802.  
  4803.     savehmod = NLS_MODULE;
  4804.     memset((PCH)&pi, 0, sizeof(PAGEINFO));
  4805.  
  4806.     // "Errors"
  4807.     pcnbp = malloc(sizeof(CREATENOTEBOOKPAGE));
  4808.     memset(pcnbp, 0, sizeof(CREATENOTEBOOKPAGE));
  4809.     pcnbp->somSelf = somSelf;
  4810.     pcnbp->hwndNotebook = hwndDlg;
  4811.     pcnbp->hmod = savehmod;
  4812.     pcnbp->pfncbInitPage    = fncbConfigInitPage;
  4813.     pcnbp->pfncbItemChanged = fncbConfigItemChanged;
  4814.     pcnbp->fMajorTab = TRUE;
  4815.     pcnbp->pszName = pNLSStrings->pszErrors;
  4816.     pcnbp->ulDlgID = ID_XSD_SETTINGS_ERRORS;
  4817.     pcnbp->ulDefaultHelpPanel  = ID_XSH_SETTINGS_ERRORS;
  4818.     // give this page a unique ID, which is
  4819.     // passed to the common config.sys callbacks
  4820.     pcnbp->ulPageID = SP_ERRORS;
  4821.     ntbInsertPage(pcnbp);
  4822.  
  4823.     // "WPS" settings
  4824.     pcnbp = malloc(sizeof(CREATENOTEBOOKPAGE));
  4825.     memset(pcnbp, 0, sizeof(CREATENOTEBOOKPAGE));
  4826.     pcnbp->somSelf = somSelf;
  4827.     pcnbp->hwndNotebook = hwndDlg;
  4828.     pcnbp->hmod = savehmod;
  4829.     pcnbp->pfncbInitPage    = fncbConfigInitPage;
  4830.     pcnbp->pfncbItemChanged = fncbConfigItemChanged;
  4831.     pcnbp->fMajorTab = TRUE;
  4832.     pcnbp->pszName = pNLSStrings->pszWPS;
  4833.     pcnbp->ulDlgID = ID_XSD_SETTINGS_WPS;
  4834.     pcnbp->ulDefaultHelpPanel  = ID_XSH_SETTINGS_WPS;
  4835.     // give this page a unique ID, which is
  4836.     // passed to the common config.sys callbacks
  4837.     pcnbp->ulPageID = SP_WPS;
  4838.     ntbInsertPage(pcnbp);
  4839.  
  4840.     // insert file-system settings pages
  4841.     pcnbp = malloc(sizeof(CREATENOTEBOOKPAGE));
  4842.     memset(pcnbp, 0, sizeof(CREATENOTEBOOKPAGE));
  4843.     pcnbp->somSelf = somSelf;
  4844.     pcnbp->hwndNotebook = hwndDlg;
  4845.     pcnbp->hmod = savehmod;
  4846.     pcnbp->pfncbInitPage    = fncbConfigInitPage;
  4847.     pcnbp->pfncbItemChanged = fncbConfigItemChanged;
  4848.     pcnbp->fMajorTab = TRUE;
  4849.     pcnbp->pszName = "~FAT";
  4850.     pcnbp->ulDlgID = ID_XSD_SETTINGS_FAT;
  4851.     pcnbp->ulDefaultHelpPanel  = ID_XSH_SETTINGS_HPFS;
  4852.     // give this page a unique ID, which is
  4853.     // passed to the common config.sys callbacks
  4854.     pcnbp->ulPageID = SP_FAT;
  4855.     ntbInsertPage(pcnbp);
  4856.  
  4857.     pcnbp = malloc(sizeof(CREATENOTEBOOKPAGE));
  4858.     memset(pcnbp, 0, sizeof(CREATENOTEBOOKPAGE));
  4859.     pcnbp->somSelf = somSelf;
  4860.     pcnbp->hwndNotebook = hwndDlg;
  4861.     pcnbp->hmod = savehmod;
  4862.     pcnbp->pfncbInitPage    = fncbConfigInitPage;
  4863.     pcnbp->pfncbItemChanged = fncbConfigItemChanged;
  4864.     pcnbp->fMajorTab = TRUE;
  4865.     pcnbp->pszName = "~HPFS";
  4866.     pcnbp->ulDlgID = ID_XSD_SETTINGS_HPFS;
  4867.     pcnbp->ulDefaultHelpPanel  = ID_XSH_SETTINGS_HPFS;
  4868.     // give this page a unique ID, which is
  4869.     // passed to the common config.sys callbacks
  4870.     pcnbp->ulPageID = SP_HPFS;
  4871.     ntbInsertPage(pcnbp);
  4872.  
  4873.     // "Memory"
  4874.     pcnbp = malloc(sizeof(CREATENOTEBOOKPAGE));
  4875.     memset(pcnbp, 0, sizeof(CREATENOTEBOOKPAGE));
  4876.     pcnbp->somSelf = somSelf;
  4877.     pcnbp->hwndNotebook = hwndDlg;
  4878.     pcnbp->hmod = savehmod;
  4879.     pcnbp->pfncbInitPage    = fncbConfigInitPage;
  4880.     pcnbp->pfncbItemChanged = fncbConfigItemChanged;
  4881.     pcnbp->fMajorTab = TRUE;
  4882.     pcnbp->pszName = pNLSStrings->pszMemory;
  4883.     pcnbp->ulDlgID = ID_XSD_SETTINGS_KERNEL2;
  4884.     pcnbp->ulDefaultHelpPanel  = ID_XSH_SETTINGS_KERNEL2;
  4885.     // give this page a unique ID, which is
  4886.     // passed to the common config.sys callbacks
  4887.     pcnbp->ulPageID = SP_MEMORY;
  4888.     // for this page, start a timer
  4889.     pcnbp->ulTimer = 2000;
  4890.     pcnbp->pfncbTimer = fncbConfigTimer;
  4891.     ntbInsertPage(pcnbp);
  4892.  
  4893.     // "Scheduler"
  4894.     pcnbp = malloc(sizeof(CREATENOTEBOOKPAGE));
  4895.     memset(pcnbp, 0, sizeof(CREATENOTEBOOKPAGE));
  4896.     pcnbp->somSelf = somSelf;
  4897.     pcnbp->hwndNotebook = hwndDlg;
  4898.     pcnbp->hmod = savehmod;
  4899.     pcnbp->pfncbInitPage    = fncbConfigInitPage;
  4900.     pcnbp->pfncbItemChanged = fncbConfigItemChanged;
  4901.     pcnbp->fMajorTab = TRUE;
  4902.     pcnbp->pszName = pNLSStrings->pszScheduler;
  4903.     pcnbp->ulDlgID = ID_XSD_SETTINGS_KERNEL1;
  4904.     pcnbp->ulDefaultHelpPanel  = ID_XSH_SETTINGS_KERNEL1;
  4905.     // give this page a unique ID, which is
  4906.     // passed to the common config.sys callbacks
  4907.     pcnbp->ulPageID = SP_SCHEDULER;
  4908.     // for this page, start a timer
  4909.     pcnbp->ulTimer = 2000;
  4910.     pcnbp->pfncbTimer = fncbConfigTimer;
  4911.     return (ntbInsertPage(pcnbp));
  4912.  
  4913. }
  4914.  
  4915. /*
  4916.  *@@ wpAddSettingsPages:
  4917.  *           this instance method is overridden in order
  4918.  *           to add the new XFolder page after the default
  4919.  *           "Screen" page in the settings notebook. In
  4920.  *           order to to this, unlike the procedure used in
  4921.  *           the "Workplace Shell" object, we will explicitly
  4922.  *           call the WPSystem methods which insert the
  4923.  *           pages we want to see here into the notebook.
  4924.  *           As a result, the "Workplace Shell" object
  4925.  *           inherits all pages from the "System" object
  4926.  *           which might be added by other WPS utils, while
  4927.  *           this thing does not.
  4928.  */
  4929.  
  4930. SOM_Scope BOOL  SOMLINK xfsys_wpAddSettingsPages(XFldSystem *somSelf,
  4931.                                                  HWND hwndNotebook)
  4932. {
  4933.     // XFldSystemData *somThis = XFldSystemGetData(somSelf);
  4934.     XFldSystemMethodDebug("XFldSystem","xfsys_wpwpAddSettingsPages");
  4935.  
  4936.     // do _not_ call the parent, but call the page methods
  4937.     // explicitly
  4938.     /* if (ulRC)
  4939.         ulRC = XFldSystem_parent_WPSystem_wpAddSystemScreenPage(somSelf, hwndNotebook); */
  4940.  
  4941.     // XFolder "Internals" page bottommost
  4942.     _xfAddObjectInternalsPage(somSelf, hwndNotebook);
  4943.     // "Symbol" page next
  4944.     _wpAddObjectGeneralPage(somSelf, hwndNotebook);
  4945.     // "Screen" page 2 next; this page may exist on some systems
  4946.     // depending on the video driver, and we want this in "OS/2 Kernel"
  4947.     // also
  4948.     _wpAddDMQSDisplayTypePage(somSelf, hwndNotebook);
  4949.     // "Screen" page 1 next
  4950.     _wpAddSystemScreenPage(somSelf, hwndNotebook);
  4951.  
  4952.     // XFolder CONFIG.SYS pages on top
  4953.     _xfAddXFldSystemPages(somSelf, hwndNotebook);
  4954.  
  4955.     return (TRUE);
  4956. }
  4957.  
  4958. /* ******************************************************************
  4959.  *                                                                  *
  4960.  *   here come the XFldSystem class methods                         *
  4961.  *                                                                  *
  4962.  ********************************************************************/
  4963.  
  4964. /*
  4965.  *@@ wpclsSetSetting:
  4966.  *           this WPAbstract method sets the class object
  4967.  *           settings in the settings notebook via setup
  4968.  *           strings. WPSystem defines the WPS-wide system
  4969.  *           setting strings here, and XFolder needs to
  4970.  *           introduce its own settings here also.
  4971.  */
  4972.  
  4973. SOM_Scope BOOL  SOMLINK xfsysM_wpclsSetSetting(M_XFldSystem *somSelf,
  4974.                                                PSZ pszSetting,
  4975.                                                PVOID pValue)
  4976. {
  4977.     // M_XFldSystemData *somThis = M_XFldSystemGetData(somSelf);
  4978.     M_XFldSystemMethodDebug("M_XFldSystem","xfsysM_wpclsSetSetting");
  4979.  
  4980.     return (M_XFldSystem_parent_M_WPSystem_wpclsSetSetting(somSelf,
  4981.                                                            pszSetting,
  4982.                                                            pValue));
  4983. }
  4984.  
  4985. /*
  4986.  *@@ wpclsQuerySettingsPageSize:
  4987.  *           this WPObject class method should return the
  4988.  *           size of the largest settings page in dialog
  4989.  *           units; if a settings notebook is initially
  4990.  *           opened, i.e. no window pos has been stored
  4991.  *           yet, the WPS will use this size, to avoid
  4992.  *           truncated settings pages.
  4993.  */
  4994.  
  4995. SOM_Scope BOOL  SOMLINK xfsysM_wpclsQuerySettingsPageSize(M_XFldSystem *somSelf,
  4996.                                                           PSIZEL pSizl)
  4997. {
  4998.     BOOL brc;
  4999.     /* M_XFldSystemData *somThis = M_XFldSystemGetData(somSelf); */
  5000.     M_XFldSystemMethodDebug("M_XFldSystem","xfsysM_wpclsQuerySettingsPageSize");
  5001.  
  5002.     brc = M_XFldSystem_parent_M_WPSystem_wpclsQuerySettingsPageSize(somSelf,
  5003.                                                                       pSizl);
  5004.     if (brc) {
  5005.         pSizl->cy = 162;        // this is the height of the "WPS Classes" page,
  5006.                                 // which seems to be the largest in the "Workplace
  5007.                                 // Shell" object
  5008.         if (doshIsWarp4())
  5009.             // on Warp 4, reduce again, because we're moving
  5010.             // the notebook buttons to the bottom
  5011.             pSizl->cy -= WARP4_NOTEBOOK_OFFSET;
  5012.     }
  5013.  
  5014.     return (brc);
  5015. }
  5016.  
  5017. /*
  5018.  *@@ wpclsQueryIconData:
  5019.  *           give the WPS object a new icon
  5020.  */
  5021.  
  5022. SOM_Scope ULONG  SOMLINK xfsysM_wpclsQueryIconData(M_XFldSystem *somSelf,
  5023.                                                    PICONINFO pIconInfo)
  5024. {
  5025.     // M_XFldSystemData *somThis = M_XFldSystemGetData(somSelf);
  5026.     M_XFldSystemMethodDebug("M_XFldSystem","xfsysM_wpclsQueryIconData");
  5027.  
  5028.     if (pIconInfo) {
  5029.        pIconInfo->fFormat = ICON_RESOURCE;
  5030.        pIconInfo->resid   = ID_ICONSYS;
  5031.        pIconInfo->hmod    = modQueryHandle();
  5032.     }
  5033.  
  5034.     return (sizeof(ICONINFO));
  5035.  
  5036.     /* return (M_XFldSystem_parent_M_WPSystem_wpclsQueryIconData(somSelf,
  5037.                                                               pIconInfo)); */
  5038. }
  5039.  
  5040. /*
  5041.  *@@ wpclsQueryTitle:
  5042.  *           tell the WPS the new class name: System (XFolder)
  5043.  */
  5044.  
  5045. SOM_Scope PSZ  SOMLINK xfsysM_wpclsQueryTitle(M_XFldSystem *somSelf)
  5046. {
  5047.     // M_XFldSystemData *somThis = M_XFldSystemGetData(somSelf);
  5048.     M_XFldSystemMethodDebug("M_XFldSystem","xfsysM_wpclsQueryTitle");
  5049.  
  5050.     return ("OS/2 Kernel");
  5051. }
  5052.  
  5053. /*
  5054.  *@@ wpclsInitData:
  5055.  *           initialize XFldSystem class data
  5056.  */
  5057.  
  5058. SOM_Scope void  SOMLINK xfsysM_wpclsInitData(M_XFldSystem *somSelf)
  5059. {
  5060.     // M_XFldSystemData *somThis = M_XFldSystemGetData(somSelf);
  5061.     M_XFldSystemMethodDebug("M_XFldSystem","xfsysM_wpclsInitData");
  5062.  
  5063.     M_XFldSystem_parent_M_WPSystem_wpclsInitData(somSelf);
  5064.  
  5065.     // _hmodXFldSystem = NULLHANDLE;
  5066. }
  5067.  
  5068.  
  5069.