I'm trying to use SenMessage() to turn the display on or off under program
control of a console application.    I got the function to work, and it
turns off the display, but then the program just hangs.  

Does anyone know what I am doing wrong?

 

Here's my sample program

Program Displaycontrol;

Uses Windows;

Begin

  Writeln('Turning Off Display');

  SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2);
//This seems to work, turning off my display

  Writeln('Display is Off');                      // This Writeln never
happens.    I need to force terminate the program.

  sleep(10000);

  Writeln('Turning On Display');

  SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, -1);

  Writeln('Display is On');

End.

 

James

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to