Solved

showDialog() - what's going on when it is invoked?

Posted on 2004-09-01
9
415 Views
Last Modified: 2013-12-03

I have been using Forms - and therefore .showDialog() -  (in J++ - although I'm pretty sure this is just WinAPI stuff so applies equally from C++ or VBasic) for a long time but they seem to (mis)behave in seemingly strange ways from time to time - refusing to become visible once hidden, blocking when they shouldnt etc.

To shed light on this I would like to understand what happens (at a lower level) when showDialog() is invoked.

Also whats the difference between showDialog() and showDialog(anotherForm) and show() exactly.

A clear explaination would be appreciated - but also references to online sources (although I have yet to find anything that  explains this clearly)

0
Comment
Question by:flashdriver
  • 5
  • 2
9 Comments
 
LVL 16

Expert Comment

by:nonubik
ID: 11952555
>Also whats the difference between showDialog() and showDialog(anotherForm)

showDialog() Shows the form as a modal dialog box with no owner window
showDialog(anotherForm) Shows the form as a modal dialog with the specified owner (the top-level window that will own the modal dialog - 'anotherForm')
0
 
LVL 16

Expert Comment

by:nonubik
ID: 11952579
show() displays the control(for in this case) to the user. Showing the control is equivalent to setting the Visible property to true. After the Show method is called, the Visible property returns a value of true until the Hide method is called.

0
 

Author Comment

by:flashdriver
ID: 11955672
Yes but not what I meant.

What is going on at 'control' level.

When showDialog() is executed control blocks until the user exits to form ( or close() is executed, or dispose() - and are these the same btw) - so what happens to control in the meanwhile?

If I use a timer does it share the same thread (seems to).

What is the break down of what happens when showDialog() and close()n are issued?

0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 16

Expert Comment

by:nonubik
ID: 11961787
>When showDialog() is executed control blocks until the user exits to form

The dialog is displayed as modal. There are two kinds of dialog boxes:

Modal dialog boxes, which require the user to respond before continuing the program
Modeless dialog boxes, which stay on the screen and are available for use at any time but permit other user activities

>so what happens to control in the meanwhile?
The dialog stays in a message loop, DoModalLoop() until a closing message is sent (WM_CLOSE, WM_DESTROY, etc)

>If I use a timer does it share the same thread (seems to).
If the timer is set for your dialog, the WM_TIMER messages are treated inside the above message loop and passed to your handler (if any). So, the same window message loop (not necesarly the same thread).
0
 

Author Comment

by:flashdriver
ID: 11964416
Thanks - good start.

This is the level I need to understand.

How can I see what's going on and/or tap into the message process?

(I'm in J++)
0
 
LVL 16

Expert Comment

by:nonubik
ID: 11964456
I'm sorry I can't take you further, for I'm in C++ :)
But there (in VC++) you can put some breakpoints in the MFC CDialog class methods.
0
 
LVL 16

Accepted Solution

by:
nonubik earned 500 total points
ID: 11964501
But I think that in J++ you can, too, set a hook, with SetWindowsHookEx or something. In that way you can replace the dialog's wndproc and tap messages.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question