|
-
Jul 10th, 2003, 02:02 PM
#1
Attempting to save current screen
Here is the code that I can not get to work to save the current screen and to restore it. What did I do incorretly?
Code:
HDC SaveScn;
// other variables in code
tx=GetSystemMetrics(SM_CXFULLSCREEN);
ty=GetSystemMetrics(SM_CYFULLSCREEN);
void SaveScreen()
{
HDC CurScn;
// Save all graphics on screen
SaveScn = CreateCompatibleDC(0);
CurScn = GetDC(OrghWnd);
BitBlt(SaveScn, 0, 0, tx, tx+360, CurScn, 0, 0, SRCCOPY);
ReleaseDC(OrghWnd,CurScn);
GetKey(OrghWnd);
}
void RestoreScreen()
{
HDC CurScn;
// Restore saved screen
CurScn = GetDC(OrghWnd);
// SelectObject(CurScn, SaveScn);
BitBlt(CurScn, 0, 0, tx, ty+360, SaveScn, 0, 0, SRCCOPY);
ReleaseDC(OrghWnd,CurScn);
GetKey(OrghWnd);
}
Last edited by randem; Jul 10th, 2003 at 02:18 PM.
-
Jul 11th, 2003, 07:34 AM
#2
Well, what is the problem (beside that it "doesn't work" )?
You should pass a real DC to CreateCompatibleDC.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jul 11th, 2003, 08:48 AM
#3
Corned Bee,
The problem may be my understanding of the DC. I get no errors but the if I call SaveScreen() then change the screen then call RestoreScreen()... nothing appears to happen.
I would expect the old screen to reappear. I can load an image and put that to the screen (other code) but I can not save the current screen then restore it later with the posted code. Since I am not getting any errors I have to assume that it is a logic problem (me).
I was hoping someone could shed some light on this (for it is dark in this tunnel).
-
Jul 11th, 2003, 11:09 AM
#4
Hyperactive Member
Why are you saving and restoring the whole screen? Is your app window cover everything?
If you want to restore the desktop window and the windows in it, you may try the below,
Code:
RedrawWindow (NULL, NULL, NULL, RDW_ERASE+ RDW_INVALIDATE+ RDW_ALLCHILDREN+ RDW_ERASENOW);
-
Jul 13th, 2003, 12:03 PM
#5
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jul 13th, 2003, 12:15 PM
#6
transcendental,
I shall try this, I'll let you know and thanks Corned Bee for the correction. Now how does RedrawWindow know which window to redraw or does it just redraw the window that is active at the moment?
-
Jul 13th, 2003, 12:15 PM
#7
Frenzied Member
Originally posted by CornedBee
|, not +
Does the same thing in this case.
Z.
-
Jul 13th, 2003, 12:18 PM
#8
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jul 13th, 2003, 09:19 PM
#9
And still... What is wrong with my posted code????
-
Jul 14th, 2003, 12:50 AM
#10
Hyperactive Member
Originally posted by randem
transcendental,
I shall try this, I'll let you know and thanks Corned Bee for the correction. Now how does RedrawWindow know which window to redraw or does it just redraw the window that is active at the moment?
All the windows in the Desktop will be redrawn.
Originally posted by CornedBee
Lucky then...
It is not a matter of luck. I know my C++ well.
-
Jul 14th, 2003, 02:45 AM
#11
I know, I do too. Actually it was bound to work in this case.
Other matter if you accidentally write
WS_OVERLAPPEDWINDOW + WS_POPUP 
randem: which, the saving code? Windows simply doesn't work that way. Every window is supposed to draw itself, not be drawn by someone else.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jul 14th, 2003, 09:23 AM
#12
CornedBee,
Well, suppose I want to save a current window (unknown to what is in it) then paint it into another location or window etc... How would be the senario there?
Save the windows data
Paint the windows data elsewhere (another window or memory DC).
Do something with it
What is the best way for this?
-
Jul 14th, 2003, 09:26 AM
#13
That depends on what you actually want to do with the data. Screenshots work that way.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jul 14th, 2003, 09:42 AM
#14
Hey Guys,
I placed the RedrawWindow function (as posted) in my WM_ACTIVATEAPP message section, it fires and my windows are not redrawn. I am switching between apps and want the windows to refresh when the program is selected again.
There is no error in the RedrawWindow functions return.
Any clue?
Last edited by randem; Jul 14th, 2003 at 09:48 AM.
-
Jul 14th, 2003, 02:40 PM
#15
Try InvalidateRect to invalidate all windows, thus forcing redraw? Pass NULL as the RECT*.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|