OK,

i wanna be able to switch off my screen via code (using v/c)

looked through my old code and found this.... - it doesnt work though, comes out with Error 6: overflow, pointing to sendmessage....

now ive got a fresh xp install so maybe its something i havent set up correctly, so does this need something setting to be able to use it?

vb Code:
  1. Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Long) As Long
  2.  
  3. Const SC_MONITORPOWER = &HF170&
  4. Const MONITOR_ON = -1&
  5. Const MONITOR_OFF = 2&
  6. Const WM_SYSCOMMAND = &H112
  7.  
  8. Private Sub ControlScreenPower(bTurnOn As Boolean)
  9.  
  10.     Select Case bTurnOn
  11.         Case True:
  12.             'Turn Monitor on:
  13.             SendMessage Me.hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_ON
  14.         Case False:
  15.             'Turn Monitor off:
  16.             SendMessage Me.hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF
  17.     End Select
  18.  
  19. End Sub
  20.  
  21. 'me.hwnd = 2294342
  22. ' WM_SYSCOMMAND= 274
  23. ' sc_monitorpower = 61808
  24. ' monitor on = -1
  25. ' and off = 2

i havent actually tried it on another machine yet, but if you guys say its right ill make an install n check it on the other machine