Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

bitmap buttons

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
how would i make a bitmap button??? what would the code for it look like?
 
There is more than one technique. You might want to start by looking at the MFC class CBitmapButton Reference on MSDN. If you do not have an MSDN CDROM go to
Good luck
-pete
 
To creat a bit map buton it's easy to use the CBitmapButton but that class has its own limitation. You can't store images with more colours. So better take the image and cut it in a way required by you and then check for teh mouse move and put new image on the same location when you wann give a impression of pressed image.
Hope this help you.
For source code contact jitendar.rawat@igiindia.com
 
The easiest and fastest way:

Create a button with the dialog editor. Set the ID as IDC_BITBUTTON. Set the caption as MYBUTTON. You could change these to what you want I'm just using them for this example.

Import or draw the bitmaps you want. You can have up to four per button. One for button up, button down, button focus, button no focus (I think). I only use button up and down.

Next, set your bitmaps IDs as "MYBUTTONU", notice the U for up. Set the ID of one to "MYBUTTOND" for the bitmap you want for down. Basically you're mapping these names to the MYBUTTON caption you put on the Button in your dialog. The quotes for the bitmap IDs are needed !!!

Code in your dialog class is as follows.

Header file under public add:

CBitmapButton myBitMap;

Your .cpp file in OnInitDialog():

// load images for MYBUTTON
myBitMap.AutoLoad(IDC_BITBUTTON,this);

See how fast and easy that is, and man does it look impressive !

Brother C
 
How would i make a button display 256 color bitmaps?? when i try them with autoload, it just makes a gray box and doesnt display the bitmap...
 
It's gray because you have no message map so it's disabled. Add a message map manually. Example:


BEGIN_MESSAGE_MAP(CDialogAllDlg, CDialog)
//{{AFX_MSG_MAP(CDialogAllDlg)

ON_BN_CLICKED(IDC_CREATEBUTTON,OnCreateButton)

//}}AFX_MSG_MAP
END_MESSAGE_MAP()



void CMyDlg::OnCreateButton()
{

AfxMessageBox("Clicked Create Button");

}

Don't forget afx_msg void OnCreateButton(); in the header file.


If you still have trouble I can mail you my example. I use it as a template for many projects.

Brother C
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top