Board index » cppbuilder » detect Keypress

detect Keypress

hello,
How can I detect a KeyPress (Page down, -Up, Pos...) in my application,
and react to it.  That must be independent of which component in my
application has the focus .

(How can I use "WM_KEYDOWN-Message...")

Any Info would be nice.

Thanks,
    Shapur

 

Re:detect Keypress


Hi Shapur,

Quote
> How can I detect a KeyPress (Page down, -Up, Pos...) in my application,
> and react to it.  That must be independent of which component in my
> application has the focus .

Depending on your version of Builder, you can override the dynamic
TCustomForm::IsShortCut() member function...

// in header...
    DYNAMIC bool __fastcall IsShortCut(TWMKey& Msg);

// in source...
bool __fastcall TForm1::IsShortCut(TWMKey& Msg)
{
    char Key = Msg.CharCode;
    return false;
    // return true to trap

Quote
}

Otherwise, you'll need to set up a handler for the TApplication::OnMessage
event, explicitly testing for the WM_KEYDOWN message.

Good luck!

--
Damon Chandler
http://bcbcaq.freeservers.com

Re:detect Keypress


Hi Damon

it works.

can you give me a next Tip (How can I add (Pgup, pgdown, pos,end...) into the
Shortcut list?

thanks
shapur

Damon Chandler schrieb:

Quote
> Hi Shapur,
> > How can I detect a KeyPress (Page down, -Up, Pos...) in my application,
> > and react to it.  That must be independent of which component in my
> > application has the focus .

> Depending on your version of Builder, you can override the dynamic
> TCustomForm::IsShortCut() member function...

> // in header...
>     DYNAMIC bool __fastcall IsShortCut(TWMKey& Msg);

> // in source...
> bool __fastcall TForm1::IsShortCut(TWMKey& Msg)
> {
>     char Key = Msg.CharCode;
>     return false;
>     // return true to trap
> }

> Otherwise, you'll need to set up a handler for the TApplication::OnMessage
> event, explicitly testing for the WM_KEYDOWN message.

> Good luck!

> --
> Damon Chandler
> http://bcbcaq.freeservers.com

Other Threads