为什么出错?
谁帮我贴到大富翁,加100分(留qq号)
unit Unit2;
interface
uses
Classes, Windows, Messages;
type
TMyThread = class(TThread)
FHandle1: THandle;
procedure WinProc(var Msg: TMessage);
function GetHandle: THandle;
protected
procedure Execute; override;
public
constructor Create;
destructor Destroy;
property Handle1: THandle read GetHandle;
end;
implementation
{ TMyThread }
constructor TMyThread.Create;
begin
if Handle1 = 0 then
Exit;
end;
destructor TMyThread.Destroy;
begin
if FHandle1 <> 0 then
DeallocateHWnd(FHandle1);
end;
procedure TMyThread.Execute;
begin
inherited;
end;
function TMyThread.GetHandle: THandle;
begin
if FHandle1 = 0 then
FHandle1 := AllocateHwnd(WinProc);
Result := FHandle1;
end;
procedure TMyThread.WinProc(var Msg: TMessage);
begin
try
Dispatch(Msg);
except
if Assigned(ApplicationHandleException) then
ApplicationHandleException(Self);
end;
end;
end.