Solved

Changing icon in MDI child window

Posted on 1997-05-07
2
922 Views
Last Modified: 2013-11-20
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
0
Comment
Question by:RJV
2 Comments
 
LVL 2

Accepted Solution

by:
SamratAshok earned 100 total points
ID: 1301401
Hi

Code that you are having is correct as far as changing the Icon is concerned.
Try it from your View object

Since you may have to change icon more than once, best way is to define
it in a function and call it.

From the View, access the MDIChildWnd or ChildFrame by a call to
GetParent, assert on the Kindof Window and proceed with LoadIcon/SetIcon
exactly the same way as before

If you are changing icons on activation /deactivation of the View or Frame
override View classes  
OnActivateView and/or OnActivateFrame


Bye


Try this from other way around


0
 

Author Comment

by:RJV
ID: 1301402
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

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now