Thread

AwWait in C++ (Sdk)

AwWait in C++ // Sdk

1  |  

trekkerx

Sep 30, 2001, 11:21pm
Dose anyone know a good way to call AwWait instead of using

while (!aw_wait (-1));

because when i do that it just loops and i cant change the windows.
--
TrekkerX - CEO
Commatron
http://www.commatron.com

grimble

Sep 30, 2001, 11:44pm
while (!aw_wait (-1)) hogs the process control without giving windows a
lookin.

You have to do it on a windows driven event, otherwise your application will
never relinquish program control back to Windows to update the environment
(such as handling the form itself). I'd stick to the same way as in VB -
call aw_wait on a timer event. The good thing about C++ here is that a timer
is started with StartTimer(<timer id>, <interval>, NULL) without that dumb
visual control (although you could use these calls in VB as well). When you
want to close the app, make sure you kill the timers. Example snippets
below.

In some header file ...

#define TIMER_ID_AWWAIT 1001 // declare the internal timer id for
the AW wait timer
#define TIMER_ID_OTHER 1002 // declare another timer (just for
example)


In the dialog class OnInitDialog method ...

StartTimer(TIMER_ID_AWWAIT, 64, NULL) // Start the aw_wait timer (interval =
64ms)
StartTimer(TIMER_ID_OTHER, 1000, NULL) // Start the other timer

// This is the OnTimer method in the dialog class
void CMyAWBotDlg::OnTimer(UINT nIDEvent)
{

switch(nIDEvent)
{
case TIMER_ID_AWWAIT:
aw_wait(0);
break;

case TIMER_ID_OTHER:
// Do something for the other timer
break;

default:
// Do nothing (unhandled timer)
break;
}

CDialog::OnTimer(nIDEvent); // Let Windows do what it needs to do with
the timer event
}

.... and this goes where the dialog shuts down like in the dialog class
OnCancel method (depends how the dialog is closed really - by default,
OnCancel is fired when you click the Cancel button or press escape).

KillTimer(TIMER_ID_AWWAIT) // Stop the aw_wait timer
KillTimer(TIMER_ID_OTHER) // Stop the other timer

It might take some time to get it sorted, but once you're comfortable with
windows timers in C++ it should be reasonably straight forward. Have fun.

Grims



[View Quote]

grimble

Sep 30, 2001, 11:53pm
Sorry ... if you're going to cut/paste any of this, there are a few ";"s
missing :o)

Grims

[View Quote]

ananas

Oct 1, 2001, 3:01am
A PeekMessage() with PM_NOREMOVE in your loop might help.

[View Quote]
--
"_
|
/\
\ /
__/ /_

billybob

Mar 12, 2002, 1:10am
It all depends. If you are using message mapping, then timer is the best
way. If you do a message loop then just have it do aw_wait(0); whenever
there are no messages to handle.

1  |  
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn