4
votes

I have an ActiveX control hosted in our application. The control was imported using Delphi Import component menu.

The ActiveX control contains an edit box for user input. When I run the control in its own sandbox application(not a Delphi app) the arrow keys work as expected moving the cursor within the edit control.
However when I run my Delphi application the arrow key behaviour seems to change. It seems to work more like a tab key instead.

I assume this is happening because of the way the VCL processes key strokes. Any ideas how to get around this?

1

1 Answers

0
votes

The control should handle WM_GETDLGCODE and include in the result at least DLGC_WANTARROWS.

In addition, if the ActiveX control is written in Delphi and is using csReflector in its ControlStyle, it should be rebuilt with WM_KEYDOWN and WM_KEYUP (and any other required) message handlers added to the TReflectorWindow class in AxCtrls unit to delegate the messages to the VCL control:

procedure TReflectorWindow.WMKeyDown(var Message: TMessage);
begin
  Message.Result := FControl.Perform(Message.Msg, Message.WParam, Message.LParam);
end;

procedure TReflectorWindow.WMKeyUp(var Message: TMessage);
begin
  Message.Result := FControl.Perform(Message.Msg, Message.WParam, Message.LParam);
end;

This seems to be sufficient to work in my tests using D2007.