Important alert: (current site time 7/16/2013 3:09:24 AM EDT)
 

winzip icon

CHAMELEON BUTTON - An awesome multi-style button

Email
Submitted on: 11/9/2001 1:32:12 AM
By: malachi  
Level: Advanced
User Rating: By 69 Users
Compatibility: VB 5.0, VB 6.0
Views: 38834
 
     This is a multi-style command button to add to your applications. It can emulate seven different styles at a very accurate way!!! see the screenshot to belive... you will really be astonished. And the best of all: no external dll's or ocx's need to be used, an even the XP button is ownerdrawn!!! A must have for any coder. UPDATE!!! now it supports cool color changes!

 
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
  3. Scan the source code with Minnow's Project Scanner

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
11/9/2001 2:08:03 AMgonchuki

feel free to leave your comments...
(If this comment was disrespectful, please report it.)

 
11/9/2001 3:32:28 AMbob

fantastic.

Great code
5 *'s
(If this comment was disrespectful, please report it.)

 
11/9/2001 9:50:05 AMJC

Excellent Work!! I'd give you 6 globes if I could.
(If this comment was disrespectful, please report it.)

 
11/9/2001 12:16:56 PMAaron Morris

Very nice .... You could add a mouse over state. That would make the buttons even cooler.
(If this comment was disrespectful, please report it.)

 
11/9/2001 12:26:38 PMgonchuki

yes... i could do that but no one of these buttons have a mouse over state in real life
(If this comment was disrespectful, please report it.)

 
11/9/2001 1:37:31 PMMarc

Great code. One question though. Is there an easy way to change it so the focus rectangle isn't there when you click on the buttons?
(If this comment was disrespectful, please report it.)

 
11/9/2001 3:18:38 PMgonchuki

I updated the zip with this feature. Now you can hide the focus rect.
(If this comment was disrespectful, please report it.)

 
11/9/2001 5:34:33 PMgonchuki

NEW UPDATE!!! it now supports custom colors!
(If this comment was disrespectful, please report it.)

 
11/10/2001 3:14:29 AMRayson

hey man, good code :) especially what you did with the XP button :) I LIKE !
(If this comment was disrespectful, please report it.)

 
11/10/2001 7:34:06 AMshadowlynx

great code! is there a way to change the font of the buttons though?
(If this comment was disrespectful, please report it.)

 
11/10/2001 10:40:17 AMgonchuki

This property already exists since the
first upload....


(If this comment was disrespectful, please report it.)

 
11/10/2001 11:50:11 AMJesse Wilson

Great code! I was working on a custom button myself, but your's is by far more stable and usable than mine at this point. There are two things I should point out however, and only b/c you asked in your code comments. 1) The XP button does not have the blue border highlight unless it is the default button, otherwise the border highlight is the same as the rest of the button, 2) the XP button does have a mouse over effect, the border highlight turns an orange color. Other than those two items (really insignificant points at that) this is some nice professional coding... something that seems to be becoming a rarity on PSC anymore. Keep up the good work!
(If this comment was disrespectful, please report it.)

 
11/10/2001 11:56:19 AMJesse Wilson

Oh before I forget, one other "problem" I noticed is that while the other button styles can have a custom or user chosen backcolor, the XP button style does not seem to be able to. That and it doesn't seem to match the system colors either. Fixing this shouldn't be an issue however, if I can "fix" it I will send you my update. Anyways, sorry for the nitpicking, and once again... great code!
(If this comment was disrespectful, please report it.)

 
11/10/2001 7:47:15 PMSlippah

Hey, great, and I mean GREAT code here. I've already implemented it in all of my best projects. One "itsy bitsy" comment/suggestion for ya'. You got the Windows XP Style Buttons wrong, not greatly, but wrong. I'm working on fixing it right now, but if you would like to see the template that I'm working from, this link will bring you: http://downloads.redjupiter.com/users/images/JarrettInteraction/ButtonStates.jpg
Good
job, 5 Globes!
(If this comment was disrespectful, please report it.)

 
11/10/2001 9:57:31 PMAckbar

Very nice job here.
(If this comment was disrespectful, please report it.)

 
11/11/2001 2:35:37 PMCory G.

i like this code, i am going to use it in my project to replace one of the buttons i was using from a ocx, i have added a very small amount of code to make the style of a flat button on ie5, if you want it just email me.
(If this comment was disrespectful, please report it.)

 
11/12/2001 2:58:15 AMRobin Schuil

Very nice code. However, it is not original. I've seen the same lib a few weeks ago on some other VB site. I will look up the URL and post it here..
(If this comment was disrespectful, please report it.)

 
11/12/2001 4:43:16 AMJon

These buttons are very nice, however what stops me using them is the absence of a picture property (and/or picture and text).

Great work though.
(If this comment was disrespectful, please report it.)

 
11/12/2001 6:24:41 PMmario

not original? this is Unique. it's the best button i've seen!
(If this comment was disrespectful, please report it.)

 
11/12/2001 8:52:16 PMnunya bidness

very nice 5 globes
(If this comment was disrespectful, please report it.)

 
11/13/2001 3:34:21 AMdumbass

kick(butt)! :)
(If this comment was disrespectful, please report it.)

 
11/13/2001 6:26:22 AMtibisan

very nice, 5* from me!
(If this comment was disrespectful, please report it.)

 
11/13/2001 8:16:41 AMgonchuki

i'm working to fix the XP button, come soon to see!
(If this comment was disrespectful, please report it.)

 
11/13/2001 1:01:02 PMMike Jenkings

Very nice work, easy to use and adds a touch of interest and professionalism to any project. Nice to be rid of those nasty gray buttons. 5*s
(If this comment was disrespectful, please report it.)

 
11/13/2001 2:43:30 PMgonchuki

UPDATE!!! the Windows XP buttons now look as they should. Thanks for the feedback and the votes folks!
(If this comment was disrespectful, please report it.)

 
11/13/2001 9:34:19 PMVinchenzo

Incredible! It's simply wonderful and neat! No piggy coding here!
(If this comment was disrespectful, please report it.)

 
11/14/2001 5:36:10 PMPxHxAxNxTxOxM

Very, I mean VERY, excellent coding here. I've been trying to simulate the exact same XP button since it came out...I just couldn't get it down pat...Thanks a million for this code...5 and 1/2 globes :)
(If this comment was disrespectful, please report it.)

 
11/14/2001 5:38:04 PMPxHxAxNxTxOxM

Dude, I've been workin on a WINXP button since it came out...Major Props to you dude. I've d/led almost all your work, but my special favorite was your computer lock out thing...That was major sweet. Keep up the good work! 5 Globes
(If this comment was disrespectful, please report it.)

 
11/15/2001 9:58:21 AMJanekk

Applauses! With these buttons every application can get a new, spicy and interesting look. 5 globes.
(If this comment was disrespectful, please report it.)

 
11/16/2001 3:46:32 AMJE

Good Job Man!! 5 s' for u
(If this comment was disrespectful, please report it.)

 
11/16/2001 6:23:42 AMDylan Morley

Excellent work, a very effective control
(If this comment was disrespectful, please report it.)

 
11/18/2001 8:03:09 AMgonchuki

Another Update... it wasn't slow, but now is FASTER!
(If this comment was disrespectful, please report it.)

 
11/20/2001 8:19:58 AMDylan Morley

One thing I've picked up on using this is the absence of a multi-line feature. With the standard VB button, if the caption-text is wider than the button and the button height allows it, the text will shift onto multiple lines. It would be nice to add in, if you have the time.
(If this comment was disrespectful, please report it.)

 
11/24/2001 3:39:42 PMBjörn

Superb code and looks. Never seen better.
(If this comment was disrespectful, please report it.)

 
12/29/2001 10:57:07 AMgonchuki

next version coming soon...
(If this comment was disrespectful, please report it.)

 
12/30/2001 5:55:32 AMMH

The XP Button is wrong. The blue border stands for default, not focus.
Look at the Windows XP Guidelines provided by Microsoft.
Hope you change it.
(If this comment was disrespectful, please report it.)

 
1/3/2002 5:25:02 AMSchoedler

Good work !!! You got 5 balls ... C'ya.
(If this comment was disrespectful, please report it.)

 
1/3/2002 5:51:29 AMSchoedler

Hey man! In the next version, how about insert pictures with customizable position (top, bottom, left, right) ??? Thanks and sorry my bad english !!!!
(If this comment was disrespectful, please report it.)

 
1/4/2002 10:03:44 PMshaohua

This is the work result I've ever dreamed of. Thanks god! You've just placed a stepping stone for every others who walks through it.
(If this comment was disrespectful, please report it.)

 
1/5/2002 4:36:17 PMJon B. Mooty

There is a bug with the Font property. When you change any property of the Font object for the button the display is not updated with the new Font properties. Just insert a cb.Font.Size = 28 into one of the button's click events to test it. I have had this problem in some controls I have created. I found a workaround but there has to be a better way. Just let me know if you want to see it.
(If this comment was disrespectful, please report it.)

 
1/22/2002 10:38:13 AMschoedler

One suggestion ... Try to use the keybd_event API, no SendKeys. Win2k has a bug that freeze the keyboard using SendKeys VB function. Try no use With vb command ... It makes the code slow. C´ya !!!!
(If this comment was disrespectful, please report it.)

 
1/22/2002 10:43:36 AMschoedler

One little bug !!! When you set the ButtonType to [Java Metal] and after to another type, the font remain bold. Try use the follow code instead the If:

UserControl.FontBold = (MyButtonType = [Java metal])


One more thing: In the ButtonType (let), you read the ButtonType property ... Always use the local variable for the test ... Ex.:

Wrong:
If ButtonType = [Java metal] Then UserControl.FontBold = True

Correct:
If MyButtonType = [Java metal] Then UserControl.FontBold = True



Best Regards!
(If this comment was disrespectful, please report it.)

 
1/22/2002 11:01:04 AMschoedler

Hi again !!!

I have found some performance tips ...

In SetAccessKeys function, try to use Mid$ (with the $ ... this way the function returns a String value ... In Mid, the return is a variant ... 20% faster with Mid$!) ... Use also LCase$, UCase$, Str$, String$, Space$ ...


Best Regards!
(If this comment was disrespectful, please report it.)

 
1/22/2002 11:23:12 AMschoedler

Hey !

More one tip: if you want the control MORE faster, try to use the SendMessage API, using the WM_SETREDRAW option. Disabling the redraw, the system dont lost time redrawing the object !!!

Example:

'To disable the redraw
SendMessage UserControl.hwnd, WM_SETREDRAW, False, 0&

'type here commands to draw in the object


'To re-enable the redraw
SendMessage UserControl.hwnd, WM_SETREDRAW, True, 0&
UserControl.Refresh



C´ya !!!!

(If this comment was disrespectful, please report it.)

 
1/23/2002 1:12:42 PMMika Viitapohja

GRRREEEAAAT CODE!
(If this comment was disrespectful, please report it.)

 
1/31/2002 4:09:26 AMLogan009

Hi,

the dblclick should look like this (I added a line):

Private Sub UserControl_DblClick()
If LastButton = 1 Then
UserControl_Click
Call UserControl_MouseDown(1, 1, 1, 1)
End If
End Sub

That way, two fast clicks on the button will result in two click-Events.

Nevertheless: Good Work! Picture-Support would be good... :-))

Best regards,

Logan009@gmx.de
(If this comment was disrespectful, please report it.)

 
2/2/2002 8:42:24 AMPROBLEM!

You get 5*s but there is a PROBLEM! When I have any kind of button once I click it once whenever I click the form (or outside of the form) instead of doing what it is supposed to (like if I click the [X]) the button will get pressed. And if i click on the form the button and evertthing else won't work.
(If this comment was disrespectful, please report it.)

 
2/5/2002 7:53:34 AMKevin Meagher

Ok, not sure what the heck the guy above is trying to say. Reading his comments is not incredibly easy on the eyes. GREAT CODE!! Latley I have been checking out posts from PSC LESS AND LESS due to the diminishing worth of these posts. One more "fake e-mail" or "new trojan" and I think I'll puke, ha. Anyway the code is absolutely excellent. I like it so much I'm having difficulty deciding if I want to change out my buttons or not. SUGGESTIONS: two things, a) graphic / picture support would be nice; b) "wrapping" should be added for captions longer than the width of the button. I myself often use mult-line buttons. 5 globes!
(If this comment was disrespectful, please report it.)

 
2/5/2002 9:27:45 AMMac Guru

I'll be really impressed when it emulates a MacOS X button! Woo hoo! Pretty cool as is, though.
(If this comment was disrespectful, please report it.)

 
2/5/2002 10:18:11 AMLCensoni

I think there's not much left to say...
(If this comment was disrespectful, please report it.)

 
2/5/2002 10:58:17 AMMohammad Asif

Is there any way to have a small 2nd caption on the button, say at a top-left corner. I am looking for ways to have a short-cut key indicator on the button but I don't like it part of the standard caption, or inside paranthese. Would it be easy for you to add this feature?
(If this comment was disrespectful, please report it.)

 
2/6/2002 5:29:01 AMschoedler

Hey gonchuki !!!

You can implement graphics support in the buttons and the "check-style" ...
What you think ???


(If this comment was disrespectful, please report it.)

 
6/20/2002 12:40:01 AMAl

What more can I say other than truley AWSOME!
(If this comment was disrespectful, please report it.)

 
7/15/2002 6:37:10 AMEric

Great!!!
Max. globes.
Keep up the good work..
(If this comment was disrespectful, please report it.)

 
8/14/2002 2:56:30 AMZeven

very nice......
5 dogs for your very cool submission

(If this comment was disrespectful, please report it.)

 
8/14/2002 11:14:35 PMZeven

thanks for your code
I aready use it for my project
and its working

Very Awsome code!!!!
Greate job man
(If this comment was disrespectful, please report it.)

 
11/9/2002 12:55:22 AMAdam

alhtough it is nice the windows xp buttons borders change to orange when the mouse is over the button.
(If this comment was disrespectful, please report it.)

 
3/9/2003 8:23:20 PM

excellent control keep it up
(If this comment was disrespectful, please report it.)

 
11/26/2003 7:04:49 PMBryant Zadegan

hmmm, hasnt been updated in 8 months eh? well, ill be the first to post in 8 months! Woohoo! noce code, awesome, just awesome. 5,080,786,767,067,068 globes (tho psc only lets me give 5, and tho uve already won a contest.
(If this comment was disrespectful, please report it.)

 
11/27/2003 3:39:28 PM

Very, very nice work!!!!

But I have a question:
I put a *.gif image that have a transparent background, but when i put into the button, the image lost the transparency. What can i do???
(If this comment was disrespectful, please report it.)

 
9/2/2004 4:20:28 AM

nic it's a great attempt, keep up
(If this comment was disrespectful, please report it.)

 
12/13/2004 2:03:03 PMmork

I was wondering the same thing about an image with transparent bg on the XP styled button. The demo seems to have accomplished this, but it is not clear as to how.
(If this comment was disrespectful, please report it.)

 
1/1/2005 1:17:25 PMTasos

Great work 5 globes for me
But I'm having a little problem with the KDE 2 buttons.The problem is when I have the button in a form and the form is minimized and the restored again 2 times all the project crashes or stucks .Any tips???????
(If this comment was disrespectful, please report it.)

 
3/2/2005 7:08:53 PM

can this code work in access as a module to skin the form
(If this comment was disrespectful, please report it.)

 
9/11/2005 5:06:54 PMPatrick Dinklage

5 stars!
this simply kicks ass!
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.