what is the command in PB correspond to VB's "DoEvens&a

Just starting out? Need help? Post your questions and find answers here.
annehsieh
New User
New User
Posts: 2
Joined: Fri Jun 20, 2003 6:12 am

what is the command in PB correspond to VB's "DoEvens&a

Post 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
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Re: what is the command in PB correspond to VB's "DoEve

Post 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.
ARGENTINA WORLD CHAMPION
annehsieh
New User
New User
Posts: 2
Joined: Fri Jun 20, 2003 6:12 am

Re: what is the command in PB correspond to VB's "DoEve

Post 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!!! :D
Tipperton
Addict
Addict
Posts: 1286
Joined: Thu Jun 19, 2003 7:55 pm

Almost right

Post 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?
Berikco
Administrator
Administrator
Posts: 1326
Joined: Wed Apr 23, 2003 7:57 pm
Location: Belgium
Contact:

Post by Berikco »

Just use WaitWindowEvent()
No API needed
Tipperton
Addict
Addict
Posts: 1286
Joined: Thu Jun 19, 2003 7:55 pm

Post 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).
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Put a delay(10) inside your loop to prevent CPU hogging
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post 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.
ARGENTINA WORLD CHAMPION
Tipperton
Addict
Addict
Posts: 1286
Joined: Thu Jun 19, 2003 7:55 pm

Post 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! :)
Tipperton
Addict
Addict
Posts: 1286
Joined: Thu Jun 19, 2003 7:55 pm

Post 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...
Post Reply