How to show hint for a disabled TDBEdit? - delphi

I have a TDBEdit that is not enabled and thus not showing the Hint.
What would be the best way to have it display the Hint while staying disabled?

The only thing I can think of is overlaying the TDBEdit with a fully transparent control that has ShowHint set to True and a Hint property set.

Drop your disabled TWinControl (TDBEdit is a TWinControl) onto an enabled TWinControl container (a TPanel for example) and set the TPanel hint to the desired value.

Related

What is the ideal way to modify sub control styles in a custom firemonkey control?

I am attempting to develop my first proper custom control for the Firemonkey framework and have ran into what may possibly be an obvious (or not) solution.
Inside my Firemonkey control I have declared FPanel: TPanel; which is then created in the constructor and freed in the destructor. The panel is created along with my control when I add it to a new Multi-Device Form without any problems.
By default the TPanel has borders around the sides of the control which I do not need in my control.
So my question is, what is the ideal way to remove the borders of a TPanel which is child to my custom control? I could not see an obvious property to change, unless I am mistaking I believe we must modify the style of the panel which I assume would be done via a TStyleBook.
Am I right then in thinking that I need to add a TStyleBook to my control, and from there add the panel to the Style book and modify it this way? Unless I am missing something this seems like a lot of extra work for what should be a very quick and simple change.
Assuming this is the correct way, is there an example of modifying a TStyleBook through code?
Thanks.
Because all Firemonkey controls can be parents, one way is to not use TPanel at all and instead replace it with another Firemonkey control such as the TRectangle shape.
The TRectangle shape can then be customised directly through its properties to remove the border which can be achieved by setting the Corners and Sides to False.
Additionally if you don't require any borders whatsoever then the TLayout control behaves just like a TPanel but without the borders.

What are there advantages to using Static Text instead of Label in Delphi?

From the docwiki for labels:
You place a label on a form when you need to identify or annotate another component such as an edit box or when you want to include text on a form. The standard label component, TLabel, is a non-windowed control, so it cannot receive focus; when you need a label with a window handle, use TStaticText instead.
What does the statement "when you need a label with a window handle, use TStaticText instead" mean?
At work, we use a TStaticText when we want our UI automation testing tool to 'read' the text of a "label". Most of the interaction is done by Windows API messaging, so a TStaticText will respond to GetWindowText, while a TLabel will not. This is a simplistic overview on how we use TStaticText and a TLabel.
Also, if you're creating forms that need to work with screen readers for visually impaired users, TLabels can't be seen by the software, but TStaticText labels can.
Cut and pasted from Embarcadero
The TStaticText component functions like TLabel, except that it
descends from TWinControl and therefore has a window handle. Use
TStaticText instead of TLabel when the component's accelerator key
must belong to a windowed control—for example, on an ActiveX property
page.
I believe the reason there are these two label controls with almost the same functionality is (pre)historical.
In old versions of Windows (old as Windows 3.x), there was a practical limit of number of handles the whole system could have. So using handle-less label control was good way to save these precious system resources. That's why Borland introduced the TLabel.
TStaticText
TStaticText has a Window Handle and can accept focus whereas TLabel does not have a Window Handle and cannot accept focus
TStaticText allows the user to edit the text displayed whereas TLabel does not allow the user to edit the text displayed
TLabel
TLabel's caption property can be changed programmatically whereas TStaticText's Caption property cannot be changed programmatically
TLabel does not have a ShowAccelChar property whereas TStaticText does have a ShowAccelChar property

When to use TPanel FullRepaint?

I noticed that the resize flicker gets much better when I set TPanel.FullRepaint to False. Since the property exists and is True by default, there must be some reason for that.
How to decide whether it should be set or not?
The help just states:
FullRepaint controls how the panel responds when it is resized. When FullRepaint is true, the entire panel, including the beveled border repaints when the size changes. When FullRepaint is false, only the area inside the beveled border repaints.
http://docwiki.embarcadero.com/Libraries/XE3/en/Vcl.ExtCtrls.TPanel.FullRepaint
That text says what it does, but not why ...
The effect of a missing Fullrepaint can be shown and you will have to decide if you need it or not.
Place a panel on a form, set anchors to all directions
Set PaintCaption to false or use a empty caption
Place another panel on the form, so that if you are resizing the
form, parts of the first panel will be covered by the second panel.
Run the program and size the form, somtimes the borders of the first panel will not be refreshed.
This happens because in WMWindowPosChanged in case of (FullRepaint or (ShowCaption and (Caption <> ''))) a invalidate will be called, otherwise only InvalidateRect(Handle, Rect, True) of a rects only containing the right and/or bottom border are invalidated. (thanks to Sertac Akyuz for correction)
As you mentioned avoiding invalidate reduces flicker and in many cases the need for a full invalidate is not given, so the user can decide on his own how to proceed.
Panels as the rarely will be used, upper without Fullrepaint
In previous versions of Windows (not sure up to which version, exactly) FullRepaint was required to prevent graphical artefacting on panel borders when a form was resized.
To the best of my knowledge, this hasn't been an issue since at least Windows XP.

How to change TBitBtn back color?

I need to change TBitBtn's back color. Please suggest me the way to change it.
You can't.
You might replace your BitButton to another button component that implements this property.
One simple and quick solution is to replace each of your BitButton with a pair SpeedButton/Panel. Set SpeedButton's Flat property to False; set Panel's BevelInner and BevelOuter to None; and carefully arrange the SpeedButton over the Panel. Then you might change the Panel Color property and it will appear like Button's color has changed. There is some change in functionality, as SpeedButtons can't get Focus; this may prevent its usage for you or might be a premium indeed, test and decide.

How to prevent form from being resized in Delphi?

How do I prevent my form from being resized? I don't want it to be maximized (which can be toggled via the property editor), but I don't want anyone to be able to drag-resize it. Am I missing something simple, or does this require a little bit of coding?
I'm using Delphi 2007.
TForm has the property you need. Set
BorderStyle to bsSingle
so that the form doesn't appear to be sizable, and it has the added benefit of actually not being sizable. :-)
You can set the BorderStyle to bsDialog.
Don't forget about the Constraint properties of TForm, i.e. MaxHeight, MinHeight, MaxWidth, MinWidth.
You can set the BorderStyle to bsSingle, too. That will give you a proper top level frame, with icon and everything.
And if you want to get really geeky (i.e. the answers above are better), you can intercept the RESIZE Windows message.
I would go with the Constraints property myself.
Cheers
Set borderstyle to bstoolwindow. The windows will only have a close button and title bar.

Resources