确实,当mouse点击TStringGrid外部时,焦点还是停留在TCombobox上,并没有触发TCombobox的OnExit事件。TStringGrid外部包括20多个菜单项,10多个工具按钮,还有其它控件,它对OnMouseDown事件都是忽略的,我想可能是这个原因没有触发TCombobox的OnExit事件。除了响应每个控件的OnMouseDown事件外,还有别的方法吗? to FrameSniper(§绕瀑游龙§):使用TStringGrid的TInplaceEdit对象的方法能说的详细一些吗?
to cmain83(龙行天下2008) 能说明白些吗?
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Menus;type TForm1 = class(TForm) ComboBox1: TComboBox; MainMenu1: TMainMenu; fdasfdsaf1: TMenuItem; fdsafdsa1: TMenuItem; dfasf1: TMenuItem; fdasf1: TMenuItem; dfsafda1: TMenuItem; Button1: TButton; procedure FormCreate(Sender: TObject); private { Private declarations } procedure ApplicationMessage(var Msg: tagMSG; var Handled: Boolean); public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}{ TForm1 }procedure TForm1.ApplicationMessage(var Msg: tagMSG; var Handled: Boolean); begin if NOT (IsChild(Self.ComboBox1.Handle, Msg.Hwnd)) and ((Msg.Message = WM_LBUTTONDOWN) or (Msg.Message = WM_RBUTTONDOWN ))then begin //在此处加上你的处理语句 inherited; end; end;procedure TForm1.FormCreate(Sender: TObject); begin Application.OnMessage := Self.ApplicationMessage; end;end.
begin
showmessage('a');
end;
我菜,就想到这办法。
to FrameSniper(§绕瀑游龙§):使用TStringGrid的TInplaceEdit对象的方法能说的详细一些吗?
能说明白些吗?
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Menus;type
TForm1 = class(TForm)
ComboBox1: TComboBox;
MainMenu1: TMainMenu;
fdasfdsaf1: TMenuItem;
fdsafdsa1: TMenuItem;
dfasf1: TMenuItem;
fdasf1: TMenuItem;
dfsafda1: TMenuItem;
Button1: TButton;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure ApplicationMessage(var Msg: tagMSG; var Handled: Boolean);
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}{ TForm1 }procedure TForm1.ApplicationMessage(var Msg: tagMSG; var Handled: Boolean);
begin
if NOT (IsChild(Self.ComboBox1.Handle, Msg.Hwnd)) and ((Msg.Message = WM_LBUTTONDOWN)
or (Msg.Message = WM_RBUTTONDOWN ))then
begin
//在此处加上你的处理语句
inherited;
end;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMessage := Self.ApplicationMessage;
end;end.