-
December 1st, 2008, 05:29 PM
#1
[RESOLVED] Add Icon to a Button , keeping the Text
Hi, I've lurked many hours to understand this... but I'm not so good to understand the code of the others..
- I have a button in a dialog application.
- To get some colours, I would like to place an ICON or a BITMAP (as you wish..) on the left of the button, keeping my previous Text (I made text changes to the button during execution... so text is dynamic).
-The Icon/Bitmap must move up and down with the button , better with transparency background color.
I use Visual C++ 6.0 upon Windows Me, so the problem could be this... because code I've tried fail in data exception or something...
Can you post the Best, simple, and easy way to get the Icon/bitmap on the left of a CButton ?
Thanks in advance.
-
December 1st, 2008, 05:32 PM
#2
Re: Add Icon to a Button , keeping the Text
Owner draw button would help you.
Have a look at "button" sections on www.codeguru.com and www.codeproject.com
Victor Nijegorodov
-
December 1st, 2008, 05:42 PM
#3
Re: Add Icon to a Button , keeping the Text
yes, and I've tryed many ways... but failed.
Essentially, I dont want to use a foreign class already prepared, I would like to understand what to put in OnInitDialog ....
-
December 2nd, 2008, 04:01 AM
#4
Re: Add Icon to a Button , keeping the Text
Originally Posted by LordHolNapult
yes, and I've tryed many ways... but failed.
What did fail? Could you showhow you did it and where it "failed"?
Originally Posted by LordHolNapult
Essentially, I dont want to use a foreign class already prepared, I would like to understand what to put in OnInitDialog ....
If you "dont want to use a foreign class already prepared" then you will need to create your own class from the very begin...
However, I recommend you to start with some of already designed class and extend it according your needs. One more example: A Better Bitmap Button Class
Victor Nijegorodov
-
December 2nd, 2008, 07:19 AM
#5
Re: Add Icon to a Button , keeping the Text
Originally Posted by VictorN
Owner draw button would help you.
No, you don't need owner-draw at all for this.
-
December 2nd, 2008, 07:32 AM
#6
Re: Add Icon to a Button , keeping the Text
Originally Posted by fred100
No, you don't need owner-draw at all for this.
Good answer!
And would you so kind to explain how to implement the
Originally Posted by LordHolNapult
I would like to place an ICON or a BITMAP (as you wish..) on the left of the button, keeping my previous Text ...
without owner drawing under:
Originally Posted by LordHolNapult
I use Visual C++ 6.0 upon Windows Me...
Victor Nijegorodov
-
December 2nd, 2008, 04:21 PM
#7
Re: Add Icon to a Button , keeping the Text
Well, thank u for the code. I will study it later.
At the moment I've found a class that does what I've needed... but it's not mine :|
I was suppose not to create a class, but to modify my already defined dialog class to reach my purpose. Anyway, after seeing all the code you and I have found (3 examples tried and 10 i.e.pages readed), I must admit that the task thieves at least 200 lines of code, just to manage the position of the icon and a bit of resize...
I must also admit that no one did as I would like to do, but everyone creates a class and applied a "dodataexchange" that binds between the buttonimage class and the button ID...
Probably you are right (... and me I'm wrong . Class is required, just to add a simple icon to a button....
I quote you. Thanks. But let me say a last thing... Microsoft! Hell fu@&%+**in B@st4%&&&ds!!!
ciao
-
December 3rd, 2008, 08:19 AM
#8
Re: Add Icon to a Button , keeping the Text
Originally Posted by VictorN
Good answer!
And would you so kind to explain how to implement the
without owner drawing under:
Just read MSDN on Button control v6.
5 lines of code...
-
December 3rd, 2008, 08:29 AM
#9
Re: Add Icon to a Button , keeping the Text
Originally Posted by fred100
Just read MSDN on Button control v6.
5 lines of code...
Could you provide a link to these "5 lines of code" or just post these lines?
Victor Nijegorodov
-
December 18th, 2008, 04:41 AM
#10
Re: [RESOLVED] Add Icon to a Button , keeping the Text
Hi,
I want to add an icon with transparent back color to a common radio button with push-like property, CButton class. Just this! I don't want complex derived classes to redraw a all control, I search in MSDN an many places more, but I don't know how to do it.
Please, may you help me to find this 5 lines of code that do it?
Thank you very much.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|