UP
解决方案 »
- Uindexweb运行不了,请使用过的朋友帮帮忙。
- delphi通过html如何调用WinForm?
- DELPHI中的打印报表设置
- 如何取得动态创建的combobox的值
- TADOTable+ACCESS增加和删除记录时出错
- 在edit编辑框中输入w1: String来实现w1:Tshape的控制问题???急,急,急!!!
- 如何真正实现对象之间的赋值!
- 设计操作员菜单权限的基本设计思想怎么样?
- 30分求WINDOWS优化大师的注册号!!!
- 窗体的创建
- 及!!!!!@@@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;