pattern.c
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 18k
Category:

Windows Kernel

Development Platform:

Visual C++

  1. #include "precomp.h"
  2. #pragma hdrstop
  3. BOOL bBkgdOrText;
  4. BOOL bCaptured;
  5. BOOL bHotText;
  6. BOOL bChanged;
  7. short nChanged;
  8. extern TCHAR g_szClose[];
  9. #define CXYDESKPATTERN 8
  10. #define NONE_LENGTH 16
  11. WORD patbits[CXYDESKPATTERN];                  /* bits for Background pattern */
  12. HWND g_hWndListSrc = NULL;  // yucko, but it worked right from win31 with this
  13. void FAR PASCAL ReadPattern(LPTSTR lpStr, WORD FAR *patbits);
  14. HBRUSH NEAR PASCAL CreateBkPatBrush(HWND hDlg)
  15. {
  16.   HBITMAP hbmDesktop, hbmMem;
  17.   HDC hdcScreen, hdcMemSrc, hdcMemDest;
  18.   HBRUSH hbrPat = NULL;
  19.   if (hbmDesktop=CreateBitmap(CXYDESKPATTERN, CXYDESKPATTERN, 1, 1, patbits))
  20.     {
  21.       hdcScreen = GetDC(hDlg);
  22.       if (hdcMemSrc=CreateCompatibleDC(hdcScreen))
  23. {
  24.   SelectObject(hdcMemSrc, hbmDesktop);
  25.   if (hbmMem=CreateCompatibleBitmap(hdcScreen,
  26. CXYDESKPATTERN, CXYDESKPATTERN))
  27.     {
  28.       if (hdcMemDest=CreateCompatibleDC(hdcScreen))
  29. {
  30.   SelectObject(hdcMemDest, hbmMem);
  31.   SetTextColor(hdcMemDest, GetSysColor(COLOR_BACKGROUND));
  32.   SetBkColor(hdcMemDest, GetSysColor(COLOR_WINDOWTEXT));
  33.   BitBlt(hdcMemDest, 0, 0, CXYDESKPATTERN, CXYDESKPATTERN,
  34. hdcMemSrc, 0, 0, SRCCOPY);
  35.   hbrPat = CreatePatternBrush(hbmMem);
  36.   /* Clean up */
  37.   DeleteDC(hdcMemDest);
  38. }
  39.       DeleteObject(hbmMem);
  40.     }
  41.   DeleteDC(hdcMemSrc);
  42. }
  43.       ReleaseDC(hDlg, hdcScreen);
  44.       DeleteObject(hbmDesktop);
  45.     }
  46.   return(hbrPat);
  47. }
  48. void PatternPaint(HWND hDlg, HDC hDC, LPRECT lprUpdate)
  49. {
  50.   short x, y;
  51.   RECT rBox, PatRect;
  52.   HBRUSH hbrBkgd, hbrText;
  53.   GetWindowRect(GetDlgItem(hDlg, IDD_PATTERN), (LPRECT)&PatRect);
  54.   PatRect.top++, PatRect.left++, PatRect.bottom--, PatRect.right--;
  55.   // Use MapWindowPoints instead of ScreenToClient 
  56.   // because it works on mirrored windows and on non mirrored windows.
  57.   MapWindowPoints(NULL, hDlg, (LPPOINT) &PatRect, 2);
  58.   if (IntersectRect((LPRECT)&rBox, (LPRECT)lprUpdate, (LPRECT)&PatRect))
  59.     {
  60.       if (hbrBkgd=CreateSolidBrush(GetNearestColor(hDC,
  61.     GetSysColor(COLOR_BACKGROUND))))
  62. {
  63.   if (hbrText=CreateSolidBrush(GetSysColor(COLOR_WINDOWTEXT)))
  64.     {
  65.       rBox.right = PatRect.left;
  66.       for (x = 0; x < CXYDESKPATTERN; x++)
  67. {
  68.   rBox.left = rBox.right;
  69.   rBox.right = PatRect.left+((PatRect.right-PatRect.left)*(x+1))/CXYDESKPATTERN;
  70.   rBox.bottom = PatRect.top;
  71.   for (y = 0; y < CXYDESKPATTERN; y++)
  72.     {
  73.       rBox.top = rBox.bottom;
  74.       rBox.bottom = PatRect.top+((PatRect.bottom-PatRect.top)*(y+1))/CXYDESKPATTERN;
  75.       FillRect(hDC, (LPRECT) &rBox,
  76.                             (patbits[y] & (0x01 << (7-x))) ? hbrText : hbrBkgd);
  77.     }
  78. }
  79.       DeleteObject(hbrText);
  80.     }
  81.   DeleteObject(hbrBkgd);
  82. }
  83.     }
  84.   GetWindowRect(GetDlgItem(hDlg, IDD_PATSAMPLE), (LPRECT)&PatRect);
  85.   PatRect.top++, PatRect.left++, PatRect.bottom--, PatRect.right--;
  86.   // Use MapWindowPoints instead of ScreenToClient 
  87.   // because it works on mirrored windows and on non mirrored windows.
  88.   MapWindowPoints(NULL, hDlg, (LPPOINT) &PatRect, 2);
  89.   if (IntersectRect((LPRECT)&rBox, (LPRECT)lprUpdate, (LPRECT)&PatRect))
  90.     {
  91.       if (hbrBkgd=CreateBkPatBrush(hDlg))
  92. {
  93.   FillRect(hDC, (LPRECT) &rBox, hbrBkgd);
  94.   DeleteObject(hbrBkgd);
  95. }
  96.     }
  97. }
  98. void PatternUpdate(HWND hDlg)
  99. {
  100.   RECT rBox;
  101.   HDC hDC = GetDC(hDlg);
  102.   GetWindowRect(GetDlgItem(hDlg, IDD_PATTERN), (LPRECT)&rBox);
  103.   // Use MapWindowPoints instead of ScreenToClient 
  104.   // because it works on mirrored windows and on non mirrored windows.
  105.   MapWindowPoints(NULL, hDlg, (LPPOINT) &rBox, 2);
  106.   PatternPaint(hDlg, hDC, (LPRECT)&rBox);
  107.   GetWindowRect(GetDlgItem(hDlg, IDD_PATSAMPLE), (LPRECT)&rBox);
  108.   // Use MapWindowPoints instead of ScreenToClient 
  109.   // because it works on mirrored windows and on non mirrored windows.
  110.   MapWindowPoints(NULL, hDlg, (LPPOINT) &rBox, 2);
  111.   PatternPaint(hDlg, hDC, (LPRECT)&rBox);
  112.   ReleaseDC(hDlg, hDC);
  113.   return;
  114. }
  115. BOOL RemoveMsgBox( HWND hWnd, LPTSTR lpStr1 )
  116. {
  117.   TCHAR lpS[CCH_MAX_STRING];
  118.   TCHAR removemsg[CCH_MAX_STRING];
  119.   TCHAR caption[CCH_MAX_STRING];
  120.   LoadString(hInstance, IDS_REMOVEPATCAPTION, caption, ARRAYSIZE(caption));
  121.   LoadString(hInstance, IDS_PAT_REMOVE, removemsg, ARRAYSIZE(removemsg));
  122.   wsprintf( lpS, removemsg, lpStr1);
  123.   MessageBeep( MB_ICONQUESTION );
  124.   return MessageBox(hWnd, lpS, caption, MB_YESNO | MB_ICONQUESTION) == IDYES;
  125. }
  126. int ChangeMsgBox( HWND hWnd, LPTSTR lpStr1, BOOL fNew )
  127. {
  128.   TCHAR lpS[CCH_MAX_STRING];
  129.   TCHAR changemsg[CCH_MAX_STRING];
  130.   TCHAR caption[CCH_MAX_STRING];
  131.   LoadString(hInstance, IDS_CHANGEPATCAPTION, caption, ARRAYSIZE(caption));
  132.   LoadString(hInstance, ( fNew? IDS_PAT_CREATE : IDS_PAT_CHANGE ),
  133.     changemsg, ARRAYSIZE(changemsg));
  134.   wsprintf( lpS, changemsg, lpStr1);
  135.   MessageBeep( MB_ICONQUESTION );
  136.   return MessageBox( hWnd, lpS, caption, MB_YESNOCANCEL | MB_ICONQUESTION );
  137. }
  138. int NEAR PASCAL CheckSaveChanges( HWND hDlg )
  139. {
  140.     int result = IDYES;
  141.     BOOL fNew = IsWindowEnabled( GetDlgItem( hDlg, IDD_ADDPATTERN ) );
  142.     if( fNew || IsWindowEnabled( GetDlgItem( hDlg, IDD_CHANGEPATTERN ) ) )
  143.     {
  144.         TCHAR name[ 81 ];
  145.         SendMessage( GetDlgItem( hDlg, IDD_PATTERNCOMBO ), WM_GETTEXT, ARRAYSIZE(name) - 1,
  146.             (LPARAM)name );
  147.         if( ( result = ChangeMsgBox( hDlg, name, fNew ) ) == IDYES )
  148.             SendMessage( hDlg, WM_APP, fNew, 0L );
  149.     }
  150.     return result;
  151. }
  152. /*--------------------------------------------------------------------------*/
  153. /*                                                                          */
  154. /*  PatternDlgProc() -                                                      */
  155. /*                                                                          */
  156. /*--------------------------------------------------------------------------*/
  157. const static DWORD /* _based(__segname("_CODE")) */ aPatternHelpIDs[] = {  // Context Help IDs
  158.   IDC_NO_HELP_1,       NO_HELP,
  159.   IDC_NO_HELP_2,       NO_HELP,
  160.   IDD_PATTERNCOMBO,    IDH_PATTERN_EDIT_NAME,
  161.   IDD_ADDPATTERN,      IDH_PATTERN_EDIT_ADD,
  162.   IDD_CHANGEPATTERN,   IDH_PATTERN_EDIT_CHANGE,
  163.   IDD_DELPATTERN,      IDH_PATTERN_EDIT_REMOVE,
  164.   IDD_PATSAMPLE_TXT,   IDH_PATTERN_EDIT_SAMPLE,
  165.   IDD_PATSAMPLE,       IDH_PATTERN_EDIT_SAMPLE,
  166.   IDD_PATTERN,         IDH_PATTERN_EDIT_PIXEL_SCREEN,
  167.   IDD_PATTERN_TXT,     IDH_PATTERN_EDIT_PIXEL_SCREEN,
  168.   IDCANCEL,            IDH_PATTERN_EDIT_EXIT,
  169.   0, 0
  170. };
  171. BOOL CALLBACK PatternDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam)
  172. {
  173.   HWND hWndCombo;
  174.   short nPats;
  175.   int x, y;
  176.   TCHAR szPats[81];
  177.   TCHAR szLHS[81], szRHS[81];
  178.   short nOldBkMode;
  179.   RECT rBox;
  180.   PAINTSTRUCT ps;
  181.   POINT ptParam;
  182.   switch (wMsg)
  183.     {
  184.       case WM_INITDIALOG:
  185.         bChanged = bCaptured = bHotText = FALSE;
  186.         GetWindowText(hDlg, szPats, ARRAYSIZE(szPats));
  187.         hWndCombo = GetDlgItem(hDlg, IDD_PATTERNCOMBO);
  188.         g_hWndListSrc = (HWND)lParam;
  189.         for (nPats = (WORD)SendMessage(g_hWndListSrc, LB_GETCOUNT, 0, 0L) - 1;
  190.                                                           nPats > 0; nPats--)
  191.           {
  192.             SendMessage(g_hWndListSrc, LB_GETTEXT,nPats,(LPARAM)szPats);
  193.             SendMessage(hWndCombo, CB_ADDSTRING, 0, (LPARAM)szPats);
  194.           }
  195. /* This is kind of cute.  Since the NULL selection is index 0 in the parent,
  196.    the indexes are 1 less than in the parent, and the user won't be editing
  197.    a NULL bitmap, selecting (nPats - 1) highlights the appropriate item, or
  198.    no item at all if the index was 0.  */
  199.         nChanged = (WORD)SendMessage(g_hWndListSrc, LB_GETCURSEL, (WPARAM)NULL, 0L),
  200.         SendMessage(hWndCombo, CB_SETCURSEL, --nChanged, 0L);
  201.         if (nChanged >= 0)
  202.           {
  203.             SendMessage(hWndCombo, CB_GETLBTEXT, nChanged, (LPARAM)szPats);
  204.             GetPrivateProfileString(g_szPatterns, szPats, g_szNULL, szPats, 81, g_szControlIni);
  205.             ReadPattern(szPats,patbits);
  206.           }
  207.         else
  208.           {
  209.             patbits[0] = patbits[1] = patbits[2] = patbits[3] =
  210.             patbits[4] = patbits[5] = patbits[6] = patbits[7] = 0;
  211.           }
  212. /* Both ADD and CHANGE are always disabled, since no new scheme has been
  213.    entered and no change to an old scheme has been made.  DELETE is
  214.    enabled only if an old scheme is selected. */
  215.         EnableWindow(GetDlgItem(hDlg, IDD_DELPATTERN), nChanged >= 0);
  216.         EnableWindow(GetDlgItem(hDlg, IDD_ADDPATTERN), FALSE);
  217.         EnableWindow(GetDlgItem(hDlg, IDD_CHANGEPATTERN), FALSE);
  218.         break;
  219.       case WM_PAINT:
  220.         BeginPaint(hDlg, &ps);
  221.         nOldBkMode = SetBkMode(ps.hdc, TRANSPARENT);
  222.         PatternPaint(hDlg,  ps.hdc, &ps.rcPaint);
  223.         SetBkMode(ps.hdc, nOldBkMode);
  224.         EndPaint(hDlg, &ps);
  225.         return FALSE; // let defdlg proc see this
  226.         break;
  227.       case WM_MOUSEMOVE:
  228.         if (!bCaptured)
  229.             return(FALSE);     /* Let it fall through to the DefDlgProc */
  230.       case WM_LBUTTONDOWN:
  231.         GetWindowRect(GetDlgItem(hDlg, IDD_PATTERN), (LPRECT)&rBox);
  232.         // Use MapWindowPoints instead of ScreenToClient 
  233.         // because it works on mirrored windows and on non mirrored windows.
  234.         MapWindowPoints(NULL, hDlg, (LPPOINT) &rBox, 2);
  235.         LPARAM2POINT(lParam, &ptParam);
  236.         if (PtInRect((LPRECT) &rBox, ptParam))
  237.           {
  238.             x = ((ptParam.x - rBox.left) * CXYDESKPATTERN)
  239.                                                    / (rBox.right - rBox.left);
  240.             y = ((ptParam.y - rBox.top) * CXYDESKPATTERN)
  241.                                                    / (rBox.bottom - rBox.top);
  242.             nPats = patbits[y];     /* Save old value */
  243.             if (wMsg == WM_LBUTTONDOWN)
  244.               {
  245.                 SetCapture(hDlg);
  246.                 EnableWindow(GetDlgItem(hDlg, IDD_DELPATTERN), FALSE);
  247.                 bChanged = bCaptured = TRUE;
  248.                 bBkgdOrText = patbits[y] & (0x01 << (7-x));
  249.                 if( nChanged >= 0 )
  250.                   EnableWindow(GetDlgItem(hDlg,IDD_CHANGEPATTERN),TRUE);
  251.               }
  252.             if (bBkgdOrText)
  253.                 patbits[y] &= (~(0x01 << (7-x)));
  254.             else
  255.                 patbits[y] |= (0x01 << (7-x));
  256.             if (nPats != (short) patbits[y])
  257.                 PatternUpdate(hDlg);
  258.           }
  259.         return(FALSE);     /* Let it fall through to the DefDlgProc */
  260.         break;
  261.       case WM_LBUTTONUP:
  262.         if (bCaptured)
  263.           {
  264.             ReleaseCapture();
  265.             bCaptured = FALSE;
  266.           }
  267.         return(FALSE);     /* Let it fall through to the DefDlgProc */
  268.         break;
  269.       case WM_APP:  // we send this to ourselves to save the current item
  270.         hWndCombo = GetDlgItem(hDlg, IDD_PATTERNCOMBO);
  271.         SendMessage(hWndCombo, WM_GETTEXT, ARRAYSIZE(szLHS)-1, (LPARAM)szLHS);
  272.         if (wParam) {
  273.             nChanged = (short) SendMessage(hWndCombo, CB_ADDSTRING, 0, 
  274.                                             (LPARAM)szLHS);
  275.             SendMessage (hWndCombo,CB_SETCURSEL,nChanged,0L);
  276.         }
  277.         wsprintf(szRHS, TEXT("%d %d %d %d %d %d %d %d"),
  278.                 (int)patbits[0], (int)patbits[1], (int)patbits[2], (int)patbits[3],
  279.                 (int)patbits[4], (int)patbits[5], (int)patbits[6], (int)patbits[7] );
  280.         WritePrivateProfileString(g_szPatterns, szLHS,
  281.                                         szRHS, g_szControlIni);
  282.         bChanged = FALSE;
  283.         // Make sure we don't disable a button that has the current focus
  284.         {
  285.             HWND hwndFoc = GetFocus();
  286.             if (hwndFoc == GetDlgItem(hDlg, IDD_ADDPATTERN) || hwndFoc == GetDlgItem(hDlg, IDD_CHANGEPATTERN)) {
  287.                 SendMessage( hDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hDlg, IDD_PATTERNCOMBO), TRUE );
  288.             }
  289.         }
  290.         EnableWindow( GetDlgItem (hDlg, IDD_ADDPATTERN), FALSE);
  291.         EnableWindow( GetDlgItem (hDlg, IDD_CHANGEPATTERN), FALSE);
  292.         EnableWindow( GetDlgItem(hDlg, IDD_DELPATTERN),TRUE);
  293.         break;
  294.       case WM_HELP:
  295.         WinHelp((HWND)((LPHELPINFO) lParam)->hItemHandle, NULL,
  296.           HELP_WM_HELP, (DWORD)aPatternHelpIDs);
  297.         break;
  298.       case WM_CONTEXTMENU:
  299.         WinHelp((HWND) wParam, NULL, HELP_CONTEXTMENU,
  300.           (DWORD)(LPVOID) aPatternHelpIDs);
  301.         break;
  302.       case WM_COMMAND:
  303.         switch (LOWORD(wParam))
  304.           {
  305.             case IDD_PATTERNCOMBO:
  306.                 hWndCombo = GetDlgItem(hDlg, IDD_PATTERNCOMBO);
  307.                 switch( HIWORD(wParam) )
  308.                 {
  309.                     case CBN_SELCHANGE:
  310.                         nChanged=x=(short)SendMessage(hWndCombo, CB_GETCURSEL, 0, 0L);
  311.                         SendMessage(hWndCombo, CB_GETLBTEXT, x, (LPARAM)szLHS);
  312.                         GetPrivateProfileString(g_szPatterns, szLHS, g_szNULL, szPats, ARRAYSIZE(szPats), g_szControlIni);
  313.                         ReadPattern(szPats,patbits);
  314.                         PatternUpdate(hDlg);
  315.                         EnableWindow(GetDlgItem(hDlg, IDD_ADDPATTERN),bChanged=FALSE);
  316.                         EnableWindow(GetDlgItem(hDlg, IDD_CHANGEPATTERN), FALSE);
  317.                         EnableWindow(GetDlgItem(hDlg, IDD_DELPATTERN), TRUE);
  318.                         bHotText = FALSE;
  319.                         break;
  320.                     case CBN_EDITCHANGE:
  321.                         x = (short)SendMessage( hWndCombo, WM_GETTEXTLENGTH, 0, 0L );
  322.                         if( x <= 0 )
  323.                         {
  324.                             EnableWindow(GetDlgItem(hDlg, IDD_DELPATTERN), FALSE);
  325.                             EnableWindow(GetDlgItem(hDlg, IDD_CHANGEPATTERN), FALSE);
  326.                             EnableWindow(GetDlgItem(hDlg, IDD_ADDPATTERN), FALSE);
  327.                         }
  328.                         else
  329.                         {
  330.                             SendMessage(hWndCombo, WM_GETTEXT, ARRAYSIZE(szLHS)-1, (LPARAM)szLHS);
  331.                             y = (int)SendMessage(hWndCombo, CB_FINDSTRINGEXACT,
  332.                                                 (WPARAM)-1, (LPARAM)szLHS);
  333.                             bHotText = ( y >= 0 );
  334.                             if( bHotText && ( nChanged != y ) )
  335.                             {
  336.                                 nChanged = y;
  337.                                 bChanged = TRUE;
  338.                             }
  339.                             EnableWindow( GetDlgItem( hDlg, IDD_DELPATTERN ),
  340.                                 ( y >= 0 ) );
  341.                             EnableWindow( GetDlgItem( hDlg, IDD_CHANGEPATTERN ),
  342.                                 ( y >= 0 ) );
  343.                             EnableWindow( GetDlgItem( hDlg, IDD_ADDPATTERN ),
  344.                                 ( y < 0 ) );
  345.                         }
  346.                         break;
  347.                     case CBN_SETFOCUS:
  348.                         bHotText = FALSE;
  349.                         break;
  350.                     case CBN_KILLFOCUS:
  351.                         if( bHotText )
  352.                         {
  353.                             // update here so we don't disrupt the typing
  354.                             SendMessage( GetDlgItem( hDlg, IDD_PATTERNCOMBO ),
  355.                                 CB_SETCURSEL, nChanged, 0L );
  356.                             bHotText = FALSE;
  357.                         }
  358.                         break;
  359.                 }
  360.                 break;
  361.             case IDD_ADDPATTERN:
  362.             case IDD_CHANGEPATTERN:
  363.               SendMessage( hDlg, WM_APP, (LOWORD(wParam) == IDD_ADDPATTERN), 0L );
  364.               break;
  365.             case IDD_DELPATTERN:
  366.               hWndCombo = GetDlgItem(hDlg, IDD_PATTERNCOMBO);
  367.               if ((x = (short)SendMessage(hWndCombo, CB_GETCURSEL, 0, 0L)) >= 0)
  368.                 {
  369.                   SendMessage(hWndCombo, WM_GETTEXT, ARRAYSIZE(szLHS)-1, (LPARAM)szLHS);
  370.                   if (RemoveMsgBox(hDlg, szLHS)) {
  371.                       SendMessage(hWndCombo, CB_DELETESTRING, x, 0L);
  372.                       WritePrivateProfileString (g_szPatterns,szLHS,NULL,
  373.                                                  g_szControlIni);
  374.                       SendMessage( hDlg, WM_NEXTDLGCTL, (WPARAM)hWndCombo,
  375.                         TRUE );
  376.                       EnableWindow (GetDlgItem (hDlg,IDD_DELPATTERN),FALSE);
  377.                    }
  378.                 }
  379.               break;
  380.             case IDCANCEL:
  381.             {
  382.               int action = CheckSaveChanges( hDlg );
  383.               if( action == IDCANCEL )
  384.                 break;
  385.               hWndCombo = GetDlgItem(hDlg, IDD_PATTERNCOMBO);
  386.               /* Save current selection in parent combobox */
  387.               nChanged = (int)SendMessage (g_hWndListSrc,LB_GETCURSEL,0,0L);
  388.               SendMessage (g_hWndListSrc,LB_GETTEXT,nChanged,
  389.                            (LPARAM) szLHS);
  390.               /* Now rebuild parent combobox */
  391.               SendMessage(g_hWndListSrc, LB_RESETCONTENT, 0, 0L);
  392.               for (nPats = (WORD) SendMessage (hWndCombo,CB_GETCOUNT,
  393.                                                0,0L) - 1;nPats >= 0; 
  394.                    nPats--) {
  395.                  SendMessage(hWndCombo,CB_GETLBTEXT,nPats,
  396.                              (LPARAM)szPats);
  397.                  SendMessage(g_hWndListSrc, LB_ADDSTRING,0,
  398.                              (LPARAM)szPats);
  399.               }
  400.               SendMessage(g_hWndListSrc, LB_INSERTSTRING,0,
  401.                           (LPARAM)g_szNone);
  402.               if (action == IDYES)
  403.               {
  404.                  nPats = (WORD)SendMessage(hWndCombo, CB_GETCURSEL, (WPARAM)NULL, 0L);
  405.                  SendMessage(g_hWndListSrc, LB_SETCURSEL, ++nPats, 0L);
  406.               }
  407.               else
  408.               {
  409.                  nChanged = (int)SendMessage (g_hWndListSrc,LB_FINDSTRING,
  410.                                          (WPARAM)-1, (LPARAM) szLHS);
  411.                  if (nChanged > 0)
  412.                     SendMessage(g_hWndListSrc, LB_SETCURSEL,nChanged, 0L);
  413.                  else
  414.                     SendMessage(g_hWndListSrc, LB_SETCURSEL,0, 0L);
  415.               }
  416.               EndDialog( hDlg, ( action == IDYES ) );
  417.               break;
  418.             }
  419.             default:
  420.               return FALSE;
  421.           }
  422.         break;
  423.       default:
  424.         return FALSE;
  425.     }
  426.   return(TRUE);
  427. }