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 » TopWindow&PopUp, TrayIcon » How to call class1 member after closing class2
How to call class1 member after closing class2 [message #9955] Mon, 11 June 2007 13:07 Go to next message
michael is currently offline  michael
Messages: 153
Registered: May 2007
Location: Germany
Experienced Member
I have a class mainWindow and a class editWindow. Both are TopWindows.

I open the editWindow from the mainWindow by calling editWindow.Open(). Then i close the editWindow and here starts my problem.

I want to call a member of mainWindow after closing the editWindow.

How can i get the info when the editWindow was closed? I know WhenClose but i don't know where to use it in my mainWindow.

Quiet compicated and not so easy to post a code-example.

Help would be great.

Michael
Re: How to call class1 member after closing class2 [message #9956 is a reply to message #9955] Mon, 11 June 2007 13:27 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
You can, e.g., assign callback to mainWindow method to editWindow WhenClose.

void MainWindow::CloseEdit()
{
   editWindow.Close();
....
}

MainWindow::MainWindow()
{
    editWindow.WhenClose = THISBACK(CloseEdit);
}
Re: How to call class1 member after closing class2 [message #9959 is a reply to message #9955] Mon, 11 June 2007 15:32 Go to previous messageGo to next message
michael is currently offline  michael
Messages: 153
Registered: May 2007
Location: Germany
Experienced Member
Ok, this works. Smile But only when i use the X to close the editWindow.

I use this method in my editWindow-Class to close the editWindow:
void EditWindow::CloseDlg()
{
  Close();
}

But when i use this, my mainWindow can't catch the editWindow.WhenClose action. Is there a difference between Close() and the X on the Window-Header?

Michael
Re: How to call class1 member after closing class2 [message #9962 is a reply to message #9959] Mon, 11 June 2007 16:32 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
Yes. The X triggers the WhenClose callback, which normally triggers Ctrl::Close. Calling Ctrl::Close yourself doesn't trigger the callback.

This is how I get around it:
button <<= callback(&WhenClose, &Callback::Execute)

This assigns a callback to a button that calls the WhenClose callback (instead of close). Even if you change WhenClose it will still work correctly.

James
Re: How to call class1 member after closing class2 [message #9964 is a reply to message #9955] Mon, 11 June 2007 16:59 Go to previous messageGo to next message
michael is currently offline  michael
Messages: 153
Registered: May 2007
Location: Germany
Experienced Member
And is there a way to create this callback without assigning it to button?

Lets say i press a button, do some things and then want to call this callback(&WhenClose, &Callback::Execute).

How can i do that?

Michael
Re: How to call class1 member after closing class2 [message #9966 is a reply to message #9964] Mon, 11 June 2007 17:17 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
Well in that case you can just call WhenClose() Smile
Re: How to call class1 member after closing class2 [message #9967 is a reply to message #9955] Mon, 11 June 2007 17:22 Go to previous messageGo to next message
michael is currently offline  michael
Messages: 153
Registered: May 2007
Location: Germany
Experienced Member
This is too simple... Shocked

Thanks again, James. Works perfectly!

Michael
Re: How to call class1 member after closing class2 [message #9969 is a reply to message #9959] Mon, 11 June 2007 17:52 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
"X" calls WhenClose, which in turn calls "Close".

Anyway, there is a trivial solution to your problem, just call WhenClose() in your method.

Alternatively, you can override Close, call some new Callback (e.g. WhenMyClose) in it and then inherited TopWindow::Close().

Mirek
Previous Topic: How to handle child windows
Next Topic: Can't get rid of minimize button on Linux, okay on Win32
Goto Forum:
  


Current Time: Wed Apr 24 16:29:05 CEST 2024

Total time taken to generate the page: 0.01781 seconds