Главная страница | назад





Article #16008: Turning an low power compliant monitor off?

 Question and Answer Database

FAQ1008D.txt   Turning an low power compliant monitor off?
Category   :Windows API
Platform    :All
Product    :All 32 bit  

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;


7/16/98 4:31:28 PM
 

Last Modified: 01-SEP-99