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 » Modal vs non-modal window
Re: Modal vs non-modal window [message #11958 is a reply to message #11950] Thu, 04 October 2007 13:08 Go to previous messageGo to previous message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
Hello and welcome!

I assume you've already decided against a seperate class for the window, so what I would do is something like this:
One<AWindow> wnd;
void OpenAWindow() {
	if (!wnd) {
		wnd = new AWindow();
		CtrlLayout(*wnd, "A Window");
		wnd->ok	<<= THISBACK(AWindowOK);
		wnd->WhenClose = wnd->cancel <<= THISBACK(AWindowClose);
		//wnd->Open(this);			
		wnd->OpenMain();
	}
	else
		wnd->TopMost(false, false);
}	
void AWindowOK() { 
	if (wnd->Accept()) { 
		// Do Something with data 
		AWindowClose();
	}
}
void AWindowClose() 	{ wnd.Clear(); }
(all members of another class)

This allows the window to be displayed non-modally. By changing OpenMain to Open(this) you will get a child window (always above parent). It's possible that Mirek might come along and tell me I've got this wrong though Smile

Also, if you didn't care about memory release after closing (if it's a small app I wouldn't bother), you could just add the line:
AWindow &wnd = Single<AWindow>()
to all the functions you need to access the window, and remove the member variable.

Hope that helps.
James

edit: Forgot AWindowClose

[Updated on: Thu, 04 October 2007 14:59]

Report message to a moderator

 
Read Message icon5.gif
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: TopWindow Backup/Restore
Next Topic: Minor bug: TopWindow::GetStdSize()
Goto Forum:
  


Current Time: Mon May 06 12:07:57 CEST 2024

Total time taken to generate the page: 0.01971 seconds