为什么没有createwindow却可以响应windows的消息呢?
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了,看来是白学了。