by rhcarpenter » Wed Apr 18, 2012 7:40 pm
Ray,
I found a clunky way to add this functionality to XP. In a nutshell, what I did was overlay my TRzDBEdit control with a TRzEdit control.
I set the Visible property of my TRzEdit1 control to False. Then.....
In the OnEnter event of my TRzDbEdit1 control I set the following properties of the TRzEdit1:
Color, FocusColor, ReadOnlyColor to same colors of the TRZDBEdit1
Left to TRzDBEdit1.Left +4
Height to := TRzDBEdit1.Height - 4;
Top to TRzDBEdit1.Top + 2;
Width to TRzDBEdit1.Width - 6;
Visible to True if TRzDBEdit1.Text = ''
In the OnExit event of my TRzDbEdit1 control I set the following properties of the TRzEdit1:
if TRzDBEdit1.Text = '' then
TRzEdit1.Color := TRzDBEdit1.Color
else
TRzEdit1.Visible := False;
In the OnChange event of my TRzDbEdit1 control I set the following properties of the TRzEdit1:
if TRzDBEdit1.Text = '' then
TRzEdit1.Visible := True
else
TRzEdit1.Visible := False;
In the OnEnter event of my >> TRzEdit1 << control I set the following properties of the TRzEdit1:
TRzEdit1.Color := TRzDBEdit1.FocusColor;
TRzEdit1.FocusColor := TRzDBEdit1.FocusColor;
TRzEdit1.ReadOnlyColor := TRzEdit1.FocusColor;
ActiveControl := TRzDBEdit1;
This was necessary for those times when the user clicked on what appears to be the TRzDBEdit1 control (since TRzEdit1 is actually on top of TRzDBEdit1).
Also in the FormResize event I added the following (when the form is resized I resize the controls by a specific ratio).
TRzEdit1.Left := TRzDBEdit1.Left + 4;
TRzEdit1.Height := TRzDBEdit1.Height - 4;
TRzEdit1.Top := TRzDBEdit1.Top + 2;
TRzEdit1.Width := TRzDBEdit1.Width - 6;
I wanted to try to componetize this. I tried but I'm not a component writer. I created a new component based on your TRzDBedit component. I added a new property named EmbeddedHint. This property holds the hint to display. But I was not successful at completing the component. So I'll use my clunky solution for now. It works great on XP, Vista, and W7.
I'm sure you could develop an elegant solution in a single component. Maybe in a future release...