The dialog is not vet visible when the WM_INITDIALOG message is received. It is still hidden.

If you want the code to run after the dialog is first painted, you nedd to look for the WM_PAINT message. Pass this message on to the default dialog procedure (DefDlgProc()) so that the window is painted, then what the default dialog procedure returns, do your processing. If your processing needs to be done only the first time the dialog is painted, you can use some sort of semaphore to insure it is not done every time the windows is repainted.

let me know if you have any questions.

0

michael_telmapAuthor Commented: 2000-03-26

Could you please send me an Example,
I dont understand exactly how to do it.

At the end of your OnInitDialog (or the code that handles WM_INITDIALOG if your not MFC), post yourself a message (eg a WM_USER or a registered message) and in the handler for that message do whatever it is you want to do.

I don't think that will work, you usually only get WM_PAINT messages when there are no messages waiting in the message queue, so the message you post will get handled before the WM_PAINT message. I think. Its possible that when the window is made visible, a WM_PAINT will be forced earlier, I'm not sure.

>> One can always do an Invalidate/UpdateWindow
>> or a RedrawWindow to force painting earlier
Right. MY point (question?) is that being done by the OS? If so then your suggestion will work, other wise it won't because the message you are posting will get handled before the paint.

......Or when, the message is handled, you could force a paint first, is that your point? That would make sense.

>> (perhaps at the end of OnInitDialog?)
You can't force a paint there, because the dialog is still hidden. But you could force the paint when the posted message gets handled.