Click here to Skip to main content
15,912,665 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralWin 32 error Pin
jetournier31-Mar-04 2:55
jetournier31-Mar-04 2:55 
GeneralRe: Win 32 error Pin
Antti Keskinen31-Mar-04 3:26
Antti Keskinen31-Mar-04 3:26 
GeneralRe: Win 32 error Pin
jetournier1-Apr-04 19:35
jetournier1-Apr-04 19:35 
GeneralSetCursor Pin
ns31-Mar-04 2:46
ns31-Mar-04 2:46 
GeneralRe: SetCursor Pin
Antti Keskinen31-Mar-04 3:23
Antti Keskinen31-Mar-04 3:23 
GeneralRe: SetCursor Pin
ns31-Mar-04 3:40
ns31-Mar-04 3:40 
GeneralRe: SetCursor Pin
ns31-Mar-04 4:05
ns31-Mar-04 4:05 
GeneralRe: SetCursor Pin
Antti Keskinen31-Mar-04 4:49
Antti Keskinen31-Mar-04 4:49 
There is no MFC version, as there is no icon wrapper class (CIcon) for MFC. All this is handled by the CBitmap class, and unfortunately, it does not directly support creation of icons.

Under MFC, you can get the application instance handle by calling a global (macro) function AfxGetInstanceHandle. Alternatively, you can query for AfxGetApp to get the CWinApp class, and use it's CWinApp::m_hInstance data member. The prior function call is a macro wrapper for this approach.

Nothing prevents you from using the Win32 API calls ::CreateIcon and ::DestroyIcon to manage a HICON object in the MFC environment. Note, that the MFC's clean-up framework is not available, so you must be very careful to release and destroy all reserved memory and objects, otherwise your application will cause memory leaks.

You can set the cursor by using ::SetCursor and restore the default cursor by using the same method. Know, though, that for MFC classes derived from CWnd, you must overwrite the CWnd::SetCursor method and determine some sort of a method to decide what cursor to load (by using ::SetCursor).

The default implementation of this function always sends the call down to the base class, and thus, the resulting icon will always be the default one. This manifests itself so that if you call ::SetCursor without overriding the respective method, then the cursor will change, but instantly as you move the mouse (or the cursor), it will be reverted back to the original one.

To restore the icon when it is no longer needed, call ::SetCursor with IDC_ARROW parameter, or pass the call to the base class, which will use the IDC_ARROW as default. After the icon has been detached from the cursor, you can destroy it (the icon) and free the memory it reserved.

-Antti Keskinen

----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
GeneralRe: SetCursor Pin
ns31-Mar-04 8:51
ns31-Mar-04 8:51 
GeneralProblems with GetMsgProc & WH_GETMESSAGE using SetWindowsHookEx Pin
triptiarora31-Mar-04 1:57
triptiarora31-Mar-04 1:57 
GeneralMenu Bar Color Pin
olis31-Mar-04 0:57
olis31-Mar-04 0:57 
GeneralRe: Menu Bar Color Pin
ohadp31-Mar-04 2:13
ohadp31-Mar-04 2:13 
GeneralFile Property Pin
hb.sapto nugroho31-Mar-04 0:21
hb.sapto nugroho31-Mar-04 0:21 
GeneralRe: File Property Pin
David Crow31-Mar-04 2:07
David Crow31-Mar-04 2:07 
GeneralRe: File Property Pin
hb.sapto nugroho31-Mar-04 3:07
hb.sapto nugroho31-Mar-04 3:07 
GeneralRe: File Property Pin
David Crow31-Mar-04 3:46
David Crow31-Mar-04 3:46 
GeneralRe: File Property Pin
hb.sapto nugroho31-Mar-04 15:52
hb.sapto nugroho31-Mar-04 15:52 
GeneralRe: File Property Pin
David Crow1-Apr-04 3:12
David Crow1-Apr-04 3:12 
QuestionHow to take screenshots Pin
Anonymous30-Mar-04 23:24
Anonymous30-Mar-04 23:24 
AnswerRe: How to take screenshots Pin
Uwe Keim31-Mar-04 1:26
sitebuilderUwe Keim31-Mar-04 1:26 
GeneralRe: How to take screenshots Pin
Alexander M.,31-Mar-04 2:01
Alexander M.,31-Mar-04 2:01 
GeneralRe: How to take screenshots Pin
Prakash Nadar31-Mar-04 5:06
Prakash Nadar31-Mar-04 5:06 
GeneralRe: How to take screenshots Pin
Anonymous31-Mar-04 7:56
Anonymous31-Mar-04 7:56 
AnswerRe: How to take screenshots Pin
David Crow31-Mar-04 2:11
David Crow31-Mar-04 2:11 
GeneralRe: How to take screenshots Pin
Anonymous31-Mar-04 7:58
Anonymous31-Mar-04 7:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.