为什么没有createwindow却可以响应windows的消息呢?

peihexian peihexian 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
TTEST = class(TObject)
private
FWindowHandle: HWND;
procedure WndProc(var Msg: TMessage);
protected
public
constructor Create;
destructor Destroy; override;
end;

constructor TUSB.Create;
begin
FWindowHandle := AllocateHWnd(WndProc);
USBRegister;
end;

destructor TUSB.Destroy;
begin
DeallocateHWnd(FWindowHandle);
inherited Destroy;
end;

procedure TUSB.WndProc(var Msg: TMessage);
begin
if (Msg.Msg = WM_DEVICECHANGE) then
begin
try
//WMDeviceChange(Msg);
except
Application.HandleException(Self);
end;
end
else
Msg.Result := DefWindowProc(FWindowHandle, Msg.Msg, Msg.wParam, Msg.lParam);
end;

这个东东是从TObject继承下来的,为什么加了个 procedure WndProc(var Msg: TMessage);
就可以接收windows的消息了呢?我的理解好像是要有Window才可以处理消息循环的啊???

偶搞了6年的delphi了,看来是白学了。
...全文

相关推荐

评论 7
收藏 已收藏
分享
返回顶部
peihexian
Windows SDK/API 1,184 成员 22,326 内容