Answer:
I have wrote this article because I'm shure that there are many developers that encounters the same problems like me.
In example, I have stayed many time to align a editbox. Or a Button. In my opinion, the best way to align controls is using the Align property. But how? If you are looking on Object Inspector, you will see that for edits, checkboxes or some other controls, the Align property is missing.
Looking inside VCL source, you will observe that the ancestor of TEdit is TCusomEdit and the ancestor of TCustomEdit is TWinControl. TWinControl has fully implemented the align property! Wow! This is cool because that means that we can create easy and fast a Edit control with Align property. So let's do the work. From "Component" menu choose NewComponent and, in the opened dialog set as AncestorType TEdit. Fill the remaining properties and then press Install. A new component, derived from TEdit, is now on the component pallete. Open it's unit and in the published area add the align property like bellow.
{ Public declarations }
published
{ Published declarations }
property Align;
............
Now recompile your package and... AMAZING! You have the align property for your TEdit. Good Work!
The same action you can do with TDbEdit, TSpeedButton. In fact, you can use the Align property with any VCL component thats not has this property implemented.
Now let's make another little hacking inside buttons. Create a TButton descendant and add in the published area the Brush and BorderWidth properties. Cool. Now you have a button with border. Do you want it with bevel? Just add the BevelKind, BevelInner and BevelOuter properties and now your button has a new look. Little more cool...
As a test of new look edit box, activate bevels and BorderWidth for it, set the CTL3d property to false and the BevelKind property to bkSoft. It's look different, isn't it?
From this point, the action is in your hand. I have descibed you the way. VCL has many other "hidden" properties. If you find more, add your "discovery" as a comment to this article.
|