Re: Automatically run procedure after starting SDI Application
 
"Ajay Kalra" <ajaykalra@yahoo.com> wrote in message 
news:1154658956.992067.292570@i3g2000cwc.googlegroups.com...
I tried calling my function directly from OnInitialUpdate, but it was
processed before the view came up.  So I put a timer in that function
and it worked great...
Thank you all so much for your help!
I am not sure if timer is a good idea as you are guessing the time. Use
PostMessage at the end of InitInstance and do it there. Thats the
foolproof way to do it.
Calling PostMessage() from CDialog::OnInitDialog() causes the dialog to be 
displayed before the posted message is dispatched, so your suggestion works 
for dialogs.  However, it doesn't work for cases such as OnShowWindow(), and 
apparently OnInitialUpate() from what Jen said.  This is because if 
PostMessag() is called from these handlers, Windows dispatches the posted 
message before any pending WM_PAINT message, and the window will not display 
until after the posted message is handled, which is too late.
To get WM_PAINT to occur first, Jen is absolutely right that setting a timer 
with a 0 interval causes any pending WM_PAINT to be dispatched prior to the 
WM_TIMER message.
SetTimer (id, 0, NULL) is a great way to ensure your window is painted prior 
to processing any posted messages.
-- David