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