Hm,
good idea to use the control key, thanks - anyhow it is still tricky for me, because the window seems be glued now to the mouse cursor and even when I release the control key, the window follows the cursor. This wouldn't be a problem, but I need another click to "free" the window - and this should not start an action. I added
Code: Select all
Case #WM_LBUTTONUP
If Down
Down=0
EndIf
now, this seems to work now.
Now I try to do some finetuning, a first click in the top area produces four (!) events here, must check that as well.
Code: Select all
Enumeration
#MainWindow
#MenuQuit
EndEnumeration
Define p.POINT,m.POINT
Global Counter
Procedure ShowCounter()
StartDrawing(CanvasOutput(0))
DrawText(10,10,"Counter "+Str(counter),#Black,#White)
DrawText(400,10,"Down "+Str(Down),#Black,#White)
LineXY(0,50,500,50,#Red)
DrawingMode(#PB_2DDrawing_Outlined)
Box(0,0,500,500,#Blue)
StopDrawing()
EndProcedure
WinID=OpenWindow(#MainWindow,0,0,500,500,"", #PB_Window_ScreenCentered|#PB_Window_BorderLess|#PB_Window_Invisible)
SetWindowColor(#MainWindow,#Red)
CanvasGadget(0,0,0,500,500); <------
AddKeyboardShortcut(#MainWindow,#PB_Shortcut_Escape,#MenuQuit)
ShowCounter()
StickyWindow(#MainWindow,1)
HideWindow(#MainWindow,0)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Menu
If EventGadget()=#MenuQuit
Break
EndIf
Case #PB_Event_Gadget
Select EventGadget()
Case 0
If EventType() = #PB_EventType_LeftButtonDown Or (EventType() = #PB_EventType_MouseMove And GetGadgetAttribute(0, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
;If GetAsyncKeyState_(#VK_CONTROL) & 32768 = 0
If GetKeyState_(#VK_CONTROL)&128=0
Debug FilterButton
If 1;FilterButton=0
x = GetGadgetAttribute(0, #PB_Canvas_MouseX)
y = GetGadgetAttribute(0, #PB_Canvas_MouseY)
If y<55
Counter+1
ShowCounter()
Else
StartDrawing(CanvasOutput(0))
Circle(x, y, 10, RGB(Random(255), Random(255), Random(255)))
StopDrawing()
EndIf
Else
FilterButton=0
EndIf
EndIf
EndIf
EndSelect
Case #WM_MOUSEMOVE
GetCursorPos_(m.POINT)
ScreenToClient_(WindowID(#MainWindow),m)
If Down
Down=2
ResizeWindow(#MainWindow,WindowX(#MainWindow)+m\x-p\x,WindowY(#MainWindow)+m\y-p\y,#PB_Ignore,#PB_Ignore)
EndIf
Case #WM_LBUTTONUP
If Down
Down=0
; FilterButton=1
EndIf
Case #WM_LBUTTONDOWN
;If GetAsyncKeyState_(#VK_CONTROL) & 32768 = 32768
If GetKeyState_(#VK_CONTROL)&128
GetCursorPos_(p.POINT)
ScreenToClient_(WindowID(#MainWindow),p)
Down = 1
Else
Down = 0
Debug "Null"
EndIf
EndSelect
ForEver