Some Windows events are not captured

Just updated to Hydra version 6.3.0.1259, from version 6.2.99.1229. Using Delphi 10 Seattle.

The first thing that was noticed was that the OnActivate event on a THYVisualPlugin form wasn’t triggered, until you clicked on a control(i.e.: a button) on the form(yet the code behind the button doesn’t get executed). We also noticed that a lot of the controls(placed an a THYVisualPlugin form) were no longer responding as expected. As an example, we have a TMS TPlanner component on a THYVisualPlugin form, and a double-click event on a cell within TPlanner should return which column and row that the user double-clicked, but instead it is now returning the first column and first row everytime.

I did compare the code between version 6.2.99.1229 and 6.3.0.1259, and noticed that there was a change in the THYVisualPlugin.SetFocusedControl method.

The old code(version 6.2.99.1229):

function THYVisualPlugin.SetFocusedControl(Control: TWinControl): Boolean;
begin
  Result := inherited SetFocusedControl(Control);
    if ActiveControl <> nil then
      SendMessage(ParentWindow, WM_FOCUSOUTOFHOST, 0, 0);
end;

The new code(version 6.3.0.1259):

function THYVisualPlugin.SetFocusedControl(Control: TWinControl): Boolean;
begin
  Result := True;
  if ActiveControl <> Control then begin
    Result := inherited SetFocusedControl(Control);
    if not (csDesigning in ComponentState) then begin
      if ActiveControl <> nil then
        SendMessage(ParentWindow, WM_FOCUSOUTOFHOST, 0, 0);
      Control.SetFocus;
    end;
  end;
end;

I noticed that the inherited SetFocusedControl might not always be called, and also that calling Control.Focus might eliminate other values that are required for some functionalities in some controls(i.e.: TPlanner).

I modified the code as follows:

function THYVisualPlugin.SetFocusedControl(Control: TWinControl): Boolean;
begin
  Result := inherited SetFocusedControl(Control);
  if not (csDesigning in ComponentState) then begin
    if ActiveControl <> nil then
      SendMessage(ParentWindow, WM_FOCUSOUTOFHOST, 0, 0);
  end;
end;

And, these modifications eliminates all the problems that I was seeing. And, that the application is now working the way it is designed, after making the changes.

Thx,
I’ll review why this code was changed

Thanks for looking into it. Will be waiting for the verdict.

Hi,

can you check this code with your app, pls?

function THYVCLVisualPlugin.SetFocusedControl(Control: TWinControl): Boolean;
begin
  Result := inherited SetFocusedControl(Control);
  if not (csDesigning in ComponentState) then begin
    if ActiveControl <> nil then
      SendMessage(ParentWindow, WM_FOCUSOUTOFHOST, 0, 0);
    Control.SetFocus; // <---------- added
  end;
end;

if it doesn’t work as expected with your app, I need your simple testcase that reproduces this issue.
you can drop email with testcase to support@ for keeping privacy

1 Like

It still works as expected. I wasn’t certain if that line was part of the problem or not, it just looked weird to me, at the time. But, it still works as expected.

Thanks for looking into it.

Thanks, logged as bugs://85671

bugs://85671 got closed with status fixed.