The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: erkki on March 20, 2006, 12:35:33 AM

Title: how to blank the screen
Post by: erkki on March 20, 2006, 12:35:33 AM
i'm looking for a way to blank the screen with masm32. the reason a screensaver wont do is that i dont want the screen to unblank on every mouse/keyb activity. any suggestions?
Title: Re: how to blank the screen
Post by: hutch-- on March 20, 2006, 01:19:22 AM
Dreate a maximised window with no titlebar or border and fill it with whatever bckground colour you want. It is in fact a very simple task.
Title: Re: how to blank the screen
Post by: erkki on March 20, 2006, 11:30:26 AM
pardon my inaccuracy. the problem is not in filling it with any color, but in turning the screen lighting / monitor off :boohoo:
Title: Re: how to blank the screen
Post by: jckl on March 20, 2006, 12:24:34 PM
Have a look at this page.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardaccelerators/keyboardacceleratorreference/keyboardacceleratormessages/wm_syscommand.asp

You can use SendMessage with WM_SYSCOMMAND and SC_MONITORPOWER

This line below will shut off your screen..

Invoke SendMessage, HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2
Title: Re: how to blank the screen
Post by: erkki on March 20, 2006, 12:52:21 PM
thnx, jckl. i'll get cracking  :U
Title: Re: how to blank the screen
Post by: Tedd on March 20, 2006, 06:12:44 PM
There should be a button on the monitor, try pressing it, I believe it will turn off the whole screen :cheekygreen:

{The SC_MONITORPOWER function will still allow reactivation of the screen when a keyboard/mouse event is detected.}


[attachment deleted by admin]
Title: Re: how to blank the screen
Post by: erkki on March 20, 2006, 10:39:04 PM
in fact there isn't.
Title: Re: how to blank the screen
Post by: erkki on March 20, 2006, 11:19:34 PM
if i get it right, there's no standard way to do it with monitorpower (or maybe only a very complicated one), and maybe no standard programmatic way at all. so unless someone has other ideas, i'm back to sq 1
Title: Re: how to blank the screen
Post by: Mark Jones on March 21, 2006, 01:48:54 AM
Hello Erkki, check this out: http://www.masmforum.com/simple/index.php?topic=1897.0

Found it by typing "monitor standby" in the search box above. Good luck.
Title: Re: how to blank the screen
Post by: ChrisLeslie on March 21, 2006, 04:31:04 AM
What is wrong with Hutch's suggestion - with black!. Then you have an easy programed control of blanking/unblanking. Keep it simple.

Chris  :wink
Title: Re: how to blank the screen
Post by: MichaelW on March 21, 2006, 08:01:42 AM
Quote from: erkki on March 20, 2006, 10:39:04 PM
in fact there isn't.

There is no power button on the monitor? Could it be that the power button is not accessible because you are trying to control someone else's monitor, in an effort to hide your activities?

Title: Re: how to blank the screen
Post by: erkki on March 21, 2006, 01:36:07 PM
Mark Jones - the thread you found is on SC_MONITORPOWER, which is of no use for me, as it unblanks on keyb/mouse activity automatically (whereas i would want a custom unblank on, say, Esc only)

ChrisLeslie - i agree that black would be simpler, but black and poweoff/standby/low power have visible difference (on my lcd at least). with black the screen is still illuminated by backlighting, on the others not

MichaelW - i have a new laptop model with no monitor switch (only lcd/crt switch, which unfortunately doesnt work if i'm not connected to an external monitor. if it worked i'd happily use this lcd/crt to unblank my screen)
Title: Re: how to blank the screen
Post by: jckl on March 21, 2006, 01:42:07 PM
If you dont mind me asking may i know the reasons at which you need to make the screen non visable to the point where you do not want it to be reinstated on key press or mouse move?
Title: Re: how to blank the screen
Post by: erkki on March 21, 2006, 01:46:26 PM
jckl - my work requires me to write a lot, and i'm used to blind typing
Title: Re: how to blank the screen
Post by: P1 on March 21, 2006, 04:53:01 PM
I have seen where you need to have the Monitor Manufacturer's inf loaded, before you can get the "Green" features to work, if they are there in the first place.  If Monitor is not "Green", then Black blanking is all you got.  Some ( dumb ) monitors have power save function that are not controlled by software, but monitoring the VGA inputs.

Time to buy a new LCD flat panel with "Green" features???

Regards,  P1  :8)
Title: Re: how to blank the screen
Post by: erkki on March 21, 2006, 06:46:09 PM
nope. the "green" (power saving?) features work ok - low power lcd, monitor off etc. i have the blank screen ("green", not black) screensaver. my problem is a generic one: screensavers and SC_MONITORPOWER unblank on user activity, whereas I WANT TO WRITE WITH MONITOR OFF, which seems to be impossible

do you think this problem could be approached with int 10h? pardon if it's a stupid suggestion, i'm new to masm32
Title: Re: how to blank the screen
Post by: Mark Jones on March 21, 2006, 07:00:37 PM
Aaah I see what you're saying. Guess it's a matter of how Windows powers up the monitor on keypress then - maybe globally hook the keyboard and force it to bypass all windows callback messages? If that is even possible, I'm not certain. :wink
Title: Re: how to blank the screen
Post by: erkki on March 21, 2006, 07:49:45 PM
this would be one (but perhaps hopelessly complicated) way to work around the problem, yes

other ideas i have are:

- int 10h (which is more a flashback from 16-bit days than a solid idea) and

- finding a way to trick the system thinking that it is connected to an external monitor. this would make the lcd/crt switch key work, and the switch key could then be used to turn lcd on/off. by default the lcd/crt switch works only when the computer is connected to an external monitor
Title: Re: how to blank the screen
Post by: P1 on March 21, 2006, 10:03:53 PM
Create a new black desktop and let everything run on the old until to switch from or destroy the new desktop.

Regards,  P1  :8)
Title: Re: how to blank the screen
Post by: erkki on March 22, 2006, 12:22:08 AM
yes, well, this would still be a black desktop - a solution i've already tried and discarded (see above) - not the lcd power off i want
Title: Re: how to blank the screen
Post by: P1 on March 22, 2006, 01:55:09 PM
Quote from: erkki on March 22, 2006, 12:22:08 AM
yes, well, this would still be a black desktop - a solution i've already tried and discarded (see above) - not the lcd power off i want
Seek manufacturer's help.

Regards,  P1   :8)
Title: Re: how to blank the screen
Post by: elmo on April 15, 2011, 12:13:06 PM
the following code will turn off the monitor directly
         invoke SendMessage, hWin,WM_SYSCOMMAND,SC_MONITORPOWER,2   ;MONITOR_OFF

but I want to do it gradually.
So, What I want is:  I want to change monitor brightness or contrast.
but how?
would you like to give me a clue?
Thank you.
sorry for my bad english
Title: Re: how to blank the screen
Post by: Tedd on April 15, 2011, 02:34:06 PM
It's not wise to fiddle with a user's settings, but it's not necessary.

Copy the contents of the screen to a memory bitmap, create a fullscreen window (make it 'on-top'), bitblt the bitmap to your window, then fade your bitmap, pause, copy to screen, repeat until black. And then put the screen into power-save mode, and destroy your window.
Title: Re: how to blank the screen
Post by: Magnum on April 15, 2011, 02:34:51 PM
Thanks Tedd.

I found your program to be very useful.



Title: Re: how to blank the screen
Post by: dedndave on April 15, 2011, 03:09:25 PM
a while back, the guys were having fun doing something similar
you will get a chuckle out of this stuff - and the code may be along the lines of what you want
there are a few examples in this thread
http://www.masm32.com/board/index.php?topic=2172.msg17208#msg17208
and one here by Erol
http://www.masm32.com/board/index.php?topic=13318.msg103634#msg103634