zoukankan      html  css  js  c++  java
  • 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 );     
    }

  • 相关阅读:
    .Net/C#: 实现支持断点续传多线程下载
    软件设计过程中常用的几种图(二)
    走马灯 代码appendChild实现的无缝滚动
    调用web service时的SOAPHEADER验证
    Excel VBA 学习总结 数据验证与正则表达式
    C#者重建C++之路 运行机制的差异
    Excel VBA 学习总结 代码优化之道
    Excel VBA 学习总结 文件系统
    软件设计:“度”、“裁剪”与“变通”
    Excel VBA 学习总结 开发模式
  • 原文地址:https://www.cnblogs.com/MakeView660/p/7705628.html
Copyright © 2011-2022 走看看