Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
1.11/5 (2 votes)
See more:
hello..
how to hide and show the image with in if-else condition im MFC 2008
Posted
Comments
Nuri Ismail 8-Apr-11 5:33am    
You have to elaborate a bit.

Did you draw this image or it comes from nowhere? If you draw it, then where is your drawing code?
Where actually the image is drawn (directly on the dialog, on a static control, etc.)?

Please post relevant parts of your code.

Hey What i understand according to this you want hide and show image on button click.
so following code is just suggestion
define object of CPitureEx in your dialog .h file.
like following,
CPictureEx m_piture;


in OnInitDialog() of you dialog just provide this lines of codes
if (m_Picture.Load(MAKEINTRESOURCE(IDR_FELIX),_T("GIF")))
m_Picture.Draw();   ///you can provide bitmap ID If you want draw bitmap

No on click of your HideShow() button
HideShow()
{
  if(m_Picture.IsWindowVisible())
  {
      m_Picture.ShowWindow(0);
   }
   else
   {
    m_Picture.ShowWindow(1);
   } 
}

For more information you may see this example
Dispaying Image[^]
 
Share this answer
 
If you are talking about the icon in the title bar, then you can do something like that:

To show the icon:
//get the main application icon for example
HICON m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
//set big icon
SetIcon(m_hIcon, TRUE);
//set small icon
SetIcon(m_hIcon, FALSE);


To hide the icon:
//set big icon
SetIcon(NULL, TRUE);
//set small icon
SetIcon(NULL, FALSE);
 
Share this answer
 
No,i just show the image in dialog box..after that i want to hide when we click on the button..vis versa i want to show..
 
Share this answer
 
Comments
Olivier Levrey 8-Apr-11 6:07am    
Please use the "Add comment" button under my the answers instead of posting answers...

The image... what image are you talking about? Are you using a Picture control? Do you want the image to be displayed as the background image of the dialog? Did you try something?...
Albert Holguin 8-Apr-11 16:18pm    
this is still very unclear

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900