Solved

How to put a bitmap image on a button in Visual C++

Posted on 2004-03-29
10
1,244 Views
Last Modified: 2013-12-03
Hi Friends

  I just need the complete code,  to put a bitmap image on a Button. Button is located in standard dialog. I need this to be done on Visual C++

Thanks
venura
0
Comment
Question by:venuraib
  • 5
  • 5
10 Comments
 
LVL 48

Expert Comment

by:AlexFM
Comment Utility
Use CBitmapButton class. Check out MFC sample CTRLTEST.
0
 

Author Comment

by:venuraib
Comment Utility
Hi AlexFM

I just want to do it using CButton Class, is it possible to do it throug CButton, Because When you add a Button Control normally it creates from CButton

thanks AlexFM
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 70 total points
Comment Utility
Create CButton member using MFC Wizard and manually change it's type to CBitmapButton. Set it's Owner Draw style to TRUE.
To set bitmap for it, use one of two ways:
1) Add line to OnInitDlalog:
m_button.LoadBitmaps(IDB_BITMAP1);

or:
2) Use CBitmapButton::AutoLoad function as described in CBitmapButton Class MSDN topic:

To include a bitmap-button control in a dialog box

Create one to four bitmap images for the button.
Create a dialog template with an owner-draw button positioned where you want the bitmap button. The size of the button in the template does not matter.
Set the button's caption to a value such as "MYIMAGE" and define a symbol for the button such as IDC_MYIMAGE.
In your application's resource script, give each of the images created for the button an ID constructed by appending one of the letters "U," "D," "F," or "X" (for up, down, focused, and disabled) to the string used for the button caption in step 3. For the button caption "MYIMAGE," for example, the IDs would be "MYIMAGEU," "MYIMAGED," "MYIMAGEF," and "MYIMAGEX." You must specify the ID of your bitmaps within double quotes. Otherwise the resource editor will assign an integer to the resource and MFC will fail when loading the image.
In your application's dialog class (derived from CDialog), add a CBitmapButton member object.
In the CDialog object's OnInitDialog routine, call the CBitmapButton object's AutoLoad function, using as parameters the button's control ID and the CDialog object's this pointer.
0
 

Author Comment

by:venuraib
Comment Utility
Hi AlexFM

I am realy thank full to you for your effort to solve my problem. Half away it solve, thanks lot but It want have that button press and release effects. I think
you have describe it bellow I coudn't get it right help. If you don't mind please help me further to co,me out this problem.

Thanks a Lot
from
venura
0
 
LVL 48

Expert Comment

by:AlexFM
Comment Utility
Press and release effects are done using different bitmaps: U," "D," "F," or "X" for up, down, focused, and disabled states.
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:venuraib
Comment Utility
yes my friend

Problem is I am not clear with that usage of U, D, F and X. Can you explain me again, I know your help is more than worth my 70 points. Just help me to get out of this problem

thank you lot
venura
0
 
LVL 48

Expert Comment

by:AlexFM
Comment Utility
U bitmap is button normal state. D bitmap is for pressed state. They may be completely different, but usually pressed state looks like normal, but with high brightness. F butmap usually contains focus rectangle, X bitmap is dimmed.
0
 

Author Comment

by:venuraib
Comment Utility
Yes friend

How to Map these images to the button

thanks lot
venura
0
 

Author Comment

by:venuraib
Comment Utility
Hi my Friend AlexFM

I am Actually appriciating your corperation towards my problem. So If you have enough time, just help me in future. I have to leave now
So Thank for you valuable effort given towards me. I'll accept your answer as the solution, but still last part is not clear. If don't mind
help me. Your help is more than this points.

Thank you
from
venura
0
 
LVL 48

Expert Comment

by:AlexFM
Comment Utility
To map these images to the button use LoadBitmaps with 4 arguments or AutoLoad function - this is described in my post.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Purpose To explain how to place a textual stamp on a PDF document.  This is commonly referred to as an annotation, or possibly a watermark, but a watermark is generally different in that it is somewhat translucent.  Watermark’s may be text or graph…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

728 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

10 Experts available now in Live!

Get 1:1 Help Now