home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / sdktools / winnt / dlgedit / styles.c < prev    next >
C/C++ Source or Header  |  1997-10-05  |  58KB  |  1,856 lines

  1.  
  2. /******************************************************************************\
  3. *       This is a part of the Microsoft Source Code Samples. 
  4. *       Copyright (C) 1993-1997 Microsoft Corporation.
  5. *       All rights reserved. 
  6. *       This source code is only intended as a supplement to 
  7. *       Microsoft Development Tools and/or WinHelp documentation.
  8. *       See these sources for detailed information regarding the 
  9. *       Microsoft samples programs.
  10. \******************************************************************************/
  11.  
  12. /****************************** Module Header *******************************
  13. * Module Name: styles.c
  14. *
  15. * Handles the control styles selection, including the styles dialogs.
  16. *
  17. * Functions:
  18. *
  19. *    StylesDialog()
  20. *    GenericStylesDlgProc()
  21. *    CheckBoxStylesDlgProc()
  22. *    RadioButtonStylesDlgProc()
  23. *    PushButtonStylesDlgProc()
  24. *    ComboBoxStylesDlgProc()
  25. *    EditStylesDlgProc()
  26. *    ListBoxStylesDlgProc()
  27. *    CustomStylesDlgProc()
  28. *    DialogStylesDlgProc()
  29. *    FontNameEnumFunc()
  30. *    PointSizeEnumFunc()
  31. *    EnableComboBoxStyles()
  32. *    EnableEditStyles()
  33. *    EnableListBoxStyles()
  34. *    SetCustomStylesField()
  35. *    GetCustomStylesField()
  36. *    EnableDialogStyles()
  37. *    FillFontNameCombo()
  38. *    FillPointSizeCombo()
  39. *    AddToPointSizeCombo()
  40. *    FillLanguageCombo()
  41. *    FillSubLanguageCombo()
  42. *    CheckStyleBoxes()
  43. *    QueryCheckedStyles()
  44. *    StylesHelp()
  45. *
  46. * Comments:
  47. *
  48. ****************************************************************************/
  49.  
  50. #include "dlgedit.h"
  51. #include "dlgfuncs.h"
  52. #include "dlgextrn.h"
  53. #include "dialogs.h"
  54.  
  55.  
  56. STATICFN VOID EnableComboBoxStyles(HWND hwnd, INT idCtrl);
  57. STATICFN VOID EnableEditStyles(HWND hwnd, INT idCtrl);
  58. STATICFN VOID EnableListBoxStyles(HWND hwnd, INT idCtrl);
  59. STATICFN VOID SetCustomStylesField(HWND hwnd, DWORD flStyle);
  60. STATICFN DWORD GetCustomStylesField(HWND hwnd);
  61. STATICFN VOID EnableDialogStyles(HWND hwnd, INT idCtrl);
  62. STATICFN VOID FillFontNameCombo(HWND hwndDlg);
  63. STATICFN VOID FillPointSizeCombo(HWND hwndDlg, LPTSTR pszFaceName);
  64. STATICFN VOID AddToPointSizeCombo(HWND hwndCombo, INT nPointSize);
  65. STATICFN VOID FillLanguageCombo(HWND hwndDlg);
  66. STATICFN VOID FillSubLanguageCombo(HWND hwndDlg, INT iLang);
  67. STATICFN VOID CheckStyleBoxes(HWND hwnd, INT iClass, DWORD flStyle);
  68. STATICFN VOID QueryCheckedStyles(HWND hwnd, INT iClass, DWORD *pflStyle);
  69. STATICFN VOID StylesHelp(VOID);
  70.  
  71. /*
  72.  * Global pointer to the CTYPE for the control or dialog whose styles
  73.  * are being worked on.  All the styles dialog procs and workers use
  74.  * this pointer.
  75.  */
  76. static NPCTYPE npcStyles;
  77.  
  78. /*
  79.  * Globals that receive the new styles the user selected.
  80.  */
  81. static DWORD flStyleNew;
  82. static DWORD flExtStyleNew;
  83. static LPTSTR pszTextNew;
  84. static DIALOGINFO diNew;
  85.  
  86.  
  87.  
  88. /************************************************************************
  89. * StylesDialog
  90. *
  91. * Displays the appropriate styles dialog for the currently selected
  92. * control.  If the user OK's the changes, this function sets the
  93. * style of the control.
  94. *
  95. ************************************************************************/
  96.  
  97. VOID StylesDialog(VOID)
  98. {
  99.     NPCTYPE npc;
  100.     HWND hwndOld;
  101.     INT fDlgResult;
  102.     BOOL fChanged = FALSE;
  103.     BOOL fFontChanged = FALSE;
  104.     TCHAR szClassNew[CCHTEXTMAX];
  105.     TCHAR szMenuNew[CCHTEXTMAX];
  106.     TCHAR szTextNew[CCHTEXTMAX];
  107.  
  108.     /*
  109.      * Quit if nothing was selected, or if we are in translate mode.
  110.      */
  111.     if (!gnpcSel || gfTranslateMode)
  112.         return;
  113.  
  114.     /*
  115.      * Set globals that the styles dialogs and worker routines will use.
  116.      */
  117.     npcStyles = gnpcSel;
  118.     flStyleNew = npcStyles->flStyle;
  119.     flExtStyleNew = npcStyles->flExtStyle;
  120.  
  121.     if (npcStyles->text)
  122.         NameOrdCpy(szTextNew, npcStyles->text);
  123.     else
  124.         *szTextNew = CHAR_NULL;
  125.  
  126.     pszTextNew = szTextNew;
  127.  
  128.     /*
  129.      * Set some other globals if this is the dialog instead of a control.
  130.      */
  131.     if (gfDlgSelected) {
  132.         diNew.fResFlags = gcd.di.fResFlags;
  133.         diNew.wLanguage = gcd.di.wLanguage;
  134.         diNew.DataVersion = gcd.di.DataVersion;
  135.         diNew.Version = gcd.di.Version;
  136.         diNew.Characteristics = gcd.di.Characteristics;
  137.  
  138.         lstrcpy(diNew.szFontName, gcd.di.szFontName);
  139.         diNew.nPointSize = gcd.di.nPointSize;
  140.  
  141.         diNew.pszClass = szClassNew;
  142.         if (gcd.di.pszClass)
  143.             NameOrdCpy(szClassNew, gcd.di.pszClass);
  144.         else
  145.             *szClassNew = CHAR_NULL;
  146.  
  147.         diNew.pszMenu = szMenuNew;
  148.         if (gcd.di.pszMenu)
  149.             NameOrdCpy(szMenuNew, gcd.di.pszMenu);
  150.         else
  151.             *szMenuNew = CHAR_NULL;
  152.     }
  153.  
  154.     /*
  155.      * Is this a custom control that has a styles proc to use?
  156.      */
  157.     if (npcStyles->pwcd->iType == W_CUSTOM && npcStyles->pwcd->lpfnStyle) {
  158.         fDlgResult = CallCustomStyle(npcStyles, &flStyleNew, &flExtStyleNew,
  159.             szTextNew);
  160.     }
  161.     else {
  162.         /*
  163.          * Show the appropriate styles dialog.
  164.          */
  165.         fDlgResult = DlgBox(npcStyles->pwcd->idStylesDialog,
  166.                 (WNDPROC)npcStyles->pwcd->pfnStylesDlgProc);
  167.     }
  168.  
  169.     if (fDlgResult == IDOK) {
  170.         /*
  171.          * Now go through and determine if anything was really changed.
  172.          */
  173.         if (npcStyles->flStyle != flStyleNew ||
  174.                 npcStyles->flExtStyle != flExtStyleNew ||
  175.                 NameOrdCmp(npcStyles->text ?
  176.                 npcStyles->text : szEmpty, szTextNew) != 0)
  177.             fChanged = TRUE;
  178.  
  179.         /*
  180.          * If this is the dialog, check if some other things were changed.
  181.          */
  182.         if (gfDlgSelected) {
  183.             if (gcd.di.fResFlags != diNew.fResFlags ||
  184.                     gcd.di.wLanguage != diNew.wLanguage ||
  185.                     NameOrdCmp(gcd.di.pszClass ?
  186.                     gcd.di.pszClass : szEmpty, diNew.pszClass) != 0 ||
  187.                     NameOrdCmp(gcd.di.pszMenu ?
  188.                     gcd.di.pszMenu : szEmpty, diNew.pszMenu) != 0)
  189.                 fChanged = TRUE;
  190.  
  191.             if (lstrcmp(gcd.di.szFontName, diNew.szFontName) != 0 ||
  192.                     (*diNew.szFontName &&
  193.                     gcd.di.nPointSize != diNew.nPointSize))
  194.                 fChanged = fFontChanged = TRUE;
  195.         }
  196.     }
  197.  
  198.     /*
  199.      * Did something change?
  200.      */
  201.     if (fChanged) {
  202.         if (gfDlgSelected) {
  203.             hwndOld = npcStyles->hwnd;
  204.             CreateControl(npcStyles, pszTextNew, flStyleNew, flExtStyleNew,
  205.                     npcStyles->id, &npcStyles->rc, (HWND)NULL, &diNew);
  206.  
  207.             /*
  208.              * Create all the control windows in the new dialog.
  209.              * They must be created (not just moved over by changing
  210.              * the parent and owner) because some controls have
  211.              * allocated memory on the old dialogs heap, and this
  212.              * heap will become invalid after the old dialog
  213.              * is destroyed below. 
  214.              */
  215.             for (npc = npcHead; npc; npc = npc->npcNext) {
  216.                 /*
  217.                  * If this is an icon control and the dialog font
  218.                  * was just changed, we need to resize the control
  219.                  * based on the new default icon size.
  220.                  */
  221.                 if (npc->pwcd->iType == W_ICON && fFontChanged) {
  222.                     npc->rc.right = npc->rc.left + awcd[W_ICON].cxDefault;
  223.                     npc->rc.bottom = npc->rc.top + awcd[W_ICON].cyDefault;
  224.                 }
  225.  
  226.                 CreateControl(npc, npc->text, npc->flStyle, npc->flExtStyle,
  227.                         npc->id, &npc->rc, (HWND)NULL, NULL);
  228.             }
  229.  
  230.             /*
  231.              * Now move all the drag windows over to the new dialog.
  232.              * This must be done after creating all the controls
  233.              * because of the touchy Z-order that the drag windows
  234.              * and the controls must have for painting and selection
  235.              * of the drag windows to work properly.  Note that we
  236.              * rely on SetParent to add the window at
  237.              * the TOP in Z-order.
  238.              */
  239.             for (npc = npcHead; npc; npc = npc->npcNext) {
  240.                 SetParent(npc->hwndDrag, npcStyles->hwnd);
  241.  
  242.                 /*
  243.                  * Adjust the position of the drag window.
  244.                  */
  245.                 SizeDragToControl(npc);
  246.             }
  247.  
  248.             ShowWindow(npcStyles->hwnd, SW_SHOWNA);
  249.             ToolboxOnTop();
  250.             DestroyWindow(hwndOld);
  251.         }
  252.         else {
  253.             hwndOld = npcStyles->hwnd;
  254.  
  255.             if (CreateControl(npcStyles, pszTextNew, flStyleNew, flExtStyleNew,
  256.                     npcStyles->id, &npcStyles->rc, hwndOld, NULL)) {
  257.                 /*
  258.                  * Get rid of the old control window.
  259.                  */
  260.                 DestroyWindow(hwndOld);
  261.  
  262.                 /*
  263.                  * Adjust the size and position of its drag window.
  264.                  */
  265.                 SizeDragToControl(npcStyles);
  266.             }
  267.         }
  268.  
  269.         gfResChged = gfDlgChanged = TRUE;
  270.         ShowFileStatus(FALSE);
  271.         StatusUpdate();
  272.         StatusSetEnable();
  273.     }
  274. }
  275.  
  276.  
  277.  
  278. /************************************************************************
  279. * GenericStylesDlgProc
  280. *
  281. * Dialog procedure for styles.
  282. *
  283. ************************************************************************/
  284.  
  285. DIALOGPROC GenericStylesDlgProc(
  286.     HWND hwnd,
  287.     UINT msg,
  288.     WPARAM wParam,
  289.     LPARAM lParam)
  290. {
  291.     switch (msg) {
  292.         case WM_INITDIALOG:
  293.             CheckStyleBoxes(hwnd, npcStyles->pwcd->iClass,
  294.                     npcStyles->flStyle);
  295.             CheckStyleBoxes(hwnd, IC_WINDOW, npcStyles->flStyle);
  296.  
  297.             CenterWindow(hwnd);
  298.  
  299.             return TRUE;
  300.  
  301.         case WM_COMMAND:
  302.             switch (LOWORD(wParam)) {
  303.                 case IDOK:
  304.                     QueryCheckedStyles(hwnd, npcStyles->pwcd->iClass,
  305.                             &flStyleNew);
  306.                     QueryCheckedStyles(hwnd, IC_WINDOW, &flStyleNew);
  307.                     EndDialog(hwnd, IDOK);
  308.                     return TRUE;
  309.  
  310.                 case IDCANCEL:
  311.                     EndDialog(hwnd, IDCANCEL);
  312.                     return TRUE;
  313.  
  314.                 case IDHELP:
  315.                     StylesHelp();
  316.                     break;
  317.             }
  318.  
  319.             return FALSE;
  320.  
  321.         default:
  322.             return FALSE;
  323.     }
  324. }
  325.  
  326.  
  327.  
  328. /************************************************************************
  329. * CheckBoxStylesDlgProc
  330. *
  331. * Dialog procedure for checkboxes.
  332. *
  333. ************************************************************************/
  334.  
  335. DIALOGPROC CheckBoxStylesDlgProc(
  336.     HWND hwnd,
  337.     UINT msg,
  338.     WPARAM wParam,
  339.     LPARAM lParam)
  340. {
  341.     DWORD dwType;
  342.     BOOL f3State;
  343.     BOOL fAuto;
  344.  
  345.     switch (msg) {
  346.         case WM_INITDIALOG:
  347.             CheckStyleBoxes(hwnd, npcStyles->pwcd->iClass,
  348.                     npcStyles->flStyle);
  349.             CheckStyleBoxes(hwnd, IC_WINDOW, npcStyles->flStyle);
  350.  
  351.             dwType = npcStyles->flStyle & BS_ALL;
  352.             if (dwType == BS_AUTOCHECKBOX || dwType == BS_AUTO3STATE)
  353.                 CheckDlgButton(hwnd, DID_BS_AUTOXXX, 1);
  354.  
  355.             if (dwType == BS_3STATE || dwType == BS_AUTO3STATE)
  356.                 CheckDlgButton(hwnd, DID_BS_3STATE, 1);
  357.  
  358.             CenterWindow(hwnd);
  359.  
  360.             return TRUE;
  361.  
  362.         case WM_COMMAND:
  363.             switch (LOWORD(wParam)) {
  364.                 case IDOK:
  365.                     QueryCheckedStyles(hwnd, npcStyles->pwcd->iClass,
  366.                             &flStyleNew);
  367.                     QueryCheckedStyles(hwnd, IC_WINDOW, &flStyleNew);
  368.  
  369.                     fAuto = IsDlgButtonChecked(hwnd, DID_BS_AUTOXXX);
  370.                     f3State = IsDlgButtonChecked(hwnd, DID_BS_3STATE);
  371.                     flStyleNew &= ~BS_ALL;
  372.                     if (fAuto) {
  373.                         if (f3State)
  374.                             flStyleNew |= BS_AUTO3STATE;
  375.                         else
  376.                             flStyleNew |= BS_AUTOCHECKBOX;
  377.                     }
  378.                     else {
  379.                         if (f3State)
  380.                             flStyleNew |= BS_3STATE;
  381.                         else
  382.                             flStyleNew |= BS_CHECKBOX;
  383.                     }
  384.  
  385.                     EndDialog(hwnd, IDOK);
  386.                     return TRUE;
  387.  
  388.                 case IDCANCEL:
  389.                     EndDialog(hwnd, IDCANCEL);
  390.                     return TRUE;
  391.  
  392.                 case IDHELP:
  393.                     StylesHelp();
  394.                     break;
  395.             }
  396.  
  397.             return FALSE;
  398.  
  399.         default:
  400.             return FALSE;
  401.     }
  402. }
  403.  
  404.  
  405.  
  406. /************************************************************************
  407. * RadioButtonStylesDlgProc
  408. *
  409. * Dialog box procedure for radio buttons.
  410. *
  411. ************************************************************************/
  412.  
  413. DIALOGPROC RadioButtonStylesDlgProc(
  414.     HWND hwnd,
  415.     UINT msg,
  416.     WPARAM wParam,
  417.     LPARAM lParam)
  418. {
  419.     switch (msg) {
  420.         case WM_INITDIALOG:
  421.             CheckStyleBoxes(hwnd, npcStyles->pwcd->iClass,
  422.                     npcStyles->flStyle);
  423.             CheckStyleBoxes(hwnd, IC_WINDOW, npcStyles->flStyle);
  424.  
  425.             if ((npcStyles->flStyle & BS_ALL) == BS_AUTORADIOBUTTON)
  426.                 CheckDlgButton(hwnd, DID_BS_AUTOXXX, 1);
  427.  
  428.             CenterWindow(hwnd);
  429.  
  430.             return TRUE;
  431.  
  432.         case WM_COMMAND:
  433.             switch (LOWORD(wParam)) {
  434.                 case IDOK:
  435.                     QueryCheckedStyles(hwnd, npcStyles->pwcd->iClass,
  436.                             &flStyleNew);
  437.                     QueryCheckedStyles(hwnd, IC_WINDOW, &flStyleNew);
  438.  
  439.                     flStyleNew &= ~BS_ALL;
  440.                     if (IsDlgButtonChecked(hwnd, DID_BS_AUTOXXX))
  441.                         flStyleNew |= BS_AUTORADIOBUTTON;
  442.                     else
  443.                         flStyleNew |= BS_RADIOBUTTON;
  444.  
  445.                     EndDialog(hwnd, IDOK);
  446.                     return TRUE;
  447.  
  448.                 case IDCANCEL:
  449.                     EndDialog(hwnd, IDCANCEL);
  450.                     return TRUE;
  451.  
  452.                 case IDHELP:
  453.                     StylesHelp();
  454.                     break;
  455.             }
  456.  
  457.             return FALSE;
  458.  
  459.         default:
  460.             return FALSE;
  461.     }
  462. }
  463.  
  464.  
  465.  
  466. /************************************************************************
  467. * PushButtonStylesDlgProc
  468. *
  469. * We do not normally allow more than one default push button in a
  470. * dialog. but if this button is already a default button, we must
  471. * allow them to change it to a normal one, even if there is already
  472. * another default button in the dialog.  Note that this condition
  473. * would normally never happen, unless they read in a res file with
  474. * this condition already.
  475. *
  476. ************************************************************************/
  477.  
  478. DIALOGPROC PushButtonStylesDlgProc(
  479.     HWND hwnd,
  480.     UINT msg,
  481.     WPARAM wParam,
  482.     LPARAM lParam)
  483. {
  484.     NPCTYPE npc;
  485.  
  486.     switch (msg) {
  487.         case WM_INITDIALOG:
  488.             CheckStyleBoxes(hwnd, npcStyles->pwcd->iClass,
  489.                     npcStyles->flStyle);
  490.             CheckStyleBoxes(hwnd, IC_WINDOW, npcStyles->flStyle);
  491.  
  492.             /*
  493.              * Only test for possibly disabling the "default"
  494.              * checkbox if the current control does not have the
  495.              * "default" style.  If it does, we must always allow
  496.              * them to turn it off.
  497.              */
  498.             if ((npcStyles->flStyle & BS_ALL) != BS_DEFPUSHBUTTON) {
  499.                 /*
  500.                  * Loop through all the controls.  If any pushbutton
  501.                  * is found with the "default" style, we disable the
  502.                  * "Default" checkbox in the styles dialog.
  503.                  */
  504.                 for (npc = npcHead; npc; npc = npc->npcNext)
  505.                     if ((npc->pwcd->iType == W_PUSHBUTTON) &&
  506.                             (npc->flStyle & BS_ALL) == BS_DEFPUSHBUTTON) {
  507.                         EnableWindow(GetDlgItem(hwnd, DID_BS_DEFPUSHBUTTON),
  508.                                 FALSE);
  509.                         break;
  510.                     }
  511.             }
  512.  
  513.             CenterWindow(hwnd);
  514.  
  515.             return TRUE;
  516.  
  517.         case WM_COMMAND:
  518.             switch (LOWORD(wParam)) {
  519.                 case IDOK:
  520.                     QueryCheckedStyles(hwnd, npcStyles->pwcd->iClass,
  521.                             &flStyleNew);
  522.                     QueryCheckedStyles(hwnd, IC_WINDOW, &flStyleNew);
  523.  
  524.                     EndDialog(hwnd, IDOK);
  525.                     return TRUE;
  526.  
  527.                 case IDCANCEL:
  528.                     EndDialog(hwnd, IDCANCEL);
  529.                     return TRUE;
  530.  
  531.                 case IDHELP:
  532.                     StylesHelp();
  533.                     break;
  534.             }
  535.  
  536.             return FALSE;
  537.  
  538.         default:
  539.             return FALSE;
  540.     }
  541. }
  542.  
  543.  
  544.  
  545. /************************************************************************
  546. * ComboBoxStylesDlgProc
  547. *
  548. * Dialog procedure for combo boxes.
  549. *
  550. ************************************************************************/
  551.  
  552. DIALOGPROC ComboBoxStylesDlgProc(
  553.     HWND hwnd,
  554.     UINT msg,
  555.     WPARAM wParam,
  556.     LPARAM lParam)
  557. {
  558.     switch (msg) {
  559.         case WM_INITDIALOG:
  560.             CheckStyleBoxes(hwnd, npcStyles->pwcd->iClass,
  561.                     npcStyles->flStyle);
  562.             CheckStyleBoxes(hwnd, IC_WINDOW, npcStyles->flStyle);
  563.  
  564.             EnableComboBoxStyles(hwnd, 0);
  565.  
  566.             CenterWindow(hwnd);
  567.  
  568.             return TRUE;
  569.  
  570.         case WM_COMMAND:
  571.             switch (LOWORD(wParam)) {
  572.                 case DID_CBS_OWNERDRAWFIXED:
  573.                 case DID_CBS_OWNERDRAWVARIABLE:
  574.                     if (HIWORD(wParam) == BN_CLICKED)
  575.                         EnableComboBoxStyles(hwnd,
  576.                                 LOWORD(wParam));
  577.  
  578.                     return TRUE;
  579.  
  580.                 case IDOK:
  581.                     QueryCheckedStyles(hwnd, npcStyles->pwcd->iClass,
  582.                             &flStyleNew);
  583.                     QueryCheckedStyles(hwnd, IC_WINDOW, &flStyleNew);
  584.                     EndDialog(hwnd, IDOK);
  585.                     return TRUE;
  586.  
  587.                 case IDCANCEL:
  588.                     EndDialog(hwnd, IDCANCEL);
  589.                     return TRUE;
  590.  
  591.                 case IDHELP:
  592.                     StylesHelp();
  593.                     break;
  594.             }
  595.  
  596.             return FALSE;
  597.  
  598.         default:
  599.             return FALSE;
  600.     }
  601. }
  602.  
  603.  
  604.  
  605. /************************************************************************
  606. * EnableComboBoxStyles
  607. *
  608. * Checks/unchecks, disables/enables various checkboxes that are
  609. * mutually exclusive and/or dependant for the Combo Box Styles dialog.
  610. *
  611. * Arguments:
  612. *   HWND hwnd   - Dialog window handle.
  613. *   INT idCtrl  - ID of the control that was clicked on.
  614. *
  615. ************************************************************************/
  616.  
  617. STATICFN VOID EnableComboBoxStyles(
  618.     HWND hwnd,
  619.     INT idCtrl)
  620. {
  621.     BOOL fFixedChecked;
  622.     BOOL fVariableChecked;
  623.  
  624.     fFixedChecked = IsDlgButtonChecked(hwnd, DID_CBS_OWNERDRAWFIXED);
  625.     fVariableChecked = IsDlgButtonChecked(hwnd, DID_CBS_OWNERDRAWVARIABLE);
  626.  
  627.     if (fFixedChecked || fVariableChecked) {
  628.         EnableWindow(GetDlgItem(hwnd, DID_CBS_HASSTRINGS), TRUE);
  629.     }
  630.     else {
  631.         EnableWindow(GetDlgItem(hwnd, DID_CBS_HASSTRINGS), FALSE);
  632.         CheckDlgButton(hwnd, DID_CBS_HASSTRINGS, 0);
  633.     }
  634.  
  635.     switch (idCtrl) {
  636.         case DID_CBS_OWNERDRAWFIXED:
  637.             if (fFixedChecked)
  638.                 CheckDlgButton(hwnd, DID_CBS_OWNERDRAWVARIABLE, 0);
  639.  
  640.             break;
  641.  
  642.         case DID_CBS_OWNERDRAWVARIABLE:
  643.             if (fVariableChecked)
  644.                 CheckDlgButton(hwnd, DID_CBS_OWNERDRAWFIXED, 0);
  645.  
  646.             break;
  647.     }
  648. }
  649.  
  650.  
  651.  
  652. /************************************************************************
  653. * EditStylesDlgProc
  654. *
  655. * Dialog procedure for edit boxes.
  656. *
  657. ************************************************************************/
  658.  
  659. DIALOGPROC EditStylesDlgProc(
  660.     HWND hwnd,
  661.     UINT msg,
  662.     WPARAM wParam,
  663.     LPARAM lParam)
  664. {
  665.     switch (msg) {
  666.         case WM_INITDIALOG:
  667.             CheckStyleBoxes(hwnd, npcStyles->pwcd->iClass,
  668.                     npcStyles->flStyle);
  669.             CheckStyleBoxes(hwnd, IC_WINDOW, npcStyles->flStyle);
  670.  
  671.             EnableEditStyles(hwnd, 0);
  672.  
  673.             CenterWindow(hwnd);
  674.  
  675.             return TRUE;
  676.  
  677.         case WM_COMMAND:
  678.             switch (LOWORD(wParam)) {
  679.                 case DID_ES_UPPERCASE:
  680.                 case DID_ES_LOWERCASE:
  681.                 case DID_ES_MULTILINE:
  682.                     if (HIWORD(wParam) == BN_CLICKED)
  683.                         EnableEditStyles(hwnd,
  684.                                 LOWORD(wParam));
  685.  
  686.                     return TRUE;
  687.  
  688.                 case IDOK:
  689.                     QueryCheckedStyles(hwnd, npcStyles->pwcd->iClass,
  690.                             &flStyleNew);
  691.                     QueryCheckedStyles(hwnd, IC_WINDOW, &flStyleNew);
  692.                     EndDialog(hwnd, IDOK);
  693.                     return TRUE;
  694.  
  695.                 case IDCANCEL:
  696.                     EndDialog(hwnd, IDCANCEL);
  697.                     return TRUE;
  698.  
  699.                 case IDHELP:
  700.                     StylesHelp();
  701.                     break;
  702.             }
  703.  
  704.             return FALSE;
  705.  
  706.         default:
  707.             return FALSE;
  708.     }
  709. }
  710.  
  711.  
  712.  
  713. /************************************************************************
  714. * EnableEditStyles
  715. *
  716. * Checks/unchecks, disables/enables various checkboxes that are
  717. * mutually exclusive and/or dependant for the Edit Field Styles dialog.
  718. *
  719. * Arguments:
  720. *   HWND hwnd  - Dialog window handle.
  721. *   INT idCtrl - ID of the control that was clicked on.
  722. *
  723. ************************************************************************/
  724.  
  725. STATICFN VOID EnableEditStyles(
  726.     HWND hwnd,
  727.     INT idCtrl)
  728. {
  729.     if (IsDlgButtonChecked(hwnd, DID_ES_MULTILINE)) {
  730.         EnableWindow(GetDlgItem(hwnd, DID_ES_CENTER), TRUE);
  731.         EnableWindow(GetDlgItem(hwnd, DID_ES_RIGHT), TRUE);
  732.         EnableWindow(GetDlgItem(hwnd, DID_WS_VSCROLL), TRUE);
  733.         EnableWindow(GetDlgItem(hwnd, DID_ES_AUTOVSCROLL), TRUE);
  734.         EnableWindow(GetDlgItem(hwnd, DID_WS_HSCROLL), TRUE);
  735.     }
  736.     else {
  737.         EnableWindow(GetDlgItem(hwnd, DID_ES_CENTER), FALSE);
  738.         EnableWindow(GetDlgItem(hwnd, DID_ES_RIGHT), FALSE);
  739.         EnableWindow(GetDlgItem(hwnd, DID_WS_VSCROLL), FALSE);
  740.         EnableWindow(GetDlgItem(hwnd, DID_ES_AUTOVSCROLL), FALSE);
  741.         EnableWindow(GetDlgItem(hwnd, DID_WS_HSCROLL), FALSE);
  742.  
  743.         CheckDlgButton(hwnd, DID_ES_LEFT, 1);
  744.         CheckDlgButton(hwnd, DID_ES_CENTER, 0);
  745.         CheckDlgButton(hwnd, DID_ES_RIGHT, 0);
  746.         CheckDlgButton(hwnd, DID_WS_VSCROLL, 0);
  747.         CheckDlgButton(hwnd, DID_ES_AUTOVSCROLL, 0);
  748.         CheckDlgButton(hwnd, DID_WS_HSCROLL, 0);
  749.     }
  750.  
  751.     if (idCtrl == DID_ES_UPPERCASE) {
  752.         if (IsDlgButtonChecked(hwnd, DID_ES_UPPERCASE))
  753.             CheckDlgButton(hwnd, DID_ES_LOWERCASE, 0);
  754.     }
  755.     else if (idCtrl == DID_ES_LOWERCASE) {
  756.         if (IsDlgButtonChecked(hwnd, DID_ES_LOWERCASE))
  757.             CheckDlgButton(hwnd, DID_ES_UPPERCASE, 0);
  758.     }
  759. }
  760.  
  761.  
  762.  
  763. /************************************************************************
  764. * ListBoxStylesDlgProc
  765. *
  766. * Dialog procedure for list boxes.
  767. *
  768. ************************************************************************/
  769.  
  770. DIALOGPROC ListBoxStylesDlgProc(
  771.     HWND hwnd,
  772.     UINT msg,
  773.     WPARAM wParam,
  774.     LPARAM lParam)
  775. {
  776.     switch (msg) {
  777.         case WM_INITDIALOG:
  778.             CheckStyleBoxes(hwnd, npcStyles->pwcd->iClass,
  779.                     npcStyles->flStyle);
  780.             CheckStyleBoxes(hwnd, IC_WINDOW, npcStyles->flStyle);
  781.  
  782.             EnableListBoxStyles(hwnd, 0);
  783.  
  784.             CenterWindow(hwnd);
  785.  
  786.             return TRUE;
  787.  
  788.         case WM_COMMAND:
  789.             switch (LOWORD(wParam)) {
  790.                 case DID_LBS_STANDARD:
  791.                 case DID_LBS_NOTIFY:
  792.                 case DID_LBS_SORT:
  793.                 case DID_WS_VSCROLL:
  794.                 case DID_WS_BORDER:
  795.                 case DID_LBS_MULTIPLESEL:
  796.                 case DID_LBS_EXTENDEDSEL:
  797.                 case DID_LBS_OWNERDRAWFIXED:
  798.                 case DID_LBS_OWNERDRAWVARIABLE:
  799.                 case DID_LBS_NODATA:
  800.                 case DID_LBS_HASSTRINGS:
  801.                     if (HIWORD(wParam) == BN_CLICKED)
  802.                         EnableListBoxStyles(hwnd,
  803.                                 LOWORD(wParam));
  804.  
  805.                     return TRUE;
  806.  
  807.                 case IDOK:
  808.                     QueryCheckedStyles(hwnd, npcStyles->pwcd->iClass,
  809.                             &flStyleNew);
  810.                     QueryCheckedStyles(hwnd, IC_WINDOW, &flStyleNew);
  811.                     EndDialog(hwnd, IDOK);
  812.                     return TRUE;
  813.  
  814.                 case IDCANCEL:
  815.                     EndDialog(hwnd, IDCANCEL);
  816.                     return TRUE;
  817.  
  818.                 case IDHELP:
  819.                     StylesHelp();
  820.                     break;
  821.             }
  822.  
  823.             return FALSE;
  824.  
  825.         default:
  826.             return FALSE;
  827.     }
  828. }
  829.  
  830.  
  831.  
  832. /************************************************************************
  833. * EnableListBoxStyles
  834. *
  835. * Checks/unchecks, disables/enables various checkboxes that are
  836. * mutually exclusive and/or dependant for the List Box Styles dialog.
  837. *
  838. * Arguments:
  839. *   HWND hwnd  - Dialog window handle.
  840. *   INT idCtrl - ID of the control that was clicked on.
  841. *
  842. ************************************************************************/
  843.  
  844. STATICFN VOID EnableListBoxStyles(
  845.     HWND hwnd,
  846.     INT idCtrl)
  847. {
  848.     WORD fCheckState;
  849.     BOOL fFixedChecked;
  850.     BOOL fVariableChecked;
  851.  
  852.     fFixedChecked = IsDlgButtonChecked(hwnd, DID_LBS_OWNERDRAWFIXED);
  853.     fVariableChecked = IsDlgButtonChecked(hwnd, DID_LBS_OWNERDRAWVARIABLE);
  854.  
  855.     if (fFixedChecked || fVariableChecked) {
  856.         EnableWindow(GetDlgItem(hwnd, DID_LBS_HASSTRINGS), TRUE);
  857.     }
  858.     else {
  859.         EnableWindow(GetDlgItem(hwnd, DID_LBS_HASSTRINGS), FALSE);
  860.         CheckDlgButton(hwnd, DID_LBS_HASSTRINGS, 0);
  861.     }
  862.  
  863.     EnableWindow(GetDlgItem(hwnd, DID_LBS_NODATA), fFixedChecked);
  864.  
  865.     switch (idCtrl) {
  866.         case DID_LBS_STANDARD:
  867.             fCheckState = (WORD)(IsDlgButtonChecked(hwnd, DID_LBS_STANDARD)
  868.                     ? 1 : 0);
  869.             CheckDlgButton(hwnd, DID_LBS_NOTIFY, fCheckState);
  870.             CheckDlgButton(hwnd, DID_LBS_SORT, fCheckState);
  871.             CheckDlgButton(hwnd, DID_WS_VSCROLL, fCheckState);
  872.             CheckDlgButton(hwnd, DID_WS_BORDER, fCheckState);
  873.  
  874.             if (fCheckState)
  875.                 CheckDlgButton(hwnd, DID_LBS_NODATA, 0);
  876.  
  877.             break;
  878.  
  879.         case DID_LBS_OWNERDRAWFIXED:
  880.             if (fFixedChecked)
  881.                 CheckDlgButton(hwnd, DID_LBS_OWNERDRAWVARIABLE, 0);
  882.             else
  883.                 CheckDlgButton(hwnd, DID_LBS_NODATA, 0);
  884.  
  885.             break;
  886.  
  887.         case DID_LBS_OWNERDRAWVARIABLE:
  888.             if (fVariableChecked) {
  889.                 CheckDlgButton(hwnd, DID_LBS_OWNERDRAWFIXED, 0);
  890.                 CheckDlgButton(hwnd, DID_LBS_NODATA, 0);
  891.                 EnableWindow(GetDlgItem(hwnd, DID_LBS_NODATA), FALSE);
  892.             }
  893.  
  894.             break;
  895.  
  896.         case DID_LBS_MULTIPLESEL:
  897.             if (IsDlgButtonChecked(hwnd, DID_LBS_MULTIPLESEL))
  898.                 CheckDlgButton(hwnd, DID_LBS_EXTENDEDSEL, 0);
  899.  
  900.             break;
  901.  
  902.         case DID_LBS_EXTENDEDSEL:
  903.             if (IsDlgButtonChecked(hwnd, DID_LBS_EXTENDEDSEL))
  904.                 CheckDlgButton(hwnd, DID_LBS_MULTIPLESEL, 0);
  905.  
  906.             break;
  907.  
  908.         case DID_LBS_NODATA:
  909.             if (IsDlgButtonChecked(hwnd, DID_LBS_NODATA)) {
  910.                 CheckDlgButton(hwnd, DID_LBS_SORT, 0);
  911.                 CheckDlgButton(hwnd, DID_LBS_HASSTRINGS, 0);
  912.                 CheckDlgButton(hwnd, DID_LBS_STANDARD, 0);
  913.             }
  914.  
  915.             break;
  916.  
  917.         case DID_LBS_HASSTRINGS:
  918.             if (IsDlgButtonChecked(hwnd, DID_LBS_HASSTRINGS))
  919.                 CheckDlgButton(hwnd, DID_LBS_NODATA, 0);
  920.  
  921.             break;
  922.  
  923.         default:
  924.             if (!IsDlgButtonChecked(hwnd, DID_LBS_NOTIFY) ||
  925.                     !IsDlgButtonChecked(hwnd, DID_LBS_SORT) ||
  926.                     !IsDlgButtonChecked(hwnd, DID_WS_VSCROLL) ||
  927.                     !IsDlgButtonChecked(hwnd, DID_WS_BORDER))
  928.                 fCheckState = 0;
  929.             else
  930.                 fCheckState = 1;
  931.  
  932.             CheckDlgButton(hwnd, DID_LBS_STANDARD, fCheckState);
  933.  
  934.             if (IsDlgButtonChecked(hwnd, DID_LBS_SORT) ||
  935.                     IsDlgButtonChecked(hwnd, DID_LBS_HASSTRINGS))
  936.                 CheckDlgButton(hwnd, DID_LBS_NODATA, 0);
  937.  
  938.             break;
  939.     }
  940. }
  941.  
  942.  
  943.  
  944. /************************************************************************
  945. * CustomStylesDlgProc
  946. *
  947. * Dialog procedure for custom controls.
  948. *
  949. ************************************************************************/
  950.  
  951. DIALOGPROC CustomStylesDlgProc(
  952.     HWND hwnd,
  953.     UINT msg,
  954.     WPARAM wParam,
  955.     LPARAM lParam)
  956. {
  957.     switch (msg) {
  958.         case WM_INITDIALOG:
  959.             SetDlgItemText(hwnd, DID_CUSTOMSTYLESCLASS,
  960.                     npcStyles->pwcd->pszClass);
  961.             SendDlgItemMessage(hwnd, DID_CUSTOMSTYLESSTYLES, EM_LIMITTEXT,
  962.                     CCHHEXLONGMAX, 0L);
  963.             SetCustomStylesField(hwnd, npcStyles->flStyle);
  964.             CheckStyleBoxes(hwnd, IC_WINDOW, npcStyles->flStyle);
  965.  
  966.             CenterWindow(hwnd);
  967.  
  968.             return TRUE;
  969.  
  970.         case WM_COMMAND:
  971.             switch (LOWORD(wParam)) {
  972.                 case DID_CUSTOMSTYLESSTYLES:
  973.                     if (HIWORD(wParam) == EN_CHANGE) {
  974.                         flStyleNew = GetCustomStylesField(hwnd);
  975.                         CheckStyleBoxes(hwnd, IC_WINDOW, flStyleNew);
  976.                     }
  977.  
  978.                     break;
  979.  
  980.                 case DID_WS_VISIBLE:
  981.                 case DID_WS_DISABLED:
  982.                 case DID_WS_GROUP:
  983.                 case DID_WS_TABSTOP:
  984.                     if (HIWORD(wParam) == BN_CLICKED) {
  985.                         flStyleNew = GetCustomStylesField(hwnd);
  986.                         QueryCheckedStyles(hwnd, IC_WINDOW, &flStyleNew);
  987.                         SetCustomStylesField(hwnd, flStyleNew);
  988.                     }
  989.  
  990.                     break;
  991.  
  992.                 case IDOK:
  993.                     flStyleNew = GetCustomStylesField(hwnd);
  994.  
  995.                     EndDialog(hwnd, IDOK);
  996.  
  997.                     return TRUE;
  998.  
  999.                 case IDCANCEL:
  1000.                     EndDialog(hwnd, IDCANCEL);
  1001.                     return TRUE;
  1002.  
  1003.                 case IDHELP:
  1004.                     StylesHelp();
  1005.                     break;
  1006.             }
  1007.  
  1008.             return FALSE;
  1009.  
  1010.         default:
  1011.             return FALSE;
  1012.     }
  1013. }
  1014.  
  1015.  
  1016.  
  1017. /************************************************************************
  1018. * SetCustomStylesField
  1019. *
  1020. * Sets the style bits in a custom control.
  1021. *
  1022. * Arguments:
  1023. *   HWND hwnd - handle to the custom control
  1024. *   DWORD flStyle - style of the custom control
  1025. *
  1026. ************************************************************************/
  1027.  
  1028. STATICFN VOID SetCustomStylesField(
  1029.     HWND hwnd,
  1030.     DWORD flStyle)
  1031. {
  1032.     TCHAR szBuf[32];
  1033.  
  1034.     wsprintf(szBuf, L"%#.8lx", flStyle);
  1035.     SetDlgItemText(hwnd, DID_CUSTOMSTYLESSTYLES, szBuf);
  1036. }
  1037.  
  1038.  
  1039.  
  1040. /************************************************************************
  1041. * GetCustomStylesField
  1042. *
  1043. * Gets the style bits of a custom control.
  1044. * Arguments:
  1045. *   HWND hwnd - handle to the custom control.
  1046. *
  1047. * Returns:
  1048. * The style bits specified for the custom control.
  1049. *
  1050. ************************************************************************/
  1051.  
  1052. STATICFN DWORD GetCustomStylesField(
  1053.     HWND hwnd)
  1054. {
  1055.     TCHAR szBuf[CCHTEXTMAX];
  1056.  
  1057.     GetDlgItemText(hwnd, DID_CUSTOMSTYLESSTYLES, szBuf, CCHTEXTMAX);
  1058.  
  1059.     return valtoi(szBuf);
  1060. }
  1061.  
  1062.  
  1063.  
  1064. /************************************************************************
  1065. * DialogStylesDlgProc
  1066. *
  1067. * Dialog procedure for a dialog box.
  1068. *
  1069. ************************************************************************/
  1070.  
  1071. DIALOGPROC DialogStylesDlgProc(
  1072.     HWND hwnd,
  1073.     UINT msg,
  1074.     WPARAM wParam,
  1075.     LPARAM lParam)
  1076. {
  1077.     DWORD flResFlagsNew;
  1078.     INT nPointSize;
  1079.     INT iLang;
  1080.     INT iSubLang;
  1081.     TCHAR szFontName[LF_FACESIZE];
  1082.     INT nIndex;
  1083.  
  1084.     switch (msg) {
  1085.         case WM_INITDIALOG:
  1086.             CheckStyleBoxes(hwnd, IC_RESFLAGS, (DWORD)diNew.fResFlags);
  1087.             CheckStyleBoxes(hwnd, IC_DIALOG, npcStyles->flStyle);
  1088.             CheckStyleBoxes(hwnd, IC_WINDOW, npcStyles->flStyle);
  1089.  
  1090.             if (IsDlgButtonChecked(hwnd, DID_WS_CAPTION)) {
  1091.                 CheckDlgButton(hwnd, DID_WS_BORDER, 1);
  1092.                 CheckDlgButton(hwnd, DID_WS_DLGFRAME, 1);
  1093.             }
  1094.  
  1095.             FillFontNameCombo(hwnd);
  1096.             FillLanguageCombo(hwnd);
  1097.  
  1098.             if (IsOrd(diNew.pszClass))
  1099.                 SetDlgItemInt(hwnd, DID_DLGSTYLECLASS,
  1100.                         OrdID(diNew.pszClass), FALSE);
  1101.             else
  1102.                 SetDlgItemText(hwnd, DID_DLGSTYLECLASS, diNew.pszClass);
  1103.  
  1104.             if (IsOrd(diNew.pszMenu))
  1105.                 SetDlgItemInt(hwnd, DID_DLGSTYLEMENU,
  1106.                         OrdID(diNew.pszMenu), FALSE);
  1107.             else
  1108.                 SetDlgItemText(hwnd, DID_DLGSTYLEMENU, diNew.pszMenu);
  1109.  
  1110.             EnableDialogStyles(hwnd, 0);
  1111.  
  1112.             CenterWindow(hwnd);
  1113.  
  1114.             return TRUE;
  1115.  
  1116.         case WM_COMMAND:
  1117.             switch (LOWORD(wParam)) {
  1118.                 case DID_WS_BORDER:
  1119.                 case DID_WS_DLGFRAME:
  1120.                 case DID_WS_CAPTION:
  1121.                 case DID_WS_POPUP:
  1122.                 case DID_WS_CHILD:
  1123.                     if (HIWORD(wParam) == BN_CLICKED)
  1124.                         EnableDialogStyles(hwnd,
  1125.                                 LOWORD(wParam));
  1126.  
  1127.                     return TRUE;
  1128.  
  1129.                 case DID_DLGSTYLEFONTNAME:
  1130.                     /*
  1131.                      * Did the font name combo change?
  1132.                      */
  1133.                     if (HIWORD(wParam) == CBN_EDITCHANGE ||
  1134.                             HIWORD(wParam) == CBN_SELCHANGE) {
  1135.                         /*
  1136.                          * Get the font name and begin looking for it.
  1137.                          */
  1138.                         if (HIWORD(wParam) == CBN_EDITCHANGE) {
  1139.                             /*
  1140.                              * The edit field was typed into.  Get the
  1141.                              * new text from there.
  1142.                              */
  1143.                             GetDlgItemText(hwnd, DID_DLGSTYLEFONTNAME,
  1144.                                     szFontName, LF_FACESIZE);
  1145.                         }
  1146.                         else {
  1147.                             /*
  1148.                              * A new string was selected from the list
  1149.                              * box.  Get it from the list box, because
  1150.                              * at this point the new text is not yet set
  1151.                              * into the edit control!
  1152.                              */
  1153.                             nIndex = (INT)SendDlgItemMessage(hwnd,
  1154.                                     DID_DLGSTYLEFONTNAME, CB_GETCURSEL, 0, 0L);
  1155.  
  1156.                             if (nIndex != CB_ERR)
  1157.                                 SendDlgItemMessage(hwnd,
  1158.                                         DID_DLGSTYLEFONTNAME, CB_GETLBTEXT,
  1159.                                         nIndex, (DWORD)szFontName);
  1160.                             else
  1161.                                 *szFontName = CHAR_NULL;
  1162.                         }
  1163.  
  1164.                         FillPointSizeCombo(hwnd, szFontName);
  1165.                     }
  1166.  
  1167.                     return TRUE;
  1168.  
  1169.                 case DID_DLGSTYLELANG:
  1170.                     /*
  1171.                      * Did the language combo change?
  1172.                      */
  1173.                     if (HIWORD(wParam) == CBN_SELCHANGE) {
  1174.                         nIndex = (INT)SendDlgItemMessage(hwnd,
  1175.                                 DID_DLGSTYLELANG, CB_GETCURSEL, 0, 0L);
  1176.                         iLang = (INT)SendDlgItemMessage(hwnd,
  1177.                                 DID_DLGSTYLELANG, CB_GETITEMDATA, nIndex, 0);
  1178.                         FillSubLanguageCombo(hwnd, iLang);
  1179.                     }
  1180.  
  1181.                     return TRUE;
  1182.  
  1183.                 case IDOK:
  1184.                     /*
  1185.                      * If they have entered a font name and an empty
  1186.                      * or zero point size, display an error.
  1187.                      */
  1188.                     nPointSize = GetDlgItemInt(
  1189.                             hwnd, DID_DLGSTYLEPOINTSIZE, NULL, FALSE);
  1190.                     if (!nPointSize &&
  1191.                             SendDlgItemMessage(hwnd,
  1192.                             DID_DLGSTYLEFONTNAME, WM_GETTEXTLENGTH, 0, 0L)) {
  1193.                         Message(MSG_ZEROPOINTSIZE);
  1194.                         SetFocus(GetDlgItem(hwnd, DID_DLGSTYLEPOINTSIZE));
  1195.                         return TRUE;
  1196.                     }
  1197.  
  1198.                     GetDlgItemText(hwnd, DID_DLGSTYLEFONTNAME,
  1199.                             diNew.szFontName, LF_FACESIZE);
  1200.                     diNew.nPointSize = nPointSize;
  1201.  
  1202.                     /*
  1203.                      * Get the Language.
  1204.                      */
  1205.                     nIndex = (INT)SendDlgItemMessage(hwnd,
  1206.                             DID_DLGSTYLELANG, CB_GETCURSEL, 0, 0L);
  1207.                     iLang = (INT)SendDlgItemMessage(hwnd,
  1208.                             DID_DLGSTYLELANG, CB_GETITEMDATA,
  1209.                             nIndex, 0);
  1210.                     nIndex = (INT)SendDlgItemMessage(hwnd,
  1211.                             DID_DLGSTYLESUBLANG, CB_GETCURSEL, 0, 0L);
  1212.                     iSubLang = (INT)SendDlgItemMessage(hwnd,
  1213.                             DID_DLGSTYLESUBLANG, CB_GETITEMDATA,
  1214.                             nIndex, 0);
  1215.                     diNew.wLanguage = MAKELANGID(gaLangTable[iLang].wPrimary,
  1216.                             gaLangTable[iLang].asl[iSubLang].wSubLang);
  1217.  
  1218.                     /*
  1219.                      * Get the resource flags.  We need to use a temporary
  1220.                      * long variable because QueryCheckedStyles requires
  1221.                      * a long.
  1222.                      */
  1223.                     flResFlagsNew = diNew.fResFlags;
  1224.                     QueryCheckedStyles(hwnd, IC_RESFLAGS, &flResFlagsNew);
  1225.                     diNew.fResFlags = (WORD)flResFlagsNew;
  1226.  
  1227.                     QueryCheckedStyles(hwnd, IC_DIALOG, &flStyleNew);
  1228.                     QueryCheckedStyles(hwnd, IC_WINDOW, &flStyleNew);
  1229.  
  1230.                     /*
  1231.                      * Set the DS_SETFONT style, if they specified
  1232.                      * a font.
  1233.                      */
  1234.                     if (*diNew.szFontName)
  1235.                         flStyleNew |= DS_SETFONT;
  1236.                     else
  1237.                         flStyleNew &= ~DS_SETFONT;
  1238.  
  1239.                     GetDlgItemText(hwnd, DID_DLGSTYLECLASS,
  1240.                             diNew.pszClass, CCHTEXTMAX);
  1241.  
  1242.                     /*
  1243.                      * Convert the class to an ordinal, if necessary.
  1244.                      */
  1245.                     StrToNameOrd(diNew.pszClass, FALSE);
  1246.  
  1247.                     GetDlgItemText(hwnd, DID_DLGSTYLEMENU,
  1248.                             diNew.pszMenu, CCHTEXTMAX);
  1249.  
  1250.                     /*
  1251.                      * Convert the menu name to an ordinal, if necessary.
  1252.                      */
  1253.                     StrToNameOrd(diNew.pszMenu, FALSE);
  1254.  
  1255.                     /*
  1256.                      * If they just removed the caption style,
  1257.                      * clear the dialog's caption text at the
  1258.                      * same time.
  1259.                      */
  1260.                     if ((npcStyles->flStyle & WS_CAPTION) == WS_CAPTION &&
  1261.                             (flStyleNew & WS_CAPTION) != WS_CAPTION)
  1262.                         *pszTextNew = CHAR_NULL;
  1263.  
  1264.                     EndDialog(hwnd, IDOK);
  1265.                     return TRUE;
  1266.  
  1267.                 case IDCANCEL:
  1268.                     EndDialog(hwnd, IDCANCEL);
  1269.                     return TRUE;
  1270.  
  1271.                 case IDHELP:
  1272.                     StylesHelp();
  1273.                     break;
  1274.             }
  1275.  
  1276.             return FALSE;
  1277.  
  1278.         default:
  1279.             return FALSE;
  1280.     }
  1281. }
  1282.  
  1283.  
  1284.  
  1285. /************************************************************************
  1286. * EnableDialogStyles
  1287. *
  1288. * Checks and unchecks various checkboxes that are mutually exclusive
  1289. * for the Dialog Styles dialog.
  1290. *
  1291. * Arguments:
  1292. *   HWND hwnd  - Dialog window handle.
  1293. *   INT idCtrl - ID of the control that was clicked on.
  1294. *
  1295. ************************************************************************/
  1296.  
  1297. STATICFN VOID EnableDialogStyles(
  1298.     HWND hwnd,
  1299.     INT idCtrl)
  1300. {
  1301.     switch (idCtrl) {
  1302.         case DID_WS_CAPTION:
  1303.             if (IsDlgButtonChecked(hwnd, DID_WS_CAPTION)) {
  1304.                 CheckDlgButton(hwnd, DID_WS_BORDER, 1);
  1305.                 CheckDlgButton(hwnd, DID_WS_DLGFRAME, 1);
  1306.             }
  1307.             else {
  1308.                 CheckDlgButton(hwnd, DID_WS_BORDER, 0);
  1309.                 CheckDlgButton(hwnd, DID_WS_DLGFRAME, 0);
  1310.             }
  1311.  
  1312.             break;
  1313.  
  1314.         case DID_WS_BORDER:
  1315.         case DID_WS_DLGFRAME:
  1316.             if (IsDlgButtonChecked(hwnd, DID_WS_BORDER) &&
  1317.                     IsDlgButtonChecked(hwnd, DID_WS_DLGFRAME))
  1318.                 CheckDlgButton(hwnd, DID_WS_CAPTION, 1);
  1319.             else
  1320.                 CheckDlgButton(hwnd, DID_WS_CAPTION, 0);
  1321.  
  1322.             break;
  1323.  
  1324.         case DID_WS_CHILD:
  1325.             if (IsDlgButtonChecked(hwnd, DID_WS_CHILD))
  1326.                 CheckDlgButton(hwnd, DID_WS_POPUP, 0);
  1327.  
  1328.             break;
  1329.  
  1330.         case DID_WS_POPUP:
  1331.             if (IsDlgButtonChecked(hwnd, DID_WS_POPUP))
  1332.                 CheckDlgButton(hwnd, DID_WS_CHILD, 0);
  1333.  
  1334.             break;
  1335.     }
  1336. }
  1337.  
  1338.  
  1339.  
  1340. /************************************************************************
  1341. * FillFontNameCombo
  1342. *
  1343. * Fills combo box with available fonts for dialog.
  1344. *
  1345. * Arguments:
  1346. *   HWND hwndDlg - Dialog window handle.
  1347. *
  1348. ************************************************************************/
  1349.  
  1350. STATICFN VOID FillFontNameCombo(
  1351.     HWND hwndDlg)
  1352. {
  1353.     HDC hDC;
  1354.     HWND hwndCombo;
  1355.     TCHAR szName1[LF_FACESIZE];
  1356.     TCHAR szName2[LF_FACESIZE];
  1357.     LPTSTR pszName;
  1358.     LPTSTR pszNameLast;
  1359.     LPTSTR pszNameTemp;
  1360.     INT iIndex;
  1361.     INT iItems;
  1362.  
  1363.     hwndCombo = GetDlgItem(hwndDlg, DID_DLGSTYLEFONTNAME);
  1364.  
  1365.     if (hDC = GetDC(ghwndMain)) {
  1366.         EnumFonts(hDC, NULL, (FONTENUMPROC) FontNameEnumFunc, (LPARAM)&hwndCombo);
  1367.         ReleaseDC(ghwndMain, hDC);
  1368.     }
  1369.  
  1370.     /*
  1371.      * Strip out any duplicate names in the combobox.  This routine
  1372.      * relies on the items being sorted first.
  1373.      */
  1374.     iItems = (INT)SendMessage(hwndCombo, CB_GETCOUNT, 0, 0);
  1375.     *szName1 = CHAR_NULL;
  1376.     *szName2 = CHAR_NULL;
  1377.     pszName = szName1;
  1378.     pszNameLast = szName2;
  1379.     for (iIndex = 0; iIndex < iItems;) {
  1380.         /*
  1381.          * Get the text of the next item.
  1382.          */
  1383.         SendMessage(hwndCombo, CB_GETLBTEXT, iIndex, (DWORD)pszName);
  1384.  
  1385.         /*
  1386.          * If it matches the previous item, delete it.  Otherwise,
  1387.          * flip the buffers to save the current items text and
  1388.          * go on to the next item.
  1389.          */
  1390.         if (lstrcmp(pszName, pszNameLast) == 0) {
  1391.             SendMessage(hwndCombo, CB_DELETESTRING, iIndex, 0);
  1392.             iItems--;
  1393.         }
  1394.         else {
  1395.             pszNameTemp = pszNameLast;
  1396.             pszNameLast = pszName;
  1397.             pszName = pszNameTemp;
  1398.             iIndex++;
  1399.         }
  1400.     }
  1401.  
  1402.     /*
  1403.      * Initialize the font fields.  The order the fields are set
  1404.      * is important, because setting the face name clears out the
  1405.      * point size combo.
  1406.      */
  1407.     SetDlgItemText(hwndDlg, DID_DLGSTYLEFONTNAME, diNew.szFontName);
  1408.     FillPointSizeCombo(hwndDlg, diNew.szFontName);
  1409. }
  1410.  
  1411.  
  1412.  
  1413. /************************************************************************
  1414. * FontNameEnumFunc
  1415. *
  1416. * Enumeration function that adds all the font face names to the
  1417. * Font Face Name combo box in the Dialog Styles dialog.
  1418. *
  1419. * Arguments:
  1420. *   LPLOGFONT lpLogFont - pointer to font structure
  1421. *   LPTEXTMETRIC lpTextMetric - pointer to textmetric struct for font
  1422. *   INT nFontType - type of font
  1423. *   LPVOID lpData - font data
  1424. *
  1425. ************************************************************************/
  1426.  
  1427. BOOL APIENTRY FontNameEnumFunc(
  1428.     LPLOGFONT lpLogFont,
  1429.     LPTEXTMETRIC lpTextMetric,
  1430.     INT nFontType,
  1431.     LPVOID lpData)
  1432. {
  1433.     /*
  1434.      * Add this name to the combo box.
  1435.      */
  1436.     SendMessage(*((LPHWND)lpData), CB_ADDSTRING, 0,
  1437.             (DWORD)lpLogFont->lfFaceName);
  1438.  
  1439.     /*
  1440.      * Keep on going...
  1441.      */
  1442.     return TRUE;
  1443. }
  1444.  
  1445.  
  1446.  
  1447. /************************************************************************
  1448. * FillPointSizeCombo
  1449. *
  1450. * This function fills the Point Size combobox with the point sizes
  1451. * that are available for the given face name.  It should be called
  1452. * whenever the Font Name combobox is changed to keep them in sync.
  1453. *
  1454. * Arguments:
  1455. *   HWND hwndDlg        - Dialog window handle.
  1456. *   LPTSTR pszFaceName  - Face name for the selected font.
  1457. *
  1458. ************************************************************************/
  1459.  
  1460. STATICFN VOID FillPointSizeCombo(
  1461.     HWND hwndDlg,
  1462.     LPTSTR pszFaceName)
  1463. {
  1464.     HDC hDC;
  1465.     HWND hwndCombo;
  1466.  
  1467.     hwndCombo = GetDlgItem(hwndDlg, DID_DLGSTYLEPOINTSIZE);
  1468.     SendMessage(hwndCombo, CB_RESETCONTENT, 0, 0L);
  1469.  
  1470.     if (*pszFaceName && (hDC = GetDC(ghwndMain))) {
  1471.         EnumFonts(hDC, pszFaceName, (FONTENUMPROC) PointSizeEnumFunc, (LPARAM)&hwndCombo);
  1472.         ReleaseDC(ghwndMain, hDC);
  1473.     }
  1474.  
  1475.     /*
  1476.      * Select a default one.  This is the point size that is currently
  1477.      * selected if the face name is the current one, or else it is the
  1478.      * first point size in the list.
  1479.      */
  1480.     if (gcd.fFontSpecified && lstrcmp(pszFaceName, gcd.di.szFontName) == 0)
  1481.         SetDlgItemInt(hwndDlg, DID_DLGSTYLEPOINTSIZE, gcd.di.nPointSize, FALSE);
  1482.     else
  1483.         SendDlgItemMessage(hwndDlg, DID_DLGSTYLEPOINTSIZE,
  1484.                 CB_SETCURSEL, 0, 0L);
  1485. }
  1486.  
  1487.  
  1488.  
  1489. /************************************************************************
  1490. * PointSizeEnumFunc
  1491. *
  1492. * Enumeration function that adds all the point sizes to the
  1493. * Pt. Size combo box in the Dialog Styles dialog.
  1494. *
  1495. * Arguments:
  1496. *   LPLOGFONT lpLogFont - pointer to font structure
  1497. *   LPTEXTMETRIC lpTextMetric - pointer to textmetric struct for font
  1498. *   INT nFontType - type of font
  1499. *   LPVOID lpData - font data
  1500. *
  1501. ************************************************************************/
  1502.  
  1503. BOOL APIENTRY PointSizeEnumFunc(
  1504.     LPLOGFONT lpLogFont,
  1505.     LPTEXTMETRIC lpTextMetric,
  1506.     INT nFontType,
  1507.     LPVOID lpData)
  1508. {
  1509.     HWND hwndCombo;
  1510.     INT nPointSize;
  1511.  
  1512.     hwndCombo = *((LPHWND)lpData);
  1513.  
  1514.     if (nFontType == RASTER_FONTTYPE) {
  1515.         /*
  1516.          * Convert the pixels to point size.  Note that because of the
  1517.          * definition of the tmHeight field, the tmInternalLeading has
  1518.          * to be subtracted from it before converting to get the proper
  1519.          * font point size.  This is done automatically by the Windows
  1520.          * CreateFont call if you pass in a nHeight parameter that is
  1521.          * negative, so be aware of this when doing the reverse calculation
  1522.          * to create a font of the proper height!
  1523.          */
  1524.         nPointSize = PixelsToPointSize(
  1525.                 lpTextMetric->tmHeight - lpTextMetric->tmInternalLeading);
  1526.  
  1527.         AddToPointSizeCombo(hwndCombo, nPointSize);
  1528.     }
  1529.     else {
  1530.         /*
  1531.          * For scalable (TrueType, ATM or vector) fonts, add the
  1532.          * common point sizes.  This list was pulled out of the
  1533.          ( commdlg.dll Font dialog.
  1534.          */
  1535.         AddToPointSizeCombo(hwndCombo, 8);
  1536.         AddToPointSizeCombo(hwndCombo, 9);
  1537.         AddToPointSizeCombo(hwndCombo, 10);
  1538.         AddToPointSizeCombo(hwndCombo, 11);
  1539.         AddToPointSizeCombo(hwndCombo, 12);
  1540.         AddToPointSizeCombo(hwndCombo, 14);
  1541.         AddToPointSizeCombo(hwndCombo, 16);
  1542.         AddToPointSizeCombo(hwndCombo, 18);
  1543.         AddToPointSizeCombo(hwndCombo, 20);
  1544.         AddToPointSizeCombo(hwndCombo, 22);
  1545.         AddToPointSizeCombo(hwndCombo, 24);
  1546.         AddToPointSizeCombo(hwndCombo, 26);
  1547.         AddToPointSizeCombo(hwndCombo, 28);
  1548.         AddToPointSizeCombo(hwndCombo, 36);
  1549.         AddToPointSizeCombo(hwndCombo, 48);
  1550.         AddToPointSizeCombo(hwndCombo, 72);
  1551.     }
  1552.  
  1553.     /*
  1554.      * Keep on going...
  1555.      */
  1556.     return TRUE;
  1557. }
  1558.  
  1559.  
  1560.  
  1561. /************************************************************************
  1562. * AddToPointSizeCombo
  1563. *
  1564. * This function adds a point size to the point size combobox.
  1565. * It does not allow duplicate point sizes, and the sizes will
  1566. * be inserted in order.
  1567. *
  1568. * Arguments:
  1569. *   HWND hwndCombo - The combobox window handle.
  1570. *   INT nPointSize - The point size to add.
  1571. *
  1572. ************************************************************************/
  1573.  
  1574. STATICFN VOID AddToPointSizeCombo(
  1575.     HWND hwndCombo,
  1576.     INT nPointSize)
  1577. {
  1578.     TCHAR szPointSize[31];
  1579.     INT nPoints2;
  1580.     INT iIndex;
  1581.     INT iIndexAdd;
  1582.     INT iItems;
  1583.  
  1584.     iItems = (INT)SendMessage(hwndCombo, CB_GETCOUNT, 0, 0);
  1585.     for (iIndex = 0, iIndexAdd = -1; iIndex < iItems; iIndex++) {
  1586.         nPoints2 = (INT)SendMessage(hwndCombo, CB_GETITEMDATA, iIndex, 0);
  1587.  
  1588.         if (nPoints2 == nPointSize) {
  1589.             /*
  1590.              * A duplicate was found.  Skip this one.
  1591.              */
  1592.             return;
  1593.         }
  1594.         else if (nPoints2 > nPointSize) {
  1595.             iIndexAdd = iIndex;
  1596.             break;
  1597.         }
  1598.     }
  1599.  
  1600.     /*
  1601.      * Add this point size to the combo box.
  1602.      */
  1603.     itoaw(nPointSize, szPointSize, 10);
  1604.     iIndex = (INT)SendMessage(hwndCombo, CB_INSERTSTRING,
  1605.             iIndexAdd, (DWORD)szPointSize);
  1606.     SendMessage(hwndCombo, CB_SETITEMDATA, iIndex, (DWORD)nPointSize);
  1607. }
  1608.  
  1609.  
  1610.  
  1611. /************************************************************************
  1612. * FillLanguageCombo
  1613. *
  1614. * This function fills the Language combobox with the known languages.
  1615. *
  1616. * Arguments:
  1617. *   HWND hwndDlg - Dialog window handle.
  1618. *
  1619. ************************************************************************/
  1620.  
  1621. STATICFN VOID FillLanguageCombo(
  1622.     HWND hwndDlg)
  1623. {
  1624.     HWND hwndCombo;
  1625.     INT i;
  1626.     INT iIndex;
  1627.     INT iSel;
  1628.     INT iLang;
  1629.     WORD wPrimary;
  1630.  
  1631.     hwndCombo = GetDlgItem(hwndDlg, DID_DLGSTYLELANG);
  1632.     SendMessage(hwndCombo, CB_RESETCONTENT, 0, 0L);
  1633.  
  1634.     for (i = 0; i < gcLanguages; i++) {
  1635.         iIndex = (INT)SendMessage(hwndCombo, CB_ADDSTRING,
  1636.                 0, (DWORD)ids(gaLangTable[i].idsLangDesc));
  1637.         SendMessage(hwndCombo, CB_SETITEMDATA, iIndex, (DWORD)i);
  1638.     }
  1639.  
  1640.     wPrimary = (WORD)PRIMARYLANGID(diNew.wLanguage);
  1641.     for (i = 0, iSel = 0; i < gcLanguages; i++) {
  1642.         iLang = (INT)SendMessage(hwndCombo, CB_GETITEMDATA, i, 0);
  1643.  
  1644.         if (gaLangTable[iLang].wPrimary == wPrimary) {
  1645.             iSel = i;
  1646.             break;
  1647.         }
  1648.     }
  1649.  
  1650.     SendMessage(hwndCombo, CB_SETCURSEL, iSel, 0L);
  1651.  
  1652.     FillSubLanguageCombo(hwndDlg,
  1653.             (INT)SendMessage(hwndCombo, CB_GETITEMDATA, iSel, 0));
  1654. }
  1655.  
  1656.  
  1657.  
  1658. /************************************************************************
  1659. * FillSubLanguageCombo
  1660. *
  1661. * This function fills the Sub-Language combobox with the sub-languages
  1662. * for the specified language.
  1663. *
  1664. * Arguments:
  1665. *   HWND hwndDlg - Dialog window handle.
  1666. *   INT iLang    - Index to the language in the language table.
  1667. *
  1668. ************************************************************************/
  1669.  
  1670. STATICFN VOID FillSubLanguageCombo(
  1671.     HWND hwndDlg,
  1672.     INT iLang)
  1673. {
  1674.     HWND hwndCombo;
  1675.     INT i;
  1676.     INT iIndex;
  1677.     INT iSel = 0;
  1678.     WORD wSubLang;
  1679.  
  1680.     hwndCombo = GetDlgItem(hwndDlg, DID_DLGSTYLESUBLANG);
  1681.     SendMessage(hwndCombo, CB_RESETCONTENT, 0, 0L);
  1682.  
  1683.     for (i = 0; i < gaLangTable[iLang].cSubLangs; i++) {
  1684.         iIndex = (INT)SendMessage(hwndCombo, CB_ADDSTRING, 0,
  1685.                 (DWORD)ids(gaLangTable[iLang].asl[i].idsSubLangDesc));
  1686.         SendMessage(hwndCombo, CB_SETITEMDATA, iIndex, (DWORD)i);
  1687.     }
  1688.  
  1689.     /*
  1690.      * Is this the language set for the dialog?  If so, find the
  1691.      * sublanguage and make that the default.
  1692.      */
  1693.     if (gaLangTable[iLang].wPrimary == (WORD)PRIMARYLANGID(diNew.wLanguage)) {
  1694.         wSubLang = SUBLANGID(diNew.wLanguage);
  1695.         for (i = 0; i < gaLangTable[iLang].cSubLangs; i++) {
  1696.             iIndex = (INT)SendMessage(hwndCombo, CB_GETITEMDATA, i, 0);
  1697.             if (wSubLang == gaLangTable[iLang].asl[iIndex].wSubLang) {
  1698.                 iSel = i;
  1699.                 break;
  1700.             }
  1701.         }
  1702.     }
  1703.  
  1704.     SendMessage(hwndCombo, CB_SETCURSEL, iSel, 0L);
  1705. }
  1706.  
  1707.  
  1708.  
  1709. /************************************************************************
  1710. * CheckStyleBoxes
  1711. *
  1712. * This function takes the given style and checks the appropriate
  1713. * check boxes and radio buttons in the styles dialog.  The iClass
  1714. * determines the lookup table to use.
  1715. *
  1716. * Arguments:
  1717. *   HWND hwnd     - Dialog window handle.
  1718. *   INT iClass    - Control class (determines the style lookup table).
  1719. *   DWORD flStyle - Style of the control.
  1720. *
  1721. ************************************************************************/
  1722.  
  1723. STATICFN VOID CheckStyleBoxes(
  1724.     HWND hwnd,
  1725.     INT iClass,
  1726.     DWORD flStyle)
  1727. {
  1728.     register INT i;
  1729.     PCLASSSTYLE pcs;
  1730.     HWND hwndControl;
  1731.     DWORD flStyleMask;
  1732.  
  1733.     i = acsd[iClass].cClassStyles;
  1734.     pcs = acsd[iClass].pacs;
  1735.  
  1736.     while (i--) {
  1737.         /*
  1738.          * Is there a DID_* defined for this style?
  1739.          */
  1740.         if (pcs->idControl) {
  1741.             /*
  1742.              * Does the dialog have a control with this id?
  1743.              */
  1744.             if (hwndControl = GetDlgItem(hwnd, pcs->idControl)) {
  1745.                 flStyleMask =
  1746.                         pcs->flStyleMask ? pcs->flStyleMask : pcs->flStyle;
  1747.  
  1748.                 /*
  1749.                  * If there is a match, check the box.  Otherwise,
  1750.                  * uncheck it.
  1751.                  */
  1752.                 SendMessage(hwndControl, BM_SETCHECK,
  1753.                         ((flStyle & flStyleMask) == pcs->flStyle) ? 1 : 0,
  1754.                         0L);
  1755.             }
  1756.         }
  1757.  
  1758.         pcs++;
  1759.     }
  1760. }
  1761.  
  1762.  
  1763.  
  1764. /************************************************************************
  1765. * QueryCheckedStyles
  1766. *
  1767. * This function returns the new style that the user has selected from
  1768. * dialog.  It reads all the checkboxes and builds up the style.
  1769. * Upon entry, the DWORD that is at pflStyle should be set to the
  1770. * original style for the control.  Chosen bits will be masked off
  1771. * and set as appropriate.  This allows bits that are not settable
  1772. * from within this styles dialog to be left untouched.
  1773. *
  1774. * Arguments:
  1775. *   HWND hwnd       - Dialog window handle.
  1776. *   INT iClass      - Control class (determines the style lookup table).
  1777. *   DWORD *pflStyle - Where to return the style of the control.  What
  1778. *                     this points to should initially have the original
  1779. *                     styles of the control.
  1780. *
  1781. ************************************************************************/
  1782.  
  1783. STATICFN VOID QueryCheckedStyles(
  1784.     HWND hwnd,
  1785.     INT iClass,
  1786.     DWORD *pflStyle)
  1787. {
  1788.     register INT i;
  1789.     PCLASSSTYLE pcs;
  1790.     HWND hwndControl;
  1791.     DWORD flStyleMask;
  1792.     DWORD flStyle;
  1793.  
  1794.     /*
  1795.      * The first step is to strip off all bits that may be changed by
  1796.      * the current dialog.
  1797.      */
  1798.     flStyle = *pflStyle;
  1799.     i = acsd[iClass].cClassStyles;
  1800.     pcs = acsd[iClass].pacs;
  1801.     while (i--) {
  1802.         /*
  1803.          * Is this a style that is settable by a dialog, and does the
  1804.          * current dialog have this style control?
  1805.          */
  1806.         if (pcs->idControl && GetDlgItem(hwnd, pcs->idControl)) {
  1807.             flStyleMask =
  1808.                     pcs->flStyleMask ? pcs->flStyleMask : pcs->flStyle;
  1809.  
  1810.             /*
  1811.              * Strip off all bits in the mask for this style.
  1812.              */
  1813.             flStyle &= ~flStyleMask;
  1814.         }
  1815.  
  1816.         pcs++;
  1817.     }
  1818.  
  1819.     /*
  1820.      * Now we go through all bits that may be set and set any that the
  1821.      * user has selected.
  1822.      */
  1823.     i = acsd[iClass].cClassStyles;
  1824.     pcs = acsd[iClass].pacs;
  1825.     while (i--) {
  1826.         if (pcs->idControl &&
  1827.                 (hwndControl = GetDlgItem(hwnd, pcs->idControl))) {
  1828.             if (SendMessage(hwndControl, BM_GETCHECK, 0, 0L))
  1829.                 flStyle |= pcs->flStyle;
  1830.         }
  1831.  
  1832.         pcs++;
  1833.     }
  1834.  
  1835.     *pflStyle = flStyle;
  1836. }
  1837.  
  1838.  
  1839.  
  1840. /************************************************************************
  1841. * StylesHelp
  1842. *
  1843. * This function shows the appropriate help context from any of the
  1844. * styles dialogs.  It uses the type of control in npcStyles to
  1845. * determine what help to show.
  1846. *
  1847. ************************************************************************/
  1848.  
  1849. STATICFN VOID StylesHelp(VOID)
  1850. {
  1851.     WinHelp(ghwndMain, gszHelpFile, HELP_CONTEXT,
  1852.             npcStyles->pwcd->HelpContext);
  1853. }
  1854.