UP
解决方案 »
- 如何把搜索的内容存放在数组中?
- 请各位大侠介绍一些网站,下在这些控件。
- (菜鸟问题)DELPHI6/7中怎样来建立一个DLL?
- 怎样用代码创建Win2000系统用户
- 解决有分,进来者有分!早解决早结,谢谢捧场!
- 好机会,想赚钱的兄弟请进,快!!!!!!
- 资源文件的使用一例求助???
- 求购HOOK SKYPE搜索用户结果数据的代码
- 急:请教delphi访问Oracle数据(网络数据库)的几个问题!
- 在C/S结构中,如何不让两个客户操作同一动作?
- 及!!!!!@@@100分!!安装FASTREPORT 时出问题!!!谢谢了!!
- 请问在DBGridEh中如何显示单列或多列下拉列表,说的明白清楚,立刻给分,谢谢!
2在Button的Onmousemove事件写如下代码
s:=activecontrol.name;
3在button的Click事件中你就知道了上个焦点控件的名称。
//是Dbgrid组件
begin
if (ActiveControl is TDbgrid) Then
With TButton(ActiveControl) Do
s:=caption;end;
//是button组件
begin
if (ActiveControl is TButton) Then
With TButton(ActiveControl) Do
s:=caption;end;
{
Suppose you have two Edit (Edit1 and Edit2) boxes on
a Form (Form1). Suppose you need to know
what Edit box had the input focus
(was selected) when you click a button (Button1).Here's how to find out what control
was the last one with the input focus...Delphi's TScreen object has an event called
OnActiveControlChange, which fires immediately
after input focus changes to a new windowed control.
}//Add a new public procedure, ActiveControlChanged,
//to the TForm1 class declaration,
//and two private TWinControl type variables
private
wcActive, wcPrevious : TWinControl;
public
procedure ActiveControlChanged(Sender: TObject);
...procedure TForm1.FormCreate(Sender: TObject);
begin
Screen.OnActiveControlChange := ActiveControlChanged;
end;procedure TForm1.ActiveControlChanged(Sender: TObject);
begin
wcPrevious := wcActive;
wcActive := Form1.ActiveControl;
end;procedure TForm1.FormDestroy(Sender: TObject);
begin
Screen.OnActiveControlChange := nil;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
if TEdit(wcPrevious) = Edit1 then
ShowMessage('Edit1 had focus')
else if TEdit(wcPrevious) = Edit2 then
ShowMessage('Edit2 had focus')
else
ShowMessage('Some other control had a focus!');
end;