Board index » delphi » ARROW-KEY MESSAGES WHEN BUTTON

ARROW-KEY MESSAGES WHEN BUTTON

[read on! There is a reward for the first one to solve my problem!]

Okay, I'll admit it, I'm at my wits end.

What I'm trying to do: Having some buttons placed horisontally below a
TMemo. I want  arrow-up and arrow-down keypresses while focus is at any
of the buttons to scroll the memo up or down (instead of moving the
focus).

Having tried several methods of intercepting arrow-key messages from
buttons placed on a form, whitout success, I'm desperate.

The help file states the following on the KeyPreview property of forms:

"When the KeyPreview property is True, most key events (OnKeyDown event,
OnKeyUp event, and OnKeyPress event) go to the form first, regardless of
which control is selected on the form. This allows your application to
determine how to process key events. After going to the form, key events
are then passed to the control selected on the form. When KeyPreview is
False, the key events go directly to the controls. The default value is
False.

The exceptions are the navigation keys, such as Tab, BackTab, the arrow
keys, and so on. If the selected control processes such keys, you can use
KeyPreview to intercept them; otherwise you can't.

If KeyPreview is False, all key events go to the selected control."

The second paragraph indicates that it should be possible to intercept
these messages, but neither in my Button.OnKeyDown nor in my
Form.OnKeyDown does any arrow-keys show up. (Of course KeyPreview is set
to true.)

I also tried to attach a good old-fashioned WindowProc to the buttons via
the SetWindowLong(Handle, gwl_wndproc ...) route. It was called on most
messages, but not on any of the 'focus-moving' presses... sigh. And I
thougt such a handler would get first shot.

I tried using the same WindowProc in the form instead (hoping it was the
form that gobbled the messages) but still no luck.

So, what am I missing? Am i blind? (probably :-) Is the help file in
error? Is it *totally* impossible to wrest these messages from the VCL
buttons?

[carrot follows]

The first one to give me a working solution will get a free registration
of the product I'm developing, and the satisfaction of having contributed
to it!

(If you choose to email me, please also post, as I'm shure others would
like to see the solution too!)

--
Mr. HillBilly (hillbi...@programmers.bbs.no)
Heaven on earth: Programmers BBS!

God is REAL unless defined as an INTEGER.
HR 0.01

 

Re:ARROW-KEY MESSAGES WHEN BUTTON


Quote
>What I'm trying to do: Having some buttons placed horisontally below a

TMemo. I want  arrow-up and arrow-down keypresses while focus is at any
of the buttons to scroll the memo up or down (instead of moving the
focus).

If I understand what you want to accomplish, my suggestion would be a
verticle scroll bar in the TMemo control.  This is an option on the
properties list.

Rick Dubbs
Technology Coordinator
Monore-Gregg School District
Monrovia (near Indianapolis), Indiana, USA

Other Threads