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

x
?
Solved

Changing icons in dialog box

Posted on 1999-08-31
7
Medium Priority
?
228 Views
Last Modified: 2013-11-20
Is it possible to change an icon in a dialog box when a program is running? I have an icon to represent a switch that the user can turn on or off and I would like to update the icon to represent these states.
Thanks in advance,
Sman
0
Comment
Question by:Sman
[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
7 Comments
 
LVL 23

Expert Comment

by:chensu
ID: 1953709
Call CWnd::SetIcon.

SetIcon(hIcon, TRUE);    // Set big icon
SetIcon(hIcon, FALSE);    // Set small icon
0
 

Author Comment

by:Sman
ID: 1953804
With CWnd::SetIcon I am able to change the main icon in the top left corner of the dialog box, but how/ where do I use it to set other icons within my dialog box?
Thanks again,
Sman.
0
 
LVL 5

Expert Comment

by:vachooho
ID: 1953897
Call SetIcon() on your dialog;s childs
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 23

Expert Comment

by:chensu
ID: 1955075
Use ClassWizard to associate the static control with a CStatic member variable and call the following member function.

CStatic::SetIcon
HICON SetIcon( HICON hIcon );
0
 

Author Comment

by:Sman
ID: 2035832
The only reason that I rejected your answer is that I dont know how to implement it. I have an icon in my dialog box and I have associated it with a CStatic member variable. I then created another icon but I don't know how to replace the first icon with this new one.

I will offer you more points for your answer,
Thank you!
0
 
LVL 23

Expert Comment

by:chensu
ID: 2037457
What do you mean by replacing it? You can associate it with another CStatic member variable.
0
 

Accepted Solution

by:
AAB earned 200 total points
ID: 2121533
hi..
first you must cteate an icon by resource icon editor with specific ID in the example I create icon with ID = IDI_RIGHT

second :
in the class add :
HICON hIcon;

third in your implementation first you must need to handle the icon like this "load"
hIcon = AfxGetApp()->LoadIcon (IDI_RIGHT);

finaly to chang the icon :
SetIcon(hIcon);

by this example you change the dialog box icon.
to change the CStatic member variable.
you must create control for it by ClassWizard.
goto ClassWizaed and choose the member variable tab.
then make sure that u have choose the dialog name class under class name, choose the ID for the static control and then press add variable.
another dialog will appear ---> write the name of your
variable example "m_editCtrl"  , then choose under catogory --> control
then press ---> Ok .
this step create a control for static control.

in any part of your code you can in the class dialog and after init the hIcon , you can add
m_editCtrl.SetIcon(hIcon);

try it
Good Luck.
AAB


 
 
 
   
 
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

670 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