Page 1 of 1
Posted: Mon Aug 19, 2002 5:38 pm
by BackupUser
Restored from previous forum. Originally posted by cor.
How to programmatically fire an event so that
WaitWindowEvent automatically is executed?
Code: Select all
repeat
EventID = WaitWindowEvent()
do checking
until quit=1
Using Windows 98 SE
Registered PB version : 3.2 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
Posted: Mon Aug 19, 2002 9:06 pm
by BackupUser
Restored from previous forum. Originally posted by PB.
> How to programmatically fire an event so that WaitWindowEvent automatically is executed?
To do what, exactly? From your example, it looks like you want to loop something
over and over until the close gadget on your window is clicked... is that right?
And using WaitWindowEvent is pausing your loop? If this is your problem, then
use WindowEvent instead of WaitWindowEvent, and put a tiny 1 millisecond delay
in to prevent the loop from using up 100% of your PC's CPU. Like this:
Code: Select all
Repeat
Sleep_(1) ; To prevent 100% CPU usage (important!).
EventID=WindowEvent() ; Check if an event just happened.
;
; Loop code goes here.
;
Until EventID=#PB_EventCloseWindow
PB - Registered PureBasic Coder
Posted: Mon Aug 19, 2002 11:25 pm
by BackupUser
Restored from previous forum. Originally posted by cor.
PB,
I have found it:
PostMessage_(myhandle,WM_LBUTTONCLK,0,0)
will emulate a buttunclick so that the
WaitWindowEvent is called.
Must sleep_(1) be there because in all the PB examples e.g.
has no sleep code.
And is this also the same with Threads
procedure testThread()
repeat
sleep_(1)
bla bla bla...
until forever
endprocedure
Is there a program to see the CPU usage of running programs?
Code: Select all
Repeat
EventID.l = WaitWindowEvent()
;
If EventID = #PB_Event_CloseWindow ; If the user has pressed on the close button
Quit = 1
EndIf
;
Until Quit = 1
Posted: Mon Aug 19, 2002 11:37 pm
by BackupUser
Restored from previous forum. Originally posted by Franco.
Danilo wrote a lib for CPU usage.
Posted: Tue Aug 20, 2002 12:14 am
by BackupUser
Restored from previous forum. Originally posted by cor.
Just found a CPU monitor, with graphical display.
http://jongrieve.net/cpumon/
Posted: Tue Aug 20, 2002 12:22 am
by BackupUser
Restored from previous forum. Originally posted by cor.
Strange!!!!
If I leave out the sleep_(1) both within the
WindowWaitEvent and inside a Thread then my CPU usage is decreasing 8 to 10 %.
Posted: Tue Aug 20, 2002 7:22 am
by BackupUser
Restored from previous forum. Originally posted by fred.
WaitWindowEvent() waits for an event, no need for sleep_(). It's needed ONLY when using WindowEvent(), and it's must be done correctly:
Repeat
Event=WindowEvent()
If Event ; Process this event and DON'T sleep as if another event is in the queue, it should be processed ASAP
Else ; No Event, so sleep a bit
Delay(1)
EndIf