DBGrid raises "Can not focus to disable or invisible window" when hides inplace editor
Original Reporter info from Mantis: zgabrovski
-
Reporter name: Zdravko Gabrovski
Original Reporter info from Mantis: zgabrovski
- Reporter name: Zdravko Gabrovski
Description:
DBGrid raises "Can not focus to disabe or invisible window" when hide inplace editor after enable dataset controls.
To reproduce the problem you must enable "dgAlwaysShowEditor" option.
In my case I have a page control with 2 tab controls. In first one there is a DBGrid with dgAlwaysShowEditor set to true.
When user change the active tab sheet, I do a dataset "DisableControls", some work over the data, and after that "EnableControls".
All this happens in PageControl "OnChange" event handler.
After "Enablecontrols" it fire "Can not focus to disable or invisible window" exception.
The exception comes from line 7215 in Grids.pas file in DoEditorHide method.
ParentForm.ActiveControl := self;
To solve the case, I just add a sanity check:
if Self.CanFocus then
ParentForm.ActiveControl := self;
Steps to reproduce:
Please, use attached example.
- Click button "Delete"
- Click over "TabSheet2".
It will raise exception.
Additional information:
I catch the bug over Win32/64 lcl, but may be there is the same problem over all other widgetsets.
Mantis conversion info:
- Mantis ID: 37385
- OS: Windows
- OS Build: All
- Build: trunk
- Platform: Windows
- Fixed in revision: r63596 (#727eb0ef)