views:

209

answers:

1

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?

A: 

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.

TOndrej
I should have mentioned that this control was not written in Delphi. I will try hooking the WindowProc to see what is happening with the WM_GETDLGCODE message
Jamie