View Issue Details

IDProjectCategoryView StatusLast Update
0006277JEDI VCL00 JVCL Componentspublic2014-12-04 14:57
Reportersp40Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status acknowledgedResolutionopen 
Product Version3.45 
Target VersionFixed in Version 
Summary0006277: Focus with TJvDbGrid - TWebBrowser
DescriptionI put a TJvDbGrid and a TWebBrowser on my form.
As I select a cell in my grid, I load the adress from table displayed in the JvdbGrid (some GoogleMaps location). If I click on the webBrowser, the jvDbGrid seems to lost focus, and I can't change the selected record.
I can catch the focus back on the jvdbgrid as I click in a ComboBox before.
Additional InformationThis bug was told on the native DBGrid. I've overloaded the fix on the TJvDbGrid and it fixes it too.
(https://groups.yahoo.com/neo/groups/delphi-webbrowser/conversations/topics/3668)

The answer was :
For everybody - problem with DBGrid is fixed now...
How? Error was in DBGrid not in TWebBrowser...
Compile unit from this mail and use TFixedDBGrid instead of TDBGrid...

Enjoy now it...!

Milan Kajnar


******************************************************************
unit FixedDBGrid;

interface

uses
Winprocs,wintypes, Messages, SysUtils, Classes, Graphics,
Controls, Forms, Dialogs, Grids, DBGrids;

type
TFixedDBGrid = class(TDBGrid)
private
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
procedure WMRButtonDown(var Message: TWMRButtonDown); message
WM_RBUTTONDOWN;
procedure WMLButtonDown(var Message: TWMLButtonDown); message
WM_LBUTTONDOWN;
published
{ Published declarations }
end;

procedure Register;

implementation


procedure TFixedDBGrid.WMRButtonDown(var Message: TWMRButtonDown);
begin
winprocs.SetFocus(handle); {remember that winprocs in Delphi 1
only!}
inherited;
end;

procedure TFixedDBGrid.WMLButtonDown(var Message: TWMLButtonDown);
begin
winprocs.SetFocus(handle); {remember that winprocs in Delphi 1
only!}
inherited;
end;

procedure Register;
begin
RegisterComponents('Samples', [TFixedDBGrid]);
end;

end.

*******************************************************************
TagsNo tags attached.

Activities

sp40

2014-04-28 17:11

reporter   ~0020955

https://groups.yahoo.com/neo/groups/delphi-webbrowser/conversations/topics/3668

AHUser

2014-04-28 22:09

developer   ~0020956

> Error was in DBGrid not in TWebBrowser

Actually the bug is in the COM-Container that hosts the TWebBrowser. The IWebBrowser takes the focus but the VCL isn't notified correctly and still thinks the Grid has the focus. So the Grid's TWinControl.SetFocus call from MouseDown doesn't do anything because FocusedControl is already the Grid.

Your bug fix is a work around by using Windows.SetFocus to circumvent the "if FocusedControl <> Grid" check.

sp40

2014-04-29 09:19

reporter   ~0020957

I don't know about the TWebBrowser, but I trust you... :)
The "bug fix" isn't mine (it's a quotation from Milan Kajnar).

It's strange by the way that others controls can catch the focus back... If you put a combo, a checkbox or an edit, there's no problem at all.

AHUser

2014-05-01 16:15

developer   ~0020958

Last edited: 2014-05-01 16:17

> If you put a combo, a checkbox or an edit, there's no problem at all.

Those controls are "real" Windows controls and use the Windows.SetFocus function if you click on them. But DBGrid depends on the VCL's FocusedControls to be in sync with the actual "GetFocus" window handle. And DBGrid has this code in it

  SetFocus; // VCL's SetFocus
  if not Focused then Exit; // uses Windows.GetFocus = Self.Handle

And because the VCL's FocusedControl is out of sync with the actual focused window handle, the "if not Focused then Exit" stops the MouseDown handler from being processed. The purpose of this code in DBGrid is to handle the InplaceEdit controls. But it fails if VCL's focus and Windows's focus are out of sync.

Every VCL control that uses the "function Focused: Boolean" function will run into a problem with the TWebBrowser.

obones

2014-09-03 11:43

administrator   ~0021042

Please provide the zipped sources of a sample application showing this

2014-09-04 10:57

 

Demo Grid.rar (3,935,899 bytes)

sp40

2014-09-04 10:59

reporter   ~0021048

Sample application uploaded

Issue History

Date Modified Username Field Change
2014-04-28 17:08 sp40 New Issue
2014-04-28 17:11 sp40 Note Added: 0020955
2014-04-28 22:09 AHUser Note Added: 0020956
2014-04-29 09:19 sp40 Note Added: 0020957
2014-05-01 16:15 AHUser Note Added: 0020958
2014-05-01 16:16 AHUser Note Edited: 0020958
2014-05-01 16:17 AHUser Note Edited: 0020958
2014-09-03 11:43 obones Note Added: 0021042
2014-09-03 11:43 obones Status new => feedback
2014-09-04 10:57 sp40 File Added: Demo Grid.rar
2014-09-04 10:59 sp40 Note Added: 0021048
2014-12-04 14:57 obones Status feedback => acknowledged