Detectar activacion del Protector de Pantalla
Hola. Necesito que alguien me ayude como hacer para detectar el momento en que se activa el protector de pantalla, usando C++ Builder. Agradezco de antemano cualquier ayuda que me puedan proporcionar.
Por fin una pregunta algo interesante: aqui te va el codigo::::
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
// Averiguar si el protector activo
//y cual es su timeout
BOOL bActive;
int nTimeout;
SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, &bActive, 0);
SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0, &nTimeout, 0);
if(bActive)
Label1->Caption = "Screensaver esta activo";
else
Label1->Caption = "Screensaver fue desactivado";
Label2->Caption = "El timeout es " + IntToStr(nTimeout);
}
//---------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
// habilita el screensaver.
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, TRUE, NULL, 0);
}
//---------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
//deshabilitar el screensaver.
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, FALSE,NULL, 0);
}
//---------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
//setear el timeout a 30 segundos.
SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, 30, NULL, 0);
}
//********************************************
OTRA FORMA
//----------------------------------------------
// UNIT1.H
private: // User declarations
void __fastcall WndProc(Messages::TMessage &Message);
//----------------------------------------------
// UNIT1.CPP
void __fastcall TForm1::WndProc(Messages::TMessage &Message)
{
if( (Message.Msg == WM_SYSCOMMAND) &&
(Message.WParam == SC_SCREENSAVE) )
{
ShowMessage("screensaver DESHABILITADO!");
Message.Result = true;
}
else
TForm::WndProc(Message);
}
Espero te sirva, a mi me funciona de maravillas !!!
Suerte en eso!
chau
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
// Averiguar si el protector activo
//y cual es su timeout
BOOL bActive;
int nTimeout;
SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, &bActive, 0);
SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0, &nTimeout, 0);
if(bActive)
Label1->Caption = "Screensaver esta activo";
else
Label1->Caption = "Screensaver fue desactivado";
Label2->Caption = "El timeout es " + IntToStr(nTimeout);
}
//---------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
// habilita el screensaver.
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, TRUE, NULL, 0);
}
//---------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
//deshabilitar el screensaver.
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, FALSE,NULL, 0);
}
//---------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
//setear el timeout a 30 segundos.
SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, 30, NULL, 0);
}
//********************************************
OTRA FORMA
//----------------------------------------------
// UNIT1.H
private: // User declarations
void __fastcall WndProc(Messages::TMessage &Message);
//----------------------------------------------
// UNIT1.CPP
void __fastcall TForm1::WndProc(Messages::TMessage &Message)
{
if( (Message.Msg == WM_SYSCOMMAND) &&
(Message.WParam == SC_SCREENSAVE) )
{
ShowMessage("screensaver DESHABILITADO!");
Message.Result = true;
}
else
TForm::WndProc(Message);
}
Espero te sirva, a mi me funciona de maravillas !!!
Suerte en eso!
chau
