Dave's Brain

Browse - Programming Tips - Is there a Windows message my control can receive to intialize?

Date: 2009sep29
Language: C/C++
Platform: win32

Q.  Is there a Windows message my control can receive to intialize?
WM_CREATE, WM_INITDIALOG and others don't do what I want.

A.  Yes, use WM_UPDATEUISTATE (but only in Windows 2000 and later)

Here's how to do it with MFC:

--- In the .h file: 

//{{AFX_MSG(CMyControl) afx_msg LRESULT OnUpdateUIState(WPARAM, LPARAM); //}}AFX_MSG
--- In the .cpp file:
#ifndef WM_UPDATEUISTATE #define WM_UPDATEUISTATE (0x128) // Message that is sent when InitDialog() has been done. #endif BEGIN_MESSAGE_MAP(CMyControl, CMyBaseClass) //{{AFX_MSG_MAP(CMyControl) ON_MESSAGE(WM_UPDATEUISTATE, OnUpdateUIState) //}}AFX_MSG_MAP END_MESSAGE_MAP() LRESULT CMyControl::OnUpdateUIState(WPARAM, LPARAM) { // (Initialize everything) return 0; }

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.