Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » CDialog::OnInitDialog (MFC) like method?
CDialog::OnInitDialog (MFC) like method? [message #29681] Mon, 08 November 2010 11:48 Go to next message
alex100 is currently offline  alex100
Messages: 118
Registered: November 2007
Experienced Member
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?

Thanks you very much

Alex
Re: CDialog::OnInitDialog (MFC) like method? [message #29683 is a reply to message #29681] Mon, 08 November 2010 12:21 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
alex100 wrote on Mon, 08 November 2010 05:48

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...
Re: CDialog::OnInitDialog (MFC) like method? [message #29685 is a reply to message #29683] Mon, 08 November 2010 13:09 Go to previous messageGo to next message
alex100 is currently offline  alex100
Messages: 118
Registered: November 2007
Experienced Member
"I guess the simple approach is just to call whatever equivalent of OnInitDialog after you open the window."

It seems interesting for me. But tell me how i know that window is already opened?

I simply make:

MyApp app;
app.run();



Thanks

Alex

[Updated on: Mon, 08 November 2010 13:11]

Report message to a moderator

Re: CDialog::OnInitDialog (MFC) like method? [message #29686 is a reply to message #29685] Mon, 08 November 2010 14:10 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

alex100 wrote on Mon, 08 November 2010 13:09

But tell me how i know that window is already opened?

I simply make:

MyApp app;
app.run();

You can open the window explicitly:
MyApp app;
app.Open();
//do your customization here
app.Run(); //now this only starts the event loop for the already opened window


Honza
Re: CDialog::OnInitDialog (MFC) like method? [message #29687 is a reply to message #29686] Mon, 08 November 2010 14:36 Go to previous messageGo to next message
cbpporter is currently offline  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.
Re: CDialog::OnInitDialog (MFC) like method? [message #29688 is a reply to message #29686] Mon, 08 November 2010 14:38 Go to previous messageGo to next message
alex100 is currently offline  alex100
Messages: 118
Registered: November 2007
Experienced Member
I want to customize the main (frame) dialog. I want to access to the controlbox options

class MyApp: public WithMyAppLayout<TopWindow>


It stills return null on

HMENU hMenu = GetSystemMenu(GetHWND(),0);

I am calling it in this way inside OnInitDialog

myApp app;
app.Open();
app.OnInitDialog()
app.Run();


If i call an Exclamation dialog inside the OnInitDialog() I can not see yet the main frame window, just the exclamation box



Any further help?

Alex

[Updated on: Mon, 08 November 2010 14:47]

Report message to a moderator

Re: CDialog::OnInitDialog (MFC) like method? [message #29689 is a reply to message #29688] Mon, 08 November 2010 14:49 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Sorry, I ran your example and both GetHWND and GetSystemMenu return non-NULL value. Maybe you can post a test case?
Re: CDialog::OnInitDialog (MFC) like method? [message #29692 is a reply to message #29689] Mon, 08 November 2010 15:15 Go to previous message
alex100 is currently offline  alex100
Messages: 118
Registered: November 2007
Experienced Member
Mistake of mine Sad

I wrote:

myApp app;
app.OnInitDialog()
app.Open();
app.Run();

Now using
myApp app;
app.Open();
app.OnInitDialog()
app.Run();

It works perfectly!

Thanks to all of you


Alex
(Upp is a very nice tool!)

[Updated on: Mon, 08 November 2010 15:15]

Report message to a moderator

Previous Topic: Problem with Calendar control
Next Topic: widget or source code to handle dicom files
Goto Forum:
  


Current Time: Thu Mar 28 10:53:39 CET 2024

Total time taken to generate the page: 0.02083 seconds