I want to move my gadget but it is not working.
Can anybody give me some clue about the problem?
Is there any fastest solution?
Code: Select all
Global StartMoving.l = #False
Global MovingMouseOffset.l = -1
Global LastMouseLocation.l = -1
Enumeration
#MainWindow
#MainContainer
#MoveButton
EndEnumeration
If OpenWindow(#MainWindow, 800, 0, 155, 25, "", #PB_Window_BorderLess)
ButtonGadget( #MoveButton, 1, 1, 30, 20, "Test")
Repeat
Event = WaitWindowEvent()
If StartMoving
xx.l = WindowMouseX(#MainWindow)
If Not LastMouseLocation = xx
LastMouseLocation = xx
xx = xx - MovingMouseOffset
Debug Str(xx)
ResizeWindow(#MainWindow, xx, 0, #PB_Ignore, #PB_Ignore)
EndIf
EndIf
If Event = #PB_Event_Gadget
SelectedGadget.l = EventGadget()
If SelectedGadget = #MoveButton
If StartMoving
StartMoving = #False
Debug "Stop Moving"
Else
StartMoving = #True
Debug "Start Moving"
MovingMouseOffset = WindowMouseX(#MainWindow) - WindowX(#MainWindow, #PB_Window_FrameCoordinate)
EndIf
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
EndIf