Solved

Bitmap Button

Posted on 2004-08-10
20
553 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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. …
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…

746 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

14 Experts available now in Live!

Get 1:1 Help Now