🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
6 messages
6 total messages Started by Anders Johansen Sun, 26 Mar 2006 14:48
Passing key presses on to another form
#4074
Author: Anders Johansen
Date: Sun, 26 Mar 2006 14:48
15 lines
1203 bytes
Hi,

Not sure if this question goes here, but here we go:

I have a tool bar form floating over the main form with StayOnTop set to
true. Sometimes the tool form has focus, but I want keyboard key presses
(not mouse key events) to be passed on to the main form. I know which
control on the main form to give focus, and how to do it, but the catching,
screening and then passing on of the keyboard events eludes me.

Any easy solutions?

Sincerely,
  Anders
Re: Passing key presses on to another form
#4075
Author: Bob Gonder
Date: Sun, 26 Mar 2006 17:39
13 lines
1447 bytes
Anders Johansen wrote:

> I want keyboard key presses
>(not mouse key events) to be passed on to the main form. I know which
>control on the main form to give focus, and how to do it, but the catching,
>screening and then passing on of the keyboard events eludes me.
>
>Any easy solutions?

Look at  SetWindowsHookEx()

If you have trouble with it, Google "borland SetWindowsHook"
Remy has posted code and advise several times on this.
Re: Passing key presses on to another form
#4077
Author: Bruce Larrabee
Date: Sun, 26 Mar 2006 21:12
38 lines
2004 bytes
Bob Gonder wrote:
> Anders Johansen wrote:
> 
> 
>>I want keyboard key presses
>>(not mouse key events) to be passed on to the main form. I know which
>>control on the main form to give focus, and how to do it, but the catching,
>>screening and then passing on of the keyboard events eludes me.
>>
>>Any easy solutions?
> 
> 
> Look at  SetWindowsHookEx()
> 
> If you have trouble with it, Google "borland SetWindowsHook"
> Remy has posted code and advise several times on this.
> 
> 

How about writing a function in the main form and using it from the toolbar
to pass any keys 'intercepted' by the toolbar?

void __fastcall TMainForm::InterceptedKeys( char &Key)
{
     // route 'Key' to whatever normally handles key strokes...

}


void __fastcall TTlBar::FormKeyPress(TObject *Sender, char &Key)
{
	MainForm->InterceptedKeys( char &Key);
}


Laters,

Bruce Larrabee
Re: Passing key presses on to another form
#4076
Author: Bruce Larrabee
Date: Sun, 26 Mar 2006 21:13
38 lines
1981 bytes
Bob Gonder wrote:
> Anders Johansen wrote:
> 
> 
>>I want keyboard key presses
>>(not mouse key events) to be passed on to the main form. I know which
>>control on the main form to give focus, and how to do it, but the catching,
>>screening and then passing on of the keyboard events eludes me.
>>
>>Any easy solutions?
> 
> 
> Look at  SetWindowsHookEx()
> 
> If you have trouble with it, Google "borland SetWindowsHook"
> Remy has posted code and advise several times on this.
> 
> 

How about writing a function in the main form and using it from the toolbar
to pass any keys 'intercepted' by the toolbar?

void __fastcall TMainForm::InterceptedKeys( char &Key)
{
     // route 'Key' to whatever normally handles key strokes...

}


void __fastcall TTlBar::FormKeyPress(TObject *Sender, char &Key)
{
	MainForm->InterceptedKeys( Key);
}


Laters,

Bruce Larrabee
Re: Passing key presses on to another form
#4080
Author: Anders Johansen
Date: Mon, 27 Mar 2006 14:41
22 lines
1606 bytes
Bob Gonder <notbg@notmindspring.invalid> wrote:
>Anders Johansen wrote:
>
>> I want keyboard key presses
>>(not mouse key events) to be passed on to the main form. I know which
>>control on the main form to give focus, and how to do it, but the catching,
>>screening and then passing on of the keyboard events eludes me.
>>
>>Any easy solutions?
>
>Look at  SetWindowsHookEx()
>
>If you have trouble with it, Google "borland SetWindowsHook"
>Remy has posted code and advise several times on this.

Well, I had hoped for something a little less heavy duty. I am already 
using swhe for quite a few things, but would like to contain the usage
somewhat.

Sincerely
A
Re: Passing key presses on to another form
#4082
Author: Anders Johansen
Date: Tue, 28 Mar 2006 05:58
23 lines
1476 bytes
"Anders Johansen" <home@dduck.dk> wrote:
>Well, I had hoped for something a little less heavy duty. I am already 
>using swhe for quite a few things, but would like to contain the usage
>somewhat.

OK, found a solution that seems to work. It goes roughly like this:

In the OnKeyDown event of the floating form:

-------------

<control in the main form for focus>->SetFocus();
Application->ProcessEvents(); // Make it so
kbd_event(Key, 0, 0, 0);
kbd_event(Key, <up>);

-------------

Seems to work fine.

Sincerely,
  Anders
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads