Sign in to follow this  
gargling_mayonnaise

Help with GDI screenshot

Recommended Posts

Hello, i need a little help, i'd like to take a shot of my desktop using GDI functions but excluding a particular window(i've the hWnd of that window because of a shell hook) so that the final image will have the desktop screen with every windows on it except that window, i've tried to hide it before taking the shot but without any good result, i think the problem was that hiding a windows need at least a refresh of the desktop but i'm taking the shot inside the wndproc, i'm sure i'm doing something wrong with it. Any help appreciated! -GM

Share this post


Link to post
Share on other sites
The problem is refreshing the desktop, i've tried to change the style removing WS_VISIBLE and then calling SetWindowPos to refresh it but desktop keeps holding the window(at least graphically), i need to do it quickly, hide the window take the shot and show back the window, user should not recognize it, the only way it worked was calling ChangeDisplaySettings(0,0) but i think it's a forcing apart from an evident refresh.

-GM

Share this post


Link to post
Share on other sites
Erik Rufelt    5901
How do you set the window style?
Have you tried simply using ShowWindow, or CloseWindow?
Minimizing won't be invisible probably, but not much of a distraction..
Also try putting a Sleep(100) or something after hiding the window, not enough time to really be noticeable, but might be enough for background windows to refresh. Ofcourse this won't be a guarantee on all systems, for that you would probably need to iterate through all visible windows that was behind the window you hide, and call UpdateWindow on them.

Share this post


Link to post
Share on other sites

DWORD style = GetWindowLongPtr(hW,GWL_STYLE);
style &= ~WS_VISIBLE;
SetWindowLongPtr(hW, GWL_STYLE, style );
SetWindowPos( hW, hW, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED );



Uhmm, tried to invalide and update with hwnd_broadcast but nothing to do, it's quite strange, the only way it worked is ChangeDisplaySettings, that is a forcing and it's not good for what i need to do, i really dunno how to get away with it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this