Try this sample (code + form).
The panel will receive the focus (see "edit -> exit" output in the memo).
Use TDBEdit instead of TEdit.
ic
------ code (unti1.pas) ------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
Edit1: TEdit;
SpeedButton1: TSpeedButton;
Memo1: TMemo;
procedure SpeedButton1Click(Sender: TObject);
procedure Edit1Exit(Sender: TObject);
procedure Panel1Enter(Sender: TObject);
procedure Edit1Enter(Sender: TObject);
procedure Panel1Exit(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.SpeedButton1Click(S
begin
Form1.SetFocusedControl(Pa
end;
procedure TForm1.Edit1Exit(Sender: TObject);
begin
Memo1.Lines.Add('edit -> exit');
end;
procedure TForm1.Panel1Enter(Sender:
begin
Memo1.Lines.Add('panel2 -> Enter');
end;
procedure TForm1.Edit1Enter(Sender: TObject);
begin
Memo1.Lines.Add('edit -> Enter');
end;
procedure TForm1.Panel1Exit(Sender: TObject);
begin
Memo1.Lines.Add('panel -> exit');
end;
end.
------ form (unit1.dfm) ------
object Form1: TForm1
Left = 192
Top = 107
Width = 314
Height = 202
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Panel1: TPanel
Left = 8
Top = 16
Width = 185
Height = 41
Caption = 'Panel1'
TabOrder = 0
OnEnter = Panel1Enter
OnExit = Panel1Exit
object SpeedButton1: TSpeedButton
Left = 138
Top = 11
Width = 23
Height = 22
OnClick = SpeedButton1Click
end
object Edit1: TEdit
Tag = 1
Left = 8
Top = 12
Width = 121
Height = 21
TabOrder = 0
Text = 'Edit1'
OnEnter = Edit1Enter
OnExit = Edit1Exit
end
end
object Memo1: TMemo
Left = 8
Top = 80
Width = 185
Height = 73
Lines.Strings = (
'Memo1')
TabOrder = 1
end
end
Main Topics
Browse All Topics





by: esoftbgPosted on 2005-07-11 at 11:55:43ID: 14415061
Just use TButton or TBitButton - they get the focus OnClick them