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

  • 相关阅读:
    HNOI2018退役记
    codeforces 960G Bandit Blues
    codeforces 933D A Creative Cutout
    tyvj1953 Normal
    loj6119 「2017 山东二轮集训 Day7」国王
    codeforces 293E Close Vertices
    bzoj1808 [Ioi2007]training 训练路径
    bzoj2219 数论之神
    bzoj4361 isn
    loj2064[HAOI2016]找相同字符
  • 原文地址:https://www.cnblogs.com/MakeView660/p/7705628.html
Copyright © 2020-2023  润新知