有winsight32和spy++都能检测到应用程序的窗口句柄, 像form,edit,button这些组件都有句柄,效果和windowfrompoint()差不多.但有些组件没有句柄的,像image,label等控件,我想给这些事件发送一些消息(键盘,鼠标消息),要怎样才能发送?
没有句柄不能用sendmessage和postmessage了.
谁有办法解决一下?
没有句柄不能用sendmessage和postmessage了.
谁有办法解决一下?
解决方案 »
- 急招Delphi程序员。
- 关于用DLL作为MDI窗体问题
- 怎样让ADO的表在DBGrid中显示出来
- 贵州贵阳地区招聘程序员
- 有关软件特征码的问题?高手请进来!
- select 语句的写法问题,在线给分(简单)
- 关于webbrowser的向前后退问题.
- 运行客户端产生Dax error!!ErrorMessage:Name not unique in this context.????????????
- 如何利用内存映射机制在两个进程中传递图像
- sql server &Delphi
- 如何在运行时刻,显示ADOConnection控件ConnectionString属性的设置对话框
- 有没有输入XML和XSL文件输出HTML结果的控件?
有句柄的是从TWinControl下继承的。
没有句柄的是从TGraphicControl下继承的。
除非你自己从TWinControl下继承写个控件。
procedure TFormTest.Image1Click(Sender: TObject);
begin
ShowMessage('abc');
end;再写个给它发送消息的程序
procedure TForm1.Button1Click(Sender: TObject);
var
handle1: HWND;
begin
handle1 := FindWindow('TFormTest', nil);
SendMessage(handle1, WM_LBUTTONDOWN, MK_LBUTTON, 0);
SendMessage(handle1, WM_LBUTTONUP, MK_LBUTTON, 0);
end;
Windows, Messages, SysUtils, Classes,Forms;type
TTest = class(TComponent)
private
{ Private declarations }
FHandle : HWND;
protected
destructor Destroy; override;
procedure WndProc(var Message: TMessage); virtual;
{ Protected declarations }
public
constructor Create(AOwner : TComponent); override;
property Handle: HWND read FHandle;
{ Public declarations }
published
{ Published declarations }
end;procedure Register;implementation
constructor TTest.Create;
begin
inherited;
FHandle := AllocateHWND(WndProc);
end;destructor TTest.Destroy;
begin
DeallocateHWND(FHandle);
inherited;
end;procedure TTest.WndProc(var Message: TMessage);
begin
if Message.Msg = WM_QUERYENDSESSION then Message.Result := 1 else
try
Dispatch(Message);
except
Application.HandleException(Self);
end;
end;
procedure Register;
begin
RegisterComponents('Standard', [TTest]);
end;end.