Seite 1 von 1

(Win32) Die Maus in ihrer Bewegung einschränken

Verfasst: 08.10.2004 04:18
von nco2k
hi folks,

ich habe auf die schnelle mal ein beispielcode geschrieben, welcher solange das fenster aktiv ist, die maus in ihrer "bewegungsfreiheit" einschränkt und somit nur innerhalb der client area zulässt.

die includefile findet ihr hier: http://forums.purebasic.com/german/viewtopic.php?t=360

Code: Alles auswählen

IncludeFile "ClientSize.pbi"

If OpenWindow(0, 0, 0, 320, 240, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "Lock Mouse Demo")
  If CreateGadgetList(WindowID(0))
    ButtonGadget(0, 210, 205, 100, 25, "Exit", #PB_Button_Default)
    AddKeyboardShortcut(0, #PB_Shortcut_Escape, 0)
    
    Repeat
      
      If GetForegroundWindow_() = WindowID(0)
        MouseRect.RECT
        MouseRect\left = WindowClientX(0)
        MouseRect\top = WindowClientY(0)
        MouseRect\right = WindowClientX(0) + WindowWidth(0)
        MouseRect\bottom = WindowClientY(0) + WindowHeight(0)
        ClipCursor_(MouseRect.RECT)
      Else
        ClipCursor_(0)
      EndIf
      
      Select WaitWindowEvent()
        Case #PB_Event_Menu
          Select EventMenu()
            Case 0
              End
          EndSelect
        Case #PB_Event_Gadget
          Select EventGadget()
            Case 0
              End
          EndSelect
        Case #PB_Event_CloseWindow
          End
      EndSelect
      
    ForEver
    
  EndIf
EndIf

End
c ya,
nco2k