码迷,mamicode.com
首页 > 其他好文 > 详细

CFindReplaceDialog学习

时间:2017-10-21 22:30:03      阅读:387      评论:0      收藏:0      [点我收藏+]

标签:void   back   rac   table   messages   表示   custom   min   cat   

The CFindReplaceDialog class allows you to implement standard string Find/Replace dialog boxes in your application. Unlike the other Windows common dialog boxes, CFindReplaceDialog objects are modeless, allowing users to interact with other windows while they are on screen. There are two kinds of CFindReplaceDialog objects: Find dialog boxes and Find/Replace dialog boxes. Although the dialog boxes allow the user to input search and search/replace strings, they do not perform any of the searching or replacing functions. You must add these to the application.

To construct a CFindReplaceDialog object, use the provided constructor (which has no arguments). Since this is a modeless dialog box, allocate the object on the heap using the new operator, rather than on the stack.

Once a CFindReplaceDialog object has been constructed, you must call the Create member function to create and display the dialog box.

Use the m_fr structure to initialize the dialog box before calling Create. The m_fr structure is of type FINDREPLACE. For more information on this structure, see the Win32 SDK documentation.

In order for the parent window to be notified of find/replace requests, you must use the Windows RegisterWindowMessage function and use the ON_REGISTERED_MESSAGE message-map macro in your frame window that handles this registered message. You can call any of the member functions listed in the “Operations” section of the CFindReplaceDialog Class Members table from the frame window’s callback function.

You can determine whether the user has decided to terminate the dialog box with the IsTerminating member function.

CFindReplaceDialog relies on the COMMDLG.DLL file that ships with Windows versions 3.1 and later.

To customize the dialog box, derive a class from CFindReplaceDialog, provide a custom dialog template, and add a message map to process the notification messages from the extended controls. Any unprocessed messages should be passed to the base class.

Customizing the hook function is not required.

/*
     第一个参数为true显示的是查找对话框,为False时显示的是查找和替换对话框
     第二个参数指定在查找对话框中显示的字符串
     第三个参数指定在替换对话框中显示的字符串
     第四个参数为指定标志位,用来定制对话框,其中FR_DOWM表示对话框中的“向下”单选按钮被选中,否则“向上”单选按钮被选中,具体可取值参考MSDN
     第五个参数为指向父窗口的指针,如果为NULL,则为主框架窗口,使用时需要让它指向接收查找和替换消息的窗口
 */
void CMfcFindReplaceDlgDlg::OnBtnF() 
{
    CFindReplaceDialog* pFRDlg = new CFindReplaceDialog();  // Must be created on the heap    
    pFRDlg->Create( TRUE, "", "", FR_DOWN, this );     
}

void CMfcFindReplaceDlgDlg::OnBtnFr() 
{ 
    CFindReplaceDialog* pFRDlg = new CFindReplaceDialog();  // Must be created on the heap    
    pFRDlg->Create( FALSE, "", "", FR_DOWN, this );     
}

技术分享

CFindReplaceDialog学习

标签:void   back   rac   table   messages   表示   custom   min   cat   

原文地址:http://www.cnblogs.com/MakeView660/p/7705628.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!