Open a text editor, press Ctrl + F to display the left-side pattern dialog box-Search dialog box, press Ctrl + H to display the right-side pattern dialog box-replace dialog box, two struct and two functions are defined in windows, so that we can easily create these two dialogs during programming.
Unlike other dialogs in the system, these two dialogs are non-modal, allowing users to switch back and forth between the main window and the two windows.
Before creating the dialog box, you must call registerwindowmessage to register a findmsgstring message to obtain the Message ID.
Findreplace struct:
Typedef struct {<br/> DWORD lstructsize; <br/> hwnd hwndowner; <br/> hinstance; <br/> DWORD flags; <br/> lptstr lpstrfindwhat; <br/> lptstr lpstrreplacewith; <br/> word wfindwhatlen; <br/> word wreplacewithlen; <br/> lparam lcustdata; <br/> lpfrhookproc lpfnhook; <br/> lpctstr lptemplatename; <br/>} findreplace, * lpfindreplace;
The size of the lstructsize struct, Which is initialized using sizeof (findreplace.
Hwndowner creates a window handle for the find and replace dialog box, which is also the handle for receiving the previously registered message dialog box.
The string to be searched by lpstrfindwhat uses a dynamically assigned global or static character array.
The string to which lpstrreplacewith is replaced.
Wfindwhatlen
Length of the string replaced by wreplacewithlen
/*
If the hinstance, lcustdata, lpfnhook, and lptemplatename do not use complex hooks, you can ignore these four parameters.
*/
If the fr_down bit is set for flages, the down radio button is selected;
If you click the Find Next button in the dialog box, the flages bit is set before the Message notification creation window is sent, in the message processing function, you can use this to determine whether the "Find Next button" is clicked ".
After the struct is configured, call
The findtext or replacetext function creation dialog box.