Link to home
Start Free TrialLog in
Avatar of logosapience
logosapience

asked on

TForm & focus

Hello,

I have 2 TForm created, one above the other.
What I want to do is to use the VK_LEFT or VK_RIGHT key on the top-most window but the problem is when I press one of these 2 keys, the windows beside the other gets the focus.

How can I do?
Avatar of rwilson032697
rwilson032697

The form which has focus will be sent these keypresses, it seems strange the the topmost form (which would normally have focus) isn't getting them.

I assume you are using an OnKeyDown handler in the form? You might like to make sure that KeyPreview property for the forms is set to true...

Cheers,

Raymond.
Avatar of logosapience

ASKER

new thing :
I put the following procedure on each form :

Procedure CMDialogKey( Var msg: TCMDialogKey );
     message CM_DIALOGKEY;

and when I press VK_Left or Right, it's the procedure in the hidden window which is executed...

So, it means that the hidden window always have the focus...

I put a Form2.setfocus on the OnShow event of the topmost window but it's the same.
Have you tried it with a simple OnKeyDown event in the form?

Cheers,

Raymond.
Yes I tried but all this happens before the onkeydown event...
ASKER CERTIFIED SOLUTION
Avatar of inthe
inthe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok, it works, thanks very much!