WinControl.CanFocus returns True when ParentForm is not visible.
Original Reporter info from Mantis: zoran
-
Reporter name: Zoran Vučenović
Original Reporter info from Mantis: zoran
- Reporter name: Zoran Vučenović
Description:
If the control itself has properties Visible and Enabled set to true, but its parent form is not visible, CanFocus method returns true, but trying to invoke SetFocus raises the exception.
Additional information:
If C is TWinControl (any TWinControl's descendant) then if C.ParentForm.Visible is False, this code will raise the exception:
...
if C.CanFocus then // returns True!
C.SetFocus; // raises
...
I believe that CanFocus should return True only when SetFocus will not raise the exception, so I'm uploading the patch which solves the problem.