Page 1 of 1
					
				what is the command in PB correspond to VB's "DoEvens&a
				Posted: Fri Jun 20, 2003 6:16 am
				by annehsieh
				Dear all,
Plz tell me what 's the command in PB correspond to VB's "DoEvens"?
And How to use it?
Thanks a lot!
Anne Hsieh
			 
			
					
				Re: what is the command in PB correspond to VB's "DoEve
				Posted: Fri Jun 20, 2003 6:48 am
				by ricardo
				annehsieh wrote:Dear all,
Plz tell me what 's the command in PB correspond to VB's "DoEvens"?
And How to use it?
Thanks a lot!
Anne Hsieh
DoEvents = WindowEvent() in PB.
Use it as the same, per example in loops, etc.
 
			
					
				Re: what is the command in PB correspond to VB's "DoEve
				Posted: Fri Jun 20, 2003 9:49 am
				by annehsieh
				ricardo wrote:annehsieh wrote:Dear all,
Plz tell me what 's the command in PB correspond to VB's "DoEvens"?
And How to use it?
Thanks a lot!
Anne Hsieh
DoEvents = WindowEvent() in PB.
Use it as the same, per example in loops, etc.
 
Thanks!!!  

 
			
					
				Almost right
				Posted: Mon Jun 30, 2003 6:54 pm
				by Tipperton
				The definition for Visual Basic's DoEvents is:
DoEvents switches control to the operating-environment kernel. Control returns to your application as soon as all other applications in the environment have had a chance to respond to pending events.
The definition for PureBasic's WindowEvent() is:
Check if an event has occured on any of the opened windows.
Notice the difference? The DoEvents command gives control to the OS so it can process it's event que where the WindowEvent() command only checks for events relating to the openned windows (for the current PureBasic program?).
So is there possibly an API call that can duplicate the DoEvents command?
 
			
					
				
				Posted: Mon Jun 30, 2003 8:46 pm
				by Berikco
				Just use WaitWindowEvent()
No API needed
			 
			
					
				
				Posted: Mon Jun 30, 2003 9:14 pm
				by Tipperton
				Berikco wrote:Just use WaitWindowEvent()
The problem with that is that until an event for the PureBasic program occurs it stops the program, I want to be able to put this in a loop so the program won't hog the system. WindowEvent() works to a degree but it won't let me do anything with the PureBasic program window (like move or minimise it).
 
			
					
				
				Posted: Mon Jun 30, 2003 10:39 pm
				by Num3
				Put a delay(10) inside your loop to prevent CPU hogging
			 
			
					
				
				Posted: Mon Jun 30, 2003 10:56 pm
				by ricardo
				Num3 wrote:Put a delay(10) inside your loop to prevent CPU hogging
Yes, IMHO this is the best answer to use inside loops.
 
			
					
				
				Posted: Mon Jun 30, 2003 11:03 pm
				by Tipperton
				Num3 wrote:Put a delay(10) inside your loop to prevent CPU hogging
C8)8)L!
With Delay() and WindowEvent() together that works great!
Thanks!
PS: I almost bought PowerBasic, I'm sure glad I found PureBasic before I did! 

 
			
					
				
				Posted: Wed Jul 02, 2003 2:12 am
				by Tipperton
				After doing some digging on the Internet I ran across a page that shows how to implement the DoEvents in Visual Basic CE (which doesn't have the DoEvents command) using API calls.
http://www.vbce.com/code/vbce6/doevents/index.asp
I've converted it to PureBasic:
Code: Select all
Procedure DoEvents()
  msg.MSG
  If PeekMessage_(@msg,0,0,0,1)
    TranslateMessage_(@msg)
    DispatchMessage_(@msg)
  Else
    Sleep_(1)
  EndIf
EndProcedure
A C programmer friend who uses the API exclusively (says he doesn't like MFC) recommended I put the Sleep_ in there for good measure. I could have used Delay there but I wasn't sure if the Delay command was the same as Sleep_ and it was just as easy to type so...