editpat.cpp
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 19k
Category:

Windows Kernel

Development Platform:

Visual C++

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