Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

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

, 18 Jan 2008 CPOL
This article explains how to use the GPS API and Web Service on a SmartPhone to show demographics information for the current location.
gpsdemographics.zip
GPSDemographicsSetup
GPSDemographicsSetup.vddproj
GPSDemographics
com_cdynews
DemographixQuery.disco
DemographixQuery.wsdl
results.discomap
res
background.bmp
Demographics.ico
gpsdemographicssetupcab.zip
GPSDemographicsSetup.CAB
// 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)

Share

About the Author

Valentin Ivanov
Chief Technology Officer CDYNE Corporation
United States United States
Developer, Maker and Tinkerer

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141223.1 | Last Updated 18 Jan 2008
Article Copyright 2008 by Valentin Ivanov
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid