Page 1 of 1

WaitWindowEvent()

Posted: Wed Dec 01, 2004 3:43 am
by CaddMan
Hello,
Can anyone tell me if I am using this correctly

Thanks
Ken

Code: Select all

;Capture mousedown and abort events
  CallFunction (0,"VCSetAlertAppDll",@iError,"Test","DrawLine",ALERT_APP_UTOOL_MOUSEDOWN)
    
;User tool prompt 
  CallFunction (1,"VCSetUserTool",2,"DrawLine","Enter lower left corner")
  CallFunction (1,"VCSetPrompt",1,"Enter lower right corner")
  
  
  Repeat 
    WaitWindowEvent() 
    Event = EventType()
  If Event = #PB_EventType_LeftClick
;Get 1st mouse down point  
  ;CallFunction (0,"VCGetUserToolLBDown",@iError,StartLine())
  MessageRequester("Test", "MouseClick1", 0)
  Else  
    Delay(1)  ; No event, let the others apps get some CPU time too ! 
  EndIf 
  Until ToolState  = 10 
  

Posted: Wed Dec 01, 2004 4:02 am
by fsw
NO :!:

Re: WaitWindowEvent()

Posted: Wed Dec 01, 2004 4:10 am
by fsw
It should more look like:

Code: Select all

;Capture mousedown and abort events
  CallFunction (0,"VCSetAlertAppDll",@iError,"Test","DrawLine",ALERT_APP_UTOOL_MOUSEDOWN)
   
;User tool prompt
  CallFunction (1,"VCSetUserTool",2,"DrawLine","Enter lower left corner")
  CallFunction (1,"VCSetPrompt",1,"Enter lower right corner")
 
 OpenWindow(0,0,0,230,90,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"Event handling example...") 


  Repeat
    Event = WaitWindowEvent()
    ; EventType() is only used with Gadgets...
    ; #PB_EventType_LeftClick is only used with Gadgets...

    If Event = #WM_LBUTTONDOWN ;this is a WinAPI constant
      ;Get 1st mouse down point 
      ;CallFunction (0,"VCGetUserToolLBDown",@iError,StartLine())
      MessageRequester("Test", "MouseClick1", 0)
    Else 
      Delay(1)  ; No event, let the others apps get some CPU time too !
    EndIf
  Until EventID = #PB_Event_CloseWindow
  ; don't know what this should be -> Until ToolState  = 10 
hope this helps a bit...

Posted: Wed Dec 01, 2004 5:52 pm
by Kale
No need for

Code: Select all

Delay(1)
in the updated code when using

Code: Select all

WaitWindowEvent()
because this command waits for an event then continues the main loop. If this was used

Code: Select all

WindowEvent()
the the delay would be necessary because this is nothing to halt the program taking 100% cpu time.

Posted: Wed Dec 01, 2004 8:20 pm
by PB
> If this was used
> WindowEvent()
> the the delay would be necessary because this is nothing to halt the
> program taking 100% cpu time

And you should only use Delay(1) if the result of WindowEvent() = 0,
otherwise it'll slow down the updating of all gadgets on your window.

Posted: Fri Dec 03, 2004 12:52 am
by CaddMan
Thanks all,

This is good info. I will try it out as soon as I can & let you know

Ken