home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / winui / cmddlg / cdtest / replace.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-17  |  1.7 KB  |  65 lines

  1. /************************************************************************
  2.  
  3.   File: replace.c
  4.  
  5.   Purpose:
  6.  
  7.     This file contains only one function that set the bDoFindDlg global
  8.     variable to FALSE and then creates a dialog box with the same Callback
  9.     function as the DoFindDialog() function does.
  10.  
  11.     Since FindText() and ReplaceText() both use the FINDREPLACE
  12.     structure to create their dialogs, one dialog proc and dialog box
  13.     can handle both.
  14.  
  15.   Functions:
  16.  
  17.     - DoReplaceDialog()    -- Creates CDTEST's Find/Replace dialog.
  18.  
  19. ************************************************************************/
  20.  
  21. #include <windows.h>
  22. #include <commdlg.h>
  23. #include "cdtest.h"
  24. #include "replace.h"
  25. #include "find.h"
  26.  
  27.  
  28.  
  29. /************************************************************************
  30.  
  31.   Function: DoReplaceDialog(HWND)
  32.  
  33.   Purpose: To create CDTEST's find/replace dialog box.
  34.  
  35.  
  36.   Returns: Nothing.
  37.  
  38.   Comments:
  39.  
  40.     FindText() and ReplaceText() are similiar enough so that
  41.     the same dialog can be used to edit their creation structure elements,
  42.     so a global variable "bDoFindDlg" keeps track of which one to create
  43.     when the user clicks the OK or Multithread buttons...
  44.  
  45. ************************************************************************/
  46.  
  47. void DoReplaceDialog(HWND hwnd)
  48. {
  49.  
  50.   bDoFindDlg = FALSE ;
  51.  
  52.  
  53.   /* in order for the keyboard to work, a hook has to be installed before
  54.      the dialog is created.  See find.c for more detail on this. */
  55.  
  56.   hHook = SetWindowsHookEx(WH_MSGFILTER, lpfnFilterProc, hInst, GetCurrentThreadId()) ;
  57.  
  58.   if (!hHook) return ;
  59.  
  60.   DialogBox(hInst, MAKEINTRESOURCE(ID_FINDDIALOG), hwnd, FindProc) ;
  61.  
  62.   UnhookWindowsHookEx(hHook) ;
  63.  
  64. }
  65.