& Character problem
#6
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."

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
Reply


Messages In This Thread
& Character problem - by Robert Alvarez - 30.09.2025, 08:08 PM
RE: & Character problem - by Dale Yarker - 30.09.2025, 09:00 PM
RE: & Character problem - by Robert Alvarez - 01.10.2025, 12:38 AM
RE: & Character problem - by Stuart McLachlan - 01.10.2025, 03:36 AM
RE: & Character problem - by Dale Yarker - 01.10.2025, 02:55 AM
RE: & Character problem - by Borje Hagsten - 01.10.2025, 02:29 PM
RE: & Character problem - by Stuart McLachlan - 01.10.2025, 05:09 PM
RE: & Character problem - by Dale Yarker - 01.10.2025, 03:24 PM
RE: & Character problem - by Robert Alvarez - 01.10.2025, 06:07 PM
RE: & Character problem - by Borje Hagsten - 01.10.2025, 07:21 PM
RE: & Character problem - by Robert Alvarez - 02.10.2025, 12:54 AM
RE: & Character problem - by Stuart McLachlan - 02.10.2025, 02:23 AM
RE: & Character problem - by Borje Hagsten - 02.10.2025, 02:28 AM
RE: & Character problem - by Robert Alvarez - 02.10.2025, 04:59 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)