Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Icon in a CStatic control

Status
Not open for further replies.

CMR

Programmer
Apr 30, 2002
76
AU
I'm trying to get an Icon to appear in a CStatic control but I'm damned if I can get it to work. I'm using VC++5 and all the help files tell me I can use ModifyStyle() to set the control to load an Icon but it doesn't seem to do anything.

here's my code:

m_cStatic.ModifyStyle(0, SS_ICON | SS_CENTERIMAGE | SS_SUNKEN, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER);
HICON warningIcon (((CMyApp*)AfxGetApp())->LoadIcon(IDI_WARNING));
m_cStatic.SetIcon(warningIcon);
m_cStatic.SetRedraw(TRUE);
m_cStatic.RedrawWindow();

My CStatic control remains empty.
Any ideas?
Thanks in advance

CMR
 
Try so:
m_cStatic.ModifyStyle( SS_BITMAP, SS_ICON | SS_CENTERIMAGE ); //Default style is SS_BITMAP - remove
m_cStatic.ShowWindow(SW_HIDE ); //To make it working allways - hide it first
HICON warningIcon = (((CMyApp*)AfxGetApp())->LoadIcon(IDI_WARNING));
if(warningIcon) //Is it loaded at all?
m_cStatic.SetIcon(warningIcon );
m_cStatic.ShowWindow( SW_SHOWNORMAL );//To make it working allways - show it
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top