This code fixes the problem with fast clicking.
Code: Select all
EnableExplicit
Enumeration EnumImage
#Image_FlyOut
EndEnumeration
Enumeration EnumWindow
#Window_Main
#Window_FlyOut
EndEnumeration
Enumeration EnumGadget
#Canvas_Bar
#Canvas_FlyOut
EndEnumeration
Enumeration EnumTimer
#Timer_FlyOut
#Timer_FlyIn
EndEnumeration
Define oldStyle, i
Global FlyOutWidth.d
Procedure Event_MoveWindow_Main()
Protected x = WindowX(#Window_Main) + GadgetWidth(#Canvas_Bar)
Protected y = WindowY(#Window_Main, #PB_Window_InnerCoordinate)
ResizeWindow(#Window_FlyOut, x, y, #PB_Ignore, #PB_Ignore)
EndProcedure
Procedure Event_Timer()
Protected Width.d
Select EventTimer()
Case #Timer_FlyOut
FlyOutWidth * 0.85
If FlyOutWidth < 1
FlyOutWidth = 0
RemoveWindowTimer(#Window_Main, #Timer_FlyOut)
EndIf
Width = GadgetWidth(#Canvas_FlyOut) - FlyOutWidth
Case #Timer_FlyIn
FlyOutWidth * 0.65
If FlyOutWidth < 1
FlyOutWidth = 0
HideWindow(#Window_FlyOut, #True)
RemoveWindowTimer(#Window_Main, #Timer_FlyIn)
EndIf
Width = FlyOutWidth
EndSelect
ResizeWindow(#Window_FlyOut, #PB_Ignore, #PB_Ignore, Width, #PB_Ignore)
EndProcedure
Procedure Event_CanvasBar_Click()
Static FlyDirection = #Timer_FlyIn
FlyOutWidth = GadgetWidth(#Canvas_FlyOut) - FlyOutWidth
If FlyDirection = #Timer_FlyIn
FlyDirection = #Timer_FlyOut
RemoveWindowTimer(#Window_Main, #Timer_FlyIn)
HideWindow(#Window_FlyOut, #False)
AddWindowTimer(#Window_Main, #Timer_FlyOut, 1)
Else
FlyDirection = #Timer_FlyIn
RemoveWindowTimer(#Window_Main, #Timer_FlyOut)
AddWindowTimer(#Window_Main, #Timer_FlyIn, 1)
EndIf
EndProcedure
LoadImage(#Image_FlyOut, #PB_Compiler_Home + "Examples\Sources\Data\PureBasicLogo.bmp")
OpenWindow(#Window_Main, 0, 0, 640, ImageHeight(#Image_FlyOut) * 6, "Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(#Canvas_Bar, 0, 0, 30, WindowHeight(#Window_Main))
If StartDrawing(CanvasOutput(#Canvas_Bar))
Box(0, 0, OutputWidth(), OutputHeight(), $989898)
StopDrawing()
EndIf
If OpenWindow(#Window_FlyOut, WindowX(#Window_Main) + GadgetWidth(#Canvas_Bar), WindowY(#Window_Main, #PB_Window_InnerCoordinate), ImageWidth(#Image_FlyOut), WindowHeight(#Window_Main), "", #PB_Window_BorderLess | #PB_Window_Invisible, WindowID(#Window_Main))
CanvasGadget(#Canvas_FlyOut, 0, 0, WindowWidth(#Window_FlyOut), WindowHeight(#Window_FlyOut))
If StartDrawing(CanvasOutput(#Canvas_FlyOut))
For i = 0 To OutputHeight() Step 68
DrawImage(ImageID(#Image_FlyOut), 0, i)
Next i
StopDrawing()
EndIf
; From RSBasic - WinAPI Library - Do not change focus
oldStyle=GetWindowLongPtr_(WindowID(#Window_FlyOut),#GWL_STYLE)
SetWindowLongPtr_(WindowID(#Window_FlyOut),#GWL_STYLE,oldStyle|#WS_CHILD &(~#WS_POPUP))
SetWindowPos_(WindowID(#Window_FlyOut), 0,0,0,0,0,#SWP_NOMOVE|#SWP_NOSIZE|#SWP_NOZORDER|#SWP_FRAMECHANGED)
SetActiveWindow(#Window_Main)
ResizeWindow(#Window_FlyOut, #PB_Ignore, #PB_Ignore, 0, #PB_Ignore)
EndIf
BindEvent(#PB_Event_MoveWindow, @Event_MoveWindow_Main())
BindEvent(#PB_Event_Timer, @Event_Timer())
BindEvent(#PB_Event_Gadget, @Event_CanvasBar_Click(), #Window_Main, #Canvas_Bar, #PB_EventType_LeftClick)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver