Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
End Users
Pocket PCActiveSyncMultimediaEBooksWirelessSmartPhones
Developers
Windows MobileSmartPhonesWinCE ProgrammingVB for WinCEVC++ for WinCEPlatform BuilderTest Tools
PocketPC DirectoryFree SoftwareWeb Resources
Related Topics
PalmMobile PhonesMore Topics ...

Pocket PC Forum / Developers / VC++ for WinCE / July 2009

Tip: Looking for answers? Try searching our database.

Change icon dynamically

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
FmF - 30 Jun 2009 17:24 GMT
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
Paul G. Tobey [eMVP] - 30 Jun 2009 17:48 GMT
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]
>
> Thanks
FmF - 30 Jun 2009 18:23 GMT
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__ *)"

>Take a look at this page and try to give us complete information with your
>posts:
[quoted text clipped - 11 lines]
>>
>> Thanks
Paul G. Tobey [eMVP] - 30 Jun 2009 19:50 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.