last day (15 days later) » 

7:11 PM
0
Q: Can I restore the window without focusing it?

Tomáš ZatoAs a normal windows user, I rarely distinguish between window being in background and minimised - the effect is usually the same: I don't see it. But in fact, minimised windows do have client rectangle of zero dimensions. As such, it's impossible to take a screenshot of them. My application need...

 
You seem to be confusing foreground and visible. The foreground window is the window the user is currently working with. It need not be visible. A visible window is not necessarily the foreground window. Please update your question with established terminology (see Windows (Windows)).
 
I'm not confusing anything in this case, even though your comment was useful to me in the therms of giving things correct names. I want to make window visible while not putting in foreground.
 
This is not generally possible. You will not win the arms race for becoming the really really topmost window. While SetWindowPos with the right parameters goes a long way, there is no guarantee for success. In general, it is not possible to have an invisible window render itself (WM_PRINTCLIENT helps, but not all windows will handle it). You could try the thumbnail toolbar facilities, but applications will get it wrong, too.
 
And why is it not possible to make window visible by native system approach (like when I click it in the taskbar) but without it also becoming foreground? I keep reading and searching the documentation without success. It's, however, possible to "restore" the window on background using SW_SHOWNOACTIVATE. But if the window was maximised before being minimised, it will be normal. This is bad for programs like web browser. But maybe, I could GetForegroundWindow then SW_SHOW and then show the formerly foreground window. But this effect would be visible to me and annoying. Needs test.
WM_PRINTCLIENT will not help in my opinion. What I actually have trouble with is GetClientRect not giving any rectangle (I get [0,0,0,0]) but returning true like everything was OK. This happens for minimised windows.
 
You assume that you are always able to make a window visible by means of user input. That is not correct. Open Task Manager, go to Options and enable Always on top. Now maximize the window. Even though you are still able to make other windows the foreground window, no window besides Task Manager will be visible. The same concepts apply to API calls. You cannot win this game.
 
7:11 PM
Can we talk about that more? I would be really graceful if you could explain this
to me, but I think other visitors wouldn't benefit from the comment thread
To your last message: I was thinking that even a window, that is not visible for the user still can be visible as being rendered
Especially then now with the Windows 7 Aero that makes windows transparent
However I already succeeded in restoring the window on background properly
I think at least
But screenshot is white, even though it has correct dimensions.
 
7:38 PM
If a window is obscured by other windows, your code to take a screenshot will not produce the desired result.
The code will simply copy what's on the screen, irrespective of which window rendered it.
As an aside, the Aero glass effect is gone starting with Windows 8. So no translucent borders anymore (although the Desktop Window Manager would still be capable of producing the effect).
 
You're wrong on that one. I can make screenshot of windows that are not visible on the screen
I'm doing this for a long time - but as my question suggests, it's not 100% reliable
Particularly, the minimalisation causes problems
 
If I say "It's not possible" it is meant to say "It's not reliably possible".
 
Then you're right as of what I know noe
*now
However I was thinking that there could be a way to convince the window that it's visible. The question is what the OS does with the rendered data then
I started sending WM_PAINT just to see what happens.
Though I had 0 fails until then, I'm not sure how reliable this is
and according to MS documentation it's wrong to do it.
 
Again, this won't work reliably. Certain applications implement logic to check, whether they are minimized/visible and will not perform any rendering even in response to a WM_PAINT message.
 
Why do they do so?
 
7:47 PM
If rendering is expensive, for example.
 
I suppose games turn of the renderer when they are minimalised. But I'm restoring the window before calling paint event
Which would get pretty annoying for games
And do you think it's possible to check whether my attempt was sucessful or not?
So that the unreliable code at least knows it failed?
 
I wouldn't know of any way to check the result of an unsupported operation.
 

last day (15 days later) »