I have a SDI application. In the application there's a modeless dialog which is used to show some message like communicating with the server during doing work. Question is, when the dialog's parent window is set to main frame, the ShowWindow method doesn't work as expected. It seems that the dialog is covered by the main frame. If I put a Sleep call next to ShowWindow call, I can see the dialog. And when Sleep ends, the dialog disappear.If I don't set the dialog's parent, the ShowWindow call works normally. But I do want to set the dialog's parent window. So how to sovle it ?
Asked
Active
Viewed 1,711 times
2
-
Why do you want the modeless dialog to be a child of the main one ? Pass NULL to the parent unless there is a good reason you want to set up that relationship. I feel you probably misunderstood the semantics of the parent window for modeless dialogs. – Mike Kwan Jun 13 '11 at 12:04
-
The main reason is that if the dialog's parent window isn't set, it will have a taskbar button when shown. And I also find that if the dialog is created like pDlg->Create(IDD, AfxGetMainWnd()), which set the parent window automatically, the ShowWindow call works normally. Is there any difference between the two method of setting parent window? – Wilbur Jun 13 '11 at 12:18
-
There are styles you can set which will not get that taskbar button. For example setting it as a tooltip window (if that's what you want) – Mike Kwan Jun 13 '11 at 12:27
-
Too calls, one to Create with NULL as second parameter and the other to SetParent – Wilbur Jun 13 '11 at 12:29
-
Did you consider a message box for your needs? (CWnd::MessageBox(): http://msdn.microsoft.com/en-us/library/0eebkf6f(VS.80).aspx). Also look at: http://msdn.microsoft.com/en-us/library/ms645505(VS.85).aspx – yasouser Jun 13 '11 at 12:51
-
Thought this link might be useful for you: Window features - http://msdn.microsoft.com/en-us/library/ms632599(VS.85).aspx – yasouser Jun 13 '11 at 13:00
1 Answers
1
The thing with the 'sleep' making it work for a while makes me think you're creating the dialog on the stack and it's going out of scope, therefore destroying itself.

Roel
- 19,338
- 6
- 61
- 90