Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Changing icon in MDI child window

Posted on 1997-05-07
2
Medium Priority
?
1,038 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 200 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

715 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