Notepad features:
1. Look up, case, whole word match, use Cfinddlg's base class member function to implement;
Switch case
PreTranslateMessage () function
Http://blog.sina.com.cn/s/blog_9cd8465f01010cwe.html
http://blog.csdn.net/liuzhuomju/article/details/7380539
2. The Find dialog box is allowed only once, taking advantage of the "if ... else ... In the main dialog box before create CFindReplaceDialog "to determine the implementation;
3. Use the profile correlation function in CWinApp to implement the function of recording the window position and font when exiting, and the status when the position and font load exit when starting again
The use of 4.PreTranslateMessage functions (mapping in the Class wizard) enables the ability to set shortcut keys
About PreTranslateMessage
The most characteristic of MFC message control flow is the virtual function PreTranslateMessage () of CWnd class, by overloading this function, we can change the message control process of MFC, even make a new control flow out. Only messages that pass through the message queue are affected by PreTranslateMessage (), and messages that are sent directly to the window in SendMessage () or other similar ways, without Message Queuing, do not respond to the presence of PreTranslateMessage () at all.
As the name implies, PreTranslateMessage is the message sent to the window before the message is intercepted, and then processed (that is, the message control process of MFC changes)
Be aware of two points:
1) whether calling TranslateMessage () and DispatchMessage () is determined by a return value called the PreTranslateMessage () function, and if the function returns True, the message is not distributed to the window function for processing.
2) The message passed to PreTranslateMessage () is an untranslated message that has not been processed by TranslateMessage (). You can use (Pmsg->wparam==vk_return) in this function to intercept the ENTER key.
5.OnInitDialog added in the Class Wizard if you cannot find a filter that can go to the last page (Message Filter) set to Dialog
6. Function of shortcut keys
Defining shortcut keys is a custom accelerator
1) First add the shortcut key resource ID in the resource file accelerator Select the name of the menu item you want to associate and then set your shortcut key
2) Add a haccel haccel to the. h file;
3) Variables are then added haccel=::loadaccelerators (AfxGetInstanceHandle (), Makeintresource (Idr_menu_main)) in OnInitDialog or initialization; Idr_menu_main the resource file name for the accelerator key
4) Finally, in PreTranslateMessage (msg* pMsg), add:
[CPP] View plain copy
if (:: TranslateAccelerator (GetSafeHwnd (), haccel,pmsg))
return true;
This allows you to add a shortcut key in the accelerator resource file.
7.CFindReplaceDialog () This non-modal dialog box establishes the mapping method for "override" and "Replace All":
Method One:
1. Use PreTranslateMessage () to intercept messages before they are delivered, to process them in advance
2. Using on_bn_clicked (0x400,onreplace) to establish a connection between functions and controls
Method Two:
Message registration, message Map, dialog box creation
Http://blog.sina.com.cn/s/blog_9cd8465f01010cwe.html
On the implementation of some functions of notepad