Board index » cppbuilder » Alt key shoercuts in VCL form

Alt key shoercuts in VCL form


2008-03-09 03:34:11 AM
cppbuilder106
Hi Folks,
Is it possible at design time to find a list of the Alt key shortcuts
assigned in a form? This information MUST be held somewhere.
How does the form determine what to do with a specific shortcut? Does it
just scan all the controls?, and in what order?
Can I assign, in code, a shortcut to a control such as a Button? How?
Using BCB2007 but it's a question been in my mind on and off since BCB1!,
yes I am that old!
Derek
 
 

Re:Alt key shoercuts in VCL form

Derek Harvey wrote:
Quote
Is it possible at design time to find a list of the Alt key shortcuts
assigned in a form?
Don't think so.
Quote
This information MUST be held somewhere.
Why?
Quote
How does the form determine what to do with a specific shortcut? Does it
just scan all the controls?
Yes
Quote
, and in what order?
Tab order.
Quote
Can I assign, in code, a shortcut to a control such as a Button? How?
Place & in the text: Bu&tton is Alt-T
Quote
Using BCB2007 but it's a question been in my mind on and off since BCB1!,
Really has nothing to do with BCB.
Works with plain .rc dialog files too.
Quote
yes I am that old!
That is still young.
 

Re:Alt key shoercuts in VCL form

"Derek Harvey" < XXXX@XXXXX.COM >wrote in message
Quote
Hi Folks,
Is it possible at design time to find a list of the Alt key shortcuts
assigned in a form? This information MUST be held somewhere.
How does the form determine what to do with a specific shortcut? Does it
just scan all the controls?, and in what order?
See this article:
msdn2.microsoft.com/en-us/library/ms644995(VS.85).aspx#keyboard_iface
Specifically, read the section about "mnemonics":
"When the user presses a letter or digit key, the system first determines
whether the current control having the input focus processes the key. The
system sends a WM_GETDLGCODE message to the control, and if the control
returns the DLGC_WANTALLKEYS or DLG_WANTMESSAGE value, the system passes the
key to the control. Otherwise, it searches for a control whose mnemonic
matches the specified letter or digit. It continues to search until it
locates a control or has examined all controls. During the search, it skips
any static controls that have the SS_NOPREFIX style."
If you want to find a list; you will have to do the same logic as the system
and search through all the controls, looking for shortcut mnemonics, and
keeping track of them.
Quote
Can I assign, in code, a shortcut to a control such as a Button? How?
Yes, you can set the text of the button to something with an & in it. For
example, if you have a button with the caption "Something"; and then you
decide you want to make Alt+O activate that button, then at runtime:
MyButton->Caption = "S&omething";
Should do the trick.
Quote

Using BCB2007 but it's a question been in my mind on and off since BCB1!,
yes I am that old!
Derek


 

{smallsort}

Re:Alt key shoercuts in VCL form

Thanks for that, Jason, although I could not get that link to go anywhere
useful ('content not found'). A search for MS644995 found nothing, a search
for 'mnemonics' did not find anything about the implementation of the
facility like your quoted paragraph, but I did glean that MS Visual studio
provides a way of checking duplicates; useful.
Anyway I get the main principle of what goes on and its not worth either of
us spending more time on it..
Derek
"Jason Cipriani" < XXXX@XXXXX.COM >wrote in message
Quote
"Derek Harvey" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...
>Hi Folks,
>Is it possible at design time to find a list of the Alt key shortcuts
>assigned in a form? This information MUST be held somewhere.
>How does the form determine what to do with a specific shortcut? Does it
>just scan all the controls?, and in what order?

See this article:

msdn2.microsoft.com/en-us/library/ms644995(VS.85).aspx#keyboard_iface

Specifically, read the section about "mnemonics":

"When the user presses a letter or digit key, the system first determines
whether the current control having the input focus processes the key. The
system sends a WM_GETDLGCODE message to the control, and if the control
returns the DLGC_WANTALLKEYS or DLG_WANTMESSAGE value, the system passes
the key to the control. Otherwise, it searches for a control whose
mnemonic matches the specified letter or digit. It continues to search
until it locates a control or has examined all controls. During the
search, it skips any static controls that have the SS_NOPREFIX style."

If you want to find a list; you will have to do the same logic as the
system and search through all the controls, looking for shortcut
mnemonics, and keeping track of them.

>Can I assign, in code, a shortcut to a control such as a Button? How?

Yes, you can set the text of the button to something with an & in it. For
example, if you have a button with the caption "Something"; and then you
decide you want to make Alt+O activate that button, then at runtime:

MyButton->Caption = "S&omething";

Should do the trick.

>
>Using BCB2007 but it's a question been in my mind on and off since BCB1!,
>yes I am that old!
>Derek
>
>


 

Re:Alt key shoercuts in VCL form

Derek Harvey wrote:
Quote
Thanks for that, Jason, although I could not get that link to go anywhere
useful ('content not found'). A search for MS644995 found nothing, a search
You need to use the text he provided as the URL:
msdn2.microsoft.com/en-us/library/ms644995(VS.85).aspx#keyboard_iface.
Following the link doesn't work.
[...]
Cheers,
James Watson
 

Re:Alt key shoercuts in VCL form

Derek Harvey wrote:
Quote
Thanks for that, Jason, although I could not get that link to go anywhere
useful ('content not found').
In case my last post wasn't clear enough, you should use as the URL
everything between the following two double quotation marks:
"msdn2.microsoft.com/en-us/library/ms644995(VS.85).aspx#keyboard_iface"
[...]
Cheers,
James Watson
 

Re:Alt key shoercuts in VCL form

"Derek Harvey" < XXXX@XXXXX.COM >wrote in message
Quote
Thanks for that, Jason, although I could not get that link to go anywhere
useful ('content not found'). A search for MS644995 found nothing, a
search for 'mnemonics' did not find anything about the implementation of
the facility like your quoted paragraph, but I did glean that MS Visual
studio provides a way of checking duplicates; useful.
Hmm.... that's really weird. Well, do what James Watson says and copy +
paste the link into your browser. Or, you could try this (it really is a
good article worth reading, it contains a lot of other information besides
stuff about the keyboard shortcuts):
tinyurl.com/2u86tc
FWIW, I believe I originally found that article searching for
TranslateMessage(), which is the Windows API function that takes care of
changing keyboard key down/up into other messages like WM_CHAR, searching
for mnemonics, dealing with standard accelerator keys, etc.
"James Watson" < XXXX@XXXXX.COM >wrote in message
Quote
You need to use the text he provided as the URL:
msdn2.microsoft.com/en-us/library/ms644995(VS.85).aspx#keyboard_iface.

Following the link doesn't work.
That's strange. What newsgroup reader are you using? I am able to click on
the link and go to the correct page with no problem with Outlook Express,
through Google Groups, and also through newsgroups.borland.com:
newsgroups.borland.com/cgi-bin/dnewsweb
Jason
 

Re:Alt key shoercuts in VCL form

Jason Cipriani wrote:
Quote
>Following the link doesn't work.
>msdn2.microsoft.com/en-us/library/ms644995(VS.85).aspx#keyboard_iface.

That's strange. What newsgroup reader are you using?
Forte Agent for me.
The (VS.85) that MS recently added to their links kills them.
 

Re:Alt key shoercuts in VCL form

On Mon, 10 Mar 2008 18:58:45 -0700, Bob Gonder wrote:
Quote
Jason Cipriani wrote:

>>Following the link doesn't work.
>>msdn2.microsoft.com/en-us/library/ms644995
(VS.85).aspx#keyboard_iface.
>
>That's strange. What newsgroup reader are you using?

Forte Agent for me.
The (VS.85) that MS recently added to their links kills them.
"Pan" also screws up the link at the (. How about that. Tinyurl from now
on, I guess. What a pain.
Jason
 

Re:Alt key shoercuts in VCL form

Thanks. Eventually I did get the link to work.
The article is quite interesting and answered some questions, i.e., how
Windows finds the control.
It does not clarify the following:
Suppose there is an Edit and a Button. The Edit has the focus and something
has been entered into it.
The mnemonic for the button is then invoked by Alt+b.
The OnClick for the button occurs, BUT the OnExit for the Edit does not, or
at least not until later.
This means that any content checking meant to be done in the EditExit is not
done before the ButtonClick.
A break at the start of the ButtonClick shows that ActiveControl is still
the Edit, so the focus has NOT been changed as the article says it should
have.
Or am I overlooking somethng?
Derek
"James Watson" < XXXX@XXXXX.COM >wrote in message
Quote
Derek Harvey wrote:

>Thanks for that, Jason, although I could not get that link to go anywhere
>useful ('content not found').

In case my last post wasn't clear enough, you should use as the URL
everything between the following two double quotation marks:

"msdn2.microsoft.com/en-us/library/ms644995(VS.85).aspx#keyboard_iface"

[...]

Cheers,

James Watson