Link to home
Start Free TrialLog in
Avatar of RJV
RJV

asked on

Changing icon in MDI child window

I need to change the icon on each MDI child window under VC4.2, MFC. The icon can be changed when the child window is created or at runtime. I've searched for solutions and the best found is the following:

CMyApp* pApp = (CMyApp*)AfxGetApp();
ASSERT (pApp!=NULL);
HICON m_Icon;
repIC = pApp->LoadIcon(IDI_REPLY);
<Picture>SetIcon(m_Icon,FALSE);

This only changed the icon of the program's main (or mainframe) caption, but not the child window (or childframe). I then changed it to this, also to no avail:

CMyApp* pApp = (CMyApp*)AfxGetApp();
ASSERT (pApp!=NULL);
HICON m_Icon;
repIC = pApp->LoadIcon(IDI_REPLY);
((CMDIFrameWnd*)
(AfxGetApp()->m_pMainWnd))->MDIGetActive()->SetIcon(m_Icon,FALSE);

Many thanks in advance for your help!
RJV
ASKER CERTIFIED SOLUTION
Avatar of SamratAshok
SamratAshok

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RJV
RJV

ASKER

Hi Sam,

Indeed, from the childframe (i.e. ActivateFrame) it works. It doesn't work from the mainframe. The view is more complex for this app.

Thanks!
RJV