C language > Pocket PC and Smartphone questions

pocket pc and gps

(1/2) > >>

drgott:
The sample GPS program uses a for(;;) loop to handle messages.  I was wondering why.  Can events triggered by the GPS driver only be handled with MsgWaitForMultipleObjects() ?  Why do we even have to wait for the GPS events?  They'll come when and if they'll come, just like the user tapping a button.  And why wait INFINITEly?   

Mavis Enderby:
I am not sure that the GPS sample gives the best advice for the message passing loop. After looking through MSDN the following code appears to be the recommended way of handling the events.


--- Code: --- int notFinished = 0;
do {
/* Wait for GPS or message queue events */
switch (MsgWaitForMultipleObjects(NUM_EVENTS, ahEvents, FALSE, INFINITE, QS_ALLINPUT)) {
case WAIT_OBJECT_0 + EVENT_NEWPOSITION:
/* Change in GPS position -- update dialog */
GPSPosition(hDevice, hwndDlg);
notFinished = 1;
break;
case WAIT_OBJECT_0 + EVENT_NEWSTATE:
/* Change in GPS state -- update dialog */
GPSState(hDevice, hwndDlg);
notFinished = 1;
break;
case WAIT_OBJECT_0 + NUM_EVENTS:
/* New message in queue */
/* need to use PeekMessage loop instead of simple GetMessage:
* multiple messages might have arrived in between,
* so GetMessage would lead to delayed processing */
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
if (msg.message == WM_QUIT) {
notFinished = 0;;
break;
} else {
if (!IsWindow(hwndDlg) || !IsDialogMessage(hwndDlg, &msg)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
notFinished = 1;
}
}
break;
default:
notFinished = 0;
}
} while (notFinished > 0);
--- End code ---

Hope this helps.







AlexN:
I don't know if it helps you, but at Pelles homepage at the capter Source code -> Pocket PC Samples -> GPS there is an example for handling GPS-datas.

sergey:
See http://forum.pellesc.de/index.php?topic=3096.0

Sergey

saliha:
The site covering PocketPC (Pocket PC) products that are related GPS or to Navigation. In some cases these products may also be used with WinCE palmtops. The terms "pocket pc," sometimes called ppc, and "WinCE" may be used interchangeably in this context however some products may be specific to one platform or the other.

Navigation

[0] Message Index

[#] Next page

Go to full version