Find and replace dialog boxes find and replace dialog box

Source: Internet
Author: User

 

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.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.