如何避免在mfc中默认生成windows API的热键? [英] How to avoid default hot key generation of windows API in mfc?

查看:70
本文介绍了如何避免在mfc中默认生成windows API的热键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的VC ++项目中,我遇到了这样的问题。即,有一个编辑框,它接受来自用户的字符串输入。按下另一个按钮时,此字符串将设置在按钮上。使用

In my VC++ project i got an issue like this. ie, there is an edit box which accepts string input from user. while pressing another button, this string will be set on a Button. to set this text on this button iam using

SetWindowText()

API在此按钮上设置此文本。但问题是用户输入这样的输入

& abcd然后&不会在按钮上设置。它将a作为热键。即,

现在文本将显示在按钮上,如 a bcd。如何避免Windows API的默认热键转换?这可能吗?如果是,请给我回复。

API. But the issue was when user enter the input like this
"&abcd" then "&" will not be set on button. It will make "a" as hot key. ie,
now the text will be displayed on button like this "abcd". How can i avoid default hot key conversion of windows API? Is this possible? If yes give me a reply.

推荐答案

您有两个选项可以避免使用&符号生成热键:

1.全部删除字符串中的&符号:& button - >按钮

2.确保字符串中的单个&符实例加倍:& button - > && button

   第一个&符号逃脱第二个&符号,只显示一个&符号。



问候,



- Manfred
You have two options to avoid having the ampersand generate a hot key:
1. Remove all ampersands from the string: &button -> button
2. Make sure that single ampersand instances inside the string are doubled: &button -> &&button
   The first ampersand escapes the second one and only one ampersand is displayed.

Regards,

— Manfred


除了Manfred在解决方案1中提到的选项外,还有一个第三个:

使用所有者绘制按钮时(请参阅 CButton :: DrawItem() [ ^ ]), DrawText()格式标志 DT_NOPREFIX 将禁用前缀字符的处理并按原样显示文本。
Besides the options mentioned by Manfred in solution 1, there is a third one:
When using owner draw buttons (see the MSDN example at CButton::DrawItem()[^]), the DrawText() format flag DT_NOPREFIX will disable processing of prefix characters and show the text as it is.


这篇关于如何避免在mfc中默认生成windows API的热键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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