khaledo
asked on
Wait for me to hide
I want to hide my application window then capture the screen. I tried the code below but the screen shot capture parts of my application window. How to make my application wait till its window is completely hidden?
Here is the code that does not work:
IsHide = AfxGetMainWnd()->SetWindow Pos(AfxGet MainWnd(), 0,0,0,0,SW P_HIDEWIND OW);
ASSERT(IsHide);
AfxGetMainWnd()->UpdateWin dow(); //Make sure it is hidden
// Wait until everybody repaints themselves
while (PeekMessage(&msg,NULL,0,0 ,PM_REMOVE ) != 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
keybd_event(VK_SNAPSHOT,1, 0,0); //full screen
.........
Thanks
Here is the code that does not work:
IsHide = AfxGetMainWnd()->SetWindow
ASSERT(IsHide);
AfxGetMainWnd()->UpdateWin
// Wait until everybody repaints themselves
while (PeekMessage(&msg,NULL,0,0
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
keybd_event(VK_SNAPSHOT,1,
.........
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I worked this problem out for several hours, tried everything like WaitForSingleObject() or SendMessage(WM_PAINT,0,0) for instantaneously redrawing the mainframe-window, but nothing seems to work. Somewhere I had read that the WM_TIMER-message doesn't block any other windows-message and if you read in help-file of VC++ you find 'The WM_TIMER message is a low-priority message.', what means that all higher priority messages like windows-redrawing and something else are first processed and the WM_TIMER is the last one that will be processed. Sorry, the statement, that refreshes begin after ending of member-function was my own mistake. I hope that you got a little more ideas about that !
Bye,
atari
Bye,
atari
ASKER
It worked, even when I set the timer to zero (because I thought it will be just like Wait() function if timer is not zero). I still do not understand why it worked. If updating starts after the end of the member function then we could simply put the function ShowWindow(SW_HIDE) in a separate member function and call it before the screen capturing. But such solution did not work while yours worked fine. If you can explain more I will be gratefull but for now, you solved my problem and I will accept your answer.