Ah, it wasn't clear that you meant an instance of a STATIC window by that!
This appears to me to be the standard case of MFC is a piece of $#&@. You
need to send the STM_SETIMAGE message to your control, passing, in the
WPARAM parameter either IMAGE_ICON or IMAGE_BITMAP (icon, in your case), and
the icon image in the LPARAM parameter:
HICON icon = LoadIcon( g_hInst, MAKEINTRESOURCE(IDI_MYICON) );
SendDlgItemMessage( hDlg, IDC_MYSTATIC, STM_SETIMAGE, IMAGE_ICON,
(LPARAM)icon );
I'm unable to figure out how you event got something to compile with a call
to
pStaticControl->SetIcon( icon );
As far as I can tell, the SetIcon() method should take two parameters, an
HICON and a BOOL.
Paul T.
> Ok,
>
[quoted text clipped - 25 lines]
>>>
>>> Thanks
FmF - 01 Jul 2009 15:28 GMT
Yes, i´m using MFC. It seems not to work on MFC.
But i worked if i send STM_SETIMAGE message.
Thanks!,
FmF
>Ah, it wasn't clear that you meant an instance of a STATIC window by that!
>
[quoted text clipped - 23 lines]
>>>>
>>>> Thanks
Paul G. Tobey [eMVP] - 01 Jul 2009 15:46 GMT
It just means that this version of MFC, for this version of Windows CE,
probably does not override SetIcon() in the CStatic class, so you're just
using the one from CWindow (or is it CWnd? Stupid design). That one used
WM_SETICON, which doesn't do what you want for a STATIC control.
Paul T.
> Yes, i´m using MFC. It seems not to work on MFC.
>
[quoted text clipped - 33 lines]
>>>>>
>>>>> Thanks
FmF - 01 Jul 2009 16:12 GMT
I looked up deeply on the MFC source code, I think i found the problem. Here
is the definition of the method SetIcon:
// Window control functions
_AFXWIN_INLINE CStatic::CStatic()
{ }
WCE_DEL _AFXWIN_INLINE HICON CStatic::SetIcon(HICON hIcon)
WCE_DEL { ASSERT(::IsWindow(m_hWnd)); return (HICON)::SendMessage(m_hWnd,
STM_SETICON, (WPARAM)hIcon, 0L); }
The macro WCE_DEL excludes the method SetIcon from MFC library. That's why it
compiles successfuly but i´m not able to link the program.
Anyway, it works with STM_SETIMAGE
>It just means that this version of MFC, for this version of Windows CE,
>probably does not override SetIcon() in the CStatic class, so you're just
[quoted text clipped - 8 lines]
>>>>>>
>>>>>> Thanks
Paul G. Tobey [eMVP] - 01 Jul 2009 16:17 GMT
Well done! Nice design, huh?
Paul T.
>I looked up deeply on the MFC source code, I think i found the problem.
>Here
[quoted text clipped - 25 lines]
>>>>>>>
>>>>>>> Thanks