Solved

Bitmap Button

Posted on 2004-08-10
20
554 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Can someone Identify This font 4 86
Font install problem 9 42
Deploying Open Type Font (.OTF) company wide ? 3 84
mapBully challenge 6 114
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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…

920 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

16 Experts available now in Live!

Get 1:1 Help Now