Dave's Brain

Browse - programming tips - win32 windows message to initialize a control

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 Windows XP ... not
Vista)

Here's how to do it with MFC but it can be adabled for convention win32:

--- 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;
}
What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2012, 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.
Advertisements: