Click to See Complete Forum and Search --> : how to restore screen
sjcguy
September 21st, 2005, 08:16 PM
Hello
i have a function to draw entire of screen with know pattern or black out screen.
HWND hWnd = GetDesktopWindow();
RECT cRect;
GetClientRect(hWnd, &cRect);
HDC hdc = GetWindowDC(hWnd);
// Create a SolidBrush object.
HBRUSH hbr = CreateSolidBrush(RGB(0,0,0));
HRGN hrgn = CreateRectRgn(cRect.left,cRect.top,cRect.right,cRect.bottom);
// Fill the region.
FillRgn(hdc, hrgn, hbr);
However, i dont know how to get back to original state like refresh the whole screen unless i do mouse movement or alt_ctl_del
running on WindowXP
thanks.
golanshahar
September 22nd, 2005, 02:30 AM
do you mean you need:
::InvalidateRect(0,0,0);
?
Cheers
sjcguy
September 22nd, 2005, 12:24 PM
Hi
I thought I did that but doesn't work. Now it works perfectly.
thanks.
I have another question hopefully someone can help:
From the code above I can black out screen but there are still mouse cursor, editor cursor blinking if editor happens to be on top and some icons at the very right bottom of screen is active(anti virus is active) and screwed up my black screen.
I'd like to blackout screen, draw some pattern so the data going down the DVI cable is known data.
Thanks.
golanshahar
September 22nd, 2005, 12:29 PM
Hi
I thought I did that but doesn't work. Now it works perfectly.
thanks.
Your welcome :)
From the code above I can black out screen but there are still mouse cursor, editor cursor blinking if editor happens to be on top and some icons at the very right bottom of screen is active(anti virus is active) and screwed up my black screen.
well i think better solution will be if you will create a window that covers the whole screen, you can paint it in any color you want, you will put it as a top window, and you will not have refreshing problems at all, mouse blinking and stuff like that!
its the proper way to do it.
Cheers
sjcguy
September 22nd, 2005, 12:44 PM
thanks for the suggestion but I know (probably) did in MFC but i don't know how to do it in win32. In MFC, i create a Dialog the cover the entire of screen but how about win32? Would you give me a hint?
thanks.
golanshahar
September 22nd, 2005, 12:59 PM
look at the attached sample i just wrote something very basic....hope it will give you some good start ;)
Cheers
sjcguy
September 22nd, 2005, 02:49 PM
Sorry I am lost :(.
Let me ask this way;
how do I create a window ( as class) so in my generic c++ class, i can instantiate and show on screen??
thanks.
golanshahar
September 22nd, 2005, 03:24 PM
did you look and run the code i sent you?
if you want it in a class then add it to a class... i dont know what's the problem :confused:
Cheers
sjcguy
September 23rd, 2005, 05:09 PM
I did but now i know how to use it. not sure it's the right way.
thanks :)
golanshahar
September 23rd, 2005, 05:16 PM
I did but now i know how to use it. not sure it's the right way.
thanks :)
well its much better then ::FillRgn(..) or ::FillRect(..) on the desktop dc, cause you will have a lot of problems with refreshing/paintings , and if some kind of window will revieve paint message part of your black rect can be earsed...not mention the problem you had with caret blinking ;)
Cheers
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.