Share via


CWinApp

The CWinApp class is the base class from which you derive a Windows CE application object. An application object provides methods for initializing your application — and each instance of it—and for running the application.

Each application that uses the MFC for Windows CE can only contain one object derived from CWinApp. This object is constructed when other Microsoft eMbedded Visual C++ global objects are constructed and is already available when Windows CE calls the WinMain function, which is supplied by MFC for Windows CE. Declare your derived CWinApp object at the global level.

When you derive an application class from CWinApp, override the InitInstance method to create the main window object for your application.

In addition to the CWinApp methods, MFC for Windows CE provides the following global functions to access your CWinApp object and other global information:

  • AfxGetApp   Obtains a pointer to the CWinApp object.
  • AfxGetInstanceHandle   Obtains a handle to the current application instance.
  • AfxGetResourceHandle   Obtains a handle to the resources of the application.
  • AfxGetAppName   Obtains a pointer to a string containing the name of the application. Alternately, if you have a pointer to the CWinApp object, use m_pszExeName to get the name of the application.

Remarks

The CWinApp constructor has been changed. In addition to providing the name of the application, you can optionally provide the name of its help file as well.

Windows CE supports the CWinApp::LoadIcon method differently than Windows 98 and Windows NT do.

MFC for Windows CE supports the CWinApp::ProcessMessageFilter method for compatibility with existing code, but this method does not do anything in Windows CE.

Windows CE does not initialize the m_pszExeName property to the executable file name of the application. If you use this data member, you must assign it a value, yourself.

MFC for Windows CE does not support the m_pActiveWnd property of the CWinApp class.

MFC for Windows CE does not support the following methods of the CWinApp class:

  • CreatePrinterDC
  • EnableShellOpen
  • Enable3dControls
  • Enable3dControlsStatic
  • GetPrinterDeviceDefaults
  • LoadOEMCursor
  • OnContextHelp
  • OnFilePrintSetup
  • OnHelpIndex
  • OnHelpFinder
  • OnHelpUsing
  • PreTranslateMessage
  • ProcessMessageFilter
  • RegisterShellFileTypes
  • RunAutomated
  • RunEmbedded
  • SelectPrinter

Requirements

**  Windows CE versions:** 1.0 and later  
  Header file: Declared in Afxwin.h
  Platform: H/PC Pro, Palm-size PC, Pocket PC

See Also

CWinApp::CWinApp, CWinApp::LoadIcon, Application Architecture Classes