We help IT Professionals succeed at work.

Help screen capturing and drawing a bitmap

flynny
flynny asked
on
295 Views
Last Modified: 2008-01-09
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.
Comment
Watch Question

CERTIFIED EXPERT

Commented:
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
jkr
CERTIFIED EXPERT
Top Expert 2012

Commented:
Just an idea - everything should be drawn when you call 'WaitForInputIdle()' on the process whose window you want to capture and the call returns...

Author

Commented:
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.
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.