name22

Lock Window Position

Nov 18th, 2012
176
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <WinAPI.au3>
  2. #include <WindowsConstants.au3>
  3. #include <GUIConstants.au3>
  4.  
  5. ; -Author: name22 (www.autoit.de)
  6.  
  7. Global $bLock = False, $tRect_Pos
  8.  
  9. Global $hWnd = GUICreate("Test", 200, 100)
  10. Global $cButton_LockPos = GUICtrlCreateButton("Lock Window", 50, 35, 100, 30)
  11. GUISetState()
  12.  
  13. While True
  14.     Switch GUIGetMsg()
  15.         Case $GUI_EVENT_CLOSE
  16.             Exit
  17.         Case $cButton_LockPos
  18.             Switch $bLock
  19.                 Case False
  20.                     $tRect_Pos = _WinAPI_GetWindowRect($hWnd)
  21.                     GUIRegisterMsg($WM_MOVING, "_Moving")
  22.                 Case True
  23.                     GUIRegisterMsg($WM_MOVING, "")
  24.             EndSwitch
  25.             $bLock = Not $bLock
  26.     EndSwitch
  27. WEnd
  28.  
  29. Func _Moving($hWnd, $iMsg, $wParam, $lParam)
  30.     Local $tRect_Moving = DllStructCreate($tagRECT, $lParam)
  31.     For $i = 1 To 4
  32.         DllStructSetData($tRect_Moving, $i, DllStructGetData($tRect_Pos, $i))
  33.     Next
  34. EndFunc
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×