CDialogs failing to show in MSVS6 MFC C++ program

KevinMU1

Senior member
Sep 23, 2001
673
0
0
I'm using Microsoft Visual Studio 6, MFC with C++, and having a really weird problem. I am creating a dialog using Create for a modeless dialog, and sometimes the dialog just doesn't show. I can try twice in a row to do the same action, and the first time it may fail to show and the second time it will show fine. It's not a matter of whether or not the dialog is created... it's always created (I can tell b/c it spawns another thread and I can tell it's running). The visible property is checked, so it's not like it's not always calling ShowWindow(SW_SHOW) in MY code... it should be doing it all the time b/c of that property. Perhaps I could insert a ShowWindow statement manually, but I'd like to know if this is a known bug for I create a workaround, or if this is possibly the symptom of some larger problem.

Any thoughts/ideas? Thanks in advance.
 

singh

Golden Member
Jul 5, 2001
1,449
0
0
I always put in ShowWindow() because that little check-box is pretty easy to mess up with when you're designing the dialog. I can't recall any incidents of the dialog not appearing, so I think it's probably your fault :)
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
Could there be a problem with a control on the dialog, or any code in your OnInitDialog handler? i.e. the thread is created but window creation / initialization fails? One example of how this happens is if you have a wrong control ID in your code and don't check for GetDlgItem etc. returning NULL.
 

KevinMU1

Senior member
Sep 23, 2001
673
0
0
The dialog is pretty dang simple, and like I said it can have the problem and then not within the SAME RUN of the program, so it's not like the box is getting cleared or I'm changing the code.

About the only thing I do relating to the box itself in InitDialog is use SetIcon.

I think it's a bug in the underlying MFC, but that's just my theory.
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
Originally posted by: KevinMU1
I think it's a bug in the underlying MFC, but that's just my theory.
Possible of course, though I've been using MFC heavily for about 6 years now and have never had a dialog problem that wasn't my own fault. Some TRACE statements and ASSERTs might help, and if you have BoundsChecker you might give a BC build a test run.

 

KevinMU1

Senior member
Sep 23, 2001
673
0
0
Is BoundsChecker a program that's part of Visual Studio? I'm not familiar with it. Thanks for the tip though, and I will certainly keep trying to figure out what makes the window not appear.
 

EJ

Member
Oct 18, 1999
99
0
0
If you call CDialog::eek:nCancel it calls EndDialog which makes the dialog invisible but doesn't destroy it. Maybe that's the reason, you need to override OnCancel and call DestroyWindow.

Probably not it though, I'm using V5.0 and just learning.

EJ