Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
203 views
in Technique[技术] by (71.8m points)

c++ - Why simple console app runs but dialog based does not run in WIN CE 6.0?

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,

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Does the target device have the MFC runtimes on it? They also have to be the ones your app is built for. Be aware that eVC 4.0 used mfcce400.dll, which did not ship with Platform Builder 6.0 at all (in fact IIRC MFC isn't even in the CE 6.0 OS catalog and Studio '08 used a newer MFC version for devices). You'll have to distribute the mfcce400 binaries (they're in the eVC SDKs) along with your app.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...