FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Modal dialogs

 
Post new topic   Reply to topic     Forum Index -> DFL
View previous topic :: View next topic  
Author Message
tim



Joined: 24 Jul 2005
Posts: 26

PostPosted: Wed Aug 03, 2005 5:30 am    Post subject: Modal dialogs Reply with quote

Is there any support for showing forms modally?
Back to top
View user's profile Send private message
tim



Joined: 24 Jul 2005
Posts: 26

PostPosted: Wed Aug 03, 2005 5:36 am    Post subject: Reply with quote

Nevermind, there is Smile

MyForm form = new MyForm;
form.hide();
form.showDialog(this);
Back to top
View user's profile Send private message
tim



Joined: 24 Jul 2005
Posts: 26

PostPosted: Wed Aug 03, 2005 5:45 am    Post subject: Reply with quote

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
View user's profile Send private message
tim



Joined: 24 Jul 2005
Posts: 26

PostPosted: Wed Aug 03, 2005 5:57 am    Post subject: Reply with quote

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
View user's profile Send private message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Wed Aug 03, 2005 7:30 am    Post subject: Reply with quote

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
View user's profile Send private message
tim



Joined: 24 Jul 2005
Posts: 26

PostPosted: Wed Aug 03, 2005 7:35 am    Post subject: Reply with quote

Instantiating a form automatically creates the handle here (latest snapshot) ...
Back to top
View user's profile Send private message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Wed Aug 03, 2005 7:57 am    Post subject: Reply with quote

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
View user's profile Send private message
tim



Joined: 24 Jul 2005
Posts: 26

PostPosted: Wed Aug 03, 2005 8:08 am    Post subject: Reply with quote

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
View user's profile Send private message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Wed Aug 03, 2005 8:39 am    Post subject: Reply with quote

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
View user's profile Send private message
saivert



Joined: 15 Aug 2005
Posts: 8
Location: Norway

PostPosted: Wed Aug 17, 2005 3:44 pm    Post subject: Derailing here a bit Reply with quote

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
View user's profile Send private message MSN Messenger
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Thu Aug 18, 2005 5:04 am    Post subject: on track Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DFL All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group