CWinApp Class
The base class from which you derive a Windows application object.
class CWinApp : public CWinThread
Members
Public Constructors
Name |
Description |
---|---|
Constructs a CWinApp object. |
Public Methods
Name |
Description |
---|---|
Adds a document template to the application's list of available document templates. |
|
Adds a filename to the most recently used (MRU) file list. |
|
Called by the framework when the application unexpectedly exits. |
|
Closes all open documents. |
|
Creates a printer device context. |
|
Deletes a specified key and all its subkeys. |
|
Implements AfxMessageBox for the application. |
|
Turns the wait cursor on and off. |
|
Enables application D2D support. Call this method before the main window is initialized. |
|
Implements HTMLHelp for the application, rather than WinHelp. |
|
Enables Taskbar interaction. |
|
Override to clean up when your application terminates. |
|
Retrieves the input parameter for the application recovery method. |
|
Returns the length of time that the restart manager waits for the recovery callback function to return. |
|
Returns the flags for the restart manager. |
|
Returns key for HKEY_CURRENT_USER\"Software"\RegistryKey\ProfileName. |
|
Gets the data recovery handler for this instance of the application. |
|
Retrieves the position of the first document template. |
|
Retrieves the type of help used by the application. |
|
Retrieves the position of a document template. Can be used recursively. |
|
Retrieves the printer device defaults. |
|
Retrieves binary data from an entry in the application's .INI file. |
|
Retrieves an integer from an entry in the application's .INI file. |
|
Retrieves a string from an entry in the application's .INI file. |
|
Returns key for HKEY_CURRENT_USER\"Software"\RegistryKey\AppName\lpszSection. |
|
Hides the application before closing all documents. |
|
Calls the HTMLHelp Windows function. |
|
Override to perform Windows instance initialization, such as creating your window objects. |
|
Tells whether Windows 7 Taskbar interaction is enabled. |
|
Loads a cursor resource. |
|
Loads an icon resource. |
|
Loads a Windows OEM predefined cursor that the OCR_ constants specify in WINDOWS.H. |
|
Loads a Windows OEM predefined icon that the OIC_ constants specify in WINDOWS.H. |
|
Loads a Windows predefined cursor that the IDC_ constants specify in WINDOWS.H. |
|
Loads a Windows predefined icon that the IDI_ constants specify in WINDOWS.H. |
|
Called by the framework in response to a dynamic data exchange (DDE) execute command. |
|
Override to perform application-specific idle-time processing. |
|
Called by the framework to open a document from a file. |
|
Parses individual parameters and flags in the command line. |
|
Filters messages before they are dispatched to the Windows functions TranslateMessage and DispatchMessage. |
|
Intercepts certain messages before they reach the application. |
|
Handles command-line arguments and flags. |
|
Intercepts all unhandled exceptions thrown by the application's message and command handlers. |
|
Performs customized registration. |
|
Registers the application with the restart manager. |
|
Determines whether the restart manager reopens the files that were open when the application exited unexpectedly. |
|
Handles an application restart initiated by the restart manager. |
|
Determines whether the restart manager restores the autosaved files when it restarts the application. |
|
Runs the default message loop. Override to customize the message loop. |
|
Tests the application's command line for the /Automation option. Obsolete. Instead, use the value in CCommandLineInfo::m_bRunAutomated after calling ParseCommandLine. |
|
Tests the application's command line for the /Embedding option. Obsolete. Instead, use the value in CCommandLineInfo::m_bRunEmbedded after calling ParseCommandLine. |
|
Prompts the user to save all modified documents. |
|
Selects a printer previously indicated by a user through a print dialog box. |
|
Sets and initializes the type of help used by the application. |
|
Determines whether the restart manager recovers an application that exited unexpectedly. |
|
Determines whether the restart manager autosaves open documents at a regular interval. |
|
Determines whether the restart manager autosaves any open documents when the application restarts. |
|
Determines whether the application supports the restart manager. |
|
Unregisters everything known to be registered by the CWinApp object. |
|
Calls the WinHelp Windows function. |
|
Writes binary data to an entry in the application's .INI file. |
|
Writes an integer to an entry in the application's .INI file. |
|
Writes a string to an entry in the application's .INI file. |
Protected Methods
Name |
Description |
---|---|
Allows the user to open data files from the Windows File Manager. |
|
Loads standard .INI file settings and enables the MRU file list feature. |
|
Handles SHIFT+F1 Help within the application. |
|
Implements the ID_FILE_NEW command. |
|
Implements the ID_FILE_OPEN command. |
|
Implements the ID_FILE_PRINT_SETUP command. |
|
Handles F1 Help within the application (using the current context). |
|
Handles the ID_HELP_FINDER and ID_DEFAULT_HELP commands. |
|
Handles the ID_HELP_INDEX command and provides a default Help topic. |
|
Handles the ID_HELP_USING command. |
|
Registers all the application's document types with the Windows File Manager. |
|
Explicitly sets Application User Model ID for the application. This method should be called before any user interface is presented to user (the best place is the application constructor). |
|
Causes application settings to be stored in the registry instead of .INI files. |
|
Unregisters all the application's document types with the Windows File Manager. |
Public Data Members
Name |
Description |
---|---|
Indicates if the user is in Help context mode (typically invoked with SHIFT+F1). |
|
Specifies the type of help used by the application. |
|
Identifies the current instance of the application. |
|
Points to a null-terminated string that specifies the command line for the application. |
|
Specifies how the window is to be shown initially. |
|
Pointer to the main window of the container application when an OLE server is in-place active. |
|
Application User Model ID. |
|
Specifies the name of the application. |
|
The module name of the application. |
|
The path to the application's Help file. |
|
The application's .INI filename. |
|
Used to determine the full registry key for storing application profile settings. |
Protected Data Members
Name |
Description |
---|---|
Flags that determine how the restart manager behaves. |
|
The length of time in milliseconds between autosaves. |
|
Pointer to the data recovery handler for the application. |
Remarks
An application object provides member functions for initializing your application (and each instance of it) and for running the application.
Each application that uses the Microsoft Foundation classes can only contain one object derived from CWinApp. This object is constructed when other C++ global objects are constructed and is already available when Windows calls the WinMain function, which is supplied by the Microsoft Foundation Class Library. Declare your derived CWinApp object at the global level.
When you derive an application class from CWinApp, override the InitInstance member function to create your application's main window object.
In addition to the CWinApp member functions, the Microsoft Foundation Class Library 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 application's resources.
AfxGetAppName Obtains a pointer to a string containing the application's name. Alternately, if you have a pointer to the CWinApp object, use m_pszExeName to get the application's name.
See CWinApp: The Application Class for more on the CWinApp class, including an overview of the following:
CWinApp-derived code written by the Application Wizard.
CWinApp's role in the execution sequence of your application.
CWinApp's default member function implementations.
CWinApp's key overridables.
The m_hPrevInstance data member no longer exists. For information on detecting a previous instance of CWinApp, see the Knowledge Base article "How To Identify a Previous Instance of an Application" (KB106385) at https://support.microsoft.com/default.aspx?scid=kb;en-us;106385.
Inheritance Hierarchy
CWinApp
Requirements
Header: afxwin.h
See Also
Tasks
How to: Add Restart Manager Support