Bitmap Button

Can I implement a bitmap button with EVC. If so, how? If not, what other ways can I implement a bitmap on a button?
mwcmpAsked:
Who is Participating?
 
Jaime OlivaresSoftware ArchitectCommented:
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
 
Jaime OlivaresSoftware ArchitectCommented:
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
 
mwcmpAuthor Commented:
What is a dialog template?
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
Jaime OlivaresSoftware ArchitectCommented:
The dialog resource.
0
 
mwcmpAuthor Commented:
just a CDialog?
0
 
Jaime OlivaresSoftware ArchitectCommented:
a CDialog or CPropertyPage derived class, the same.
0
 
mwcmpAuthor Commented:
erm.. I think the 3 bitmaps are yet to be link with the button. Am I right?
0
 
mwcmpAuthor Commented:
Do I do this? I suppose.. :)
m_myButton.LoadBitmaps(MYBUTTONU, MYBUTTOND, MYBUTTONF);
0
 
mwcmpAuthor Commented:
Hmm...
I only get a grey patch on my dialog. The grey patch is where the button had been drew.
0
 
Jaime OlivaresSoftware ArchitectCommented:
>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
 
mwcmpAuthor Commented:
still the same results...
0
 
Jaime OlivaresSoftware ArchitectCommented:
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
 
mwcmpAuthor Commented:
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
 
Jaime OlivaresSoftware ArchitectCommented:
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
 
mwcmpAuthor Commented:
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
 
Jaime OlivaresSoftware ArchitectCommented:
>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
 
mwcmpAuthor Commented:
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
 
Jaime OlivaresSoftware ArchitectCommented:
0
 
mwcmpAuthor Commented:
Those are what I had been trying too. But I am wondering, how the bitmap get link to the button in this case.
0
 
mwcmpAuthor Commented:
I guess I had missed the most maual method. Thanks. :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.