Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Change icon dynamically

14 views
Skip to first unread message

FmF via PocketPCJunkies.com

unread,
Jun 30, 2009, 12:24:27 PM6/30/09
to

Hello,

I´m using the a CStatic object to hold an icon. I want to change it
dynamically. The problem is that when the program is linked throws this error:


error LNK2019: unresolved external symbol "public: struct HICON__ * __cdecl
CStatic::SetIcon(struct HICON__ *)"

The line is:

pStaticWnd->SetIcon(::LoadIcon(NULL, MAKEINTRESOURCE(IDI_SAMPLE)));

Does anyone knows a way to fix it?

Thanks

--
Message posted via PocketPCJunkies.com
http://www.pocketpcjunkies.com/Uwe/Forums.aspx/wince-vc/200906/1

Paul G. Tobey [eMVP]

unread,
Jun 30, 2009, 12:48:42 PM6/30/09
to

Take a look at this page and try to give us complete information with your
posts:

http://guruce.com/blogpost/howtoaskquestionsonnewsgroups

In particular, Windows CE version, MFC/Visual Studio version, *what* you're
actually trying to do (change the icon shown on the task bar?)

Paul T.

"FmF via PocketPCJunkies.com" <u49788@uwe> wrote in message
news:9861972a07573@uwe...

FmF via PocketPCJunkies.com

unread,
Jun 30, 2009, 1:23:39 PM6/30/09
to

Ok,

I´m developing in Windows CE 5.0
As I said in my post, I´m using a CStatic control to display an ICON.

The CStatic class provides a method "SetIcon" to set an icon.

The program compiles successful but I can't link it because of this error:

error LNK2019: unresolved external symbol "public: struct HICON__ * __cdecl
CStatic::SetIcon(struct HICON__ *)"


Paul G. Tobey [eMVP] wrote:
>Take a look at this page and try to give us complete information with your
>posts:
>
>http://guruce.com/blogpost/howtoaskquestionsonnewsgroups
>
>In particular, Windows CE version, MFC/Visual Studio version, *what* you're
>actually trying to do (change the icon shown on the task bar?)
>
>Paul T.
>

>> Hello,
>>
>[quoted text clipped - 13 lines]

Paul G. Tobey [eMVP]

unread,
Jun 30, 2009, 2:50:22 PM6/30/09
to

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.

"FmF via PocketPCJunkies.com" <u49788@uwe> wrote in message

news:98621b969ab43@uwe...

FmF via PocketPCJunkies.com

unread,
Jul 1, 2009, 10:28:15 AM7/1/09
to

Yes, i´m using MFC. It seems not to work on MFC.

But i worked if i send STM_SETIMAGE message.

Thanks!,

FmF

Paul G. Tobey [eMVP] wrote:
>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]

Paul G. Tobey [eMVP]

unread,
Jul 1, 2009, 10:46:39 AM7/1/09
to

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.

"FmF via PocketPCJunkies.com" <u49788@uwe> wrote in message

news:986d25ec13d5c@uwe...

FmF via PocketPCJunkies.com

unread,
Jul 1, 2009, 11:13:00 AM7/1/09
to

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


Paul G. Tobey [eMVP] wrote:
>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

--
Message posted via http://www.pocketpcjunkies.com

Paul G. Tobey [eMVP]

unread,
Jul 1, 2009, 11:17:30 AM7/1/09
to

Well done! Nice design, huh?

Paul T.

"FmF via PocketPCJunkies.com" <u49788@uwe> wrote in message

news:986d89f2b1dd6@uwe...

0 new messages