Solved

Changing icon in MDI child window

Posted on 1997-05-07
2
936 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

920 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

15 Experts available now in Live!

Get 1:1 Help Now