Solved

Bitmap Button

Posted on 2004-08-10
20
555 Views
Last Modified: 2013-12-03
Can I implement a bitmap button with EVC. If so, how? If not, what other ways can I implement a bitmap on a button?
0
Comment
Question by:mwcmp
  • 11
  • 9
20 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 250 total points
ID: 11762882
Yes you can, but it is different from VC.

First create a dialog template with a button, set owner-draw attribute to on, give it a caption label, let's say "MYBUTTON"

Then, create 3 bitmaps named "MYBUTTOND", "MYBUTTONF", "MYBUTTONU" for down, focused and up states, respectively.

(continues)
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11763053
Sorry, I was bussy.

(continues)

Then, create  a CBitmapButton object in you dialog object, let's say m_MyButton. Don't declare it in ClassWizard.

Inside the OnInitDialog() function, use:

   m_MyButton.AutoLoad(ID_MYBUTTON, this);

I think is enough.
Good luck,
Jaime.
0
 

Author Comment

by:mwcmp
ID: 11764716
What is a dialog template?
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11764798
The dialog resource.
0
 

Author Comment

by:mwcmp
ID: 11765027
just a CDialog?
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11765081
a CDialog or CPropertyPage derived class, the same.
0
 

Author Comment

by:mwcmp
ID: 11765238
erm.. I think the 3 bitmaps are yet to be link with the button. Am I right?
0
 

Author Comment

by:mwcmp
ID: 11765285
Do I do this? I suppose.. :)
m_myButton.LoadBitmaps(MYBUTTONU, MYBUTTOND, MYBUTTONF);
0
 

Author Comment

by:mwcmp
ID: 11765319
Hmm...
I only get a grey patch on my dialog. The grey patch is where the button had been drew.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11765346
>erm.. I think the 3 bitmaps are yet to be link with the button. Am I right?
Yes

>Do I do this? I suppose.. :)
>m_myButton.LoadBitmaps(MYBUTTONU, MYBUTTOND, MYBUTTONF);
No, don't do it. Just use:

   m_MyButton.AutoLoad(ID_MYBUTTON, this);        (inside the OnInitDialog)

0
 

Author Comment

by:mwcmp
ID: 11765447
still the same results...
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11765529
Have you declared m_MyButton as CBitmapButton?

In the dialog resource:
In the caption label of the button, don't use quotes
Also declare button id as ID_MYBUTTON .
0
 

Author Comment

by:mwcmp
ID: 11765636
ya...
1) create dialog with button
2) set button to owner draw and caption as MYBUTTON and id as ID_MYBUTTON
3) 3 bitmaps created
4) declared CBitmapButton m_MyButton;
5) in OnInitDialog, m_MyButton.AutoLoad(ID_MYBUTTON, this);
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11765752
1) the 3 buttons you have created have string labels?  "MYBUTTONU", etc... Them must be string, don't use an identifier.
2) I suppose you have not declared it in the ClassWizard as a member variable.
 
0
 

Author Comment

by:mwcmp
ID: 11765792
Do you mean that I have to create the 3 bitmaps with CBitmap? If so, how do I link the bitmap (member variable) with my bitmaps?
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11765865
>Do you mean that I have to create the 3 bitmaps with CBitmap? If so, how do I link the bitmap (member variable) with my bitmaps?
No.

I think this could be your problem: Is your button implemented? If not, it is in disabled state.
Just associate it with a Message Handler in the ClassWizard (don't create a associated variable there).
Also you can create a bitmap for disabled state: "MYBUTTONX"

 
0
 

Author Comment

by:mwcmp
ID: 11765974
Got it, the problem lies in the string identifier. Sorry.
Can you tell me briefly how it works? I mean this is much simpler as what I had been searching around and found. All of them have long codes.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11766182
0
 

Author Comment

by:mwcmp
ID: 11766236
Those are what I had been trying too. But I am wondering, how the bitmap get link to the button in this case.
0
 

Author Comment

by:mwcmp
ID: 11766251
I guess I had missed the most maual method. Thanks. :)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

808 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