Hi!
ma**@thusan.com schrieb:
It's a application to Windows CE, Have you any code example to how i
can fix this?
This is the code i have now:
// ExampleManualDlg.cpp : implementation file
[snip]
#include <stdio.h>
prefer <cstdio>
#include <string>
#ifdef _DEBUG
#define new DEBUG_NEW
Don't define keywords to mean something different. Don't "#define new ...".
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define CLIENT_NAME "client"
Why not use a char array here, too? Does the macro further down require
CLIENT_NAME to be a macro?
static char CLIENT_NAME[] = "client";
int res;
CString str;
CString strout;
CTomTomAPI::TError err;
CTomTomAPI::TVersion version;
CTomTomAPI::TGeocodeResult GeoRes;
char *aCity;
char *aStreet;
char *aNumber;
char *aPostCode;
I guess these are not global variables, but members of CExampleManualDlg.
void CExampleManualDlg::OnButtontt()
{
MTomTomCommunicationLayerInterface *comms =
DEFAULT_TRANSPORTATION_LAYER(CLIENT_NAME,
2005,TOMTOM_TCPIP_PORT);
Further down you "delete comms;" which means it is dynamically
allocated. So prefer automatic memory management:
const std::auto_ptr<MTomTomCommunicationLayerInterface>
comms = DEFAULT_TRANSPORTATION_LAYER(CLIENT_NAME,
2005,TOMTOM_TCPIP_PORT);
You will probably need #include <memoryfor auto_ptr.
CTomTomAPI api(*comms);
//Read
aCity = "Randers";
aStreet = "Urtevangen";
aNumber = "9";
aPostCode = "8900";
Notice: string literals contain chars and must not be modified. you
therefore try to declare the variables as "const char *aCity;". But
maybe the "NavigateToAddress" functions does not permit this.
>
res =
api.NavigateToAddress(&err,&*aCity,&*aStreet,&*aNu mber,&*aPostCode);
"&*aCity" is the same as "aCity". Just drop the "&*" part everywhere:
api.NavigateToAddress(&err, aCity, aStreet, aNumber, aPostCode);
res = api.BringNavigatorToForeground(&err);
strout = "";
str.Format(_T("Geocode = %d\r\n"), res);
strout = strout + aStreet + " | " + aNumber + " | " + aPostCode +
" | " + aCity;
m_EditResult.SetWindowText(strout);
delete comms;
When using auto_ptr just drop the "delete comms;". It will be
automatically deleted.
HTH,
Frank