Capturing keyboard input in TWinControl derived class.

Giganews Newsgroups
Subject:Capturing keyboard input in TWinControl derived class.
Posted by: Justin Wright
Date:Fri, 20 Aug 2010

Hi,

I originally had a container (derived from TPanel) which contained a TImage and TStatusbar.  I am displaying a map in the TImage and want to capture the space bar press to enable shifting the map within the TImage.

I have read that the TImage cannot receive keyboard input so I change the container from a TPanel into a TWinControl, hoping that it wouold get the keypress, being the next up the line.  I overrode the keyup and keydown methods but only the parent Forms key events were being called.

I have read that I can set up a WindowsHook to get the inpt, but could not see how to pass the HookFunction a pointer to the control that was supposed to receive the input.

I am sure there is an obvious answer to this but I am stuck.

Any help will be greatly appreciated.

regards

Justin.

Replies