Solved

Changing icon in MDI child window

Posted on 1997-05-07
2
999 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
not able to insert into temp table 68 179
Separate into files by filename 12 92
Tab names are off by one 5 54
mapBully challenge 6 201
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.

752 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