CFindReplaceDialog学习

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 );     
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值