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)
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:
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.
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.
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