473,507 Members | 2,387 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MenuItem needs a Custom Shortcut

Lex
I am writing a C# app that has a Menu. Some of the menu items will
have short cuts that do not exist in the Shortcut enum. I would like
the custom shortcuts to appear on the menu but as far as I can tell
there is no way to add a short cut that is not in the Shortcut enum.

I have my on keyboard hook so I am not worried about the custom
shortcut magically working. I just want it to appear nicely formated
on the menu.

Anyone have any suggestions for doing this?

Regards
Nov 16 '05 #1
10 1668
Subclass a menu item and make it owner drawn. Then override OnDrawItem and
draw all the text yourself. That way, you can control where the text is
drawn and what is drawn.

-vJ

"Lex" <de**@homerlex.mailshell.com> wrote in message
news:c5*************************@posting.google.co m...
I am writing a C# app that has a Menu. Some of the menu items will
have short cuts that do not exist in the Shortcut enum. I would like
the custom shortcuts to appear on the menu but as far as I can tell
there is no way to add a short cut that is not in the Shortcut enum.

I have my on keyboard hook so I am not worried about the custom
shortcut magically working. I just want it to appear nicely formated
on the menu.

Anyone have any suggestions for doing this?

Regards

Nov 16 '05 #2
Lex
Thanks for the reply.

Is there any way to tell if the Accelerator key was hit so I know if I
need to draw an underline or simply ignore the "&" in the text for
items with a mnemonic?

Regards
"Vijaye Raji" <no*************@hotmail.com> wrote in message news:<um**************@tk2msftngp13.phx.gbl>...
Subclass a menu item and make it owner drawn. Then override OnDrawItem and
draw all the text yourself. That way, you can control where the text is
drawn and what is drawn.

-vJ

"Lex" <de**@homerlex.mailshell.com> wrote in message
news:c5*************************@posting.google.co m...
I am writing a C# app that has a Menu. Some of the menu items will
have short cuts that do not exist in the Shortcut enum. I would like
the custom shortcuts to appear on the menu but as far as I can tell
there is no way to add a short cut that is not in the Shortcut enum.

I have my on keyboard hook so I am not worried about the custom
shortcut magically working. I just want it to appear nicely formated
on the menu.

Anyone have any suggestions for doing this?

Regards

Nov 16 '05 #3
I think there's a way you can set the accelerator key for a menu item so, it
works automatically.

I think it was called Mnemonic or something like that.

-vJ

"Lex" <de**@homerlex.mailshell.com> wrote in message
news:c5*************************@posting.google.co m...
Thanks for the reply.

Is there any way to tell if the Accelerator key was hit so I know if I
need to draw an underline or simply ignore the "&" in the text for
items with a mnemonic?

Regards
"Vijaye Raji" <no*************@hotmail.com> wrote in message
news:<um**************@tk2msftngp13.phx.gbl>...
Subclass a menu item and make it owner drawn. Then override OnDrawItem
and
draw all the text yourself. That way, you can control where the text is
drawn and what is drawn.

-vJ

"Lex" <de**@homerlex.mailshell.com> wrote in message
news:c5*************************@posting.google.co m...
>I am writing a C# app that has a Menu. Some of the menu items will
> have short cuts that do not exist in the Shortcut enum. I would like
> the custom shortcuts to appear on the menu but as far as I can tell
> there is no way to add a short cut that is not in the Shortcut enum.
>
> I have my on keyboard hook so I am not worried about the custom
> shortcut magically working. I just want it to appear nicely formated
> on the menu.
>
> Anyone have any suggestions for doing this?
>
> Regards

Nov 16 '05 #4
Hi

Here's a real simple solution:
If you have menuitem Open and you for example want the shortcut Ctrl+Alt+F1 (which does not exist in the shortcut enum) to appear in your menuitem.
Just write the following in the Text property of the menuitem: Open\tCtrl+Alt+F1.

Note: You still have to handle the shortcut in your keyboard hook.

- Kristian Sandven
"Lex" wrote:
I am writing a C# app that has a Menu. Some of the menu items will
have short cuts that do not exist in the Shortcut enum. I would like
the custom shortcuts to appear on the menu but as far as I can tell
there is no way to add a short cut that is not in the Shortcut enum.

I have my on keyboard hook so I am not worried about the custom
shortcut magically working. I just want it to appear nicely formated
on the menu.

Anyone have any suggestions for doing this?

Regards

Nov 16 '05 #5
That works a treat. I'll have to remember that one.

--
Mick Doherty
http://homepage.ntlworld.com/mdaudi1...nate/home.html
"Kristian Sandven" <Kr*************@discussions.microsoft.com> wrote in
message news:FA**********************************@microsof t.com...
Hi

Here's a real simple solution:
If you have menuitem Open and you for example want the shortcut Ctrl+Alt+F1 (which does not exist in the shortcut enum) to appear in your
menuitem. Just write the following in the Text property of the menuitem: Open\tCtrl+Alt+F1.
Note: You still have to handle the shortcut in your keyboard hook.

- Kristian Sandven

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004
Nov 16 '05 #6
Thanx for the suggestion but I had tried this in the past and it didn't work for me. The Text shows up as OpenCtrl+Alt+F1.

I did not purse this option as I figured there would still be a problem knowing how many tabs to put in.

Lets say you have a short Menu Text like Open and and longer one like "Start Without Debugging". Obviously you'd need more tabs after "Open" to line up the shortcuts.

Regards

"Kristian Sandven" wrote:
Hi

Here's a real simple solution:
If you have menuitem Open and you for example want the shortcut Ctrl+Alt+F1 (which does not exist in the shortcut enum) to appear in your menuitem.
Just write the following in the Text property of the menuitem: Open\tCtrl+Alt+F1.

Note: You still have to handle the shortcut in your keyboard hook.

- Kristian Sandven
"Lex" wrote:
I am writing a C# app that has a Menu. Some of the menu items will
have short cuts that do not exist in the Shortcut enum. I would like
the custom shortcuts to appear on the menu but as far as I can tell
there is no way to add a short cut that is not in the Shortcut enum.

I have my on keyboard hook so I am not worried about the custom
shortcut magically working. I just want it to appear nicely formated
on the menu.

Anyone have any suggestions for doing this?

Regards

Nov 16 '05 #7
Hi

It works for me if i set the text in the menu editor or directly in code.
Example
MenuItem item.....
item.Text = "Open\tCtrl+Alt+F1";

It does not work if you set the Text Property of the menuitem in the propertygrid.
I have no problems with the alignment of the shortcut text.

Regards

"HomerLex" wrote:
Thanx for the suggestion but I had tried this in the past and it didn't work for me. The Text shows up as OpenCtrl+Alt+F1.

I did not purse this option as I figured there would still be a problem knowing how many tabs to put in.

Lets say you have a short Menu Text like Open and and longer one like "Start Without Debugging". Obviously you'd need more tabs after "Open" to line up the shortcuts.

Regards

"Kristian Sandven" wrote:
Hi

Here's a real simple solution:
If you have menuitem Open and you for example want the shortcut Ctrl+Alt+F1 (which does not exist in the shortcut enum) to appear in your menuitem.
Just write the following in the Text property of the menuitem: Open\tCtrl+Alt+F1.

Note: You still have to handle the shortcut in your keyboard hook.

- Kristian Sandven
"Lex" wrote:
I am writing a C# app that has a Menu. Some of the menu items will
have short cuts that do not exist in the Shortcut enum. I would like
the custom shortcuts to appear on the menu but as far as I can tell
there is no way to add a short cut that is not in the Shortcut enum.

I have my on keyboard hook so I am not worried about the custom
shortcut magically working. I just want it to appear nicely formated
on the menu.

Anyone have any suggestions for doing this?

Regards

Nov 16 '05 #8
Hi

The text must be set in the Menudesigner or in code. Setting the text in the propertygrid does not work.
Example:
MenuItem item...
item.Text = "Open\tCtrl+Alt+F1";

Also I have no problem with the alignment of the shortcut text in the menuitems. I have a mix of the approach above and standard Shortcut enum in my menus and shortcut text is always nicely aligned to the right.

PS. I'm using Visual Studio .NET 7.1 and .NET framework 1.1.

Regards.

"HomerLex" wrote:
Thanx for the suggestion but I had tried this in the past and it didn't work for me. The Text shows up as OpenCtrl+Alt+F1.

I did not purse this option as I figured there would still be a problem knowing how many tabs to put in.

Lets say you have a short Menu Text like Open and and longer one like "Start Without Debugging". Obviously you'd need more tabs after "Open" to line up the shortcuts.

Regards

"Kristian Sandven" wrote:
Hi

Here's a real simple solution:
If you have menuitem Open and you for example want the shortcut Ctrl+Alt+F1 (which does not exist in the shortcut enum) to appear in your menuitem.
Just write the following in the Text property of the menuitem: Open\tCtrl+Alt+F1.

Note: You still have to handle the shortcut in your keyboard hook.

- Kristian Sandven
"Lex" wrote:
I am writing a C# app that has a Menu. Some of the menu items will
have short cuts that do not exist in the Shortcut enum. I would like
the custom shortcuts to appear on the menu but as far as I can tell
there is no way to add a short cut that is not in the Shortcut enum.

I have my on keyboard hook so I am not worried about the custom
shortcut magically working. I just want it to appear nicely formated
on the menu.

Anyone have any suggestions for doing this?

Regards

Nov 16 '05 #9
Works great here. Just one tab needed.
You did try this on a non ownerdraw item didn't you? It won't work on an
ownerdraw menuitem.

--
Mick Doherty
http://homepage.ntlworld.com/mdaudi1...nate/home.html
"HomerLex" <Ho******@discussions.microsoft.com> wrote in message
news:F5**********************************@microsof t.com...
Thanx for the suggestion but I had tried this in the past and it didn't work for me. The Text shows up as OpenCtrl+Alt+F1.
I did not purse this option as I figured there would still be a problem knowing how many tabs to put in.
Lets say you have a short Menu Text like Open and and longer one like "Start Without Debugging". Obviously you'd need more tabs after "Open" to
line up the shortcuts.
Regards

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004
Nov 16 '05 #10
lex
Ah! - Thanx, yeah I was still owner drawing. Works very nicely!.

Regards
"Mick Doherty"
<EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> wrote in
message news:u9****************@TK2MSFTNGP11.phx.gbl...
Works great here. Just one tab needed.
You did try this on a non ownerdraw item didn't you? It won't work on an
ownerdraw menuitem.

--
Mick Doherty
http://homepage.ntlworld.com/mdaudi1...nate/home.html
"HomerLex" <Ho******@discussions.microsoft.com> wrote in message
news:F5**********************************@microsof t.com...
Thanx for the suggestion but I had tried this in the past and it didn't

work for me. The Text shows up as OpenCtrl+Alt+F1.

I did not purse this option as I figured there would still be a problem

knowing how many tabs to put in.

Lets say you have a short Menu Text like Open and and longer one like

"Start Without Debugging". Obviously you'd need more tabs after "Open" to
line up the shortcuts.

Regards

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004

Nov 16 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
2535
by: Lex | last post by:
I am writing a C# app that has a Menu. Some of the menu items will have short cuts that do not exist in the Shortcut enum. I would like the custom shortcuts to appear on the menu but as far as I...
9
1624
by: Beacher | last post by:
I want to make a custom menu so when you click it it will run code that I've written.. only I don't know how to get the menu to run code I want, and I know nothing of modules... can anyone explain...
0
2895
by: ARC | last post by:
Hello all, For right-click (shortcut) menus in access 2007, I've been using a round-about method of opening access 97 on an old computer, modifying my own custom shortcut menus, then importing...
3
2514
by: munkee | last post by:
Hi all, I have been playing with pivotcharts lately to display my data from my database. I have since found however that I will need to get rid of a lot of the "options" a user has to mess around...
0
7111
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7485
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5042
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1542
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
412
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.