definitely beginner !!!!!!!!

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Skipsy.

Damned !! One more strange thing... not easy to explain what's
going on :

I have the following code :

EVT_RESEAU.l = NetworkServerEvent()
If EVT_RESEAU
beep_ (1000,100)
etc...
endif

Then I run the "client" app which sends a packet. At
this time, the "server" window is no more at the foreground. The
strange thing is that I don't hear the beep until I move the mouse
OVER THE "SERVER" WINDOW, no need to click on it... only move the
mouse.

It is like if the "server" was not running until an event for this
window is detected.
Is there anything I am supposed to mention in the main loop ?

Thks,ww
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Berikco.

Use WindowEvent() in the main loop, not WaitWindowEvent()
And maybe put a delay(5) so your app dont take all CPU time


Regards,

Berikco

http://www.benny.zeb.be/purebasic.htm
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tranquil.

There are two methodes to get server/client network events.

- Pooling
- Waiting for Events

I prefer the second one, its not the fastes but it keeps more CPU time for other applications.
Possible you dont hear the BEEP_ couse your mainloop waits for a window event. Are you using WaitWindowEvent() at the beginning of your mainloop?
A network event is not reported in WaitWindowEvent(). You have to do it manualy by using the Api WSAASyncSelect_(). But its STRONGLY recomanded that you get thouse messages from network in a windows-callback or you may loos events and that couses in loose of datas.

Hope that helps. Anyway, if not, please post you source as a complete one here.

Mike

Tranquilizer/ Secretly!
http://www.secretly.de
Registred PureBasic User
System: Windows 2000 Server, 512 MB Ram, GeForce4200 TI 128 MB DDR, Hercules Theater 6.1 DTS Sound
System 2: Mobile Pentium 4 2.4GHz 512 MB DDR GeForce4 420-32, Windows XP Home
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Skipsy.

Great !!
You are right... I have to use WindowEvent.
It brings to me 2 questions :
1) When you say to put "Delay(5)", is it a standard delay value
or I have to test different values ?

2) WindowEvents() description mentions :
"Test if an event has occur in one of the opened windows"
"... To get the window number where the event occured use
function EventWindowID()"
Does it only concern all the windows opened by the application
or ALL the windows from ALL applications ??

Ouch.. Looking for a book "PureBasi for dummies" :wink:
Regards,
ww
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tranquil.
Originally posted by Skipsy

Great !!
You are right... I have to use WindowEvent.
It brings to me 2 questions :
1) When you say to put "Delay(5)", is it a standard delay value
or I have to test different values ?

2) WindowEvents() description mentions :
"Test if an event has occur in one of the opened windows"
"... To get the window number where the event occured use
function EventWindowID()"
Does it only concern all the windows opened by the application
or ALL the windows from ALL applications ??

Ouch.. Looking for a book "PureBasi for dummies" :wink:
Regards,
ww
1.) a delay of 1 is of course enough. But it is not the best way to handle events.

2.) WindowEvent() reports events from every window created with OpenWindow() inside your application. To see which window fired an event use EventWindowID().

I think you dont need a book "PB for dummies" or something like that. Just post to the forum or do something like "Try and error" like most of us did. :)

Mike

Tranquilizer/ Secretly!
http://www.secretly.de
Registred PureBasic User
System: Windows 2000 Server, 512 MB Ram, GeForce4200 TI 128 MB DDR, Hercules Theater 6.1 DTS Sound
System 2: Mobile Pentium 4 2.4GHz 512 MB DDR GeForce4 420-32, Windows XP Home
Post Reply