MenuItem需要自定义快捷方式 [英] MenuItem needs a Custom Shortcut

查看:80
本文介绍了MenuItem需要自定义快捷方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个带有菜单的C#应用​​程序。一些菜单项将具有快捷方式枚举中不存在的快捷方式。我想

自定义快捷方式出现在菜单上但据我所知

没有办法添加不在快捷方式枚举中的快捷方式。


我有我的键盘挂钩所以我并不担心自定义

快捷方式神奇地工作。我只是希望它在菜单上显示出很好的格式




任何人有任何建议吗?


问候

解决方案

对菜单项进行子类化并将其绘制为所有者。然后覆盖OnDrawItem和

自己绘制所有文本。这样,你可以控制文本的位置

绘制和绘制的内容。


-vJ


"莱克斯" <德** @ homerlex.mailshell.com>在消息中写道

新闻:c5 ************************* @ posting.google.co m ... < blockquote class =post_quotes>我正在编写一个带有菜单的C#应用​​程序。某些菜单项将具有Shortcut枚举中不存在的快捷方式。我想在菜单上显示自定义快捷方式,但据我所知,
无法添加快捷方式枚举中没有的快捷方式。
我有我的键盘挂钩,所以我不担心自定义
快捷方式神奇地工作。我只是希望它在菜单上看起来很好。

任何人都有这方面的建议吗?

问候



感谢您的回复。


有没有办法判断加速键是否被击中所以我知道我是否

需要绘制下划线或简单地忽略&在带有助记符的
项目的文本中?


问候

" Vijaye Raji" <无************* @ hotmail.com>在消息新闻中写道:< um ************** @ tk2msftngp13.phx.gbl> ...

对菜单项进行子类化并使其为所有者绘制。然后重写OnDrawItem并自己绘制所有文本。这样,您就可以控制绘制文本的位置和绘制的内容。

-vJ

Lex <德** @ homerlex.mailshell.com>在消息中写道
新闻:c5 ************************* @ posting.google.co m ...

我正在编写一个带有菜单的C#应用​​程序。某些菜单项将具有Shortcut枚举中不存在的快捷方式。我想在菜单上显示自定义快捷方式,但据我所知,
无法添加快捷方式枚举中没有的快捷方式。
我有我的键盘挂钩,所以我不担心自定义
快捷方式神奇地工作。我只是希望它在菜单上看起来很好。

任何人都有任何建议吗?

问候



我认为有一种方法可以为菜单项设置加速键,所以它会自动生成。

自动生效。


我认为它被称为助记符或类似的东西。


-vJ


" Lex" <德** @ homerlex.mailshell.com>在消息中写道

新闻:c5 ************************* @ posting.google.co m ... < blockquote class =post_quotes>感谢您的回复。

有没有办法判断加速键是否被击中所以我知道我是否需要画一个下划线或者只是忽略"&安培;"在带有助记符的项目的文本中?


" Vijaye Raji" <无************* @ hotmail.com>在消息中写道
新闻:< um ************** @ tk2msftngp13.phx.gbl> ...

子类菜单项并制作它的主人画了。然后重写OnDrawItem
并自己绘制所有文本。这样,您就可以控制绘制文本的位置和绘制的内容。

-vJ

Lex <德** @ homerlex.mailshell.com>在消息中写道
新闻:c5 ************************* @ posting.google.co m ...

>我正在编写一个带有菜单的C#应用​​程序。一些菜单项将
>快捷方式枚举中不存在快捷方式。我想
>自定义快捷方式显示在菜单上但据我所知
>没有办法添加不在快捷方式枚举中的快捷方式。
>
>我有我的键盘挂钩,所以我不担心自定义
>快捷方式神奇地工作。我只是希望它看起来很合理
>在菜单上。
>
>有人有任何建议吗?
>
>问候



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

解决方案

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



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



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



这篇关于MenuItem需要自定义快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆