I am developing an application for Windows CE 6.0 in embedded Visual C++ 4.
I created a simple console application (WCE Application) with platform "Pocket PC 2003" with the following simple code:
#include "stdafx.h"
#include <stdio.h>
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
FILE * pFile;
char c;
pFile=fopen("alphabet.txt","wt");
for (c = 'A' ; c <= 'Z' ; c++) {
putc (c , pFile);
}
fclose (pFile);
return 0;
}
This simple code works correctly on my WinCE 6.0 device and "alphabet.txt" is created.
But when I create a dialog based project (WCE MFC AppWizard(exe)) and put this code in main class of my project before the initialization of my dialog window it does not work and no "alphabet.txt" file is created and my app does not open without any messages.
BOOL CFffffApp::InitInstance()
{
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
FILE * pFile;
char c;
pFile=fopen("alphabet.txt","wt");
for (c = 'A' ; c <= 'Z' ; c++) {
putc (c , pFile);
}
fclose (pFile);
CFffffDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
Why it does not work and how can I resolve this problem?
Thanks in advance,