Fastream Technologies wrote:
>
> The problem is that when the Threaddetach is called, there may be
> messages in the queue which may then revoke AllocateHwnd AFTER the
> detaching which causes problems on the subsequent attach!
Most likely you call property Handle somewhere in your code after
ThreadDetach which allocates a new HWND.
function TIcsWndControl.GetHandle: HWND;
begin
if FHandle = 0 then
AllocateHWnd;
Result := FHandle;
end;
You could make ThreadID public, the set it to zero if
TIcsWndControl.DeallocateHWnd, that enables you to check whether a
window handle is available or not.
procedure TIcsWndControl.DeallocateHWnd;
begin
if FHandle = 0 then
Exit; // Already done
GWndHandlerPool.Lock;
try
FreeMsgHandlers;
if Assigned(FWndHandler) and (FWndHandler.FMsgCnt <= 0) then
GWndHandlerPool.FreeWndHandler(FWndHandler);
FHandle := 0;
FWndHandler := nil;
FThreadID := 0;
finally
GWndHandlerPool.UnLock;
end;
end;
---
Arno Garrels [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be