Home » U++ Library support » U++ Widgets - General questions or Mixed problems » Dialog returned values
Dialog returned values [message #2448] |
Thu, 13 April 2006 07:17  |
kevinle10@gmail.com
Messages: 25 Registered: April 2006
|
Promising Member |
|
|
I have a dialog with three buttons : "Overwrite", "Append" and "Cancel". The code to invoke the dlg is as follow:
ConfirmOverwriteDlg confirmDlg;
int dlgId = confirmDlg.Execute();
switch (dlgId) {
case 100:
PromptOK("Overwrite");
break;
case 101:
PromptOK("Append");
break;
default:
PromptOK("Cancel");
}
100 and 101 are assigned to the "Overwrite" and "Append" buttons in the lay file respectively. But the above does not work. How do I wire the button to the ID? Thanks
|
|
|
Re: Dialog returned values [message #2455 is a reply to message #2448] |
Thu, 13 April 2006 13:36  |
victorb
Messages: 78 Registered: December 2005 Location: Nice, France
|
Member |
|
|
You should have your button set as rather an acceptor, rejector or breaker then you can associate and ID with the button. I have modified the Layout ref. coded and added a button ("help").
The code looks like:
GUI_APP_MAIN
{
WithDialogLayout<TopWindow> dlg;
CtrlLayoutOKCancel(dlg, "Enter a number");
dlg.Acceptor(dlg.help, IDHELP);
dlg.number <<= 10;
for(;;)
switch(dlg.Execute()) {
case IDOK:
PromptOK(AsString(~dlg.number));
break;
case IDCANCEL:
return;
case IDHELP:
PromptOK("Help me!");
break;
}
}
lay file:
LAYOUT(DialogLayout, 312, 168)
ITEM(Label, dv___0, SetLabel(t_("A number")).LeftPosZ(8, 56).TopPosZ(8, 19))
ITEM(EditIntSpin, number, LeftPosZ(64, 76).TopPosZ(8, 19))
ITEM(Button, cancel, SetLabel(t_("Cancel")).LeftPosZ(76, 64).TopPosZ(36, 24))
ITEM(Button, help, SetLabel(t_("Help")).LeftPosZ(32, 116).TopPosZ(96, 32))
ITEM(Button, ok, SetLabel(t_("OK")).LeftPosZ(8, 64).TopPosZ(36, 24))
END_LAYOUT
You should take a look at the code of CtrlLayoutOKCancel in TopWindow.h.
Victor
|
|
|
Goto Forum:
Current Time: Tue Apr 29 08:25:34 CEST 2025
Total time taken to generate the page: 0.03618 seconds
|