01.10.2025, 02:29 PM
To always show & in static (label) control, add %SS_NOPREFIX style to it.
MS explains: "Prevents interpretation of any ampersand (&) characters in the control's text as accelerator prefix characters. These are displayed with the ampersand removed and the next character in the string underlined. This static control style may be included with any of the defined static controls.
An application can combine SS_NOPREFIX with other styles by using the bitwise OR (|) operator. This can be useful when filenames or other strings that may contain an ampersand (&) must be displayed in a static control in a dialog box."
MS explains: "Prevents interpretation of any ampersand (&) characters in the control's text as accelerator prefix characters. These are displayed with the ampersand removed and the next character in the string underlined. This static control style may be included with any of the defined static controls.
An application can combine SS_NOPREFIX with other styles by using the bitwise OR (|) operator. This can be useful when filenames or other strings that may contain an ampersand (&) must be displayed in a static control in a dialog box."
Code:
'======================================================================
#COMPILE EXE
#DIM ALL
'--------------------------------------------------------------------
%UNICODE = 1
#INCLUDE "WIN32API.INC"
'--------------------------------------------------------------------
%IDC_LABEL1 = 501
%IDC_TEXTFIELD1 = 541
'======================================================================
FUNCTION PBMAIN () AS LONG
LOCAL hDlg AS DWORD
DIALOG NEW 0, "Dialog1",,, 111, 39, %WS_CAPTION OR %WS_SYSMENU OR _
%WS_MINIMIZEBOX, 0 TO hDlg
'------------------------------------------------------------------
CONTROL ADD TEXTBOX, hDlg, %IDC_TEXTFIELD1, "TextBox - X&Y", 5, 5, 100, 13
CONTROL ADD LABEL, hDlg, %IDC_LABEL1, "Label - X&Y", 5, 20, 100, 13, %SS_NOPREFIX
'-------------------------------------------------------------------
DIALOG SHOW MODELESS hDlg, CALL DlgProc
DO
DIALOG DOEVENTS
LOOP WHILE ISWIN(hDlg)
END FUNCTION
'======================================================================
CALLBACK FUNCTION DlgProc() AS LONG
SELECT CASE CB.MSG
CASE %WM_INITDIALOG
CASE %WM_COMMAND
SELECT CASE CB.CTL
CASE %IDCANCEL
IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
DIALOG END CB.HNDL, 0
END IF
END SELECT
END SELECT
END FUNCTION