Moving window glitchy

BlitzMax Forums/BlitzMax GUI Programming/Moving window glitchy

I don't think an EventHook will help, the problem is the event coordinates are relative to the panel so the act of moving it's parent window is effectively moving the mouse (window moves left mouse has effectively moved right in relation to the windows contents).

Taking this into account:

Import maxgui.drivers

Global ItemWindow:TGadget
Global Panela:TGadget 

Global X1:Int
Global Y1:Int

ItemWindow = CreateWindow("Test Window", 100, 100, 600, 450, Null, Null) 
Panela= CreatePanel(0, 0, 600, 450, ItemWindow,PANEL_ACTIVE) 

Repeat

WaitEvent()
	Select EventID() 
		Case event_mousedown
			If EventData() = 1
				If EventSource() = Panela
					x1 = CurrentEvent.x
					y1 = CurrentEvent.y
				End If
			Else
				End
			End If
		Case event_mousemove
			If EventData() = 1 
				If EventSource() = panela
					dx= CurrentEvent.x-x1
					dy= CurrentEvent.y-y1
					SetGadgetShape(ItemWindow,GadgetX(ItemWindow)+dx,GadgetY(ItemWindow)+dy,GadgetWidth(ItemWindow),GadgetHeight(ItemWindow))
					x1 = CurrentEvent.x-dx
					y1 = CurrentEvent.y-dy
				End If
			End If
	End Select
Forever