Discussion:
modeless and modal dialog
(too old to reply)
Zachary Turner
2005-01-26 16:43:36 UTC
Permalink
I am trying to create a modeless dialog that all it does is display a
static text field (I'm using ATL dialogs actually, but it maps straight
down to Windows API calls). Anyway my code is something like the
following:


CMyDialog dlg;
dlg.Create(hwndParent);
dlg.ShowWindow(SW_SHOW);
Sleep(2000):
dlg.ShowWindow(SW_HIDE);
dlg.DestroyWindow();

Now, the dialog shows up fine and I can see the title bar. However,
the static text field is not visible. If, on the other hand, I execute
the code:

CMyDialog dlg;
dlg.DoModal(hwndParent);

then I can see the static text field and the dialog displays perfectly.
My code is simple enough that I have a feeling this is just one of
those common mistakes that everyon mistakes at least once, but I can't
figure out what it is. Does anybody have an idea what could be going
wrong? Thank you.
Sten Westerback
2005-01-26 17:27:58 UTC
Permalink
Post by Zachary Turner
I am trying to create a modeless dialog that all it does is display a
static text field (I'm using ATL dialogs actually, but it maps straight
down to Windows API calls). Anyway my code is something like the
CMyDialog dlg;
dlg.Create(hwndParent);
dlg.ShowWindow(SW_SHOW);
dlg.ShowWindow(SW_HIDE);
dlg.DestroyWindow();
Now, the dialog shows up fine and I can see the title bar. However,
the static text field is not visible. If, on the other hand, I execute
CMyDialog dlg;
dlg.DoModal(hwndParent);
then I can see the static text field and the dialog displays perfectly.
My code is simple enough that I have a feeling this is just one of
those common mistakes that everyon mistakes at least once, but I can't
figure out what it is. Does anybody have an idea what could be going
wrong?
Sounds like a missing message loop...

- Sten
Tony Nelson
2005-01-26 17:47:19 UTC
Permalink
Post by Zachary Turner
I am trying to create a modeless dialog that all it does is display a
static text field (I'm using ATL dialogs actually, but it maps straight
down to Windows API calls). Anyway my code is something like the
CMyDialog dlg;
dlg.Create(hwndParent);
dlg.ShowWindow(SW_SHOW);
dlg.ShowWindow(SW_HIDE);
dlg.DestroyWindow();
Now, the dialog shows up fine and I can see the title bar. However,
the static text field is not visible. If, on the other hand, I execute
CMyDialog dlg;
dlg.DoModal(hwndParent);
then I can see the static text field and the dialog displays perfectly.
My code is simple enough that I have a feeling this is just one of
those common mistakes that everyon mistakes at least once, but I can't
figure out what it is. Does anybody have an idea what could be going
wrong? Thank you.
Well, you aren't letting your thread process any messages, while the
DoModal thing runs a message loop. Windows is based on messaging, and
you usually need to let it do its thing. There are even messages for
timers! Petzold would be a good place to start.

BTW, what books are you using now?
________________________________________________________________________
TonyN.:' <mailto:***@shore.net>
' <http://www3.primushost.com/~tonynlsn/>
Loading...