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 » Community » Newbie corner » Problems when using layouts
Re: Problems when using layouts [message #27177 is a reply to message #27173] Tue, 29 June 2010 18:27 Go to previous messageGo to previous message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
1- The code is incorrect, instead of
	dialogo.Execute();
	Result <<= (int)~dialogo.entrada_a * (int)~dialogo.entrada_b;

it should be:
	if (dialogo.Execute() == IDOK)
	   Result <<= (int)~dialogo.entrada_a * (int)~dialogo.entrada_b;

or:
	if (dialogo.ExecuteOK())
	   Result <<= (int)~dialogo.entrada_a * (int)~dialogo.entrada_b;

so that the cancel response is filtered out.

CtrlLayoutOKCancel does 2 things that CtrlLayout doesn't:
- Assign standard OS icons to buttons (for X11 really). This uses the Button::OK() or Button::Cancel() functions.
- Give each button a callback that breaks the dialog's modal loop with a specific value (like IDOK). This value is then returned by Execute so that you can check which button was pushed (as above).

Using this method there is also additional behaviour when OK or Cancel is pushed by the user. OK calls Accept which validates all the ctrls on the dialog and stops the operation if any fail. Cancel calls Reject (which is used by some controls to end editing states) and if you have called Backup at any point it also calls Restore to revert to backed-up values.

Basically the idea is that by using CtrlLayoutOKCancel you get standard functionality automatically. Sometimes you want to over-ride the default OK handling, but this is easy to:
...
ok <<= THISBACK(OnOK);

void OnOK()
{
   if (!Accept()) 
      return;
   // Do something
   ...

   Break(IDOK);
}

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Message from the system.
Next Topic: is windows SDK needed after Visual Studio 2010
Goto Forum:
  


Current Time: Mon Apr 28 08:45:02 CEST 2025

Total time taken to generate the page: 0.00493 seconds