Hello all
I need to customize some visual things in the main app window, like system menu and related.
If i call GetSystemMenu(GetHWND(),0) on constructor it returns null. But if i call it on a button handler it works.
It seems that system menu is not available yet during constructor.
My question is: Is there any handle/method like CDialog::OnInitDialog (VC++/MFC) where it is guaranteed that all visual controls are ready to be customized?
Hello all
I need to customize some visual things in the main app window, like system menu and related.
If i call GetSystemMenu(GetHWND(),0) on constructor it returns null. But if i call it on a button handler it works.
It seems that system menu is not available yet during constructor.
My question is: Is there any handle/method like CDialog::OnInitDialog (VC++/MFC) where it is guaranteed that all visual controls are ready to be customized?
No.
I guess the simple approach is just to call whatever equivalent of OnInitDialog after you open the window.
If this seems too ugly (e.g. you are creating some library), you can get as close as possible to MFC by overriding WindowProc method (Win32 specific, but so is your problem). Eventually, there is even "NcCreate" virtual method that can be overriden.
Just do not forget to call "original" WindowProc / NcCreate at the end of your init code...
cbpporter Messages: 1401 Registered: September 2007
Ultimate Contributor
U++ control exist from the point they are constructed, so usualy you should have no problems. Exception is for controls that are linked to the underlying windows system, like TopWindow. In the constructor it is not guaranteed to have a HWND because your window is not open yet and for WinAPI it may not exist. In your button handler the window already exists and is open.
I would recommend adding a method that opens the window and sets the correct parameters if it must be done each time.