?
Solved

Monitor powersave status

Posted on 2003-03-16
7
Medium Priority
?
169 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

752 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