Button Graphic Maker - April 2010
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.
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:
- Button Text - The text to be displayed in the button.
- Font Name - The font to be used in creating the text.
- Font Size - The text's font size.
- Button Width - The width of the button in pixels.
- Button Height - The height of the button in pixels.
- Move Caption Higher - Use this pixel value to move the text higher or lower in the button. This requires some experimentation.
- 3D Border - If checked a 3D border is created around the button.
- Bolded Font - If checked the font is bolded.
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.
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.
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.
Class module cButtonMaker accepts a number of properties and has two methods:
Properties with Defaults
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