Question:
How can I turn an low power compliant monitor off?
Answer:
You can send a wm_SysCommand message with the WParam parameter set
to SC_MonitorPower and the LParam parameter set to 0 to turn the
monitor off, and -1 to turn the monitor back on. The following example
turns the monitor off for a 10 second interval.
Example:
type
TForm1 = class(TForm)
Button1: TButton;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
MonitorOff : bool;
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
Timer1.Enabled := false;
Timer1.Interval := 10000;
MonitorOff := false;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if MonitorOff then begin
MonitorOff := false;
SendMessage(Application.Handle,
wm_SysCommand,
SC_MonitorPower,
-1);
Timer1.Enabled := false;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
MonitorOff := true;
Timer1.Enabled := true;
SendMessage(Application.Handle,
wm_SysCommand,
SC_MonitorPower,
0);
end;