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!

Adding Bitmaps to Buttons?

Status
Not open for further replies.

TimeOut

Programmer
Nov 21, 2000
16
GB
I've tried following the help in Visual C++, but it's quite difficult to understand for a beginner (well at least for me, anyway).

Wondering if anyone could give me a 'dumbed down' explanation? Would be really grateful for any help, as always.

Thanks.
 
Hi

I'll suppose from here that we will be working on the Ok button (Id= IDOK) of a dialogbox CTestDlg class. This is the same for all the others

to add a bitmap to a button, follow the following procedure:

- add three bitmaps in the resource of your app and called them OKU ( for Up), OKD ( for Down) and OKF ( for focus)
You draw them yourself or you try to steal from an other application ....)

- add these lines in the include file of CTestDlg class:

protected:
CBitmapButton m_OkButton;

- add these in the constructor of the CTestDlg class:

// Load Bitmaps to Display Owner-Drawn Buttons

if ( !m_OkButton.LoadBitmaps( MAKEINTRESOURCE( OKU),
MAKEINTRESOURCE( OKD), MAKEINTRESOURCE( OKF)))
{
AfxMessageBox( "Unable to get Bitmpas");

AfxThrowResourceException();
}

- add these in the OnInitDialog function of the CTestDlg class:

// Set Up Bitmap Buttons

VERIFY( m_OkButton.SubclassDlgItem( IDOK, this));
m_OkButton.SizeToContent();

That's it !!

HTH
Thierry
EMail: Thierry.Marneffe@swing.be

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top