我做了一个控件,要用到一个窗口。
怎样得知窗口那个按钮按下?
怎样得知窗口那个按钮按下?
解决方案 »
- QReport问题,在线等,未解决前长期有效
- 进来拿分吧(Treeview控件怎么判断被select的节点没有子节点)
- 喜爱编程优化的人帮我看看这个多重纤套的循环语句,看是否能有别的方法优化呢?
- Socket通讯问题,多个clientsocket连接到一个serversocket时
- 看看这个查询SQL语句该怎么写(在线等, 有正确答案立即给分)
- 关于柱状图
- 我的delphi在调试状态下,怎么不显示变量的值了?重新装了几次都没有用!急死我了!
- 谁开发过天敏VC4000监控卡
- 你是菜鸟吗,试试这道题就知道啦,呵呵..
- 在DELPHI中如何调用存储过程?
- 高分:谁能告诉我D7中的WebSnap、IntraWeb、IWISAPIProject之间有何区别?他们和ASP、JSP相比有哪些优缺点各有何优缺点?
- 我制作了一个ActiveForm网页,使用三层体系结构,需要将midas.dll文件拷贝到系统目录中,如何将该文件自动下载到客户端的系统目录中
但是没有太多的vcl开发exp.看看先
Controls, StdCtrls, Forms, Dialogs, Windows, Messages, SysUtils, Classes;type
TTestComponent = class(TComponent)
private
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
published
{ Published declarations }
end;type
TButtonProc = class(TComponent)
private
TestComponent: TTestComponent;
Button: TButton;
OldBtnWindowProc: TWndMethod;
procedure NewBtnWindowProc(var Message: TMessage);
end;procedure Register;implementationprocedure TButtonProc.NewBtnWindowProc(var Message: TMessage);
begin
OldBtnWindowProc(Message);
if Message.Msg = CN_COMMAND then
if TWMCommand(Message).NotifyCode = BN_CLICKED then begin
ShowMessage(Button.Name);
// TestComponent. ...
end;
end;constructor TTestComponent.Create(AOwner: TComponent);
var
i: Integer;
btnProc: TButtonProc;
begin
inherited Create(AOwner);
if AOwner is TForm then
with TForm(AOwner) do
for i := 0 to ComponentCount - 1 do
if Components[i] is TButton then begin
btnProc := TButtonProc.Create(Self);
with btnProc do begin
TestComponent := Self;
Button := TButton(TForm(AOwner).Components[i]);
OldBtnWindowProc := Button.WindowProc;
Button.WindowProc := NewBtnWindowProc;
end;
end;
end;procedure Register;
begin
RegisterComponents('Standard', [TTestComponent]);
end;end.