Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

CWinApp::m_hInstance

Corresponds to the hInstance parameter passed by Windows to WinMain.

HINSTANCE m_hInstance;

The m_hInstance data member is a handle to the current instance of the application running under Windows. This is returned by the global function AfxGetInstanceHandle. m_hInstance is a public variable of type HINSTANCE.

// Typically you do not need to pass the application's hInstance 
// to Windows APIs directly because there are equivalent MFC 
// member functions that pass the hInstance for you.  The following 
// example is not typical:

HCURSOR hCursor;
hCursor = ::LoadCursor(AfxGetApp()->m_hInstance, 
   MAKEINTRESOURCE(IDC_MYCURSOR));

// A more direct way to get the application's hInstance is to 
// call AfxGetInstanceHandle:
hCursor = ::LoadCursor(AfxGetInstanceHandle(), 
   MAKEINTRESOURCE(IDC_MYCURSOR));

// If you need the hInstance to load a resource, it is better 
// to call AfxGetResourceHandle instead of AfxGetInstanceHandle:
hCursor = ::LoadCursor(AfxGetResourceHandle(), 
   MAKEINTRESOURCE(IDC_MYCURSOR));

// A better way to load the cursor resource is to call 
// CWinApp::LoadCursor
hCursor = AfxGetApp()->LoadCursor(IDC_MYCURSOR);

Header: afxwin.h

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.