Modal vs. Modeless dialog and controls not showing 
Author Message
 Modal vs. Modeless dialog and controls not showing

MFC newbie alert.  There is probably a very simple solution to this
but I've missed it to this point.

I have a very simple dialog box containing 3 static text fields and 2
CProgressCtrl controls.

I create the dialog and launch it modelessly via Create(IDD_NAME) and
ShowWindow(SW_NORMAL).  When the dialog comes up, none of the controls
are visible.  When I actually SetPos() for the progress ctrls latter
on in processing, they show up.  Also, if I SetWindowText() on the
static text fields they will show as well.  I want all controls to
show from the get go, so I added this "set" code to the OnInitDialog()
but it does not seem to have the desired effect.  Only when I execute
this code at some point after OnInitDialog() in some event handling
will I see my controls suddenly appear.

For testing, I created the dialog as modal via DoModal() and it comes
up with all controls visible (note this is with no change to my actual
dialog code, just changing the way the main app instantiates it).  But
I do need this to be modeless.



Tue, 18 Oct 2005 19:24:28 GMT  
 Modal vs. Modeless dialog and controls not showing
I'm just guessing but would the WS_VISIBLE style, or lack thereof, have
anything to do with this?


Quote:
> MFC newbie alert.  There is probably a very simple solution to this
> but I've missed it to this point.

> I have a very simple dialog box containing 3 static text fields and 2
> CProgressCtrl controls.

> I create the dialog and launch it modelessly via Create(IDD_NAME) and
> ShowWindow(SW_NORMAL).  When the dialog comes up, none of the controls
> are visible.  When I actually SetPos() for the progress ctrls latter
> on in processing, they show up.  Also, if I SetWindowText() on the
> static text fields they will show as well.  I want all controls to
> show from the get go, so I added this "set" code to the OnInitDialog()
> but it does not seem to have the desired effect.  Only when I execute
> this code at some point after OnInitDialog() in some event handling
> will I see my controls suddenly appear.

> For testing, I created the dialog as modal via DoModal() and it comes
> up with all controls visible (note this is with no change to my actual
> dialog code, just changing the way the main app instantiates it).  But
> I do need this to be modeless.



Tue, 18 Oct 2005 20:11:34 GMT  
 Modal vs. Modeless dialog and controls not showing
Generally, it is easiest to get into the habit of doing Create(Classname::IDD) rather than
having to look up the class name each time. The enumeration value IDD is always set to the
correct name for the class.

I've never seen a failure mode like this, and I do a lot of modeless dialog boxes. You
must be doing something really odd.
                                        joe


Quote:
>MFC newbie alert.  There is probably a very simple solution to this
>but I've missed it to this point.

>I have a very simple dialog box containing 3 static text fields and 2
>CProgressCtrl controls.

>I create the dialog and launch it modelessly via Create(IDD_NAME) and
>ShowWindow(SW_NORMAL).  When the dialog comes up, none of the controls
>are visible.  When I actually SetPos() for the progress ctrls latter
>on in processing, they show up.  Also, if I SetWindowText() on the
>static text fields they will show as well.  I want all controls to
>show from the get go, so I added this "set" code to the OnInitDialog()
>but it does not seem to have the desired effect.  Only when I execute
>this code at some point after OnInitDialog() in some event handling
>will I see my controls suddenly appear.

>For testing, I created the dialog as modal via DoModal() and it comes
>up with all controls visible (note this is with no change to my actual
>dialog code, just changing the way the main app instantiates it).  But
>I do need this to be modeless.

Joseph M. Newcomer [MVP]

Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm


Tue, 18 Oct 2005 20:30:42 GMT  
 Modal vs. Modeless dialog and controls not showing


Quote:
> MFC newbie alert.  There is probably a very simple solution to this
> but I've missed it to this point.

> I have a very simple dialog box containing 3 static text fields and 2
> CProgressCtrl controls.

> I create the dialog and launch it modelessly via Create(IDD_NAME) and
> ShowWindow(SW_NORMAL).  When the dialog comes up, none of the controls
> are visible.  When I actually SetPos() for the progress ctrls latter
> on in processing, they show up.  Also, if I SetWindowText() on the
> static text fields they will show as well.  I want all controls to
> show from the get go, so I added this "set" code to the OnInitDialog()
> but it does not seem to have the desired effect.  Only when I execute
> this code at some point after OnInitDialog() in some event handling
> will I see my controls suddenly appear.

> For testing, I created the dialog as modal via DoModal() and it comes
> up with all controls visible (note this is with no change to my actual
> dialog code, just changing the way the main app instantiates it).  But
> I do need this to be modeless.

This sounds like a progress dialog. Are you getting back to a message loop
anytime soon? If not, the controls may not be getting their paint messages.
If so, you could try forcing the update yourself. (e.g.
RedrawWindow(GetSafeHandle(), NULL, NULL, RDW_UPDATENOW | RDW_ALLCHILDREN);
maybe with RDW_INVALIDATE also)

HTH
Jay



Tue, 18 Oct 2005 20:49:00 GMT  
 Modal vs. Modeless dialog and controls not showing
This is indeed a progress dialog.  It looked to me like I was getting
back into the message loop, but I tried your suggestion anyway but it
had no effect.

I did find a solution to this, although I am not sure why it works.
If anyone can explain I'd be interested just out of curiosity.

Actually, there where 2 solutions.  I found some other code that
showed a progress dialog and these were the differences and in fact
they did make the difference.

(1) My original code launched the dialog like this from the main
window:

ProgressDlg* prog = new ProgressDlg(this);
prog->Create(IDD_PROGRESS);
prog->ShowWindow(SW_NORMAL);

The code I found had the ShowWindow() call in the OnInitDialog()
itself.  When I did this, my static text fields showed up immediately
but still no progress controls.

(2) Also in OnInitDialog() of the code I found was:

// Have to do this twice to get progress bar to display
m_prog.SetPos(1);
m_prog.SetPos(0);

I added this to my OnInitDialog() and poof, my progress controls
showed up immediately as well.

Quote:



> This sounds like a progress dialog. Are you getting back to a message loop
> anytime soon? If not, the controls may not be getting their paint messages.
> If so, you could try forcing the update yourself. (e.g.
> RedrawWindow(GetSafeHandle(), NULL, NULL, RDW_UPDATENOW | RDW_ALLCHILDREN);
> maybe with RDW_INVALIDATE also)

> HTH
> Jay



Fri, 21 Oct 2005 14:41:58 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Showing a modal dialog in a modal dialog application

2. Modal vs modeless dialogs

3. modeless dialog not showing

4. creating Modal vs. Non-Modal dialogs

5. Modeless dialog called from Modal dialog woes.

6. Modeless Dialog box in a Modal Dialog Application...

7. Modeless dialog box together with modal dialog box

8. Modeless Dialog from Modal Dialog question ?

9. Post message from modal dialog to modeless dialog box....urgent!!!!!!!!!!!!!!1

10. Modeless dialog on top of Modal dialog

11. Modeless Child Dialog of Modal Dialog

12. modal dialog not modal?

 

 
Powered by phpBB® Forum Software