Solved

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

Posted on 2004-09-01
9
413 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now