Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Monitor powersave status

Posted on 2003-03-16
7
Medium Priority
?
171 Views
Last Modified: 2011-09-20
Hi,

How can I tell the power status of the display. I know how to turn it on/off but I need to track it's state, either manually (by getting my_syscommand messages?) or by asking the status. I'm sure there is an easy way, but I can't see the obvious way myself :(
0
Comment
Question by:Mat_a
6 Comments
 
LVL 6

Expert Comment

by:DaFox
ID: 8150188
Hi.

Try to trap the SC_MONITORPOWER message.

(procedure WMSysCommand (var Msg : TWMSysCommand); message WM_SYSCOMMAND;)

Markus
0
 

Author Comment

by:Mat_a
ID: 8150558
type
  TForm1 = class(TForm)
...
    procedure WMSysCommand(var Msg: TMessage); message
...

procedure tForm1.WMSysCommand(var Msg: TMessage);
Begin
   If msg.wParam=sc_monitorPower Then
       Memo1.Lines.Add('l:'+IntToStr(msg.LParam)+'  R:'+IntToStr(msg.Result));
   Inherited;
End;

I'd already tried that, but nothing got populated in the memo :(
0
 
LVL 6

Expert Comment

by:DaFox
ID: 8151001
Hi.

Try

procedure tForm1.WMSysCommand(var Msg: TMessage);
var
  w: WParam;
begin
  if (Msg = WM_SYSCOMMAND) then
  begin
    w := wParam and $FFF0;
    if (w = SC_MONITORPOWER) then
    begin
      Memo1.Lines.Add('l: ' + IntToStr(Msg.lParam) + '  R: ' + IntToStr(Msg.Result));
    end;
  end;
  inherited;
end;

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

Markus
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:Mat_a
ID: 8151318
Ok further investigations shows :-
1) My original routine does work!
2) It doesn't work if "SendMessage(Application.Handle,WM_SYSCOMMAND,SC_MONITORPOWER,1)" is sent by a user application (even if it's the same app, but that's no biggy)
3) It only detects the power down, and not monitor power bup again...

I've increased the points on this to 100 if I can get a satisfactory answer.
0
 

Expert Comment

by:CleanupPing
ID: 9316754
Mat_a:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 10639949
PAQed, with points refunded (100)

modulo
Community Support Moderator
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Loops Section Overview
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

579 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question