home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / memsz331.zip / Source.zip / CONFIG.CPP < prev    next >
Text File  |  1997-01-20  |  61KB  |  1,280 lines

  1. /***************************************************************** CONFIG.CPP
  2.  *                                                                          *
  3.  *                        Clock Configuration Dialog                        *
  4.  *                                                                          *
  5.  ****************************************************************************/
  6.  
  7. #define INCL_BASE
  8. #define INCL_PM
  9. #define INCL_WINSTDSPIN
  10. #define INCL_WINWORKPLACE
  11. #include <os2.h>
  12.  
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <string.h>
  16.  
  17. #include "Debug.h"
  18. #include "Support.h"
  19.  
  20. #include "Memsize.h"
  21. #include "Config.h"
  22. #include "Profile.h"
  23.  
  24. // #define DEBUG
  25.  
  26. /****************************************************************************
  27.  *                                                                          *
  28.  *                     Definitions & Declarations                           *
  29.  *                                                                          *
  30.  ****************************************************************************/
  31.  
  32.   // Function Prototypes
  33.  
  34. static FNWP InitDlg ;
  35. static FNWP Control ;
  36. static FNWP FormatFrame ;
  37. static FNWP UpdateDrives ;
  38.  
  39. static FNWP Configure_Items_Processor ;
  40. static FNWP Configure_Options1_Processor ;
  41. static FNWP Configure_Options2_Processor ;
  42. static FNWP Configure_Colors_Processor ;
  43. static FNWP Configure_Anchor_Processor ;
  44.  
  45. class Slider {
  46.  
  47.    private:
  48.       HWND Control, Entryfield ;
  49.       ULONG MinLevel, MaxLevel ;
  50.       int Divisor ;
  51.       char *Suffix ;
  52.  
  53.    public:
  54.       Slider ( HWND control, HWND entryfield, ULONG Level, ULONG minlevel, ULONG maxlevel, int divisor, char *suffix ) : 
  55.          Control(control), Entryfield(entryfield), MinLevel(minlevel), MaxLevel(maxlevel), Divisor(divisor), Suffix(suffix) {
  56.  
  57.          // Set left label.
  58.          char Text [20] ;
  59.          sprintf ( Text, "%i%s", MinLevel/Divisor, Suffix ) ;
  60.          WinSendMsg ( Control, SLM_SETSCALETEXT, MPFROMSHORT(0), MPFROMP(Text) ) ;
  61.  
  62.          // Set center label.
  63.          sprintf ( Text, "%i%s", (MinLevel+(MaxLevel-MinLevel)/2)/Divisor, Suffix ) ;
  64.          WinSendMsg ( Control, SLM_SETSCALETEXT, MPFROMSHORT(50), MPFROMP(Text) ) ;
  65.  
  66.          // Set right label.
  67.          sprintf ( Text, "%i%s", MaxLevel/Divisor, Suffix ) ;
  68.          WinSendMsg ( Control, SLM_SETSCALETEXT, MPFROMSHORT(100), MPFROMP(Text) ) ;
  69.  
  70.          // Position the slider.
  71.          short Tick = short ( ( double ( Level - MinLevel ) / ( Divisor / 100.0 ) ) / ( double ( MaxLevel - MinLevel ) / Divisor ) ) ;
  72.          WinSendMsg ( Control, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_INCREMENTVALUE), MPFROMSHORT(Tick) ) ;
  73.  
  74.          // Set the entryfield text.
  75.          sprintf ( Text, "%.1lf%s", double(Level)/Divisor, Suffix ) ;
  76.          WinSetWindowText ( Entryfield, PSZ(Text) ) ;
  77.  
  78.       } /* endmethod */
  79.  
  80.       void Set ( ULONG Level, BOOL SetText=TRUE ) {
  81.  
  82.          // Position the slider.
  83.          short Tick = short ( ( double ( Level - MinLevel ) / ( Divisor / 100.0 ) ) / ( double ( MaxLevel - MinLevel ) / Divisor ) ) ;
  84.          WinSendMsg ( Control, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_INCREMENTVALUE), MPFROMSHORT(Tick) ) ;
  85.  
  86.          // Set the entryfield text.
  87.          if ( SetText ) {
  88.             char Text [20] ;
  89.             sprintf ( Text, "%.1lf%s", double(Level)/Divisor, Suffix ) ;
  90.             WinSetWindowText ( Entryfield, PSZ(Text) ) ;
  91.          } /* endif */
  92.  
  93.       } /* endmethod */
  94.  
  95.       ULONG Read ( ) {
  96.  
  97.          // Read the slider.
  98.          ULONG Tick = LONGFROMMR ( WinSendMsg ( Control, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_INCREMENTVALUE), 0 ) ) ;
  99.          ULONG Level = ULONG ( MinLevel + ( Tick * ( double ( MaxLevel - MinLevel ) / ( Divisor * 100.0 ) ) * Divisor ) ) ;
  100.  
  101.          // Update the entry field.
  102.          char Text [20] ;
  103.          sprintf ( Text, "%.1lf%s", double(Level)/Divisor, Suffix ) ;
  104.          WinSetWindowText ( Entryfield, PSZ(Text) ) ;
  105.  
  106.          // Return the result.
  107.          return ( Level ) ;
  108.  
  109.       } /* endmethod */
  110. } ;
  111.  
  112. typedef struct {
  113.    char  DefaultLabel [80] ;
  114.    char  CurrentLabel [80] ;
  115.    ULONG DefaultLevels [2] ;
  116.    ULONG WarningLevel ;
  117.    ULONG ErrorLevel ;
  118.    int   LevelSense ;
  119.    ULONG MinLevel ;
  120.    ULONG MaxLevel ;
  121.    USHORT ShowTrueK ;
  122.    Slider *Warning ;
  123.    Slider *Error ;
  124. } LABEL_PARMS, *PLABEL_PARMS ;
  125.  
  126. static FNWP Label_Processor ;
  127. static FNWP Static_Processor ;
  128. static PFNWP OldStaticProcessor = 0 ;
  129.  
  130. /****************************************************************************
  131.  *                                                                          *
  132.  *      "Configure" Dialog Processor                                        *
  133.  *                                                                          *
  134.  ****************************************************************************/
  135.  
  136. extern MRESULT EXPENTRY ConfigureProcessor ( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) {
  137.  
  138.   /**************************************************************************
  139.    * Dispatch the message according to the method table and return the      *
  140.    *   result.  Any messages not defined above get handled by the system    *
  141.    *   default dialog processor.                                            *
  142.    **************************************************************************/
  143.  
  144.    #ifdef DEBUG
  145.       static int Indent = 0 ;
  146.       Log ( "%*sCONFIG: Message %08X received.  Parm1=%08X, Parm2=%08X.", Indent, "", msg, mp1, mp2 ) ;
  147.       Indent += 2 ;
  148.    #endif
  149.  
  150.    static METHOD Methods [] = {
  151.       { WM_INITDLG,      InitDlg      },
  152.       { WM_CONTROL,      Control      },
  153.       { WM_FORMATFRAME,  FormatFrame  },
  154.       { WM_UPDATEDRIVES, UpdateDrives }
  155.    } ;
  156.  
  157.    MRESULT Result = DispatchMessage ( hwnd, msg, mp1, mp2, Methods, sizeof(Methods)/sizeof(Methods[0]), WinDefDlgProc ) ;
  158.  
  159.    #ifdef DEBUG
  160.       Indent -= 2 ;
  161.       Log ( "%*sCONFIG: Message %08X done.  Result %08X.", Indent, "", msg, Result ) ;
  162.    #endif
  163.  
  164.    return ( Result ) ;
  165. }
  166.  
  167. /****************************************************************************
  168.  *                                                                          *
  169.  *      Initialize Dialog                                                   *
  170.  *                                                                          *
  171.  ****************************************************************************/
  172.  
  173. static MRESULT APIENTRY InitDlg ( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) {
  174.  
  175.   /**************************************************************************
  176.    * Get initial parameters.                                                *
  177.    **************************************************************************/
  178.  
  179.    PCONFIG_PARMS Parms = PCONFIG_PARMS ( PVOIDFROMMP ( mp2 ) ) ;
  180.  
  181.    WinSetWindowPtr ( hwnd, QWL_USER, Parms ) ;
  182.  
  183.   /**************************************************************************
  184.    * Associate the help instance.                                           *
  185.    **************************************************************************/
  186.  
  187.    WinAssociateHelpInstance ( WinQueryHelpInstance(OWNER(hwnd)), hwnd ) ;
  188.  
  189.   /**************************************************************************
  190.    * Mark the dialog not ready so that Control messages are ignored.        *
  191.    **************************************************************************/
  192.  
  193.    Parms->Ready = FALSE ;
  194.  
  195.   /**************************************************************************
  196.    * Create the notebook pages.                                             *
  197.    **************************************************************************/
  198.  
  199.    ResourceString   ItemsPageName ( LibraryHandle, IDS_CONFIG_PAGE_ITEMS ) ;
  200.    ResourceString OptionsPageName ( LibraryHandle, IDS_CONFIG_PAGE_OPTIONS ) ;
  201.    ResourceString  ColorsPageName ( LibraryHandle, IDS_CONFIG_PAGE_COLORS ) ;
  202.    ResourceString  AnchorPageName ( LibraryHandle, IDS_CONFIG_PAGE_ANCHOR ) ;
  203.  
  204.    HWND hwndNotebook = WinWindowFromID ( hwnd, IDD_CONFIG_NOTEBOOK ) ;
  205.  
  206.    WinSendMsg ( hwndNotebook, BKM_SETNOTEBOOKCOLORS,
  207.       MPFROMLONG(SYSCLR_FIELDBACKGROUND), MPFROMSHORT(BKA_BACKGROUNDPAGECOLORINDEX) ) ;
  208.  
  209.    struct {
  210.       char *Name ;              FNWP *Processor ;             int DialogID ;
  211.    } Pages [] = {
  212.       { PCHAR(  ItemsPageName), Configure_Items_Processor,    IDD_CONFIG_PAGE_ITEMS    },
  213.       { PCHAR(OptionsPageName), Configure_Options1_Processor, IDD_CONFIG_PAGE_OPTIONS1 },
  214.       { 0,                      Configure_Options2_Processor, IDD_CONFIG_PAGE_OPTIONS2 },
  215.       { PCHAR( ColorsPageName), Configure_Colors_Processor,   IDD_CONFIG_PAGE_COLORS   },
  216.       { PCHAR( AnchorPageName), Configure_Anchor_Processor,   IDD_CONFIG_PAGE_ANCHOR   },
  217.    } ;
  218.  
  219.    HPS hPS = WinGetPS ( hwnd ) ;
  220.    RECTL Rectangle ;
  221.    WinQueryWindowRect ( HWND_DESKTOP, &Rectangle ) ;
  222.    char *Characters = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789" ;
  223.    WinDrawText ( hPS, strlen(Characters), PSZ(Characters), &Rectangle, 0, 0, DT_LEFT | DT_BOTTOM | DT_QUERYEXTENT ) ;
  224.    long AvgWidth  = ( Rectangle.xRight - Rectangle.xLeft ) / strlen(Characters) ;
  225.    long AvgHeight = Rectangle.yTop - Rectangle.yBottom ;
  226.  
  227.    long MajorTabWidth = 0 ;
  228.    for ( int i=0; i<sizeof(Pages)/sizeof(Pages[0]); i++ ) {
  229.  
  230.       BOOL MajorTab ( ( i == 0 ) || Pages[i].Name ) ;
  231.       int PageNumber(1), PageCount(1) ;  char *Name(0);
  232.       for ( int j=i; j>=0; j-- ) 
  233.          if ( Pages[j].Name ) 
  234.             break ;
  235.       Name = Pages[j].Name ;
  236.       for ( j=j+1; j<sizeof(Pages)/sizeof(Pages[0]) && !Pages[j].Name; j++ ) {
  237.          PageCount ++ ;
  238.          if ( j <= i ) 
  239.             PageNumber ++ ;
  240.       } /* endfor */
  241.  
  242.       ULONG PageHandle = ULONG ( WinSendMsg ( hwndNotebook, BKM_INSERTPAGE,
  243.          MPFROMLONG(0), MPFROM2SHORT( (MajorTab?BKA_MAJOR:0) | BKA_STATUSTEXTON, BKA_LAST ) ) ) ;
  244.  
  245.       char StatusText [80] ;
  246.       if ( PageCount == 1 ) {
  247.          strcpy ( StatusText, Pages[i].Name ) ;
  248.       } else {
  249.          ResourceString Page ( LibraryHandle, IDS_PAGE ) ;
  250.          ResourceString Of ( LibraryHandle, IDS_OF ) ;
  251.          sprintf ( StatusText, "%s, %s %i %s %i", Name, PCHAR(Page), PageNumber, PCHAR(Of), PageCount ) ;
  252.       } /* endif */
  253.       WinSendMsg ( hwndNotebook, BKM_SETSTATUSLINETEXT, MPFROMLONG(PageHandle), MPFROMP(StatusText) ) ;
  254.  
  255.       if ( MajorTab ) {
  256.          WinSendMsg ( hwndNotebook, BKM_SETTABTEXT, MPFROMLONG(PageHandle), MPFROMP(Pages[i].Name) ) ;
  257.          POINTL TextBox [TXTBOX_COUNT] ;
  258.          GpiQueryTextBox ( hPS, strlen(Pages[i].Name), PCH(Pages[i].Name), TXTBOX_COUNT, TextBox ) ;
  259.          MajorTabWidth = max ( MajorTabWidth, TextBox[TXTBOX_CONCAT].x ) ;
  260.       } /* endif */
  261.  
  262.       HWND Dialog = WinLoadDlg ( hwndNotebook, hwnd, Pages[i].Processor, LibraryHandle, Pages[i].DialogID, Parms );
  263.       WinSendMsg ( hwndNotebook, BKM_SETPAGEWINDOWHWND, MPFROMP(PageHandle), MPFROMLONG(Dialog) ) ;
  264.  
  265.       if ( i == 0 )
  266.          WinSendMsg ( WinQueryHelpInstance(hwnd), HM_SET_ACTIVE_WINDOW, MPFROMHWND(Dialog), MPFROMHWND(Dialog) ) ;
  267.  
  268.    } /* endfor */
  269.  
  270.    WinSendMsg ( hwndNotebook, BKM_SETDIMENSIONS,
  271.       MPFROM2SHORT( SHORT(MajorTabWidth+AvgWidth*2), SHORT((AvgHeight*3)/2) ),
  272.       MPFROMSHORT( BKA_MAJORTAB ) ) ;
  273.  
  274.    WinReleasePS ( hPS ) ;
  275.  
  276.   /**************************************************************************
  277.    * Initialize state.                                                      *
  278.    **************************************************************************/
  279.  
  280.    Parms->Ready = TRUE ;
  281.    Parms->MostRecentSelection = -1 ;
  282.  
  283.   /**************************************************************************
  284.    * Return without error.                                                  *
  285.    **************************************************************************/
  286.  
  287.    return ( 0 ) ;
  288. }
  289.  
  290. /****************************************************************************
  291.  *                                                                          *
  292.  *      Process Control Messages                                            *
  293.  *                                                                          *
  294.  ****************************************************************************/
  295.  
  296. static MRESULT APIENTRY Control ( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) {
  297.  
  298.   /**************************************************************************
  299.    * Find the instance data.                                                *
  300.    **************************************************************************/
  301.  
  302. // PCONFIG_PARMS Parms = PCONFIG_PARMS ( Sys_GetWindowData ( hwnd ) ) ;
  303.  
  304.   /**************************************************************************
  305.    * Decode the message.  Find out what control sent it, and what the       *
  306.    *   control had to say.                                                  *
  307.    **************************************************************************/
  308.  
  309.    SHORT Id = SHORT1FROMMP ( mp1 ) ;
  310.    SHORT Message = SHORT2FROMMP ( mp1 ) ;
  311.  
  312.   /**************************************************************************
  313.    * Process notification according to which control sent it.               *
  314.    **************************************************************************/
  315.  
  316.    switch ( Id ) {
  317.  
  318.       case IDD_CONFIG_NOTEBOOK: {
  319.          switch ( Message ) {
  320.             case BKN_PAGESELECTED: {
  321.                PAGESELECTNOTIFY *pInfo = (PAGESELECTNOTIFY*) PVOIDFROMMP(mp2) ;
  322.                HWND Dialog = HWND ( WinSendMsg ( pInfo->hwndBook, BKM_QUERYPAGEWINDOWHWND, MPFROMLONG(pInfo->ulPageIdNew), 0 ) ) ;
  323.                WinSendMsg ( WinQueryHelpInstance(hwnd), HM_SET_ACTIVE_WINDOW, MPFROMHWND(Dialog), MPFROMHWND(Dialog) ) ;
  324.                break ; } /* endcase */
  325.          } /* endswitch */
  326.          break ; } /* endcase */
  327.  
  328.    } /* endswitch */
  329.  
  330.   /**************************************************************************
  331.    * Return no error.                                                       *
  332.    **************************************************************************/
  333.  
  334.    return ( MRFROMSHORT ( FALSE ) ) ;
  335. }
  336.  
  337. /****************************************************************************
  338.  *                                                                          *
  339.  *      Process 'Format Frame' Message                                      *
  340.  *                                                                          *
  341.  ****************************************************************************/
  342.  
  343. static MRESULT APIENTRY FormatFrame ( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) {
  344.  
  345.   /**************************************************************************
  346.    * First let the default dialog processor do its stuff.                   *
  347.    **************************************************************************/
  348.  
  349.    MRESULT Result = WinDefDlgProc ( hwnd, msg, mp1, mp2 ) ;
  350.  
  351.   /**************************************************************************
  352.    * Set the new notebook size, preserving the space for the controls below.*
  353.    **************************************************************************/
  354.  
  355.    SWP DialogPosition ;
  356.    WinQueryWindowPos ( hwnd, &DialogPosition ) ;
  357.  
  358.    SWP NotebookPosition ;
  359.    WinQueryWindowPos ( WinWindowFromID(hwnd,IDD_CONFIG_NOTEBOOK), &NotebookPosition ) ;
  360.  
  361.    LONG cyBorder = WinQuerySysValue ( HWND_DESKTOP, SV_CYSIZEBORDER ) ;
  362.    LONG cyTitle = WinQuerySysValue ( HWND_DESKTOP, SV_CYTITLEBAR ) ;
  363.  
  364.    NotebookPosition.cx = DialogPosition.cx - NotebookPosition.x*2 ;
  365.    NotebookPosition.cy = DialogPosition.cy - NotebookPosition.y - cyBorder*2 - cyTitle ;
  366.  
  367.    WinSetWindowPos ( WinWindowFromID(hwnd,IDD_CONFIG_NOTEBOOK), 
  368.       0, 0, 0, NotebookPosition.cx, NotebookPosition.cy, SWP_SIZE ) ;
  369.  
  370.   /**************************************************************************
  371.    * Return whatever the default said.                                      *
  372.    **************************************************************************/
  373.  
  374.    return ( Result ) ;
  375. }
  376.  
  377. /****************************************************************************
  378.  *                                                                          *
  379.  *      Process 'Update Drives' Message                                     *
  380.  *                                                                          *
  381.  ****************************************************************************/
  382.  
  383. static MRESULT APIENTRY UpdateDrives ( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) {
  384.  
  385.   /**************************************************************************
  386.    * Update the item list.                                                  *
  387.    **************************************************************************/
  388.  
  389.    HWND Notebook = WinWindowFromID ( hwnd, IDD_CONFIG_NOTEBOOK ) ;
  390.    ULONG ItemsID = LONGFROMMR ( WinSendMsg ( Notebook, BKM_QUERYPAGEID, 0, MPFROM2SHORT(BKA_FIRST,BKA_MAJOR) ) ) ;
  391.    HWND ItemsPage = HWND ( WinSendMsg ( Notebook, BKM_QUERYPAGEWINDOWHWND, MPFROMLONG(ItemsID), 0 ) ) ;
  392.  
  393.    WinSendMsg ( ItemsPage, msg, mp1, mp2 ) ;
  394.  
  395.   /**************************************************************************
  396.    * Return success.                                                        *
  397.    **************************************************************************/
  398.  
  399.    return ( 0 ) ;
  400. }
  401.  
  402. /****************************************************************************
  403.  *                                                                          *
  404.  *  Configuration Items Page message processor                              *
  405.  *                                                                          *
  406.  ****************************************************************************/
  407.  
  408. static MRESULT EXPENTRY Configure_Items_Processor ( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) {
  409.  
  410.    #ifdef DEBUG
  411.       static int Indent = 0 ;
  412.       Log ( "%*sItemsPage: Message %08X received.  Parm1=%08X, Parm2=%08X.", Indent, "", msg, mp1, mp2 ) ;
  413.       Indent += 2 ;
  414.    #endif
  415.  
  416.    switch ( msg ) {
  417.  
  418.       case WM_INITDLG: {
  419.          PCONFIG_PARMS Parms = PCONFIG_PARMS ( PVOIDFROMMP ( mp2 ) ) ;
  420.          WinSetWindowPtr ( hwnd, QWL_USER, Parms ) ;
  421.          WinAssociateHelpInstance ( WinQueryHelpInstance(Parms->MainWindow), hwnd ) ;
  422.          for ( int i=0; i<Parms->ItemCount; i++ ) {
  423.             char Label [164] ;
  424.             strcpy ( Label, Parms->CurrentLabels[i] ) ;
  425.             if ( strcmp ( Parms->DefaultLabels[i], Parms->CurrentLabels[i] ) ) {
  426.                strcat ( Label, " (" ) ;
  427.                strcat ( Label, Parms->DefaultLabels[i] ) ;
  428.                strcat ( Label, ")" ) ;
  429.             } /* endif */
  430.             WinSendDlgItemMsg ( hwnd, IDD_CONFIG_ITEMS, LM_INSERTITEM,
  431.                MPFROMSHORT(LIT_END), MPFROMP(Label) ) ;
  432.             if ( Parms->ItemFlags[i] )
  433.                WinSendDlgItemMsg ( hwnd, IDD_CONFIG_ITEMS, LM_SELECTITEM, MPFROMSHORT(i), MPFROMSHORT(TRUE) ) ;
  434.          } /* endfor */
  435.          break; }
  436.  
  437.       case WM_CONTROL: {
  438.          PCONFIG_PARMS Parms = PCONFIG_PARMS ( WinQueryWindowPtr ( hwnd, QWL_USER ) ) ;
  439.          SHORT Id = SHORT1FROMMP ( mp1 ) ;
  440.          SHORT Message = SHORT2FROMMP ( mp1 ) ;
  441.          switch ( Id ) {
  442.             case IDD_CONFIG_ITEMS: {
  443.                switch ( Message ) {
  444.                   case LN_SELECT: {
  445.                      if ( NOT Parms->Ready )
  446.                         break ;
  447.                      SHORT Selection = LIT_FIRST ;
  448.                      SHORT Last = -1 ;
  449.                      do {
  450.                         Selection = short ( SHORT1FROMMR ( WinSendDlgItemMsg ( hwnd,
  451.                            IDD_CONFIG_ITEMS, LM_QUERYSELECTION,
  452.                            MPFROMSHORT(SHORT(Selection)), 0 ) ) ) ;
  453.                         if ( Selection != LIT_NONE ) {
  454.                            for ( Last++; Last<Selection; Last++ ) {
  455.                               if ( Parms->ItemFlags[Last] ) {
  456.                                  Parms->ItemFlags[Last] = FALSE ;
  457.                                  Parms->MostRecentSelection = Last ;
  458.                               } /* endif */
  459.                            } /* endfor */
  460.                            if ( Parms->ItemFlags[Selection] == FALSE ) {
  461.                               Parms->ItemFlags[Selection] = TRUE ;
  462.                               Parms->MostRecentSelection = Selection ;
  463.                            } /* endif */
  464.                         } else {
  465.                            for ( Last++; Last<Parms->ItemCount; Last++ ) {
  466.                               if ( Parms->ItemFlags[Last] ) {
  467.                                  Parms->ItemFlags[Last] = FALSE ;
  468.                                  Parms->MostRecentSelection = Last ;
  469.                               } /* endif */
  470.                            } /* endfor */
  471.                         } /* endif */
  472.                      } while ( Selection != LIT_NONE ) ;
  473.                      WinSendMsg ( Parms->MainWindow, WM_UPDATEPARMS, MPFROMP(Parms), 0 ) ;
  474.                      break ;
  475.                   } /* endcase */
  476.                   case LN_ENTER: {
  477.                      if ( Parms->MostRecentSelection == -1 ) 
  478.                         break ;
  479.                      LABEL_PARMS LabelParms ;
  480.                      strcpy ( LabelParms.DefaultLabel, Parms->DefaultLabels[Parms->MostRecentSelection] ) ;
  481.                      strcpy ( LabelParms.CurrentLabel, Parms->CurrentLabels[Parms->MostRecentSelection] ) ;
  482.                      LabelParms.DefaultLevels [0] = Parms->DefaultLevels[Parms->MostRecentSelection] [0] ;
  483.                      LabelParms.DefaultLevels [1] = Parms->DefaultLevels[Parms->MostRecentSelection] [1] ;
  484.                      LabelParms.WarningLevel = Parms->WarningLevel[Parms->MostRecentSelection] ;
  485.                      LabelParms.ErrorLevel = Parms->ErrorLevel[Parms->MostRecentSelection] ;
  486.                      LabelParms.LevelSense = Parms->LevelSense[Parms->MostRecentSelection] ;
  487.                      LabelParms.MinLevel = Parms->MinLevel[Parms->MostRecentSelection] ;
  488.                      LabelParms.MaxLevel = Parms->MaxLevel[Parms->MostRecentSelection] ;
  489.                      LabelParms.ShowTrueK = Parms->ShowTrueK ;
  490.                      LabelParms.Warning = 0 ;
  491.                      LabelParms.Error = 0 ;
  492.                      if ( WinDlgBox ( HWND_DESKTOP, hwnd, Label_Processor, LibraryHandle, IDD_LABEL, &LabelParms ) ) {
  493.                         strcpy ( Parms->CurrentLabels[Parms->MostRecentSelection], LabelParms.CurrentLabel ) ;
  494.                         char Label [164] ;
  495.                         strcpy ( Label, Parms->CurrentLabels[Parms->MostRecentSelection] ) ;
  496.                         if ( strcmp ( Parms->DefaultLabels[Parms->MostRecentSelection], Parms->CurrentLabels[Parms->MostRecentSelection] ) ) {
  497.                            strcat ( Label, " (" ) ;
  498.                            strcat ( Label, Parms->DefaultLabels[Parms->MostRecentSelection] ) ;
  499.                            strcat ( Label, ")" ) ;
  500.                         } /* endif */
  501.                         Parms->WarningLevel[Parms->MostRecentSelection] = LabelParms.WarningLevel ;
  502.                         Parms->ErrorLevel[Parms->MostRecentSelection] = LabelParms.ErrorLevel ;
  503.                         WinSendDlgItemMsg ( hwnd, IDD_CONFIG_ITEMS, LM_DELETEITEM,
  504.                            MPFROMSHORT(Parms->MostRecentSelection), 0 ) ;
  505.                         WinSendDlgItemMsg ( hwnd, IDD_CONFIG_ITEMS, LM_INSERTITEM,
  506.                            MPFROMSHORT(Parms->MostRecentSelection), MPFROMP(Label) ) ;
  507.                         WinSendDlgItemMsg ( hwnd, IDD_CONFIG_ITEMS, LM_SELECTITEM,
  508.                            MPFROMSHORT(Parms->MostRecentSelection), MPFROMSHORT(TRUE) ) ;
  509.                         WinSendMsg ( Parms->MainWindow, WM_UPDATEPARMS, MPFROMP(Parms), 0 ) ;
  510.                      } /* endif */
  511.                      break ;
  512.                   } /* endcase */
  513.                } /* endswitch */
  514.                break; }
  515.          } /* endswitch */
  516.          break; }
  517.  
  518.       case WM_COMMAND: {
  519.          #ifdef DEBUG
  520.             Indent -= 2 ;
  521.             Log ( "%*sItemsPage: Message %08X done.  Result %08X.", Indent, "", msg, 0 ) ;
  522.          #endif
  523.          return ( 0 ) ; }
  524.  
  525.       case WM_UPDATEDRIVES: {
  526.          PCONFIG_PARMS Parms = PCONFIG_PARMS ( WinQueryWindowPtr ( hwnd, QWL_USER ) ) ;
  527.          Parms->Ready = FALSE ;
  528.          PINIDATA IniData = PINIDATA ( PVOIDFROMMP ( mp1 ) ) ;
  529.          WinSendDlgItemMsg ( hwnd, IDD_CONFIG_ITEMS, LM_DELETEALL, 0, 0 ) ;
  530.          Parms->ItemCount = IniData->ItemCount ;
  531.          for ( int i=0; i<IniData->ItemCount; i++ ) {
  532.             Item *pItem = IniData->Items[i] ;
  533.             Parms->ItemFlags[i] = pItem->QueryFlag () ;
  534.             strcpy ( Parms->CurrentLabels[i], PCHAR(pItem->QueryCurrentLabel()) ) ;
  535.             strcpy ( Parms->DefaultLabels[i], PCHAR(pItem->QueryDefaultLabel()) ) ;
  536.             pItem->QueryDefaultLevels ( Parms->DefaultLevels[i][0], Parms->DefaultLevels[i][1] ) ;
  537.             Parms->WarningLevel[i] = pItem->QueryWarningLevel() ;
  538.             Parms->ErrorLevel[i] = pItem->QueryErrorLevel() ;
  539.             Parms->LevelSense[i] = pItem->QueryLevelSense() ;
  540.             Parms->MinLevel[i] = pItem->QueryMinLevel() ;
  541.             Parms->MaxLevel[i] = pItem->QueryMaxLevel() ;
  542.          } /* endfor */
  543.          for ( i=0; i<Parms->ItemCount; i++ ) {
  544.             char Label [164] ;
  545.             strcpy ( Label, Parms->CurrentLabels[i] ) ;
  546.             if ( strcmp ( Parms->DefaultLabels[i], Parms->CurrentLabels[i] ) ) {
  547.                strcat ( Label, " (" ) ;
  548.                strcat ( Label, Parms->DefaultLabels[i] ) ;
  549.                strcat ( Label, ")" ) ;
  550.             } /* endif */
  551.             WinSendDlgItemMsg ( hwnd, IDD_CONFIG_ITEMS, LM_INSERTITEM,
  552.                MPFROMSHORT(LIT_END), MPFROMP(Label) ) ;
  553.             if ( Parms->ItemFlags[i] )
  554.                WinSendDlgItemMsg ( hwnd, IDD_CONFIG_ITEMS, LM_SELECTITEM, MPFROMSHORT(i), MPFROMSHORT(TRUE) ) ;
  555.          } /* endfor */
  556.          Parms->Ready = TRUE ;
  557.          #ifdef DEBUG
  558.             Indent -= 2 ;
  559.             Log ( "%*sItemsPage: Message %08X done.  Result %08X.", Indent, "", msg, 0 ) ;
  560.          #endif
  561.          return ( 0 ) ; }
  562.  
  563.    } /* endswitch */
  564.  
  565.    MRESULT Result = WinDefDlgProc ( hwnd, msg, mp1, mp2 ) ;
  566.  
  567.    #ifdef DEBUG
  568.       Indent -= 2 ;
  569.       Log ( "%*sItemsPage: Message %08X done.  Result %08X.", Indent, "", msg, Result ) ;
  570.    #endif
  571.  
  572.    return ( Result ) ;
  573. }
  574.  
  575. /****************************************************************************
  576.  *                                                                          *
  577.  *  Configuration Options Page 1 message processor                          *
  578.  *                                                                          *
  579.  ****************************************************************************/
  580.  
  581. static MRESULT EXPENTRY Configure_Options1_Processor ( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) {
  582.  
  583.    #ifdef DEBUG
  584.       static int Indent = 0 ;
  585.       Log ( "%*sOptions1Page: Message %08X received.  Parm1=%08X, Parm2=%08X.", Indent, "", msg, mp1, mp2 ) ;
  586.       Indent += 2 ;
  587.    #endif
  588.  
  589.    switch ( msg ) {
  590.  
  591.       case WM_INITDLG: {
  592.          PCONFIG_PARMS Parms = PCONFIG_PARMS ( PVOIDFROMMP ( mp2 ) ) ;
  593.          WinSetWindowPtr ( hwnd, QWL_USER, Parms ) ;
  594.          WinAssociateHelpInstance ( WinQueryHelpInstance(Parms->MainWindow), hwnd ) ;
  595.          WinSendDlgItemMsg ( hwnd, IDD_CONFIG_HIDECONTROLS,
  596.             BM_SETCHECK, MPFROMSHORT(Parms->HideControls), 0 ) ;
  597.          WinSendDlgItemMsg ( hwnd, IDD_CONFIG_FLOAT,
  598.             BM_SETCHECK, MPFROMSHORT(Parms->Float), 0 ) ;
  599.          WinSendDlgItemMsg ( hwnd, IDD_CONFIG_ANIMATE,
  600.             BM_SETCHECK, MPFROMSHORT(Parms->Animate), 0 ) ;
  601.          WinSendDlgItemMsg ( hwnd, IDD_CONFIG_TABLE,
  602.             BM_SETCHECK, MPFROMSHORT(Parms->TableFormat), 0 ) ;
  603.          WinSendDlgItemMsg ( hwnd, IDD_CONFIG_CHIME,
  604.             BM_SETCHECK, MPFROMSHORT(Parms->Chime), 0 ) ;
  605.          WinSendDlgItemMsg ( hwnd, IDD_CONFIG_SHOWREMOTES,
  606.             BM_SETCHECK, MPFROMSHORT(Parms->ShowRemoteDrives), 0 ) ;
  607.          WinSendDlgItemMsg ( hwnd, IDD_CONFIG_FSNAME,
  608.             BM_SETCHECK, MPFROMSHORT(Parms->ShowFileSystemNames), 0 ) ;
  609.          WinSendDlgItemMsg ( hwnd, IDD_CONFIG_DLABEL,
  610.             BM_SETCHECK, MPFROMSHORT(Parms->ShowDiskLabels), 0 ) ;
  611.          WinSendDlgItemMsg ( hwnd, IDD_CONFIG_SECONDS,
  612.             BM_SETCHECK, MPFROMSHORT(Parms->ShowSeconds), 0 ) ;
  613.          WinSendDlgItemMsg ( hwnd, IDD_CONFIG_HOUR24,
  614.             BM_SETCHECK, MPFROMSHORT(Parms->Hour24), 0 ) ;
  615.          break; }
  616.  
  617.       case WM_CONTROL: {
  618.          PCONFIG_PARMS Parms = PCONFIG_PARMS ( WinQueryWindowPtr ( hwnd, QWL_USER ) ) ;
  619.          SHORT Id = SHORT1FROMMP ( mp1 ) ;
  620.          SHORT Message = SHORT2FROMMP ( mp1 ) ;
  621.          switch ( Id ) {
  622.             case IDD_CONFIG_HIDECONTROLS: {
  623.                if ( Message == BN_CLICKED ) {
  624.                   Parms->HideControls = (BOOL) SHORT1FROMMR ( WinSendDlgItemMsg ( hwnd, Id, BM_QUERYCHECK, 0, 0 ) ) ;
  625.                   WinSendMsg ( Parms->MainWindow, WM_UPDATEPARMS, MPFROMP(Parms), 0 ) ;
  626.                } /* endif */
  627.                break; }
  628.             case IDD_CONFIG_FLOAT: {
  629.                if ( Message == BN_CLICKED ) {
  630.                   Parms->Float = (BOOL) SHORT1FROMMR ( WinSendDlgItemMsg ( hwnd, Id, BM_QUERYCHECK, 0, 0 ) ) ;
  631.                   WinSendMsg ( Parms->MainWindow, WM_UPDATEPARMS, MPFROMP(Parms), 0 ) ;
  632.                } /* endif */
  633.                break; }
  634.             case IDD_CONFIG_ANIMATE: {
  635.                if ( Message == BN_CLICKED ) {
  636.                   Parms->Animate = (BOOL) SHORT1FROMMR ( WinSendDlgItemMsg ( hwnd, Id, BM_QUERYCHECK, 0, 0 ) ) ;
  637.                   WinSendMsg ( Parms->MainWindow, WM_UPDATEPARMS, MPFROMP(Parms), 0 ) ;
  638.                } /* endif */
  639.                break; }
  640.             case IDD_CONFIG_TABLE: {
  641.                if ( Message == BN_CLICKED ) {
  642.                   Parms->TableFormat = (BOOL) SHORT1FROMMR ( WinSendDlgItemMsg ( hwnd, Id, BM_QUERYCHECK, 0, 0 ) ) ;
  643.                   WinSendMsg ( Parms->MainWindow, WM_UPDATEPARMS, MPFROMP(Parms), 0 ) ;
  644.                } /* endif */
  645.                break; }
  646.             case IDD_CONFIG_CHIME: {
  647.                if ( Message == BN_CLICKED ) {
  648.                   Parms->Chime = (BOOL) SHORT1FROMMR ( WinSendDlgItemMsg ( hwnd, Id, BM_QUERYCHECK, 0, 0 ) ) ;
  649.                   WinSendMsg ( Parms->MainWindow, WM_UPDATEPARMS, MPFROMP(Parms), 0 ) ;
  650.                } /* endif */
  651.                break; }
  652.             case IDD_CONFIG_SHOWREMOTES: {
  653.                if ( Message == BN_CLICKED ) {
  654.                   Parms->ShowRemoteDrives = (BOOL) SHORT1FROMMR ( WinSendDlgItemMsg ( hwnd, Id, BM_QUERYCHECK, 0, 0 ) ) ;
  655.                   WinSendMsg ( Parms->MainWindow, WM_UPDATEPARMS, MPFROMP(Parms), 0 ) ;
  656.                } /* endif */
  657.                break; }
  658.             case IDD_CONFIG_FSNAME: {
  659.                if ( Message == BN_CLICKED ) {
  660.                   Parms->ShowFileSystemNames = (BOOL) SHORT1FROMMR ( WinSendDlgItemMsg ( hwnd, Id, BM_QUERYCHECK, 0, 0 ) ) ;
  661.                   WinSendMsg ( Parms->MainWindow, WM_UPDATEPARMS, MPFROMP(Parms), 0 ) ;
  662.                } /* endif */
  663.                break; }
  664.             case IDD_CONFIG_DLABEL: {
  665.                if ( Message == BN_CLICKED ) {
  666.                   Parms->ShowDiskLabels = (BOOL) SHORT1FROMMR ( WinSendDlgItemMsg ( hwnd,
  667.                      IDD_CONFIG_DLABEL, BM_QUERYCHECK, 0, 0 ) ) ;
  668.                   WinSendMsg ( Parms->MainWindow, WM_UPDATEPARMS, MPFROMP(Parms), 0 ) ;
  669.                } /* endif */
  670.                break; }
  671.             case IDD_CONFIG_SECONDS: {
  672.                if ( Message == BN_CLICKED ) {
  673.                   Parms->ShowSeconds = (BOOL) SHORT1FROMMR ( WinSendDlgItemMsg ( hwnd, Id, BM_QUERYCHECK, 0, 0 ) ) ;
  674.                   WinSendMsg ( Parms->MainWindow, WM_UPDATEPARMS, MPFROMP(Parms), 0 ) ;
  675.                } /* endif */
  676.                break; }
  677.             case IDD_CONFIG_HOUR24: {
  678.                if ( Message == BN_CLICKED ) {
  679.                   Parms->Hour24 = (BOOL) SHORT1FROMMR ( WinSendDlgItemMsg ( hwnd, Id, BM_QUERYCHECK, 0, 0 ) ) ;
  680.                   WinSendMsg ( Parms->MainWindow, WM_UPDATEPARMS, MPFROMP(Parms), 0 ) ;
  681.                } /* endif */
  682.                break; }
  683.          } /* endswitch */
  684.          break; }
  685.  
  686.       case WM_COMMAND: {
  687.          #ifdef DEBUG
  688.             Indent -= 2 ;
  689.             Log ( "%*sOptions1Page: Message %08X done.  Result %08X.", Indent, "", msg, 0 ) ;
  690.          #endif
  691.          return ( 0 ) ; }
  692.  
  693.    } /* endswitch */
  694.  
  695.    MRESULT Result = WinDefDlgProc ( hwnd, msg, mp1, mp2 ) ;
  696.  
  697.    #ifdef DEBUG
  698.       Indent -= 2 ;
  699.       Log ( "%*sOptions1Page: Message %08X done.  Result %08X.", Indent, "", msg, Result ) ;
  700.    #endif
  701.  
  702.    return ( Result ) ;
  703. }
  704.  
  705. /****************************************************************************
  706.  *                                                                          *
  707.  *  Configuration Options Page 2 message processor                          *
  708.  *                                                                          *
  709.  ****************************************************************************/
  710.  
  711. static MRESULT EXPENTRY Configure_Options2_Processor ( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) {
  712.  
  713.    #ifdef DEBUG
  714.       static int Indent = 0 ;
  715.       Log ( "%*sOptions2Page: Message %08X received.  Parm1=%08X, Parm2=%08X.", Indent, "", msg, mp1, mp2 ) ;
  716.       Indent += 2 ;
  717.    #endif
  718.  
  719.    switch ( msg ) {
  720.  
  721.       case WM_INITDLG: {
  722.          PCONFIG_PARMS Parms = PCONFIG_PARMS ( PVOIDFROMMP ( mp2 ) ) ;
  723.          WinSetWindowPtr ( hwnd, QWL_USER, Parms ) ;
  724.          WinAssociateHelpInstance ( WinQueryHelpInstance(Parms->MainWindow), hwnd ) ;
  725.          switch ( Parms->ShowK ) {
  726.             case SHOWK_NEVER:
  727.                WinSendDlgItemMsg ( hwnd, IDD_CONFIG_SHOWK_NEVER, BM_SETCHECK, MPFROMSHORT(TRUE), 0 ) ;
  728.                break;
  729.             case SHOWK_ALWAYS:
  730.                WinSendDlgItemMsg ( hwnd, IDD_CONFIG_SHOWK_ALWAYS, BM_SETCHECK, MPFROMSHORT(TRUE), 0 ) ;
  731.                break;
  732.             case SHOWK_ABOVE512:
  733.             default:
  734.                WinSendDlgItemMsg ( hwnd, IDD_CONFIG_SHOWK_ABOVE512, BM_SETCHECK, MPFROMSHORT(TRUE), 0 ) ;
  735.                break;
  736.          } /* endswitch */
  737.          WinSendDlgItemMsg ( hwnd, IDD_CONFIG_SHOW_TRUEK,
  738.             BM_SETCHECK, MPFROMSHORT(Parms->ShowTrueK), 0 ) ;
  739.          WinSendDlgItemMsg ( hwnd, IDD_CONFIG_SHOW_MEGABYTES,
  740.             BM_SETCHECK, MPFROMSHORT(Parms->ShowM), 0 ) ;
  741.          WinSendDlgItemMsg ( hwnd, IDD_CONFIG_PRIORITY,
  742.             SPBM_SETLIMITS, (MPARAM)PRTYD_MAXIMUM, (MPARAM)0 ) ;
  743.          WinSendDlgItemMsg ( hwnd, IDD_CONFIG_PRIORITY,
  744.             SPBM_SETCURRENTVALUE, (MPARAM)(Parms->MonitorPriority), NULL ) ;
  745.          WinSendDlgItemMsg ( hwnd, IDD_CONFIG_TIMER,
  746.             SPBM_SETLIMITS, (MPARAM)300, (MPARAM)10 ) ;
  747.          WinSendDlgItemMsg ( hwnd, IDD_CONFIG_TIMER,
  748.             SPBM_SETCURRENTVALUE, (MPARAM)(Parms->TimerInterval/100), NULL ) ;
  749.          break; }
  750.  
  751.       case WM_CONTROL: {
  752.          PCONFIG_PARMS Parms = PCONFIG_PARMS ( WinQueryWindowPtr ( hwnd, QWL_USER ) ) ;
  753.          SHORT Id = SHORT1FROMMP ( mp1 ) ;
  754.          SHORT Message = SHORT2FROMMP ( mp1 ) ;
  755.          switch ( Id ) {
  756.             case IDD_CONFIG_SHOWK_NEVER: {
  757.                if ( Message == BN_CLICKED ) {
  758.                   Parms->ShowK = SHOWK_NEVER ;
  759.                   WinSendMsg ( Parms->MainWindow, WM_UPDATEPARMS, MPFROMP(Parms), 0 ) ;
  760.                } /* endif */
  761.                break; }
  762.             case IDD_CONFIG_SHOWK_ABOVE512: {
  763.                if ( Message == BN_CLICKED ) {
  764.                   Parms->ShowK = SHOWK_ABOVE512 ;
  765.                   WinSendMsg ( Parms->MainWindow, WM_UPDATEPARMS, MPFROMP(Parms), 0 ) ;
  766.                } /* endif */
  767.                break; }
  768.             case IDD_CONFIG_SHOWK_ALWAYS: {
  769.                if ( Message == BN_CLICKED ) {
  770.                   Parms->ShowK = SHOWK_ALWAYS ;
  771.                   WinSendMsg ( Parms->MainWindow, WM_UPDATEPARMS, MPFROMP(Parms), 0 ) ;
  772.                } /* endif */
  773.                break; }
  774.             case IDD_CONFIG_SHOW_TRUEK: {
  775.                if ( Message == BN_CLICKED ) {
  776.                   Parms->ShowTrueK = (USHORT) SHORT1FROMMR ( WinSendDlgItemMsg ( hwnd, Id, BM_QUERYCHECK, 0, 0 ) ) ;
  777.                   WinSendMsg ( Parms->MainWindow, WM_UPDATEPARMS, MPFROMP(Parms), 0 ) ;
  778.                } /* endif */
  779.                break; }
  780.             case IDD_CONFIG_SHOW_MEGABYTES: {
  781.                if ( Message == BN_CLICKED ) {
  782.                   Parms->ShowM = (USHORT) SHORT1FROMMR ( WinSendDlgItemMsg ( hwnd, Id, BM_QUERYCHECK, 0, 0 ) ) ;
  783.                   WinSendMsg ( Parms->MainWindow, WM_UPDATEPARMS, MPFROMP(Parms), 0 ) ;
  784.                } /* endif */
  785.                break; }
  786.             case IDD_CONFIG_PRIORITY: {
  787.                if ( Message == SPBN_CHANGE ) {
  788.                   WinSendDlgItemMsg ( hwnd, Id, SPBM_QUERYVALUE, &Parms->MonitorPriority, MPFROM2SHORT(0,SPBQ_UPDATEIFVALID) ) ;
  789.                   WinSendMsg ( Parms->MainWindow, WM_UPDATEPARMS, MPFROMP(Parms), 0 ) ;
  790.                } /* endif */
  791.                break; }
  792.             case IDD_CONFIG_TIMER: {
  793.                if ( Message == SPBN_CHANGE ) {
  794.                   WinSendDlgItemMsg ( hwnd, Id, SPBM_QUERYVALUE, &Parms->TimerInterval, MPFROM2SHORT(0,SPBQ_UPDATEIFVALID) ) ;
  795.                   Parms->TimerInterval *= 100 ;
  796.                   WinSendMsg ( Parms->MainWindow, WM_UPDATEPARMS, MPFROMP(Parms), 0 ) ;
  797.                } /* endif */
  798.                break; }
  799.          } /* endswitch */
  800.          break; }
  801.  
  802.       case WM_COMMAND: {
  803.          #ifdef DEBUG
  804.             Indent -= 2 ;
  805.             Log ( "%*sOptions2Page: Message %08X done.  Result %08X.", Indent, "", msg, 0 ) ;
  806.          #endif
  807.          return ( 0 ) ; }
  808.  
  809.    } /* endswitch */
  810.  
  811.    MRESULT Result = WinDefDlgProc ( hwnd, msg, mp1, mp2 ) ;
  812.  
  813.    #ifdef DEBUG
  814.       Indent -= 2 ;
  815.       Log ( "%*sOptions2Page: Message %08X done.  Result %08X.", Indent, "", msg, Result ) ;
  816.    #endif
  817.  
  818.    return ( Result ) ;
  819. }
  820.  
  821. /****************************************************************************
  822.  *                                                                          *
  823.  *  Configuration Colors Page message processor                             *
  824.  *                                                                          *
  825.  ****************************************************************************/
  826.  
  827. static MRESULT EXPENTRY Configure_Colors_Processor ( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) {
  828.  
  829.    #ifdef DEBUG
  830.       static int Indent = 0 ;
  831.       Log ( "%*sColorsPage: Message %08X received.  Parm1=%08X, Parm2=%08X.", Indent, "", msg, mp1, mp2 ) ;
  832.       Indent += 2 ;
  833.    #endif
  834.  
  835.    switch ( msg ) {
  836.  
  837.       case WM_INITDLG: {
  838.          PCONFIG_PARMS Parms = PCONFIG_PARMS ( PVOIDFROMMP ( mp2 ) ) ;
  839.          WinSetWindowPtr ( hwnd, QWL_USER, Parms ) ;
  840.          WinAssociateHelpInstance ( WinQueryHelpInstance(Parms->MainWindow), hwnd ) ;
  841.          WinSetPresParam ( WinWindowFromID(hwnd,IDD_CONFIG_NORMAL), 
  842.             PP_BACKGROUNDCOLOR, sizeof(Parms->NormalBackground), MPFROMP(&Parms->NormalBackground) ) ;
  843.          WinSetPresParam ( WinWindowFromID(hwnd,IDD_CONFIG_NORMAL), 
  844.             PP_FOREGROUNDCOLOR, sizeof(Parms->NormalForeground), MPFROMP(&Parms->NormalForeground) ) ;
  845.          OldStaticProcessor = WinSubclassWindow ( WinWindowFromID(hwnd,IDD_CONFIG_NORMAL), Static_Processor ) ;
  846.          WinSetPresParam ( WinWindowFromID(hwnd,IDD_CONFIG_WARNING), 
  847.             PP_BACKGROUNDCOLOR, sizeof(Parms->WarningBackground), MPFROMP(&Parms->WarningBackground) ) ;
  848.          WinSetPresParam ( WinWindowFromID(hwnd,IDD_CONFIG_WARNING), 
  849.             PP_FOREGROUNDCOLOR, sizeof(Parms->WarningForeground), MPFROMP(&Parms->WarningForeground) ) ;
  850.          WinSubclassWindow ( WinWindowFromID(hwnd,IDD_CONFIG_WARNING), Static_Processor ) ;
  851.          WinSetPresParam ( WinWindowFromID(hwnd,IDD_CONFIG_ERROR), 
  852.             PP_BACKGROUNDCOLOR, sizeof(Parms->ErrorBackground), MPFROMP(&Parms->ErrorBackground) ) ;
  853.          WinSetPresParam ( WinWindowFromID(hwnd,IDD_CONFIG_ERROR), 
  854.             PP_FOREGROUNDCOLOR, sizeof(Parms->ErrorForeground), MPFROMP(&Parms->ErrorForeground) ) ;
  855.          WinSubclassWindow ( WinWindowFromID(hwnd,IDD_CONFIG_ERROR), Static_Processor ) ;
  856.          break; }
  857.  
  858.       case WM_CONTROL: {
  859.          PCONFIG_PARMS Parms = PCONFIG_PARMS ( WinQueryWindowPtr ( hwnd, QWL_USER ) ) ;
  860.          SHORT Id = SHORT1FROMMP ( mp1 ) ;
  861.          switch ( Id ) {
  862.             case IDD_CONFIG_NORMAL: {
  863.                ULONG ppid ;
  864.                WinQueryPresParam ( WinWindowFromID(hwnd,IDD_CONFIG_NORMAL), PP_BACKGROUNDCOLOR, 0, &ppid,
  865.                   sizeof(Parms->NormalBackground), &Parms->NormalBackground, 0 ) ;
  866.                WinQueryPresParam ( WinWindowFromID(hwnd,IDD_CONFIG_NORMAL), PP_FOREGROUNDCOLOR, 0, &ppid,
  867.                   sizeof(Parms->NormalForeground), &Parms->NormalForeground, 0 ) ;
  868.                WinSendMsg ( Parms->MainWindow, WM_UPDATEPARMS, MPFROMP(Parms), 0 ) ;
  869.                break; }
  870.             case IDD_CONFIG_WARNING: {
  871.                ULONG ppid ;
  872.                WinQueryPresParam ( WinWindowFromID(hwnd,IDD_CONFIG_WARNING), PP_BACKGROUNDCOLOR, 0, &ppid,
  873.                   sizeof(Parms->NormalBackground), &Parms->WarningBackground, 0 ) ;
  874.                WinQueryPresParam ( WinWindowFromID(hwnd,IDD_CONFIG_WARNING), PP_FOREGROUNDCOLOR, 0, &ppid,
  875.                   sizeof(Parms->NormalForeground), &Parms->WarningForeground, 0 ) ;
  876.                WinSendMsg ( Parms->MainWindow, WM_UPDATEPARMS, MPFROMP(Parms), 0 ) ;
  877.                break; }
  878.             case IDD_CONFIG_ERROR: {
  879.                ULONG ppid ;
  880.                WinQueryPresParam ( WinWindowFromID(hwnd,IDD_CONFIG_ERROR), PP_BACKGROUNDCOLOR, 0, &ppid,
  881.                   sizeof(Parms->NormalBackground), &Parms->ErrorBackground, 0 ) ;
  882.                WinQueryPresParam ( WinWindowFromID(hwnd,IDD_CONFIG_ERROR), PP_FOREGROUNDCOLOR, 0, &ppid,
  883.                   sizeof(Parms->NormalForeground), &Parms->ErrorForeground, 0 ) ;
  884.                WinSendMsg ( Parms->MainWindow, WM_UPDATEPARMS, MPFROMP(Parms), 0 ) ;
  885.                break; }
  886.          } /* endswitch */
  887.          break; }
  888.  
  889.       case WM_COMMAND: {
  890.          #ifdef DEBUG
  891.             Indent -= 2 ;
  892.             Log ( "%*sColorsPage: Message %08X done.  Result %08X.", Indent, "", msg, 0 ) ;
  893.          #endif
  894.          return ( 0 ) ; }
  895.  
  896.    } /* endswitch */
  897.  
  898.    MRESULT Result = WinDefDlgProc ( hwnd, msg, mp1, mp2 ) ;
  899.  
  900.    #ifdef DEBUG
  901.       Indent -= 2 ;
  902.       Log ( "%*sColorsPage: Message %08X done.  Result %08X.", Indent, "", msg, Result ) ;
  903.    #endif
  904.  
  905.    return ( Result ) ;
  906. }
  907.  
  908. /****************************************************************************
  909.  *                                                                          *
  910.  *  Configuration Anchor Page message processor                             *
  911.  *                                                                          *
  912.  ****************************************************************************/
  913.  
  914. static MRESULT EXPENTRY Configure_Anchor_Processor ( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) {
  915.  
  916.    #ifdef DEBUG
  917.       static int Indent = 0 ;
  918.       Log ( "%*sAnchorPage: Message %08X received.  Parm1=%08X, Parm2=%08X.", Indent, "", msg, mp1, mp2 ) ;
  919.       Indent += 2 ;
  920.    #endif
  921.  
  922.    switch ( msg ) {
  923.  
  924.       case WM_INITDLG: {
  925.          PCONFIG_PARMS Parms = PCONFIG_PARMS ( PVOIDFROMMP ( mp2 ) ) ;
  926.          WinSetWindowPtr ( hwnd, QWL_USER, Parms ) ;
  927.          WinAssociateHelpInstance ( WinQueryHelpInstance(Parms->MainWindow), hwnd ) ;
  928.          switch ( Parms->AnchorCorner ) {
  929.             case CORNER_BL:
  930.             default:
  931.                WinSendDlgItemMsg ( hwnd, IDD_CONFIG_BL, BM_SETCHECK, MPFROMSHORT(TRUE), 0 ) ;
  932.                break;
  933.             case CORNER_BR:
  934.                WinSendDlgItemMsg ( hwnd, IDD_CONFIG_BR, BM_SETCHECK, MPFROMSHORT(TRUE), 0 ) ;
  935.                break;
  936.             case CORNER_TL:
  937.                WinSendDlgItemMsg ( hwnd, IDD_CONFIG_TL, BM_SETCHECK, MPFROMSHORT(TRUE), 0 ) ;
  938.                break;
  939.             case CORNER_TR:
  940.                WinSendDlgItemMsg ( hwnd, IDD_CONFIG_TR, BM_SETCHECK, MPFROMSHORT(TRUE), 0 ) ;
  941.                break;
  942.          } /* endswitch */
  943.          break; }
  944.  
  945.       case WM_CONTROL: {
  946.          PCONFIG_PARMS Parms = PCONFIG_PARMS ( WinQueryWindowPtr ( hwnd, QWL_USER ) ) ;
  947.          SHORT Id = SHORT1FROMMP ( mp1 ) ;
  948.          SHORT Message = SHORT2FROMMP ( mp1 ) ;
  949.          switch ( Id ) {
  950.             case IDD_CONFIG_BL: {
  951.                if ( Message == BN_CLICKED ) {
  952.                   Parms->AnchorCorner = CORNER_BL ;
  953.                   WinSendMsg ( Parms->MainWindow, WM_UPDATEPARMS, MPFROMP(Parms), 0 ) ;
  954.                } /* endif */
  955.                break ; } /* endcase */
  956.             case IDD_CONFIG_BR: {
  957.                if ( Message == BN_CLICKED ) {
  958.                   Parms->AnchorCorner = CORNER_BR ;
  959.                   WinSendMsg ( Parms->MainWindow, WM_UPDATEPARMS, MPFROMP(Parms), 0 ) ;
  960.                } /* endif */
  961.                break ; } /* endcase */
  962.             case IDD_CONFIG_TL: {
  963.                if ( Message == BN_CLICKED ) {
  964.                   Parms->AnchorCorner = CORNER_TL ;
  965.                   WinSendMsg ( Parms->MainWindow, WM_UPDATEPARMS, MPFROMP(Parms), 0 ) ;
  966.                } /* endif */
  967.                break ; } /* endcase */
  968.             case IDD_CONFIG_TR: {
  969.                if ( Message == BN_CLICKED ) {
  970.                   Parms->AnchorCorner = CORNER_TR ;
  971.                   WinSendMsg ( Parms->MainWindow, WM_UPDATEPARMS, MPFROMP(Parms), 0 ) ;
  972.                } /* endif */
  973.                break ; } /* endcase */
  974.          } /* endswitch */
  975.          break; }
  976.  
  977.       case WM_COMMAND: {
  978.          #ifdef DEBUG
  979.             Indent -= 2 ;
  980.             Log ( "%*sAnchorPage: Message %08X done.  Result %08X.", Indent, "", msg, 0 ) ;
  981.          #endif
  982.          return ( 0 ) ; }
  983.  
  984.    } /* endswitch */
  985.  
  986.    MRESULT Result = WinDefDlgProc ( hwnd, msg, mp1, mp2 ) ;
  987.  
  988.    #ifdef DEBUG
  989.       Indent -= 2 ;
  990.       Log ( "%*sAnchorPage: Message %08X done.  Result %08X.", Indent, "", msg, Result ) ;
  991.    #endif
  992.  
  993.    return ( Result ) ;
  994. }
  995.  
  996. /****************************************************************************
  997.  *                                                                          *
  998.  *      Item Label dialog processor.                                        *
  999.  *                                                                          *
  1000.  ****************************************************************************/
  1001.  
  1002. inline void GetDivisor ( ULONG MaxLevel, USHORT ShowTrueK, int &Divisor, char* &Suffix ) {
  1003.  
  1004.    Divisor = 1 ;  
  1005.    Suffix = "" ;
  1006.  
  1007.    if ( ShowTrueK ) {
  1008.       if ( MaxLevel > 1024*1024 ) {
  1009.          Divisor = 1024*1024 ;
  1010.          Suffix = "M" ;
  1011.       } else if ( MaxLevel > 1024 ) {
  1012.          Divisor = 1024 ;
  1013.          Suffix = "K" ;
  1014.       } /* endif */
  1015.  
  1016.    } else {
  1017.       if ( MaxLevel > 1000*1000 ) {
  1018.          Divisor = 1000*1000 ;
  1019.          Suffix = "m" ;
  1020.       } else if ( MaxLevel > 1000 ) {
  1021.          Divisor = 1000 ;
  1022.          Suffix = "k" ;
  1023.       } /* endif */
  1024.  
  1025.    } /* endif */
  1026. }
  1027.  
  1028. inline char *TrimRight ( char *Text ) {
  1029.    while ( strlen(Text) && Text[strlen(Text)-1] == ' ' ) Text[strlen(Text)-1] = 0 ;
  1030.    return ( Text ) ;
  1031. }
  1032.  
  1033. static MRESULT APIENTRY Label_Processor ( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) {
  1034.  
  1035.    switch ( msg ) {
  1036.  
  1037.       case WM_INITDLG: {
  1038.          PLABEL_PARMS Parms = PLABEL_PARMS ( PVOIDFROMMP ( mp2 ) ) ;
  1039.          WinSetWindowPtr ( hwnd, QWL_USER, Parms ) ;
  1040.          WinAssociateHelpInstance ( WinQueryHelpInstance(OWNER(hwnd)), hwnd ) ;
  1041.          WinSetDlgItemText ( hwnd, IDD_LABEL_DEFLABEL, PSZ(Parms->DefaultLabel) ) ;
  1042.          WinSetDlgItemText ( hwnd, IDD_LABEL_NEWLABEL, PSZ(Parms->CurrentLabel) ) ;
  1043.          WinSendMsg ( WinWindowFromID(hwnd,IDD_LABEL_NEWLABEL), EM_SETTEXTLIMIT, MPFROM2SHORT(sizeof(Parms->CurrentLabel),0), 0 ) ;
  1044.          if ( Parms->LevelSense ) {
  1045.             int Divisor ;  char *Suffix ;
  1046.             GetDivisor ( Parms->MaxLevel, Parms->ShowTrueK, Divisor, Suffix ) ;
  1047.             Parms->Warning = new Slider ( WinWindowFromID(hwnd,IDD_LABEL_WARNING_SLIDER), WinWindowFromID(hwnd,IDD_LABEL_WARNING_VALUE),
  1048.                Parms->WarningLevel, Parms->MinLevel, Parms->MaxLevel, Divisor, Suffix ) ;
  1049.             Parms->Error = new Slider ( WinWindowFromID(hwnd,IDD_LABEL_ERROR_SLIDER), WinWindowFromID(hwnd,IDD_LABEL_ERROR_VALUE),
  1050.                Parms->ErrorLevel, Parms->MinLevel, Parms->MaxLevel, Divisor, Suffix ) ;
  1051.          } else {
  1052.             WinEnableWindow ( WinWindowFromID(hwnd,IDD_LABEL_WARNING_SLIDER), FALSE ) ;
  1053.             WinEnableWindow ( WinWindowFromID(hwnd,IDD_LABEL_WARNING_VALUE), FALSE ) ;
  1054.             WinEnableWindow ( WinWindowFromID(hwnd,IDD_LABEL_ERROR_SLIDER), FALSE ) ;
  1055.             WinEnableWindow ( WinWindowFromID(hwnd,IDD_LABEL_ERROR_VALUE), FALSE ) ;
  1056.          } /* endif */
  1057.          return ( 0 ) ; }
  1058.  
  1059.       case WM_DESTROY: {
  1060.          PLABEL_PARMS Parms = PLABEL_PARMS ( WinQueryWindowPtr ( hwnd, QWL_USER ) ) ;
  1061.          if ( Parms->Warning ) delete Parms->Warning, Parms->Warning = 0 ;
  1062.          if ( Parms->Error ) delete Parms->Error, Parms->Error = 0 ;
  1063.          return ( 0 ) ; }
  1064.  
  1065.       case WM_CONTROL: {
  1066.          PLABEL_PARMS Parms = PLABEL_PARMS ( WinQueryWindowPtr ( hwnd, QWL_USER ) ) ;
  1067.          SHORT Id = SHORT1FROMMP ( mp1 ) ;
  1068.          SHORT Message = SHORT2FROMMP ( mp1 ) ;
  1069.          int Divisor ;  char *Suffix ;
  1070.          GetDivisor ( Parms->MaxLevel, Parms->ShowTrueK, Divisor, Suffix ) ;
  1071.          switch ( Id ) {
  1072.             case IDD_LABEL_WARNING_SLIDER: {
  1073.                if ( WinQueryFocus(HWND_DESKTOP) == WinWindowFromID(hwnd,IDD_LABEL_WARNING_SLIDER) ) {
  1074.                   if ( ( Message == SLN_CHANGE ) || ( Message == SLN_SLIDERTRACK ) ) {
  1075.                      if ( Parms->Warning ) 
  1076.                         Parms->WarningLevel = Parms->Warning->Read ( ) ;
  1077.                   } /* endif */
  1078.                } /* endif */
  1079.                break; }
  1080.             case IDD_LABEL_ERROR_SLIDER: {
  1081.                if ( WinQueryFocus(HWND_DESKTOP) == WinWindowFromID(hwnd,IDD_LABEL_ERROR_SLIDER) ) {
  1082.                   if ( ( Message == SLN_CHANGE ) || ( Message == SLN_SLIDERTRACK ) ) {
  1083.                      if ( Parms->Error ) 
  1084.                         Parms->ErrorLevel = Parms->Error->Read ( ) ;
  1085.                   } /* endif */
  1086.                } /* endif */
  1087.                break; }
  1088.             case IDD_LABEL_WARNING_VALUE: {
  1089.                if ( WinQueryFocus(HWND_DESKTOP) == WinWindowFromID(hwnd,IDD_LABEL_WARNING_VALUE) ) {
  1090.                   if ( Message == EN_CHANGE ) {
  1091.                      char Text [20] ;
  1092.                      WinQueryDlgItemText ( hwnd, IDD_LABEL_WARNING_VALUE, sizeof(Text), PSZ(Text) ) ;
  1093.                      TrimRight ( Text ) ;
  1094.                      if ( Text[strlen(Text)-1] == 'M' ) {
  1095.                         Parms->WarningLevel = ULONG ( atof ( Text ) * 1024 * 1024 ) ;
  1096.                      } else if ( Text[strlen(Text)-1] == 'K' ) {
  1097.                         Parms->WarningLevel = ULONG ( atof ( Text ) * 1024 ) ;
  1098.                      } else if ( Text[strlen(Text)-1] == 'm' ) {
  1099.                         Parms->WarningLevel = ULONG ( atof ( Text ) * 1000 * 1000 ) ;
  1100.                      } else if ( Text[strlen(Text)-1] == 'k' ) {
  1101.                         Parms->WarningLevel = ULONG ( atof ( Text ) * 1000 ) ;
  1102.                      } else {
  1103.                         Parms->WarningLevel = atol ( Text ) ;
  1104.                      } /* endif */
  1105.                      if ( Parms->Warning ) 
  1106.                         Parms->Warning->Set ( Parms->WarningLevel, FALSE ) ;
  1107.                   } /* endif */
  1108.                } /* endif */
  1109.                break; }
  1110.             case IDD_LABEL_ERROR_VALUE: {
  1111.                if ( WinQueryFocus(HWND_DESKTOP) == WinWindowFromID(hwnd,IDD_LABEL_ERROR_VALUE) ) {
  1112.                   if ( Message == EN_CHANGE ) {
  1113.                      char Text [20] ;
  1114.                      WinQueryDlgItemText ( hwnd, IDD_LABEL_ERROR_VALUE, sizeof(Text), PSZ(Text) ) ;
  1115.                      TrimRight ( Text ) ;
  1116.                      if ( Text[strlen(Text)-1] == 'M' ) {
  1117.                         Parms->ErrorLevel = ULONG ( atof ( Text ) * 1024 * 1024 ) ;
  1118.                      } else if ( Text[strlen(Text)-1] == 'K' ) {
  1119.                         Parms->ErrorLevel = ULONG ( atof ( Text ) * 1024 ) ;
  1120.                      } else if ( Text[strlen(Text)-1] == 'm' ) {
  1121.                         Parms->ErrorLevel = ULONG ( atof ( Text ) * 1000 * 1000 ) ;
  1122.                      } else if ( Text[strlen(Text)-1] == 'k' ) {
  1123.                         Parms->ErrorLevel = ULONG ( atof ( Text ) * 1000 ) ;
  1124.                      } else {
  1125.                         Parms->ErrorLevel = atol ( Text ) ;
  1126.                      } /* endif */
  1127.                      if ( Parms->Error ) 
  1128.                         Parms->Error->Set ( Parms->ErrorLevel, FALSE ) ;
  1129.                   } /* endif */
  1130.                } /* endif */
  1131.                break; }
  1132.          } /* endswitch */
  1133.          return ( 0 ) ; }
  1134.  
  1135.       case WM_COMMAND: {
  1136.          PLABEL_PARMS Parms = PLABEL_PARMS ( WinQueryWindowPtr ( hwnd, QWL_USER ) ) ;
  1137.          switch ( SHORT1FROMMP(mp1) ) {
  1138.             case DID_OK: {
  1139.                WinQueryDlgItemText ( hwnd, IDD_LABEL_NEWLABEL, sizeof(Parms->CurrentLabel), PSZ(Parms->CurrentLabel) ) ;
  1140.                if ( Parms->CurrentLabel[0] == 0 ) {
  1141.                   WinAlarm ( HWND_DESKTOP, WA_NOTE ) ;
  1142.                   WinSetFocus ( HWND_DESKTOP, WinWindowFromID ( hwnd, IDD_LABEL_NEWLABEL ) ) ;
  1143.                   break ;
  1144.                } /* endif */
  1145.                char Text [20] ;
  1146.                WinQueryDlgItemText ( hwnd, IDD_LABEL_WARNING_VALUE, sizeof(Text), PSZ(Text) ) ;
  1147.                TrimRight ( Text ) ;
  1148.                if ( Text[strlen(Text)-1] == 'M' ) {
  1149.                   Parms->WarningLevel = ULONG ( atof ( Text ) * 1024 * 1024 ) ;
  1150.                } else if ( Text[strlen(Text)-1] == 'K' ) {
  1151.                   Parms->WarningLevel = ULONG ( atof ( Text ) * 1024 ) ;
  1152.                } else if ( Text[strlen(Text)-1] == 'm' ) {
  1153.                   Parms->WarningLevel = ULONG ( atof ( Text ) * 1000 * 1000 ) ;
  1154.                } else if ( Text[strlen(Text)-1] == 'k' ) {
  1155.                   Parms->WarningLevel = ULONG ( atof ( Text ) * 1000 ) ;
  1156.                } else {
  1157.                   Parms->WarningLevel = atol ( Text ) ;
  1158.                } /* endif */
  1159.                WinQueryDlgItemText ( hwnd, IDD_LABEL_ERROR_VALUE, sizeof(Text), PSZ(Text) ) ;
  1160.                TrimRight ( Text ) ;
  1161.                if ( Text[strlen(Text)-1] == 'M' ) {
  1162.                   Parms->ErrorLevel = ULONG ( atof ( Text ) * 1024 * 1024 ) ;
  1163.                } else if ( Text[strlen(Text)-1] == 'K' ) {
  1164.                   Parms->ErrorLevel = ULONG ( atof ( Text ) * 1024 ) ;
  1165.                } else if ( Text[strlen(Text)-1] == 'm' ) {
  1166.                   Parms->ErrorLevel = ULONG ( atof ( Text ) * 1000 * 1000 ) ;
  1167.                } else if ( Text[strlen(Text)-1] == 'k' ) {
  1168.                   Parms->ErrorLevel = ULONG ( atof ( Text ) * 1000 ) ;
  1169.                } else {
  1170.                   Parms->ErrorLevel = atol ( Text ) ;
  1171.                } /* endif */
  1172.                WinDismissDlg ( hwnd, TRUE ) ;
  1173.                break ; }
  1174.             case DID_CANCEL:
  1175.                WinDismissDlg ( hwnd, FALSE ) ;
  1176.                break ;
  1177.             case IDD_LABEL_DEFAULT:
  1178.                strcpy ( Parms->CurrentLabel, Parms->DefaultLabel ) ;
  1179.                WinSetDlgItemText ( hwnd, IDD_LABEL_NEWLABEL, PSZ(Parms->CurrentLabel) ) ;
  1180.                Parms->WarningLevel = Parms->DefaultLevels [0] ;
  1181.                Parms->ErrorLevel = Parms->DefaultLevels [1] ;
  1182.                if ( Parms->LevelSense ) {
  1183.                   int Divisor ;  char *Suffix ;
  1184.                   GetDivisor ( Parms->MaxLevel, Parms->ShowTrueK, Divisor, Suffix ) ;
  1185.                   if ( Parms->Warning ) 
  1186.                      Parms->Warning->Set ( Parms->WarningLevel ) ;
  1187.                   if ( Parms->Error ) 
  1188.                      Parms->Error->Set ( Parms->ErrorLevel ) ;
  1189.                } /* endif */
  1190.                WinSetFocus ( HWND_DESKTOP, WinWindowFromID ( hwnd, IDD_LABEL_NEWLABEL ) ) ;
  1191.                break ;
  1192.          } /* endswitch */
  1193.          return ( 0 ) ; }
  1194.  
  1195.    } /* endswitch */
  1196.  
  1197.    return ( WinDefDlgProc ( hwnd, msg, mp1, mp2 ) ) ;
  1198. }
  1199.  
  1200. /****************************************************************************
  1201.  *                                                                          *
  1202.  *      Subclasses STATIC control message processor                         *
  1203.  *                                                                          *
  1204.  ****************************************************************************/
  1205.  
  1206. typedef struct _STATICDATA {
  1207.    HMODULE hPMWP ;
  1208.    HOBJECT ( APIENTRY *pWinQueryObject ) ( PCSZ pszObjectID ) ;
  1209.    BOOL ( APIENTRY *pWinOpenObject ) ( HOBJECT hObject, ULONG ulView, BOOL Flag ) ;
  1210. } STATICDATA, *PSTATICDATA ;
  1211.  
  1212. static MRESULT APIENTRY Static_Processor ( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) {
  1213.  
  1214.    switch ( msg ) {
  1215.  
  1216.       case WM_INITDLG: 
  1217.       case WM_CREATE: {
  1218.          PSTATICDATA Data = PSTATICDATA ( malloc ( sizeof(STATICDATA) ) ) ;
  1219.          memset ( Data, 0, sizeof(STATICDATA) ) ;
  1220.          WinSetWindowPtr ( hwnd, QWL_USER, Data ) ;
  1221.          if ( DosLoadModule ( 0, 0, "PMWP", &Data->hPMWP ) ) {
  1222.             Data->hPMWP = 0;
  1223.             return ( 0 ) ;
  1224.          } /* endif */
  1225.          if ( DosQueryProcAddr ( Data->hPMWP, 252, 0, (PFN*) & Data->pWinQueryObject ) ) {
  1226.             DosFreeModule ( Data->hPMWP ) ;
  1227.             Data->hPMWP = 0;
  1228.             return ( 0 ) ;
  1229.          } /* endif */
  1230.          if ( DosQueryProcAddr ( Data->hPMWP, 286, 0, (PFN*) & Data->pWinOpenObject ) ) {
  1231.             DosFreeModule ( Data->hPMWP ) ;
  1232.             Data->pWinQueryObject = 0 ;
  1233.             Data->hPMWP = 0;
  1234.             return ( 0 ) ;
  1235.          } /* endif */
  1236.          return ( 0 ) ; }
  1237.  
  1238.       case WM_DESTROY: {
  1239.          PSTATICDATA Data = PSTATICDATA ( WinQueryWindowPtr ( hwnd, QWL_USER ) ) ;
  1240.          if ( Data && Data->hPMWP ) 
  1241.             DosFreeModule ( Data->hPMWP ) ;
  1242.          if ( Data ) free ( Data ) ;
  1243.          break; }
  1244.  
  1245.       case WM_SINGLESELECT:
  1246.       case WM_CONTEXTMENU: {
  1247.          PSTATICDATA Data = PSTATICDATA ( WinQueryWindowPtr ( hwnd, QWL_USER ) ) ;
  1248.          if ( !Data ) {
  1249.             WinSendMsg ( hwnd, WM_CREATE, 0, 0 ) ;
  1250.             Data = PSTATICDATA ( WinQueryWindowPtr ( hwnd, QWL_USER ) ) ;
  1251.          } /* endif */
  1252.          if ( Data && Data->pWinQueryObject && Data->pWinOpenObject ) {
  1253.             HOBJECT hObject = Data->pWinQueryObject ( "<WP_LORESCLRPAL>" ) ;
  1254.             if ( hObject ) {
  1255.                if ( !Data->pWinOpenObject ( hObject, 0, TRUE ) ) {
  1256.                   Data->pWinOpenObject ( hObject, 0, FALSE ) ;
  1257.                } /* endif */
  1258.             } /* endif */
  1259.          } /* endif */
  1260.          break ; }
  1261.  
  1262.       case WM_PRESPARAMCHANGED: {
  1263.          USHORT Id = WinQueryWindowUShort ( hwnd, QWS_ID ) ;
  1264.          switch ( LONGFROMMP(mp1) ) {
  1265.             case PP_BACKGROUNDCOLOR: {
  1266.                WinSendMsg ( OWNER(hwnd), WM_CONTROL, MPFROM2SHORT(Id,0), 0 ) ;
  1267.                break; }
  1268.             case PP_FOREGROUNDCOLOR: {
  1269.                WinSendMsg ( OWNER(hwnd), WM_CONTROL, MPFROM2SHORT(Id,0), 0 ) ;
  1270.                break; }
  1271.          } /* endswitch */
  1272.          break ; }
  1273.  
  1274.    } /* endswitch */
  1275.  
  1276.    return ( OldStaticProcessor ( hwnd, msg, mp1, mp2 ) ) ;
  1277. }
  1278.  
  1279.  
  1280.