Important alert: (current site time 7/16/2013 2:35:06 AM EDT)
 

winzip icon

dcButton ActiveX Control - First Public Release!

Email
Submitted on: 7/28/2006 6:35:08 AM
By: Noel Dacara 
Level: Advanced
User Rating: By 51 Users
Compatibility: VB 5.0, VB 6.0
Views: 28908
author picture
(About the author)
 
     2nd UPDATED!!! Still working on other issues. New and improved button styles. Fast and efficient control. Good icon/picture handling. Heavy API usage. Rare/uncommon button events aware. Unicode text support. Popup menu support. Single-file'd ownerdrawn usercontrol. Lite & full versions supplied. Fully optimized & flexible codes. Very well commented. Compile ready. For advance & novice users. Coding history provided. In-file code links. Should work on Windows 95 or later (Based on API requirements). Free for use by everyone. No registration required. Comments/suggestions appreciated. Votes valued. Donations/promotions welcome. Made in the Philippines!

 
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.


Other 3 submission(s) by this author

 


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

7/13/2006 2:07:15 PMJuan Carlos San Román

Very nice control. 5 from me. I have found an error in sub PolylineEx
"subcript is out of range", because Points=nothing, it is at the beginning, I have put "On error resume next" and it works fine.
(If this comment was disrespectful, please report it.)

 
7/13/2006 2:44:09 PMRiccardo Cohen

Great Code... Would be nice if it could support Alpha Icons, but my 5 globes! Keep up the good work!
(If this comment was disrespectful, please report it.)

 
7/13/2006 3:53:04 PMRuturaj

Looks gr8! Can the Crystal style be made smooth on edge?
(If this comment was disrespectful, please report it.)

 
7/13/2006 5:18:01 PMJefe - Boss

ONE OF THE BEST I'VE EVER SEEN! No caps lock on, holding down the shift key to express gratitude for the sharing. An all around excellent control. The first I have downloaded from PSC that I played with for about 30 minutes and did not encounter an error with! Excellent work!
(If this comment was disrespectful, please report it.)

 
7/13/2006 10:35:10 PMSteppenwolfe

Code is clean, and button is fast, good job! Suggestion: if xp, add option to get users theme and apply the theme choice automatically.
(If this comment was disrespectful, please report it.)

 
7/13/2006 11:46:15 PMtanaya

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

 
7/14/2006 3:09:16 AMMark

Great work! Thanks for sharing.
(If this comment was disrespectful, please report it.)

 
7/14/2006 3:46:36 AMJon Parker

Works great until you start changing the font size.

Try Times New Roman/Bold/Size 14 with a picture set to right centre, to see what I mean.
(If this comment was disrespectful, please report it.)

 
7/14/2006 5:28:56 AMSoorya

Excellent !
The big worry about these sort of buttons are consumes system resource. Lack of intelligence. I mean drawing should not happen for hidden/minimized forms.
Try 100 buttons in a form check laoding and unloading speed. If it is still cool... That is it...
Hope this control will pass the test.
All the best.
(If this comment was disrespectful, please report it.)

 
7/14/2006 5:30:59 AMsolarding

the first comment I give in the web, although have been watching for a while. your work is fantastic, just a little bugs to be fixed. like the "subscript out of range" as Juan mentioned.
(If this comment was disrespectful, please report it.)

 
7/14/2006 7:16:44 AMOption Explicit

A very thorough job designing this, with easy-to-read, well-documented code. Whatever tiny issues there may be with this, you've done an outstanding job. *****
(If this comment was disrespectful, please report it.)

 
7/14/2006 7:47:48 AMSoorya

I tested this control...
Great and fast...
But very ofter I get Runtime error '9'
'Subscript out of range'
Pls. check it
(If this comment was disrespectful, please report it.)

 
7/14/2006 9:25:56 AM

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

 
7/14/2006 10:46:32 AMEriv

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

 
7/15/2006 1:19:23 PMThomas Brustbauer

1. Thank you - great!
2. You asked for suggestions: a drop down button segment right to normal button would be great - as seen in Save/Open dialog of Office 2003
(If this comment was disrespectful, please report it.)

 
7/15/2006 2:12:00 PMubt1

When used within another UserControl this line gives error 438:

If (UserControl.Parent.MDIChild) Then ' Detect activation of parent form
(If this comment was disrespectful, please report it.)

 
7/15/2006 2:20:13 PMubt1

When used as type in a var declaration like Private x as dcButton, x does not have properties Left, Height, Width etc. - really intended?
(If this comment was disrespectful, please report it.)

 
7/16/2006 3:18:03 AMSoorya

more work to be done in this control to fix lot of bug in it. when i tried in my application, my app got hung up.

pls. put some more effort to fix the minor bugs.

But I love this button, It take very less GDI Objects and light weight.

Thanks for the submission

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

 
7/16/2006 5:30:02 AMFazeel Amjad Khan

nice user control 5 globes from me.
Jaun Carlos mention the right thing to
do with the control. there is another problem. if we put the form unload code i.e. unload me. Applicaton crashes and give an error generated by windows error reporting service. What to do with this problem.
(If this comment was disrespectful, please report it.)

 
7/16/2006 5:41:42 AMNoel A. Dacara

hi, tanx evryone! tanx for the bugs :)
help me debug the control to find some more defects for the future version, not bad for the first release though...
(If this comment was disrespectful, please report it.)

 
7/16/2006 5:48:02 AMNoel A. Dacara

well, about the 100 button issue, what kind of program will you want to create having too many button like this?
(If this comment was disrespectful, please report it.)

 
7/16/2006 5:54:46 AMNoel A. Dacara

I cannot update this submission now, sorry, I'm just on a public cafe now viewing your comments, no VB program to help me work things out :)
(If this comment was disrespectful, please report it.)

 
7/17/2006 3:19:05 AMSoorya

hi Noel A. Dacara
Most of my Video Projects are with >50 buttons in single form. Like Mini Control Panel. Some time I prefer Buttons than Menus. Which is more convenient for New PC Users. I have very bad experience with most of these buttons. But I like urs. It is very fast and taking less resource. But I could use it, because of many bugs.
Thanks again for sharing.
(If this comment was disrespectful, please report it.)

 
7/17/2006 4:05:13 AMGoober Mpc

Hi, very nice button control. 5 stars from me... A little modification could be made to the position of the Picture and the Text, when the Picture is on top of the text a space would be nice between the picture and text. It looks very cramped as it currently is.
(If this comment was disrespectful, please report it.)

 
7/17/2006 7:40:35 AMRiccardo Cohen

To complete this project, it would be nice if you can implement option button properties...

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

 
7/17/2006 7:54:52 AMbob8works

Galig m bro!
5* for you.
(If this comment was disrespectful, please report it.)

 
7/17/2006 8:35:35 AMRiccardo Cohen

Little Bug: When disabling button by itself (by clickking it), picture doesn't change to disabled. Also all other graphic effects doesn't draw. So we have a disabled button that looks like a normal button. You can see this very clear on a WindowsXP button.

example: need one button (TestButton) with this code...

Sub TestButton_Click()
TestButton.Enabled = False
End sub

You will see that button doesn't Redraw!!!

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

 
7/19/2006 9:28:59 PMBugzy

Great job Noel, very nice control. Keep up the good work.

Deserves my *****!
(If this comment was disrespectful, please report it.)

 
7/21/2006 7:02:46 PMSharif aly Fouad

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

 
7/21/2006 10:51:36 PMdreamvb

Damm duno what to say lost for words, all I can say is very , very nise work, thanks for shareing with us. 5 *****

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

 
7/22/2006 4:59:33 AMJoe Jordan

Wow, compiler directives to disable unused styles?! Fantastic!

One bug in the 7/21 version - on Demo form load, in function DrawShineEffect, the line ReDim aGrad(0 To H - 1) As Long causes a Runtime Error 9.

My feature request: Alpha icon support. Check out Carles PV for that. :)
(If this comment was disrespectful, please report it.)

 
7/22/2006 5:02:26 AMdreamvb

hi tryed to give you a voteing of 5 but for some reason the Verification Code is not showing, just shows an image not found image. any ideas?
(If this comment was disrespectful, please report it.)

 
7/22/2006 10:19:12 AMNoel A. Dacara

Well, I'll take note of that error.
Thanks everyone for downloading.
Please don't forget to vote :) hehe

I'm still expecting other bugs to occur please help me find them all. And by the way, read HTML files provided on the submission for more information about existing bugs (fixed and unfixed).

Anyway, about the voting problem please consult the site moderators about this.
You're votes are too precious to be discarded...
(If this comment was disrespectful, please report it.)

 
7/23/2006 6:11:48 AMRiccardo Cohen

Little bug: Need one button. Do mouse down on button, hold it. Now if the mouse cursor is out of the button area, button draws a mouseup. Do mouseover again (hold mouse button), then button draws a mousedown. This is all good, but when mouse is double clicked and hold down, there is one drawing problem. So do same as above. Double click and by second click, hold mouse down. Do cursor out of button area, mouse turns to mouseup, which is okay. Hold mouse button down, and do mouse over and you will see that there isn't a mousedown drawing.

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

 
7/23/2006 10:50:25 AMCodE Solutions

Great Codes...if you write all this code from scratch then you deserve to get 5 globes from your hardwork....Some suggestion try to optimize ur codes..it consumes system resources...
(If this comment was disrespectful, please report it.)

 
7/23/2006 5:52:27 PMJoe Jordan

Also, double clicking and holding down the mouse button on the second click causes the button to draw pressed momentarily, then draws unpressed.
(If this comment was disrespectful, please report it.)

 
7/24/2006 6:39:02 PMNoname lol

error - script out of range
line - ReDim aGrad(0 To H - 1) As Long
got this when running Demo.vbg
(If this comment was disrespectful, please report it.)

 
7/25/2006 9:52:14 AMRiccardo Cohen

Hello, I saw you answered a lot of the questions within your updated zip file. I saw it today and you have a couple of question also. Okay, I can help you with some of it, f.e. Alpha Icon Support, Smoother Drawings... etc. Just send me an email, so I can send the zip-file with examples to your mail.

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

 
7/25/2006 3:58:05 PMIan Bunting

Regarding the PSCode verification code image, perhaps clearing the cache of the internet browser, and maybe a force-refresh (Ctrl + F5) may work. Otherwise it is a site issue. Going to have a look at the submission now.
(If this comment was disrespectful, please report it.)

 
7/26/2006 3:06:56 AMÙ­mega

Is this similar with the Candy Button developed by Mario Villanueva? I can't run the application. Error on the sub DrawShineEffect on the line

ReDim aGrad(0 To H - 1) As Long

Nice work. I'll vote when i start running the app. Mabuhay ka!
(If this comment was disrespectful, please report it.)

 
7/26/2006 4:46:57 PMJeff Mayes

Noel - First of all NICE JOB! I do have a question: I have run into a prooblem with another uc button when using a large number of buttons in my project. (Massive project, greater than 75 buttons easily). Do you know if there will be problems with numerous buttons? At any rate, 5 from me. In regards to a much earlier message on PSC, I do like the author pic. Kinda cool. Good looking model, too. Nice to see someone having fun with it. Keep up the good work.
(If this comment was disrespectful, please report it.)

 
7/26/2006 7:31:24 PMJeff Mayes

I do have a suggestion Noel. If you are using the crystal style (oval) with the icon positioned leftedge, can you have the icon drawn offset past the curvature? Are there plans for caption alignement?
(If this comment was disrespectful, please report it.)

 
7/27/2006 5:24:27 PMubt1

Clearifying misunderstanding in my previous comment of 15.07.2006:
When declaring inside a UserControl.ctl outside any procedure
Private WithEvents x As dcButton
x does not have .Left,.Width etc. when accessed in code - strange:
Dim WithEvents x As dcButton
Private Sub UserControl_Initialize()
x.Left = 100 ' <== .Left is unknown
End Sub
(If this comment was disrespectful, please report it.)

 
7/28/2006 5:28:24 AMNoel A. Dacara

Hey, its me again. I have just read the comments and I was surprised on another error 9 report, I'll take care of them. Anyway, about the author pic...kinda cool huh? she's not just a good looking model by the way, she's my girlfriend :) thanks yah all! have fun
(If this comment was disrespectful, please report it.)

 
7/28/2006 7:27:37 AMLight Templer

'Left', 'Right' and some more are VB keywords of functions. After running in similar problems years ago I didn't use them anymore for property names.
(If this comment was disrespectful, please report it.)

 
7/29/2006 1:39:17 AMHSN Murthy

I tried it on my windows xp after compiling the ocx if i add it to any form it works but when you click close button of the window generates windows error and will come out i don't know what is the problem
(If this comment was disrespectful, please report it.)

 
7/30/2006 6:11:35 AMNoel A. Dacara

The crash problem was generated by the subclasser, it's still unfixed because I just borrowed the great subclassing procedures by Paul Caton, does anyone from here know him, please tell him about this...I really like the latest subclasser SelfSub 1.2 because it's really good, just this bug because previous versions of his subclassers does not experience this error.
The problem is explained on the Unfixedbug.htm file provided on the submission.
(If this comment was disrespectful, please report it.)

 
7/30/2006 6:20:54 AMNoel A. Dacara

And hey, hello Light Templer!!!
By the way, congrats for the nice Art2Gui project, I like your IDE edit technique.
I got a crazy idea on why not implement it on this button for its next version, to position the icon and the caption in place, would you mind if I do this?
I should ask permission from you of course :)
(If this comment was disrespectful, please report it.)

 
7/31/2006 7:59:24 AMRiccardo Cohen

Hi Noel I tried to send you an email, but recieving this message:
Delivery Status Notification (Failure)

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

 
7/31/2006 8:50:36 AMNoel A. Dacara

just looking around, anyway about the subclasser...it's SelfSub 2.1 I mean by Paul Caton, he will be the only one who can solve the crash problem.
(If this comment was disrespectful, please report it.)

 
7/31/2006 2:56:26 PMOption Explicit

Noel I had a problem with Paul's previous subclasser @ txtCodeId=54117. My project would crash if I used my Caton-subclassed usercontrol button as an "exit app" button. Turns out if you change the const CODE_LEN from 200 to 204 in the Subclass_Start routine it takes care of the problem. If Paul is too busy to help you may want to experiment with the usercontrol subclasser code at txtCodeId=54117... and don't forget to change CODE_LEN!
(If this comment was disrespectful, please report it.)

 
8/2/2006 11:10:25 AMNoel A. Dacara

Oh thanks, I'll try it.
And hey everyone, thanks for all the support!!!

Until the next release, see yah!
(If this comment was disrespectful, please report it.)

 
8/3/2006 12:02:35 PMGabriele Martino

Great work!!!!
About the bug in Selfsub directory maybe i've got an idea:
'***
Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer)
End
End Sub
'*****
Too simple, but it works... :-)
(If this comment was disrespectful, please report it.)

 
8/7/2006 6:56:36 AMNSS

Greate Controls, Keep It up!
(If this comment was disrespectful, please report it.)

 
8/14/2006 8:05:46 PM

cool. where are in the phil?
(If this comment was disrespectful, please report it.)

 
8/16/2006 6:47:19 AMNoel A. Dacara

davao city. why?
(If this comment was disrespectful, please report it.)

 
8/17/2006 9:44:11 AM

oi bai! taga davao pud ko? naa ka ym? paki send sa ako imo email and cell #. opiants@gmail.com
(If this comment was disrespectful, please report it.)

 
9/13/2006 9:53:46 PMbigleedk

I am bad at english Good control.
But MdiChild Form Load . Project Die. It improved pe cyen it isn't?
(If this comment was disrespectful, please report it.)

 
9/13/2006 9:54:02 PMbigleedk

I am bad at english Good control. But MdiChild Form Load . Project Die. It improved pe cyen it isn't?
(If this comment was disrespectful, please report it.)

 
9/13/2006 9:57:59 PMbigleedk

MdiChild Form Load . Project Die
(If this comment was disrespectful, please report it.)

 
9/13/2006 9:59:12 PMbigleedk

I am bad at english Good control.
But MdiChild Form Load .
Project end.
It improved pe cyen it isn't?
(If this comment was disrespectful, please report it.)

 
9/13/2006 9:59:41 PMbigleedk

I am bad at english Good control.
But MdiChild Form Load .
Project memory lost.
It improved pe cyen it isn't?
(If this comment was disrespectful, please report it.)

 
11/10/2006 3:13:52 AMTuanHai

Any new update w/ unfixed bug solved?

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

 
11/20/2006 7:58:22 AMHector

I'm also curious to know if there is any update with the MDI bug, since this control is rather good and it's a shame it can't be used with MDIs...

Looking a bit at the code I found out that this line is the one causing the problem:

sc_AddMsg hParent, WM_NCACTIVATE

If you change it to something like

sc_AddMsg hParent, WM_ACTIVATE

The program won't crash anymore... I don't know if this would cause any problem tho... It seems WM_NCACTIVATE isn't correctly subclassed, but I'm rather new to programming, and I don't have enough knowledge to look further into it...
(If this comment was disrespectful, please report it.)

 
11/20/2006 10:30:28 AMHector

I've been looking a bit more into the problem using the sample provided... I'm not so sure that it's the same bug...

The problem with the sample is being caused because of subclassing the parent:

" With UserControl.Parent
sc_Subclass .Hwnd
"

It seems the reason of the crashing here is that since you add multiple controls it tries to subclass and terminate the parent form multiple times... if you add some variable so it's only subclassed once there won't be any crash anymore...

I don't know if this is fully right...
(If this comment was disrespectful, please report it.)

 
11/20/2006 7:38:54 PMHector

Well... after struggling with this issue for several hours, looking into other controls using Paul Caton's code, etc I've come up to 2 conclusions for the time being (since I don't have enough skills to further fix this):

1.- Not subclassing parent form nor MDI messages, and therefore losing the advantages from doing so.

2.- Subclassing parent form or MDI messages inside of themselves, adding a new public property to the button control that does the work and enabling/desabling it when the form loses or gains focus...

They are not stylish ways of solving the problem...
(If this comment was disrespectful, please report it.)

 
12/10/2006 7:19:33 AMMr.Intermediate

Wow galing mo tol!!!
Proud to be Pinoy!!!
(If this comment was disrespectful, please report it.)

 
12/10/2006 7:24:00 AMMr.Intermediate

-PROUD TO BE PINOY-
im newbie here and i really want to learn VB i just dont know where to start.. could you send me some codes or tutorials about VB just send it here Fumbary_Hotspring@yahoo.com nahihirapan kasi ako sa thesis ko.. tnx alot
(If this comment was disrespectful, please report it.)

 
3/13/2007 1:55:57 PMsunseeker

Hi Noel,
did you realize a Vista-Style for your Great Button?
(If this comment was disrespectful, please report it.)

 
3/17/2007 12:04:55 PMNoel A. Dacara

Hi, hello.

Sensya na po (sorry), no updates at the moment. (PC Memory problem)
Still saving to buy to new memory :)
You have extra? hehe...tell me.
(DDR200 or DDR266, 128MB or 256MB is enough)

Comments and suggestions are still welcome and will be noted for future developments of the control.

And also, can anyone notify me if paul's subclasser has been updated for my control's problem? Please do tell me.

Thanks. Happy programming!
(If this comment was disrespectful, please report it.)

 
4/14/2007 11:02:51 AMJason Newland

Gabriele Martino, never use "End" in a program especially in the queryunload event. Putting end here stops the form from firing the "Unload" and "Terminate" events and inevitably doesn't execute any code or clean up code in these subs. Secondly, if a control or form is subclassed and you provide an End without properly unsubclassing (cleanup) then (if running in IDE) you are like to crash VB6 (or in EXE) cause a GPF error.
(If this comment was disrespectful, please report it.)

 
4/14/2007 11:05:16 AMJason Newland

Noel, if all else fails, try a different subclassing method such as Steve McMahon's sSubTmr which is a subclassing and timer assistant DLL with source which can be used directly in your control. visit www.vbaccelerator.com
(If this comment was disrespectful, please report it.)

 
4/27/2007 12:25:35 PMyasser ahmed

very very nice looking buttons.Thanks for sharing.That is what I was looking for and finaly I found it. Thanks again.
(If this comment was disrespectful, please report it.)

 
7/30/2007 4:26:40 AMYasser Ahmed

I have used this control in one of my apps,after adding this control to this app, the app start to consume about 25% of the CPU and some time freeze up. also, some time when clicking one of the buttons in this app, the app crashed and disappear. any help?
note: I'm using XP and about 512 MB RAM

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

 
10/22/2007 9:05:15 AMABN

It is an excellent tool. Has any one tested if it is compatible with Vista?
(If this comment was disrespectful, please report it.)

 
11/5/2007 9:06:04 PMuzomaki naruto

Galing Talaga ng mga PINOY!!!!

Thanks for Sharing... Keep up the good work Pare...

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

 
6/17/2008 6:39:58 AMjuned

Excellent, mindblowing
I have never seen it, thanx
I liked it very much!!!!!
Keep it up!
(If this comment was disrespectful, please report it.)

 
2/1/2010 10:14:23 AMkizsleg

ang galing mo kuya..nakakapang hina ng loob makita ang gawa mo..di ko makita sarili ko na magagawa ko yan balang araw..hehe..nice work..galing talaga..
(If this comment was disrespectful, please report it.)

 
2/4/2010 11:51:42 AMNoel Dacara

hehe...buhay pa pala to?! kala ko ala na to, tnx sa pgpapaalala nito sakn kizsleg^_^

nwei, kaya mu yan! enjoy lang. hehe...

dko na tlga npagbigyan to ng oras para tapusin, cenxa na pipz. bc na eh, tska .net na gamit ko ngaun...dko na to naasikaso.

once agen...tnx sa lahat. peace!




-noel
ym: noeldacara
(If this comment was disrespectful, please report it.)

 
2/5/2010 10:10:59 PMTangen

wow, nice skin and totally free.
Suitable for my college project.

I got a problem there.
How to load picture into dcButton during RUN-TIME?
(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.