Jump to content
xisto Community
miCRoSCoPiC^eaRthLinG

VB.NET: How To Create Aqua Buttons Pulsing with rounded edges like OS-X

Recommended Posts

Hi all,

I'll be brief about it. The original code was NOT written by me - the author is a certain Mr. Dave Peckham whose article titled AquaButton: A sample custom button control with a Mac OS X look can be found at CodeProject.Com. The original code was written in C# though - and my development platform was VB.NET - so I ported the code to VB.NET and here I am posting it for all of you.

 

If you are unsure what an Aqua Button is - take a look at the following picture:

Posted Image

 

Right - as you can see this will help you change the look of you .NET applications entirely. For C# you can use the code by the original author - and for VB.NET you can use mine. You'll find all the code needed in the attachment with this post - along with three .png picture files titled:

left.png

right.png

fill.png

These make up the left, right and body of the button. Feel free to relpace these with any other color - try experimenting with different kind of edge shapes and fill body. The fourth file in the zip is the main AquaButton.vb class that will draw the aqua button on your forms. You have to include all 4 files in your project and preferrably leave the .png files in the directory from which your application will run. That is necessary for the code to be able to load the pictures that give the button it's custom shape.

 

Only flip side with this is - that the button is not compiled as a User Control and hence not accessible as a Form Designer component. (Maybe, I'll modify it soon to be one). Till then, you have to add the buttons to your project programmatically. A little explanation on that - if you look at the code view of you project (considering a blank form with only one button), inside the "Windows Forms Designer Generated Region", you'll see the standard windows default buttons are added similar to the following format:

Me.Button1 = New System.Windows.Forms.Button...........Me.Button1.BackColor = System.Drawing.Color.LightGrayMe.Button1.Location = New System.Drawing.Point (100, 100)Me.Button1.Name = "Button1"Me.Button1.Size = New System.Drawing.Size (60,24)Me.Button1.TabIndex = 1Me.Button1.Text = "OK"

If you delete your button in the designer - this code will go away. So make sure you note down the Location and Size of your buttons prior to deletion. Since the Aqua Button class inherits the Windows Button Class - all the default button properties are accessible in the Aqua Buttons too.

 

Towards the top of your code, above the windows forms designer generate region add in a statement:

Friend Withevents Button1 As WildGrape.Aqua.Controls.Button

Inside your Form_Load procedure add the following statements:

Button1 = New WildGrape.Aqua.Controls.ButtonMe.Controls.Add (Button1)'The rest is the same as the syntax for the default buttonsMe.Button1.BackColor = System.Drawing.Color.LightGrayMe.Button1.Location = New System.Drawing.Point (100, 100)Me.Button1.Name = "Button1"Me.Button1.Size = New System.Drawing.Size (60,24)Me.Button1.TabIndex = 1Me.Button1.Text = "OK"

Compile your code and have fun ;)

.:: Cheers ::.

 

Download the attachment (Zipped with WinZip 9):

 

 

Download the attachment (Zipped with Windows Zipper):


Share this post


Link to post
Share on other sites

Don't you get bored by the standard windows buttons ?? That was one of the primary reasons I took the pain to convert this code from C#... But it's not just limited to aqua buttons - if you modify the image files, and a little bit of the code - you can infact put ANY shape/size/color of buttons in your appz. That's the cool part about this code.. I'll try posting a small followup on howto do it. Believe me, it can completely change the look of your app

Share this post


Link to post
Share on other sites

I don't know about WinXP unzipper - I never trusted it much. I packed this file using Winzip v9 - which you can download from http://www.winzip.de/ Infact it's in version 10 now - but that wouldn't be a problem. I downloaded the file and tested it again - no problem with Winzip or WinRAR (http://winrarindia.in/)

Share this post


Link to post
Share on other sites

I tried to unzip it with WinRar but it gives errors all the time:

Unknown method in right.pngUnknown method in fill.png
Unknown method in left.png
Unknown method in AquaButton.vb
No files to extract


Where did you zipped it with? Could you reupload it? plzzzzz *begging* or do you want me to download winzip?

-=jeroen=-

Share this post


Link to post
Share on other sites

creating button in vb.net

VB.NET: How To Create Aqua Buttons

 

How can I create a button (its background ,image etc) in the window form

 

Kindly give me the responce

 

-NIRAV

Share this post


Link to post
Share on other sites

vb.net animated button creation

VB.NET: How To Create Aqua Buttons

 

How to create animated button in vb.Net.

 

-question by guna

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.