這個問題在這里已經有了答案:
我想改為顯示'B&B'。
我知道Vcl.Menus.StripHotkey洗掉加速器字符標記的功能......
function StripHotkey(const Text: string): string;
var
I: Integer;
begin
Result := Text;
I := 1;
while I <= Length(Result) do
begin
{$IF NOT DEFINED(CLR)}
if IsLeadChar(Result[I]) then
Inc(I)
else
{$ENDIF}
if Result[I] = cHotkeyPrefix then
if SysLocale.FarEast and
((I > 1) and (Length(Result)-I >= 2) and
(Result[I-1] = '(') and (Result[I 2] = ')')) then
Delete(Result, I-1, 4)
else
Delete(Result, I, 1);
Inc(I);
end;
end;
...但我不知道任何用于轉義加速器字符的特定函式,以便將其顯示Caption為原始字串 ( 'B&B')。
uj5u.com熱心網友回復:
為了不在 TLabel 上顯示加速器字符,您只需將其ShowAccelChar屬性設定為False。
編輯:TStaticText組件也是如此。
uj5u.com熱心網友回復:
我發現的唯一方法是簡單地將'&'字符加倍,但沒有找到用于此目的的任何特定功能:
uses
System.SysUtils, Vcl.Menus;
...
var
NewCaption : string;
begin
NewCaption := 'B&B';
MyLabel.Caption := StringReplace(MyNewCaption, cHotkeyPrefix, cHotkeyPrefix cHotkeyPrefix, [rfReplaceAll]);
end;
我想知道是否有更好的解決方案
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/340213.html
標籤:德尔福
