Solved

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

Posted on 2004-09-01
9
421 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

623 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