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!"


MFC Example: WM_KICKIDLE and CCmdUI and ON_UPDATE_COMMAND_UI and WM_IDLEUPDATECMDUI

 
 

Implementation details to perform with a CDialog instance

 

  1. Include the MFC header file declaring private Windows messages and macros in the source file (.cpp) of your dialog class implementation.

     

    Collapse Copy Code
    #include <afxpriv.h>
  2. In the corresponding header file where your dialog window class is defined declare the prototypes of the WM_KICKIDLE message handler and the update UI handler as well. The WM_KICKIDLE message is always sent by the system if your dialog instance is idle. This is a good time to do some framework job.

     

    Collapse Copy Code
    //{{AFX_MSG(CCmdUIDemoDlg)
    virtual BOOL OnInitDialog();
    afx_msg void OnPaint();
    [...]
    //}}AFX_MSG
    afx_msg void OnKickIdle();
    afx_msg void OnUpdateUserButton(CCmdUI* pCmdUI);
    DECLARE_MESSAGE_MAP()
    
  3. Update your message map in .cpp file to map the WM_KICKIDLE message and the update notification message for the desired resource (the push button in our sample).

     

    Collapse Copy Code
    BEGIN_MESSAGE_MAP(CCmdUIDemoDlg, CDialog)
    	//{{AFX_MSG_MAP(CCmdUIDemoDlg)
    	ON_WM_PAINT()
    	[...]
    	//}}AFX_MSG_MAP
    	ON_MESSAGE_VOID(WM_KICKIDLE, OnKickIdle)
    	ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateUserButton)
    END_MESSAGE_MAP()
    
  4. At last implement the bodies of both message handlers

     

    Collapse Copy Code
    void CCmdUIDemoDlg::OnKickIdle()
    {
    	UpdateDialogControls(this, FALSE);
    }
    
    void CCmdUIDemoDlg::OnUpdateUserButton(CCmdUI *pCmdUI)
    {
    	pCmdUI->Enable(m_bToggle);
    }
    
  5. Done! By the pCmdUI pointer you've now access to the methods of the CCmdUI instance associated with the object, e.g. the value of the Enable() method's parameter (BOOL) decides if the control is enabled or disabled as known from a menuitem or tool bar button.

Implementation details to perform with a CFormView instance (not part of the demo code)

To use the update notification mechanism for a CFormView instance instead of a CDialog instance perform the following steps by analogy:

 

  1. Include the MFC header file declaring private Windows messages and macros in the source file (.cpp) of your dialog class implementation.

     

    Collapse Copy Code
    #include <afxpriv.h>
    
  2. In the corresponding header file where your view class is defined declare the prototypes of the WM_IDLEUPDATECMDUI message handler and the update UI handler as well. The WM_IDLEUPDATECMDUI message is always sent by the system if your view instance is idle.

     

    Collapse Copy Code
    //{{AFX_MSG(CMyFormView)
    [...]
    //}}AFX_MSG
    afx_msg void OnIdleUpdateCmdUI();
    afx_msg void OnUpdateUserControl(CCmdUI* pCmdUI);
    DECLARE_MESSAGE_MAP()
    
  3. Update your message map in .cpp file to map the WM_IDLEUPDATECMDUI message and the update notification message for the desired resource.

     

    Collapse Copy Code
    BEGIN_MESSAGE_MAP(CMyFormView, CFormView)
    	//{{AFX_MSG_MAP(CMyFormView)
    	[...]
    	//}}AFX_MSG_MAP
    	ON_MESSAGE_VOID(WM_IDLEUPDATECMDUI, OnIdleUpdateCmdUI)
    	ON_UPDATE_COMMAND_UI(IDC_MY_CONTROL, OnUpdateUserControl)
    END_MESSAGE_MAP()
    
  4. At last implement the bodies of both message handlers

     

    Collapse Copy Code
    void CMyFormView::OnIdleUpdateCmdUI()
    {
    	UpdateDialogControls(this, FALSE);
    }
    
    void CMyFormView::OnUpdateUserControl(CCmdUI *pCmdUI)
    {
    	pCmdUI->Enable(...);
    }
    
  5. Done!

 

 

 

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