Button Graphic Maker - April 2010

If you download this tip please consider making a modest donation.

The application I'm currently working on uses an Asp:Button to perform actions. For example a Welcome button displays the welcome page. Rather than use an Asp:Button I began using an Asp:ImageButton which accepts a graphic. I searched the web for a button graphic maker that I could use and found several. Most create the buttons online but don't retain the button settings. So I decided to create my own button maker. Most of the operative code is contained in a class module called cButtonMaker.vb.

The ButtonMaker Application

I created a VS 2008, Asp.Net, VB.Net web solution project which is called ButtonMaker.

Default settings are displayed on this page.

Make the Button Graphics - Click this button to make four buttons. This button is shown on the top and bottom of the page.

Restore Defaults - Click this button to restore default settings.

Class cButtonMaker Properties - The properties are saved in cookies. The properties are:

Color Settings - Use hexadecimal color values for each button color. Click the button 'Link to Sorted Color Chart' to go to a web site that shows colors. The colors can be sorted. I've found this to be a very useful site to get color values.

Move the cursor... - Move the cursor over the sample button to demonstrate the mouse over/out effect.

Save In - The created buttons are saved in the folder shown. In this example they are saved in the solution folder. You will move them from this folder to your web site's folder.

This sample displays 'red' themed buttons.
These buttons are created without a 3D border and with un-bolded font,
using the 'Comic Sans MS' font.

Credits and Source

I used two sources while building this code. The first was from Shahzad Latif. Click here to view his code. The second was some code I found on MSDN. Click here to view that source.

Make a Form, Command Button, Check Box, Option Button, Picture Box any Shape and Transparent

2010/04/08 - I got this email from Douglas Gaede:

Since you were talking buttons and graphics I thought you might like to see something I cranked out 8 years ago. Its VB 6 and Iíve never ported it to .Net, but it might be useful to you. This lets you shape forms and buttons to anything you want.

Click here to view his tip. Thanks Doug. From the linked page:

The application accepts a Form, CommandButton, CheckBox, OptionButton or PictureBox and shapes it to the image assigned to the Picture property. This includes making a specified color completely transparent (you can click on objects underneath the form) during the shaping process. This is a major expansion on code submitted by Chris Yates. Now you can make specially-shaped controls using a PictureBox or real buttons.

Properties and Methods

Class module cButtonMaker accepts a number of properties and has two methods:

Properties with Defaults

Method CreateButton

Method Add3DShadow

Download VB.Net Code

Download the source code by clicking on the zipped file name. You will need to run the application in a folder on your computer that allows files to be written. I was not able to run the application from a Vista Desktop. I moved the unzipped folder to the root directory and it ran OK.

Download - Source Zipped File Size
VS2008 VB Solution ButtonMakerAspNet.zip 44K

Previous Tip   Tip Index   Next Tip

Home

Updated 2010/05/05