YOU CAN CODE!

 

With The Case Of UCanCode.net  Release The Power OF  Visual C++ !   HomeProducts | PurchaseSupport | Downloads  
Download Evaluation
Pricing & Purchase?
E-XD++Visual C++/ MFC Products
Overview
Features Tour 
Electronic Form Solution
Visualization & HMI Solution
Power system HMI Solution
CAD Drawing and Printing Solution

Bar code labeling Solution
Workflow Solution

Coal industry HMI Solution
Instrumentation Gauge Solution

Report Printing Solution
Graphical modeling Solution
GIS mapping solution

Visio graphics solution
Industrial control SCADA &HMI Solution
BPM business process Solution

Industrial monitoring Solution
Flowchart and diagramming Solution
Organization Diagram Solution

Graphic editor Source Code
UML drawing editor Source Code
Map Diagramming Solution

Architectural Graphic Drawing Solution
Request Evaluation
Purchase
ActiveX COM Products
Overview
Download
Purchase
Technical Support
  General Q & A
Discussion Board
Contact Us

Links

Get Ready to Unleash the Power of UCanCode .NET

 


UCanCode Software focuses on general application software development. We provide complete solution for developers. No matter you want to develop a simple database workflow application, or an large flow/diagram based system, our product will provide a complete solution for you. Our product had been used by hundreds of top companies around the world!

"100% source code provided! Free you from not daring to use components because of unable to master the key technology of components!"


VC++ Sample Code: CFindReplaceDialog, CFrameWnd

 

 CFindReplaceDialog

The CFindReplaceDialog class supports the use of the Windows Find and Replace dialog in MFC applications.

Use of the Find and Replace dialog is fundamentally different from the user of other common dialogs. While other common dialogs are modal, the Find and Replace dialog is modeless and must be constructed and used accordingly.

To use the Find and Replace dialog, first construct a CFindReplaceDialog object. This object cannot be constructed on the stack; it must be created using the new operator to ensure its persistence after the function in which it is created returns.

The Find and Replace dialog communicates with its owner window using special messages. To enable use of these messages, use the ::RegisterWindowMessage function. The value obtained upon registering Find and Replace dialog messages can be used in a window's message map using the ON_REGISTERED_MESSAGE macro.

The actual dialog is created by calling the Create member function. Make sure to specify the window that should receive messages from the dialog in the call to CFindReplaceDialog::Create.

Now you're ready to put all this into practice. Listing 22.3 shows how the use of the Find and Replace dialog is implemented in the CDLG application. All the code shown here is part of the MainFrm.cpp source file.

    Listing 22.3. Use of CFindReplaceDialog in CDLG.

// MainFrm.cpp : implementation of the CMainFrame class

//

...

static UINT WM_FINDREPLACE = RegisterWindowMessage(FINDMSGSTRING);

///////////////////////////////////////////////////////////////////

// CMainFrame

IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)

    //{{AFX_MSG_MAP(CMainFrame)

    ...

    //}}AFX_MSG_MAP

    ON_REGISTERED_MESSAGE(WM_FINDREPLACE, OnFindReplace)

END_MESSAGE_MAP()

...

void CMainFrame::OnViewFindreplacedialog()

{

    // TODO: Add your command handler code here

    CFindReplaceDialog *pDlg = new CFindReplaceDialog;

    pDlg->Create(TRUE, "Findme", NULL, FR_DOWN, this);

}

LRESULT CMainFrame::OnFindReplace(WPARAM wParam, LPARAM lParam)

{

    if (((LPFINDREPLACE)lParam)->Flags & FR_FINDNEXT)

    {

        CString temp = "Search string: ";

        temp = temp + ((LPFINDREPLACE)lParam)->lpstrFindWhat;

        AfxMessageBox(temp);

    }

    return 0;

}

The function OnFindReplace must also be declared in MainFrm.h. Towards the end of the class declaration, after the ClassWizard-generated message map, but before the DECLARE_MESSAGE_MAP macro call, insert the following line:

afx_msg LRESULT OnFindReplace(WPARAM wParam, LPARAM lParam);

Customization of the Find and Replace dialog involves deriving a class from CFindReplaceDialog, providing a custom dialog template, and adding your own message map to process notification messages from any extra controls you added. The original dialog template can be found in the file findtext.dlg in your \msdev\include directory.

 

Copyright ?1998-2024 UCanCode.Net Software , all rights reserved.
Other product and company names herein may be the trademarks of their respective owners.

Please direct your questions or comments to webmaster@ucancode.net