PDA

Click to See Complete Forum and Search --> : Start Screen Saver


akia
Jan 28th, 2002, 09:14 PM
I have written the code to start the Screen Saver in both C and VB, the C code works fine, but for some reason, the VB code opens up the dialoge box that warns windows is about to go into tand by. I am confused, I'm sending C the same parameters as VB, but they are behaving differently.

My code:

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long

Const WM_SYSCOMMAND = &H112
Const SC_SCREENSAVE = &HF140&

Private Sub SomeSub()
SendMessage(Form1.hwnd, WM_SYSCOMMAND, SC_SCREENSAVE, 0)
End Sub


Thankyou, akia

JoshT
Jan 29th, 2002, 10:33 AM
Try changing:

SendMessage(Form1.hwnd, WM_SYSCOMMAND, SC_SCREENSAVE, 0)

To

SendMessage(Form1.hwnd, WM_SYSCOMMAND, SC_SCREENSAVE, ByVal 0&)

It's just a hunch, but I've seen this fix weird problems before.

akia
Jan 30th, 2002, 06:13 AM
Incredible, thanks heaps. It wasn't overly important, but it was bugging me.

Works perfectly now.