I think the non-realtime events within the main PB event loop should fire only once, after the resizing is finished.
Display both methods of re-sizing and moving the window:
Code: Select all
#PB_Event_SizeWindow2 = #PB_Event_FirstCustomValue
#PB_Event_MoveWindow2 = #PB_Event_FirstCustomValue + 1
Procedure WinProc(hWnd,msg,wParam,lParam)
Static countMove, countResize, currentMode, in_WM_ENTERSIZEMOVE
Select msg
Case #WM_MOVE, #WM_MOVING
currentMode = 1
; call real-time callback function, if set
Case #WM_SIZE, #WM_SIZING
currentMode = 2
; call real-time callback function, if set
Case #WM_ENTERSIZEMOVE
currentMode = 0
in_WM_ENTERSIZEMOVE = #True
;AddGadgetItem(1,-1,"Callback: Starting move/resize...")
Case #WM_EXITSIZEMOVE
If in_WM_ENTERSIZEMOVE = #True
Select currentMode
Case 1 ; move
countMove + 1
;AddGadgetItem(1,-1,"Callback: Window Moved - "+Str(countMove))
PostEvent(#PB_Event_MoveWindow2,1,hWnd)
currentMode = 0
ProcedureReturn 0
Case 2 ; resize
countResize + 1
;AddGadgetItem(1,-1,"Callback: Window Resized - "+Str(countResize))
PostEvent(#PB_Event_SizeWindow2,1,hWnd)
currentMode = 0
ProcedureReturn 0
EndSelect
in_WM_ENTERSIZEMOVE = #False
EndIf
EndSelect
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
Procedure OnMove()
Static count
count + 1
AddGadgetItem(2,-1,"OnMove: Window Moved - "+Str(count))
SetGadgetState(2,CountGadgetItems(2)-1)
EndProcedure
Procedure OnSize()
Static count
ResizeGadget(1,0,0,WindowWidth(1)*0.5,WindowHeight(1))
ResizeGadget(2,WindowWidth(1)*0.5,0,WindowWidth(1)*0.5,WindowHeight(1))
UpdateWindow_(WindowID(1))
count + 1
AddGadgetItem(2,-1,"OnSize: Window Resized - "+Str(count))
SetGadgetState(2,CountGadgetItems(2)-1)
EndProcedure
OpenWindow(1,0,0,640,480,"Resize & Move - PB Event Loop vs. Event Procedures",#PB_Window_SizeGadget|#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
SetWindowCallback(@WinProc())
BindEvent(#PB_Event_MoveWindow, @OnMove())
BindEvent(#PB_Event_SizeWindow, @OnSize())
ListViewGadget(1, 0 ,0,WindowWidth(1)*0.5,WindowHeight(1))
ListViewGadget(2,WindowWidth(1)*0.5,0,WindowWidth(1)*0.5,WindowHeight(1))
Repeat
Event = WaitWindowEvent(10)
Select Event
Case #PB_Event_SizeWindow2
count1 + 1
AddGadgetItem(1,-1,"Main Loop: Window Resized - "+Str(count1))
SetGadgetState(1,CountGadgetItems(1)-1)
Case #PB_Event_MoveWindow2
count2 + 1
AddGadgetItem(1,-1,"Main Loop: Window Moved - "+Str(count2))
SetGadgetState(1,CountGadgetItems(1)-1)
EndSelect
Until Event = #PB_Event_CloseWindow