TCustomTabControl (TPageControl) bug??
I noticed that each time I ran an application that used the Page Control, I
would receive a leak (user object) that turned out to be a window left
undestroyed. As it turns out, the WindowHandle was being set to 0 so later,
the window did not get destroyed. Delphi 4 did not have this problem as
witnessed below:
// DELPHI 4 - COMCTRLS.PAS - WORKS FINE
procedure TCustomTabControl.WMDestroy(var Message: TWMDestroy);
var
FocusHandle: HWnd;
begin
FocusHandle := GetFocus;
if (FocusHandle <> 0) and ((FocusHandle = Handle) or
IsChild(Handle, FocusHandle)) then
Windows.SetFocus(0);
inherited;
end;
// DELPHI 5 - COMCTRLS.PAS - LEAKS A WINDOW
procedure TCustomTabControl.WMDestroy(var Message: TWMDestroy);
var
FocusHandle: HWnd;
begin
if (FTabs <> nil) and (FTabs.Count > 0) then
begin
FSaveTabs := TStringList.Create;
FSaveTabs.Assign(FTabs);
FSaveTabIndex := GetTabIndex;
end;
FocusHandle := GetFocus;
if (FocusHandle <> 0) and ((FocusHandle = Handle) or
IsChild(Handle, FocusHandle)) then
Windows.SetFocus(0);
inherited;
// USER OBJECT LEAK - WINDOW IS NEVER DELETED WITHOUT THE NEXT
// LINE COMMENTED OUT. WHY IS THIS NEXT LINE EVEN THERE??
// WindowHandle := 0;
end;
Comments???