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++ Core » How to get value from parent AppWindow class?
How to get value from parent AppWindow class? [message #43798] Thu, 16 October 2014 09:58 Go to next message
akebee is currently offline  akebee
Messages: 90
Registered: August 2011
Location: China
Member
struct ChildAppWindow : TopWindow {
ChildAppWindow();
bool IsStop();
};

bool ChildAppWindow::IsStop()
{
// how can i cat bStop ( In class MyAppWindow)?
}

struct MyAppWindow : TopWindow {
MyAppWindow() ;

bool bStop;
void IsStop(bool& b) { b = bStop;}

ChildAppWindow child;

};

One way is like below:

Callback<bool&> cb_IsStop;
child.cb_IsStop = THISBACK(IsStop);

but this is not so convenient i think Crying or Very Sad

[Updated on: Thu, 16 October 2014 10:00]

Report message to a moderator

Re: How to get value from parent AppWindow class? [message #43803 is a reply to message #43798] Mon, 20 October 2014 17:37 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
akebee wrote on Thu, 16 October 2014 09:58
struct ChildAppWindow : TopWindow {
ChildAppWindow();
bool IsStop();
};

bool ChildAppWindow::IsStop()
{
// how can i cat bStop ( In class MyAppWindow)?
}

struct MyAppWindow : TopWindow {
MyAppWindow() ;

bool bStop;
void IsStop(bool& b) { b = bStop;}

ChildAppWindow child;

};

One way is like below:

Callback<bool&> cb_IsStop;
child.cb_IsStop = THISBACK(IsStop);

but this is not so convenient i think Crying or Very Sad



In cases like this, you can do 2 things:

a) put 'backpointer' MyAppWindow * into ChildAppWindow

b) Use GetOwner with dynamic_cast (but that only works if both windows are open and MyAppWindow owns ChildAppWindow. But with e.g. parent widget or TopWindow and child widget, it is quite good option

Mirek

Mirek
Previous Topic: XmlNode class is excellent
Next Topic: Problem with copy construction of std::vector from Upp::Vector
Goto Forum:
  


Current Time: Fri Mar 29 13:22:47 CET 2024

Total time taken to generate the page: 0.01621 seconds