View previous topic :: View next topic |
Author |
Message |
tim
Joined: 24 Jul 2005 Posts: 26
|
Posted: Wed Aug 03, 2005 5:30 am Post subject: Modal dialogs |
|
|
Is there any support for showing forms modally? |
|
Back to top |
|
|
tim
Joined: 24 Jul 2005 Posts: 26
|
Posted: Wed Aug 03, 2005 5:36 am Post subject: |
|
|
Nevermind, there is
MyForm form = new MyForm;
form.hide();
form.showDialog(this); |
|
Back to top |
|
|
tim
Joined: 24 Jul 2005 Posts: 26
|
Posted: Wed Aug 03, 2005 5:45 am Post subject: |
|
|
Now after several test runs I noticed that the form is indeed first visible, then hidden, then shown again (for showDialog to work it needs to be hidden).
I think it would be more intuitive if forms were hidden by default. In every GUI toolkit I know, you have to explicitely call "show" to make a form visible. |
|
Back to top |
|
|
tim
Joined: 24 Jul 2005 Posts: 26
|
Posted: Wed Aug 03, 2005 5:57 am Post subject: |
|
|
Found out that if you call "hide()" in the constructor of the form you want to show modally, it will not be visible first and then hidden but never be visible until you explicitly call any of the "showXXX()" functions. |
|
Back to top |
|
|
Chris Miller
Joined: 27 Mar 2004 Posts: 514 Location: The Internet
|
Posted: Wed Aug 03, 2005 7:30 am Post subject: |
|
|
tim wrote: | Now after several test runs I noticed that the form is indeed first visible, then hidden, then shown again (for showDialog to work it needs to be hidden). |
The visible state of the form does not need to be false (hidden) if the form's handle hasn't been created yet. You must be doing something to trigger the form's handle to be created early, such as referencing the handle property. As soon as the handle is created, it uses the form's visible state to decide whether or not to show the form on the screen, so you must be hiding it after this to see it show, hide and show again.
You can either make sure you hide it before the handle is created, or only use the handle after the handleCreated event fires (my preference).
Quote: |
I think it would be more intuitive if forms were hidden by default. In every GUI toolkit I know, you have to explicitely call "show" to make a form visible. |
It is visible by default but only appears on the screen when the handle is created. show() invokes the handle to be created. I believe this is how some GUI toolkits do it. |
|
Back to top |
|
|
tim
Joined: 24 Jul 2005 Posts: 26
|
Posted: Wed Aug 03, 2005 7:35 am Post subject: |
|
|
Instantiating a form automatically creates the handle here (latest snapshot) ... |
|
Back to top |
|
|
Chris Miller
Joined: 27 Mar 2004 Posts: 514 Location: The Internet
|
Posted: Wed Aug 03, 2005 7:57 am Post subject: |
|
|
tim wrote: | Instantiating a form automatically creates the handle here (latest snapshot) ... |
Not here.. you must be doing something to cause it, or the bug is more complicated. If it did, then this would show the form: Code: |
import dfl.all;
int main()
{
Form form = new Form;
Application.run();
return 0;
}
|
Note: Application.run(form) will create the handle in order to start up the application. |
|
Back to top |
|
|
tim
Joined: 24 Jul 2005 Posts: 26
|
Posted: Wed Aug 03, 2005 8:08 am Post subject: |
|
|
I forgot to mention the form creates children in its constructor and sets their parent property. I assume that creates the handle?
In any case, IMHO forms should be hidden unless explictly specified otherwise ... |
|
Back to top |
|
|
Chris Miller
Joined: 27 Mar 2004 Posts: 514 Location: The Internet
|
Posted: Wed Aug 03, 2005 8:39 am Post subject: |
|
|
tim wrote: | I forgot to mention the form creates children in its constructor and sets their parent property. I assume that creates the handle? |
Still not,
Code: |
import dfl.all;
class MyForm: Form
{
this()
{
with(new Label)
{
text = "hello, world";
bounds = Rect(5, 5, 100, 15);
parent = this;
}
}
}
int main()
{
MyForm form = new MyForm;
Application.run();
return 0;
}
|
doesn't show it.
Though I think I know why it's still creating the handle for you. If any child control's handle is created then the whole hierarchy of controls and form are created as well. This is why you shouldn't use the handle property in any control until the user of the control (you adding the control to your form) creates it. Note that there is currently a documented bug with ToolTip that causes the handle to be created.
Quote: | In any case, IMHO forms should be hidden unless explictly specified otherwise ... |
I'm not sure about that.. If you feel strongly about it, how about creating a poll? Though don't expect many results this time of year; it's pretty dead around here in the summer. |
|
Back to top |
|
|
saivert
Joined: 15 Aug 2005 Posts: 8 Location: Norway
|
Posted: Wed Aug 17, 2005 3:44 pm Post subject: Derailing here a bit |
|
|
Derailing here a bit
Wasn't this about Modal dialogs??
Okay. I will try to straighten this thread:
How would a doModal() method be made? Using a MessageLoop inside doModal()?
If you were to support Win32 dialog template resources at all I assume DialogBox can be used since it is the modal equivalent of CreateDialog. But I would suggest using a MessageLoop as it gives the library more freedom.
What about application-modal/system-modal dialog boxes? _________________ - New at D, like it though - Attending Kongsberg Tekniske Fagskole (Computer technician course) - |
|
Back to top |
|
|
Chris Miller
Joined: 27 Mar 2004 Posts: 514 Location: The Internet
|
Posted: Thu Aug 18, 2005 5:04 am Post subject: on track |
|
|
saivert wrote: | Derailing here a bit
Wasn't this about Modal dialogs??
Okay. I will try to straighten this thread:
How would a doModal() method be made? Using a MessageLoop inside doModal()?
|
yes.
Quote: |
If you were to support Win32 dialog template resources at all I assume DialogBox can be used since it is the modal equivalent of CreateDialog. But I would suggest using a MessageLoop as it gives the library more freedom.
|
I wouldn't recommend using dialog resources.. they just don't fit in with DFL. Specifically because the coordinates use those dialog units instead of pixels and its children won't be DFL Control`s.
Quote: |
What about application-modal/system-modal dialog boxes? |
Only msgBox() supports those I guess. Would you really want such a dialog box though? |
|
Back to top |
|
|
|