[英]How to display an ampersand in a Windows system tray prompt?
I'm programming using C++ and WinAPIs. 我正在使用C ++和WinAPI进行编程。 I've added a system tray icon using Shell_NotifyIcon(NIM_ADD, ...) API. 我使用Shell_NotifyIcon(NIM_ADD,...)API添加了系统任务栏图标。 That icon also has an associated user prompt that contains an ampersand symbol in it, something like this, "View & Copy." 该图标还具有一个关联的用户提示,其中包含一个&符号,类似于“查看并复制”。 But what a user sees though when the prompt pops up, is "View Copy". 但是,当弹出提示时,用户看到的是“查看副本”。 I tried doubling the ampersand, like so "View && Copy" but that didn't help. 我尝试将与号加倍,例如“查看并复制”,但这没有帮助。
Does anyone have any idea how to display an ampersand in a Windows tray prompt? 有谁知道如何在Windows托盘提示中显示&符号?
It's not a matter of escaping the ampersand - Windows by design will strip any ampersands from tooltip text , for a generally good reason: 这不是逃脱&号的问题-Windows 设计使之会从工具提示文本中删除所有&号 ,这通常是有充分理由的:
Many applications create toolbars containing tools that correspond to menu commands. 许多应用程序会创建工具栏,其中包含与菜单命令相对应的工具。 For such tools, it is convenient for the tooltip control to display the same text as the corresponding menu item. 对于此类工具,工具提示控件将显示与相应菜单项相同的文本,这很方便。 The system automatically strips the ampersand (&) accelerator characters from all strings passed to a tooltip control, and terminates the string at the first tab character (\\t), unless the control has the TTS_NOPREFIX style. 系统会自动从传递给工具提示控件的所有字符串中删除与符号(&)加速器字符,并在第一个制表符(\\ t)处终止该字符串,除非该控件具有TTS_NOPREFIX样式。
As you can see, the answer is very easy: you just need to add TTS_NOPREFIX
to the tooltip class and you'll be set. 如您所见,答案非常简单:您只需将TTS_NOPREFIX
添加到工具提示类中即可进行设置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.