Re: Showing hints on disabled dbeditboxes

[ DelphiLand Discussion Forum ]

Posted by webmaster Guido on September 09, 2002 at 20:22:03:

In Reply to: Showing hints on disabled dbeditboxes posted by Keith on September 06, 2002 at 14:48:06:

: How can I show hints on dbeditboxes when they are disabled but visible (for data display purposes)? There are quite a few of them. Thanks.

If you move the cursor over a "control" (visible component), its hint is not shown if that control's "Enabled" property is set to "False". And you can't solve the problem by looking at its OnMouseMove event for showing hint-info, because that event will not fire if the component is disabled.

But if you only want the TEdits for their nice shape and you disable them in order to stop the user from changing their text, you can use another component. You can use a TStaticText instead, it looks almost like an Edit-box if you set its property BorderStyle to sbsSunken and the Color to clWhite. And because the user can't change its contents, you don't have to disable it, so it always shows its "Hint" :)

This won't help you much if you want components that at all times show a hint when the cursor is over them, but sometimes you need them for data input, while at another time you just want to show the data (and the user is not allowed to change the data). Almost everything is possible in Delphi ;-) so... that case, use TEdits for data entry, and use the same number of TStaticLabels to show the data. The TStaticLabels should have the same contents, location, and hints. Initially, the TStaticLabels are invisible (Visible := False). Next, instead of simply disabling the TEdits, hide them (Visible := False) and show the TStaticLabels. Afterwards, when necessary hide the TStaticLabels again and show the TEdits.

Tip: it saves a lot in programming code if you put all of the TEdits on a panel and the TStaticLabels on another panel, both with the same dimensions and location. Now alternately show one panel and hide the other one (Panel1.Visible := True /False).

If anybody has problems with this, let me know and we might put together some tutorial about invisible controls :)

Related Articles and Replies:

[ DelphiLand Discussion Forum ]