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 / uconvert / dialogs.c next >
C/C++ Source or Header  |  1997-10-05  |  18KB  |  531 lines

  1. /**************************************************************************\
  2. * dialogs.c -- dialog procedure support for uconvert
  3. *
  4. *         Steve Firebaugh
  5. *         Microsoft Developer Support
  6. *         Copyright (c) 1992-1997 Microsoft Corporation
  7. *
  8. \**************************************************************************/
  9. #define UNICODE
  10.  
  11.  
  12. #include <windows.h>
  13. #include "uconvert.h"
  14. #include "install.h"
  15.  
  16.  
  17. /* Define affecting the positioning of child windows in dialog. */
  18. #define DLGBORDER    GetSystemMetrics (SM_CXFRAME)*2
  19.  
  20.  
  21. /***************************************************************************\
  22. *    FUNCTION: ConversionOptionsProc
  23. *
  24. * Fill Dlg with state information on WM_INITDIALOG.
  25. *  Take it back down and change internal state on WM_COMMAND, IDOK.
  26. *
  27. * Global variables:
  28. *  gMBFlags
  29. *  gWCFlags
  30. *  glpDefaultChar
  31. *  glpUsedDefaultChar
  32. *
  33. \***************************************************************************/
  34. LRESULT CALLBACK ConversionOptionsProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  35. {
  36.  
  37.   switch (message) {
  38.  
  39.     /******************************************************************\
  40.     *  WM_INITDIALOG
  41.     *
  42.     * Set radio buttons appropriately.
  43.     \******************************************************************/
  44.     case WM_INITDIALOG:
  45.       if (gMBFlags & MB_PRECOMPOSED)
  46.         SendDlgItemMessage (hwnd, DID_PRECOMPOSED, BM_SETCHECK, 1, 0);
  47.  
  48.       if (gMBFlags & MB_COMPOSITE)
  49.         SendDlgItemMessage (hwnd, DID_COMPOSITE, BM_SETCHECK, 1, 0);
  50.  
  51.       if (gMBFlags & MB_USEGLYPHCHARS)
  52.         SendDlgItemMessage (hwnd, DID_USEGLYPHCHARS, BM_SETCHECK, 1, 0);
  53.  
  54.       if (gWCFlags & WC_COMPOSITECHECK)
  55.         SendDlgItemMessage (hwnd, DID_COMPOSITECHECK, BM_SETCHECK, 1, 0);
  56.  
  57.       if (gWCFlags & WC_DISCARDNS)
  58.         SendDlgItemMessage (hwnd, DID_DISCARDNS, BM_SETCHECK, 1, 0);
  59.  
  60.       if (gWCFlags & WC_SEPCHARS)
  61.         SendDlgItemMessage (hwnd, DID_SEPCHARS, BM_SETCHECK, 1, 0);
  62.  
  63.       if (gWCFlags & WC_DEFAULTCHAR)
  64.         SendDlgItemMessage (hwnd, DID_DEFAULTCHAR, BM_SETCHECK, 1, 0);
  65.  
  66.       SendDlgItemMessage (hwnd, DID_EFDEFAULTCHAR, EM_LIMITTEXT, 1, 0);
  67.       SetDlgItemTextA (hwnd, DID_EFDEFAULTCHAR, glpDefaultChar);
  68.  
  69.       if (gUsedDefaultChar)
  70.         SendDlgItemMessage (hwnd, DID_USEDDEFAULTCHAR, BM_SETCHECK, 1, 0);
  71.  
  72.  
  73.       SetFocus (GetDlgItem (hwnd, IDOK));
  74.     return FALSE;
  75.  
  76.  
  77.     case WM_COMMAND:
  78.       switch (LOWORD (wParam)) {
  79.         case IDCANCEL:
  80.           EndDialog (hwnd, FALSE);
  81.         break;
  82.  
  83.         /******************************************************************\
  84.         *  WM_COMMAND, IDOK
  85.         *
  86.         * Get state from radio buttons and others.
  87.         \******************************************************************/
  88.         case IDOK: {
  89.  
  90.           if (SendDlgItemMessage(hwnd, DID_PRECOMPOSED, BM_GETCHECK, 0,0))
  91.             gMBFlags |= MB_PRECOMPOSED;
  92.           else
  93.             gMBFlags &= ~MB_PRECOMPOSED;
  94.  
  95.           if (SendDlgItemMessage(hwnd, DID_COMPOSITE, BM_GETCHECK, 0,0))
  96.             gMBFlags |= MB_COMPOSITE;
  97.           else
  98.             gMBFlags &= ~MB_COMPOSITE;
  99.  
  100.           if (SendDlgItemMessage(hwnd, DID_USEGLYPHCHARS, BM_GETCHECK, 0,0))
  101.             gMBFlags |= MB_USEGLYPHCHARS;
  102.           else
  103.             gMBFlags &= ~MB_USEGLYPHCHARS;
  104.  
  105.           if (SendDlgItemMessage(hwnd, DID_DISCARDNS, BM_GETCHECK, 0,0))
  106.             gWCFlags |= WC_DISCARDNS;
  107.           else
  108.             gWCFlags &= ~WC_DISCARDNS;
  109.  
  110.           if (SendDlgItemMessage(hwnd, DID_COMPOSITECHECK, BM_GETCHECK, 0,0))
  111.             gWCFlags |= WC_COMPOSITECHECK;
  112.           else
  113.             gWCFlags &= ~WC_COMPOSITECHECK;
  114.  
  115.           if (SendDlgItemMessage(hwnd, DID_SEPCHARS, BM_GETCHECK, 0,0))
  116.             gWCFlags |= WC_SEPCHARS;
  117.           else
  118.             gWCFlags &= ~WC_SEPCHARS;
  119.  
  120.           if (SendDlgItemMessage(hwnd, DID_DEFAULTCHAR, BM_GETCHECK, 0,0))
  121.             gWCFlags |= WC_DEFAULTCHAR;
  122.           else
  123.             gWCFlags &= ~WC_DEFAULTCHAR;
  124.  
  125.           GetDlgItemTextA (hwnd, DID_EFDEFAULTCHAR, glpDefaultChar, 2); // CHAR + NULL
  126.  
  127.           EndDialog (hwnd, TRUE);
  128.         } break;
  129.  
  130.  
  131.         /******************************************************************\
  132.         *  WM_COMMAND, DID_*
  133.         *
  134.         * Manage radio button pattern.
  135.         \******************************************************************/
  136.         case DID_PRECOMPOSED:
  137.           SendDlgItemMessage (hwnd, DID_PRECOMPOSED, BM_SETCHECK, TRUE, 0);
  138.           SendDlgItemMessage (hwnd, DID_COMPOSITE,   BM_SETCHECK, FALSE, 0);
  139.         break;
  140.  
  141.         case DID_COMPOSITE:
  142.           SendDlgItemMessage (hwnd, DID_PRECOMPOSED, BM_SETCHECK, FALSE, 0);
  143.           SendDlgItemMessage (hwnd, DID_COMPOSITE,   BM_SETCHECK, TRUE, 0);
  144.         break;
  145.  
  146.       }
  147.     break; /* end WM_COMMAND */
  148.  
  149.  
  150.  
  151.     case WM_SYSCOMMAND:
  152.       if (LOWORD (wParam) == SC_CLOSE)
  153.           EndDialog (hwnd, FALSE);
  154.     break;
  155.  
  156.   } /* end switch */
  157.   return FALSE;
  158. }
  159.  
  160.  
  161.  
  162. /***************************************************************************\
  163. *    FUNCTION: SourceOptionsProc
  164. *
  165. * Fill Dlg with state information on WM_INITDIALOG.
  166. *  Take it back down and change internal state on WM_COMMAND, IDOK.
  167. *
  168. * Global variables:
  169. *   gTypeSource
  170. *   giSourceCodePage
  171. *   giDestinationCodePage
  172. *
  173. \***************************************************************************/
  174. LRESULT CALLBACK SourceOptionsProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  175. {
  176. TCHAR buffer[50];
  177.  
  178.   switch (message) {
  179.  
  180.     /******************************************************************\
  181.     *  WM_INITDIALOG
  182.     *
  183.     * Set radio buttons appropriately.
  184.     \******************************************************************/
  185.     case WM_INITDIALOG:
  186.       SetWindowText (hwnd, LoadResourceString(IDS_INTERPRET_SOURCE_AS));
  187.       ListInstalledTables (GetDlgItem (hwnd, DID_CODEPAGELIST),CB_ADDSTRING, TRUE);
  188.       if (gTypeSource == TYPEUNICODE)
  189.         SendDlgItemMessage (hwnd, DID_RBUNICODE, BM_SETCHECK, 1, 0);
  190.  
  191.       /*
  192.        * if gTypeSource == TYPECODEPAGE, then see if it is one of the
  193.        *  standard radio buttons.  If so, check the right one.
  194.        *  if not, check, "other" and select correct entry in combobox.
  195.        */
  196.       else if (gTypeSource == TYPECODEPAGE) {
  197.         if (giSourceCodePage == GetACP())
  198.           SendDlgItemMessage (hwnd, DID_RBANSICP, BM_SETCHECK, 1, 0);
  199.         else if (giSourceCodePage == GetOEMCP())
  200.           SendDlgItemMessage (hwnd, DID_RBOEMCP, BM_SETCHECK, 1, 0);
  201.         else {
  202.           SendDlgItemMessage (hwnd, DID_RBOTHERCP, BM_SETCHECK, 1, 0);
  203.           wsprintf (buffer, TEXT("%d"), giSourceCodePage);
  204.           SendDlgItemMessage (hwnd, DID_CODEPAGELIST, CB_SELECTSTRING, 0, (LPARAM)buffer);
  205.         }
  206.       } else {
  207.         // OK to not be specified here.  Wait for user to make choice.
  208.       }
  209.  
  210.  
  211.       SetFocus (GetDlgItem (hwnd, IDOK));
  212.     return FALSE;
  213.  
  214.  
  215.     case WM_COMMAND:
  216.       switch (LOWORD (wParam)) {
  217.         case IDCANCEL:
  218.           EndDialog (hwnd, FALSE);
  219.         break;
  220.  
  221.         /******************************************************************\
  222.         *  WM_COMMAND, IDOK
  223.         *
  224.         * Get state from radio buttons and others.
  225.         \******************************************************************/
  226.         case IDOK: {
  227.           BOOL success;
  228.  
  229.           if (SendDlgItemMessage(hwnd, DID_RBUNICODE, BM_GETCHECK, 0,0)) {
  230.             gTypeSource = TYPEUNICODE;
  231.           } else if (SendDlgItemMessage(hwnd, DID_RBANSICP, BM_GETCHECK, 0,0)) {
  232.             gTypeSource = TYPECODEPAGE;
  233.             giSourceCodePage=GetACP();
  234.           } else if (SendDlgItemMessage(hwnd, DID_RBOEMCP, BM_GETCHECK, 0,0)) {
  235.             gTypeSource = TYPECODEPAGE;
  236.             giSourceCodePage=GetOEMCP();
  237.           } else if (SendDlgItemMessage(hwnd, DID_RBOTHERCP, BM_GETCHECK, 0,0)) {
  238.             gTypeSource = TYPECODEPAGE;
  239.             giSourceCodePage=GetDlgItemInt (hwnd, DID_CODEPAGELIST, &success, FALSE);
  240.           } else
  241.             gTypeSource = TYPEUNKNOWN;
  242.           EndDialog (hwnd, TRUE);
  243.         } break;
  244.       }
  245.     break; /* end WM_COMMAND */
  246.  
  247.  
  248.     case WM_SYSCOMMAND:
  249.       if (LOWORD (wParam) == SC_CLOSE)
  250.           EndDialog (hwnd, FALSE);
  251.     break;
  252.  
  253.   } /* end switch */
  254.   return FALSE;
  255. }
  256.  
  257. /***************************************************************************\
  258. *    FUNCTION: DestinationOptionsProc
  259. *
  260. * Fill Dlg with state information on WM_INITDIALOG.
  261. *  Take it back down and change internal state on WM_COMMAND, IDOK.
  262. *
  263. *
  264. * Global variables:
  265. *   gTypeSource
  266. *   giSourceCodePage
  267. *   giDestinationCodePage
  268. *
  269. \***************************************************************************/
  270. LRESULT CALLBACK DestinationOptionsProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  271. {
  272. TCHAR buffer[50];
  273.  
  274.   switch (message) {
  275.  
  276.     /******************************************************************\
  277.     *  WM_INITDIALOG
  278.     *
  279.     * Set radio buttons appropriately.
  280.     \******************************************************************/
  281.     case WM_INITDIALOG:
  282.       SetWindowText (hwnd, LoadResourceString(IDS_CONVERT_DEST_TO));
  283.       ListInstalledTables (GetDlgItem (hwnd, DID_CODEPAGELIST),CB_ADDSTRING, TRUE);
  284.  
  285.       /* if source is unicode, destination will be code page. */
  286.       if (gTypeSource == TYPEUNICODE) {
  287.         EnableWindow (GetDlgItem (hwnd, DID_RBUNICODE), FALSE);
  288.  
  289.         if (giDestinationCodePage == GetACP())
  290.           SendDlgItemMessage (hwnd, DID_RBANSICP, BM_SETCHECK, 1, 0);
  291.         else if (giDestinationCodePage == GetOEMCP())
  292.           SendDlgItemMessage (hwnd, DID_RBOEMCP, BM_SETCHECK, 1, 0);
  293.         else {
  294.           SendDlgItemMessage (hwnd, DID_RBOTHERCP, BM_SETCHECK, 1, 0);
  295.           wsprintf (buffer, TEXT("%d"), giDestinationCodePage);
  296.           SendDlgItemMessage (hwnd, DID_CODEPAGELIST, CB_SELECTSTRING, 0, (LPARAM)buffer);
  297.         }
  298.  
  299.       /* otherwise destination is unicode, so disable most of the checkboxes. */
  300.       } else if (gTypeSource == TYPECODEPAGE) {
  301.         SendDlgItemMessage (hwnd, DID_RBUNICODE, BM_SETCHECK, 1, 0);
  302.         EnableWindow (GetDlgItem (hwnd, DID_RBANSICP), FALSE);
  303.         EnableWindow (GetDlgItem (hwnd, DID_RBOEMCP), FALSE);
  304.         EnableWindow (GetDlgItem (hwnd, DID_RBOTHERCP), FALSE);
  305.         EnableWindow (GetDlgItem (hwnd, DID_CODEPAGELIST), FALSE);
  306.       } else {
  307.         EndDialog (hwnd, FALSE);  // shouldn't get here.
  308.       }
  309.  
  310.       SetFocus (GetDlgItem (hwnd, IDOK));
  311.     return FALSE;
  312.  
  313.  
  314.     case WM_COMMAND:
  315.       switch (LOWORD (wParam)) {
  316.         case IDCANCEL:
  317.           EndDialog (hwnd, FALSE);
  318.         break;
  319.  
  320.         /******************************************************************\
  321.         *  WM_COMMAND, IDOK
  322.         *
  323.         * Get state from radio buttons and others.
  324.         \******************************************************************/
  325.         case IDOK: {
  326.           BOOL success;
  327.           if (SendDlgItemMessage(hwnd, DID_RBUNICODE, BM_GETCHECK, 0,0)) {
  328.             // Do nothing. gTypeSource already implies dest <-> unicode.
  329.           } else if (SendDlgItemMessage(hwnd, DID_RBANSICP, BM_GETCHECK, 0,0)) {
  330.             giDestinationCodePage=GetACP();
  331.           } else if (SendDlgItemMessage(hwnd, DID_RBOEMCP, BM_GETCHECK, 0,0)) {
  332.             giDestinationCodePage=GetOEMCP();
  333.           } else if (SendDlgItemMessage(hwnd, DID_RBOTHERCP, BM_GETCHECK, 0,0)) {
  334.             giDestinationCodePage=GetDlgItemInt (hwnd, DID_CODEPAGELIST, &success, FALSE);
  335.           }
  336.  
  337.           EndDialog (hwnd, TRUE);
  338.         } break;
  339.       }
  340.     break; /* end WM_COMMAND */
  341.  
  342.     case WM_SYSCOMMAND:
  343.       if (LOWORD (wParam) == SC_CLOSE)
  344.           EndDialog (hwnd, FALSE);
  345.     break;
  346.  
  347.   } /* end switch */
  348.   return FALSE;
  349. }
  350.  
  351.  
  352. /***************************************************************************\
  353. *    FUNCTION: ViewSourceProc
  354. *
  355. * Fill Text, Name, and Type information into the dialog.
  356. *  Set a proper font to display the text depending on what type it is.
  357. *
  358. \***************************************************************************/
  359. LRESULT CALLBACK ViewSourceProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  360. {
  361. RECT rect;
  362.  
  363.   switch (message) {
  364.  
  365.     /******************************************************************\
  366.     *  WM_INITDIALOG
  367.     \******************************************************************/
  368.     case WM_INITDIALOG:
  369.  
  370.       /* Text is unicode... use *W() variants of functions. */
  371.       if (gTypeSource == TYPEUNICODE) {
  372.         WCHAR buffer[MAX_PATH];
  373.         LOGFONTW logfont;
  374.         HFONT hFont;
  375.  
  376.         SetWindowTextW (GetDlgItem (hwnd, DID_TEXT), (LPCWSTR)pSourceData);
  377.         GetWindowTextW (hwndName0, buffer, MAX_PATH);
  378.         SetWindowTextW (GetDlgItem (hwnd, DID_NAME), buffer);
  379.         GetWindowTextW (hwndCodePage0, buffer, MAX_PATH);
  380.         SetWindowTextW (GetDlgItem (hwnd, DID_TYPE), buffer);
  381.  
  382.         GetObjectW (GetStockObject (SYSTEM_FONT), sizeof(LOGFONTW), &logfont);
  383.         logfont.lfCharSet = UNICODE_CHARSET;
  384.         lstrcpyW (logfont.lfFaceName, L"Lucida Sans Unicode");
  385.         hFont = CreateFontIndirectW (&logfont);
  386.         SendMessageW (GetDlgItem (hwnd, DID_TEXT), WM_SETFONT, (WPARAM) hFont, 0);
  387.  
  388.  
  389.       /* Text is codepage... use *A() variants of functions. */
  390.       } else {
  391.         char buffer[MAX_PATH];
  392.         LOGFONTA logfont;
  393.         HFONT hFont;
  394.  
  395.         SetWindowTextA (GetDlgItem (hwnd, DID_TEXT), pSourceData);
  396.         GetWindowTextA (hwndName0, buffer, MAX_PATH);
  397.         SetWindowTextA (GetDlgItem (hwnd, DID_NAME), buffer);
  398.         GetWindowTextA (hwndCodePage0, buffer, MAX_PATH);
  399.         SetWindowTextA (GetDlgItem (hwnd, DID_TYPE), buffer);
  400.  
  401.         GetObjectA (GetStockObject (SYSTEM_FONT), sizeof(LOGFONTA), &logfont);
  402.         logfont.lfCharSet = giSourceCodePage;
  403.         lstrcpyA (logfont.lfFaceName, "System");
  404.         hFont = CreateFontIndirectA (&logfont);
  405.         SendMessageA (GetDlgItem (hwnd, DID_TEXT), WM_SETFONT, (WPARAM) hFont, 0);
  406.  
  407.       }
  408.       SetWindowText (hwnd, LoadResourceString(IDS_VIEW_SOURCE_TITLE));
  409.       GetClientRect (hwnd, &rect);
  410.       SendMessage (hwnd, WM_SIZE, 0,
  411.                  MAKELPARAM ((rect.right - rect.left), (rect.bottom - rect.top)));
  412.       return TRUE;
  413.     break;
  414.  
  415.     case WM_SIZE: {
  416.       HWND hwndText;
  417.  
  418.       hwndText = GetDlgItem (hwnd, DID_TEXT);
  419.       MoveWindow (hwndText, DLGBORDER, 60, (int) LOWORD(lParam) - 2*DLGBORDER,
  420.                                 (int) HIWORD(lParam) - 60 - DLGBORDER , TRUE);
  421.     }
  422.  
  423.     case WM_COMMAND:
  424.       switch (LOWORD (wParam)) {
  425.         case IDCANCEL:
  426.         case IDOK:
  427.           EndDialog (hwnd, TRUE);
  428.       }
  429.     break; /* end WM_COMMAND */
  430.  
  431.     case WM_SYSCOMMAND:
  432.       if (LOWORD (wParam) == SC_CLOSE)
  433.           EndDialog (hwnd, FALSE);
  434.     break;
  435.  
  436.   } /* end switch */
  437.   return FALSE;
  438. }
  439.  
  440.  
  441.  
  442. /***************************************************************************\
  443. *    FUNCTION: ViewDestinationProc
  444. *
  445. * Fill Text, Name, and Type information into the dialog.
  446. *  Set a proper font to display the text depending on what type it is.
  447. *
  448. \***************************************************************************/
  449. LRESULT CALLBACK ViewDestinationProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  450. {
  451. RECT rect;
  452.  
  453.   switch (message) {
  454.  
  455.     /******************************************************************\
  456.     *  WM_INITDIALOG
  457.     \******************************************************************/
  458.     case WM_INITDIALOG:
  459.  
  460.       /* Destination text is unicode... use *W() variants of functions. */
  461.       if (gTypeSource != TYPEUNICODE) {
  462.         WCHAR buffer[MAX_PATH];
  463.         LOGFONTW logfont;
  464.         HFONT hFont;
  465.  
  466.         SetWindowTextW (GetDlgItem (hwnd, DID_TEXT), (LPCWSTR)pDestinationData);
  467.         GetWindowTextW (hwndName1, buffer, MAX_PATH);
  468.         SetWindowTextW (GetDlgItem (hwnd, DID_NAME), buffer);
  469.         GetWindowTextW (hwndCodePage1, buffer, MAX_PATH);
  470.         SetWindowTextW (GetDlgItem (hwnd, DID_TYPE), buffer);
  471.  
  472.         GetObjectW (GetStockObject (SYSTEM_FONT), sizeof(LOGFONTW), &logfont);
  473.         logfont.lfCharSet = UNICODE_CHARSET;
  474.         lstrcpyW (logfont.lfFaceName, L"Lucida Sans Unicode");
  475.         hFont = CreateFontIndirectW (&logfont);
  476.         SendMessageW (GetDlgItem (hwnd, DID_TEXT), WM_SETFONT, (WPARAM) hFont, 0);
  477.  
  478.  
  479.       /* Destination text is codepage... use *A() variants of functions. */
  480.       } else {
  481.         char buffer[MAX_PATH];
  482.         LOGFONTA logfont;
  483.         HFONT hFont;
  484.  
  485.         SetWindowTextA (GetDlgItem (hwnd, DID_TEXT), pDestinationData);
  486.         GetWindowTextA (hwndName1, buffer, MAX_PATH);
  487.         SetWindowTextA (GetDlgItem (hwnd, DID_NAME), buffer);
  488.         GetWindowTextA (hwndCodePage1, buffer, MAX_PATH);
  489.         SetWindowTextA (GetDlgItem (hwnd, DID_TYPE), buffer);
  490.  
  491.         GetObjectA (GetStockObject (SYSTEM_FONT), sizeof(LOGFONTA), &logfont);
  492.         logfont.lfCharSet = giDestinationCodePage;
  493.         lstrcpyA (logfont.lfFaceName, "System");
  494.         hFont = CreateFontIndirectA (&logfont);
  495.         SendMessageA (GetDlgItem (hwnd, DID_TEXT), WM_SETFONT, (WPARAM) hFont, 0);
  496.  
  497.       }
  498.       SetWindowText (hwnd, LoadResourceString(IDS_VIEW_DEST_TITLE));
  499.       GetClientRect (hwnd, &rect);
  500.       SendMessage (hwnd, WM_SIZE, 0,
  501.                  MAKELPARAM ((rect.right - rect.left),(rect.bottom - rect.top)));
  502.  
  503.       return TRUE;
  504.     break;
  505.  
  506.  
  507.     case WM_SIZE: {
  508.       HWND hwndText;
  509.  
  510.       hwndText = GetDlgItem (hwnd, DID_TEXT);
  511.       MoveWindow (hwndText, DLGBORDER, 60, (int) LOWORD(lParam) - 2*DLGBORDER,
  512.                                 (int) HIWORD(lParam) - 60 - DLGBORDER , TRUE);
  513.     }
  514.  
  515.     case WM_COMMAND:
  516.       switch (LOWORD (wParam)) {
  517.         case IDCANCEL:
  518.         case IDOK:
  519.           EndDialog (hwnd, TRUE);
  520.       }
  521.     break; /* end WM_COMMAND */
  522.  
  523.     case WM_SYSCOMMAND:
  524.       if (LOWORD (wParam) == SC_CLOSE)
  525.           EndDialog (hwnd, FALSE);
  526.     break;
  527.  
  528.   } /* end switch */
  529.   return FALSE;
  530. }
  531.