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 » Cannot get modal owned window
Cannot get modal owned window [message #15473] Fri, 25 April 2008 17:58 Go to next message
indiocolifa is currently offline  indiocolifa
Messages: 49
Registered: January 2008
Location: Argentina
Member
What I want to do is the main window to open a modal window, which must be resized at 90% of the parent window size. I get different problems, but I can't get it right.

Here's what I'm doing.

The Main Window is opened with.

MainWindow mw;
mw.Run();


in the GUI_APP_MAIN block.

Now, the window I want to open is defined in the .lay file. It's class declaration is:

class CaseExp : public WithCaseExpLayout<TopWindow> {
	typedef CaseExp CLASSNAME;

	void PrintRemClick();
	void ResolCasoClick();
	void CerrarCasoClick();
	void FillGrid();
	void gridCasosWhenSelection();
	void exit();

public:
	CaseExp();
};


So, since I want MainWindow to be the parent of this CaseExp window, in MainWindow.h I put:

class MainWindow : public TopWindow
{
	MenuBar		mainMenu;
	StatusBar	statusBar;
	LoginWindow	loginWnd;
	CaseExp		caseexp; <<<<---- HERE

... (continues)

}


The window is activated with a menu which has a callback pointing to a function with this code:

void MainWindow::OpenCaseExp()
{	
	caseexp.Run(true);	
}


Ok, this window is modal. But I can close it breaking it's modal loop properly.

The window has no close button in the form, only the system window close button at the title bar is used to close the window.

This is the constructor of CaseExp (the 'child' window):

CaseExp::CaseExp()
{
	CtrlLayout(*this, "Explorador de Casos");
	Sizeable(true);
	
	gridCasos.AddColumn((Id)COL_NUMCASO, "Número de Caso");
	gridCasos.AddColumn((Id)COL_MARCAEQ, "Marca Equipo");
	gridCasos.AddColumn((Id)COL_MODEQ, "Modelo Equipo");
	gridCasos.AddColumn((Id)COL_NSERIE, "Número de Serie");
	gridCasos.AddColumn((Id)COL_ESTADO, "Estado");
	
	FillGrid();
	
	btnPrintRem.WhenAction=THISBACK(PrintRemClick);	
	btnResolCaso.WhenAction=THISBACK(ResolCasoClick);
	btnCerrarCaso.WhenAction=THISBACK(CerrarCasoClick);
	gridCasos.WhenSel=THISBACK(gridCasosWhenSelection);
	WhenClose = THISBACK(exit);
	
}


exit Calls:

void CaseExp::exit()
{	
	Break(999);		
}


But this window won't close !!!!

Now, If I use:
void CaseExp::exit()
{	
	Break(999);
        Close();		
}


The window closes with a 'beep' and the main window (it's parent) is not focused (i must focus it manually).

It's evident that I do not fully U++ mechanisms well...

Any guidelines?

Thank you for your help.


Re: Cannot get modal owned window [message #15494 is a reply to message #15473] Sat, 26 April 2008 10:29 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Read GUI tutorial

http://www.ultimatepp.org/srcdoc$CtrlLib$Tutorial$en-us.html

section 22.

Mirek
Re: Cannot get modal owned window [message #15555 is a reply to message #15494] Tue, 29 April 2008 06:58 Go to previous messageGo to next message
indiocolifa is currently offline  indiocolifa
Messages: 49
Registered: January 2008
Location: Argentina
Member
But mirek I can manage modeless dialogs properly. My problem is with modal dialogs (I suspect my trouble comes from breaking the modal loop unproperly..)
Re: Cannot get modal owned window [message #15557 is a reply to message #15473] Tue, 29 April 2008 09:35 Go to previous messageGo to next message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
Here's old thread dealing with modal dialogs too
http://www.ultimatepp.org/forum/index.php?t=msg&goto=230 5

And from the tutorial the chapter 20 may be of some help?


Update: Found another one:
http://www.ultimatepp.org/forum/index.php?t=msg&th=2770& amp;start=0

[Updated on: Tue, 29 April 2008 09:37]

Report message to a moderator

Re: Cannot get modal owned window [message #15561 is a reply to message #15557] Tue, 29 April 2008 10:08 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
The problem is calling Run. From the manual:
Quote:

Run
Execute modal loop for TopWindow. If TopWindow is not open, it calls Open before starting loop, but it does not close it.
Execute
Similar to Run, but closes TopWindow when loop exits.

So you should call Execute instead.

This can be easy to miss as often modal dialogs are declared locally:
void ShowAWindow 
{
    AWindow wnd;
    wnd.Run();
}

in which case the window would be closed when it ran out-of-scope anyway, hiding the problem.

James
Re: Cannot get modal owned window [message #15580 is a reply to message #15473] Tue, 29 April 2008 17:08 Go to previous messageGo to next message
indiocolifa is currently offline  indiocolifa
Messages: 49
Registered: January 2008
Location: Argentina
Member
Perfect, with Execute() seems to work.

Now what I want is to get the parent window size to resize the opened window accordingly.

I'm getting ACCESS VIOLATION trying to do:

void CaseExp::Activate()
{
SetFrameRect(0,0, GetParent()->GetSize().cx - 10, GetParent()->GetSize().cy - 10);
WithCaseExpLayout<TopWindow>::Activate();
}

IDeas?
Re: Cannot get modal owned window [message #15581 is a reply to message #15580] Tue, 29 April 2008 17:26 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
AWindow wnd;
wnd.SetRect(GetRect().Deflated(GetSize()*0.1));
wnd.Execute();
Re: Cannot get modal owned window [message #15583 is a reply to message #15581] Tue, 29 April 2008 18:46 Go to previous message
indiocolifa is currently offline  indiocolifa
Messages: 49
Registered: January 2008
Location: Argentina
Member
mrjt wrote on Tue, 29 April 2008 12:26

AWindow wnd;
wnd.SetRect(GetRect().Deflated(GetSize()*0.1));
wnd.Execute();



Thanks!!!
Previous Topic: Problem, prompt when moving the window.
Next Topic: Wrong LeftUp Message send
Goto Forum:
  


Current Time: Mon Apr 22 08:34:12 CEST 2024

Total time taken to generate the page: 0.02206 seconds