Click here to Skip to main content
15,886,362 members
Articles / Mobile Apps / Windows Mobile

GPS and Web Service using C++ ATL/WTL (Windows Mobile 6, Standard)

Rate me:
Please Sign up or sign in to vote.
4.93/5 (27 votes)
18 Jan 2008CPOL7 min read 104.9K   1.4K   81  
This article explains how to use the GPS API and Web Service on a SmartPhone to show demographics information for the current location.
// DemographicsFrame.cpp : implementation of the CDemographicsFrame class
//
/////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "resourcesp.h"

#include "aboutdlg.h"
#include "DemographicsView.h"
#include "DemographicsFrame.h"
#include "GPSDevice.h"

BOOL CDemographicsFrame::PreTranslateMessage(MSG* pMsg)
{
	if(CFrameWindowImpl<CDemographicsFrame>::PreTranslateMessage(pMsg))
		return TRUE; 

	return m_view.IsWindow() ? m_view.PreTranslateMessage(pMsg) : FALSE;
}

bool CDemographicsFrame::AppHibernate( bool bHibernate)
{
	// Insert your code here or delete member if not relevant
	return bHibernate;
}

bool CDemographicsFrame::AppNewInstance( LPCTSTR lpstrCmdLine)
{
	// Insert your code here or delete member if not relevant
	return false;
}

void CDemographicsFrame::AppSave()
{
	// Insert your code here
}

void CDemographicsFrame::AppBackKey() 
{
	::SHNavigateBack();
}

BOOL CDemographicsFrame::OnIdle()
{
	UIUpdateToolBar();
	return FALSE;
}

LRESULT CDemographicsFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	CAppInfo info;

	m_bUseGPS = FALSE;

	CreateSimpleCEMenuBar();
	AtlActivateBackKey(m_hWndCECommandBar);
	UIAddToolBar(m_hWndCECommandBar);

	m_hWndClient = m_view.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);

	// register object for message filtering and idle updates
	CMessageLoop* pLoop = _Module.GetMessageLoop();
	ATLASSERT(pLoop != NULL);
	pLoop->AddMessageFilter(this);
	pLoop->AddIdleHandler(this);

	return 0;
}

LRESULT CDemographicsFrame::OnFileExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	UseGPS( FALSE );
	PostMessage(WM_CLOSE);
	return 0;
}

LRESULT CDemographicsFrame::OnAction(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	// TODO: add code

	return 0;
}

LRESULT CDemographicsFrame::OnAppAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	CAboutDlg dlg;
	FSDoModal(dlg);
	return 0;
}

LRESULT CDemographicsFrame::OnUseGPS(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	m_bUseGPS = !m_bUseGPS;
	UISetCheck( ID_MENU_USEGPS, m_bUseGPS );

	UseGPS( m_bUseGPS );

	return 0;
}


VOID CDemographicsFrame::UseGPS( BOOL bUse )
{
	if( bUse )
		CGPSDevice::TurnOn(&m_view);
	else
		CGPSDevice::TurnOff();
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Chief Technology Officer CDYNE Corporation
United States United States
Developer, Maker and Tinkerer

Comments and Discussions