Link to home
Start Free TrialLog in
Avatar of flynny
flynnyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Help screen capturing and drawing a bitmap

Hi,

I wish to take a screenshot of a particular screen window and save it to file from a program.

I have hooked into the program and when the particular screen i want the screen grab of loads ( i do this using the window title ) i grab the screen.

now, this is working and i'm using WM_WINDOWPOSCHANGING as the event to do the creation, however as it looks like the screen hasn't finished drawing when this message is sent i don't get a screen shot with all the components on it. i only get half of them.

Can anyone suggest a message or method for when or where i can grab the screen and it will have finished drawing??

many thanks,

Matt.
Avatar of Zoppo
Zoppo
Flag of Germany image

Hi flynny,

maybe you should use WM_WINDOWPOSCHANGED instead of WM_WINDOWPOSCHANGING - WM_WINDOWPOSCHANGED should be sent after the window has been moved/sized.

Hope that helps,

ZOPPO
Hi Matt,

The suggestion of Zoppo wouldn't work if there are more than one WM_WINDOWPOSCHANGING  (therefore WM_WINDOWPOSCHANGED as well). If you do some of the drawing yourself (?), you could call a PostMessage with a private message id (WM_USER + something) to the window yourself. PostMessage means that it was put at end of queue. Then when handling the private message it should grab all  (hopefully).

Regards, Alex
Just an idea - everything should be drawn when you call 'WaitForInputIdle()' on the process whose window you want to capture and the call returns...
Avatar of flynny

ASKER

Hi Guys,

thanks for the replie. As Itsme says catching th WM_WINDOWPOSCHANGED doesn't work.

ok, itsme in order to use the WM_USER message, i tried PostMessage(hwnd, WM_USER+10, 0, 0);
where i process the WM_WINDOWPOSCHANGED message, this does call my method however it seems to only be drawing a small pane of the window for some reason. (even though i know the window i have sent is the correct window.

jkr, if i were to use the waitforidleinput(), would i again for example at the end of my WM_WINDOWPOSCHANGED process be calling a <processname>.WaitForIdleInput() and then calling my bitmap write? would this cause problems as i'm waiting for no iput when im actually processing a message there too? (also how do i get the process name from the hwnd will GetWindowThreadProcessId do th trick?)

many thanks guys.

Matt.
ASKER CERTIFIED SOLUTION
Avatar of itsmeandnobodyelse
itsmeandnobodyelse
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial