Creating the VFP Base Classes with GDI+x - The Checkbox
A reader on my blog posted - why don't I create other base controls with GDI+x so I thought I'd give it a shot. This post is about recreating the VFP Base classes using pure GDI+ and the GDI+x classes to achieve neat looking base classes.
When I say "Base Class" I mean with VFP intrinsic ability to bind fields to controls. So while not all PEM's available in the Checkbox have been implemented the two most important have been - DataBinding using the ControlSource and of course sprucing up the UI experience.
After a day and a half, this is what I have come up with. This classes can be improved in a number of ways, including improving the UI but that will have to be in later versions.
Please note that to get Translucency you need VFP9Sp2.
Here is a form (included in the download) that displays some of the PEM's of the new control and also allows you to play a bit with the properties.

I have added most changeable properties to the Favourites tab for easy access. This class has the following properties that can be set. Note that some are dependant on others.
1. Background - Solid, Gradient or None.
2. Border or no border.
3. Colour of Background (colours for gradient)
4. Caption
5. 4 background shapes - Rectangular, curver top and bottom and all rounded corners
6. Ability to change the font, colour and actual displayed icon in the check box (tick, circle etc)
7. Square or circular checkbox.
8. Size of the check box
9. Ability to vary the direction of the gradient.
10. Transparent background and ability to vary the Alpha channel.
11.Vary the amount of curvature of the background.
12. Ability to change the colour and font of the caption.
13. Visual feedback when the control has the mouse over
14. As mentioned earlier, this control can be bound to your data the same as the original VFP checkbox control. So it will read and display the bound value as well as set the value in the table for the bound field.


As you can see above, by comparing my control to VFP's native, it does make a big difference to your UI
To make it even easier to use I have also included a builder that will allow you to change most custom properties easily.
To use this class, just drop it on a form the usual way and resize it to what you require.

In the properties window, select the Favourites tab and select the item - aaCheckboxBuilder. When you do, a button will appear above as in the picture. Click this button to open the builder.

The builder is very easy to use and most properties will update live so you can preview them. I have made some notes about some settings as marked in the image below which require some additional comment.

1. This item is what is displayed in the check box. The character above is the tick in the Wingdings font. The easiest is to open the Character Map from the system tools and preview the characters available. Once selected this can be copied to the clipboard and pasted here. Make sure you add the correct font.(2)
3. If no gradient is selected the control will use the colour on the left. There are 4 modes of gradient and by switching your colours you will get 4 more..
Another point I need to make that is important. With a number of these controls on the form you will notice that the form first appears, then the class with an X in the middle then the controls draw the image. This is a problem with the GDI+x. specifically the imgCanvas class, but can easily be fixed. Here's how.
Open the imgCanvas class in VFP and open the INIT method. Scroll down and after the last line in the method add this:
This.Draw()
Close and save the class. What this will do is that it will draw your controls before the Form.Show. The effect will be a slight delay in the form appearing, but that is much better than having the empty controls with the X.
Please let me know of any problem or errors in the code. Also I am welcome to suggestions for improving this class both in functionality as well as in UI appearance, with the emphasis on the latter.
Enjoy
Update:
Following feedback received, the class has now been updated to v1.1 With:
1. Disabled textboxes in builder now enabled.
2. Enabled property added to Favourites so the control can now be Enabled/Disabled at runtime.
Future improvements...?

Unfortunately because of the amount of junk mail being generated from the weblog I have switched off comments. Please post your comments, if any, at www.foxite.com