
unit UCallHwnd;
interface
uses
Classes, Messages, Windows;
const
WM_USER_MSG = WM_USER + 1;
type
TCallHwnd = class(TObject)
private
FHwnd: THandle;
protected
procedure DoUserMessage(var AMsg: TMessage);
public
constructor Create;
destructor Destroy; override;
//调用测试
function CallHwndTest: Boolean;
end;
implementation
{ TCallHwnd }
function TCallHwnd.CallHwndTest: Boolean;
begin
Result := PostMessage(FHwnd, WM_USER_MSG, 1, 2)
end;
constructor TCallHwnd.Create;
begin
FHwnd := AllocateHWnd(DoUserMessage);
end;
destructor TCallHwnd.Destroy;
begin
DeallocateHWnd(FHwnd);
inherited;
end;
procedure TCallHwnd.DoUserMessage(var AMsg: TMessage);
begin
if AMsg.Msg = WM_USER_MSG then
begin
//AMsg.LParam 2
//AMsg.WParam 1
//do something
end
else
AMsg.Result := DefWindowProc(FHwnd, AMsg.Msg, AMsg.WPARAM, AMsg.LPARAM);
end;
end.

posted @ 2016-11-26 09:25伯通心智 阅读(...) 评论(...) 编辑
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-126907-1.html
想什么想啊