center line not working with add label
#1
#COMPILE EXE


FUNCTION PBMAIN() AS LONG
LOCAL hDlg AS LONG
DIALOG NEW 0, "SET center Line Test",,,480,300, %WS_SYSMENU, 0 TO hDlg

LOCAL AA AS STRING

AA= STRING$(10, 151)

            ? AA    'PRINT LINES BELOW DOES NOT

CONTROL ADD LABEL, hDlg, 203,AA , 55, 70,75,450,

CONTROL ADD LABEL, hDlg, 203,STRING$(10, 151) , 55, 80,75,450,

DIALOG SHOW MODAL hDlg
END FUNCTION
Reply
#2
I think I put enough comments in the code
Code:
#compile exe
#dim all

function pbmain() as long
  local hDlg, DialogCount as long
  dialog new 0, "SET center Line Test",,,480,300, %ws_sysmenu, 0 to hDlg

  local AA as wstring '<<--- made it wide

  ''AA= STRING$(10, 151) '<<--- 151 in UTF16 is "End of Protected Area"

  AA = string$(10, chr$$(&h2015))

  ? AA    'PRINT LINES BELOW DOES NOT '"?" in PBWin is MSGBOX
                                      '"?" for PRINT is PBCC
                                      '???? why old had line in MSGBOX ????
                                      ' maybe OEM charset

  control add label, hDlg, 203, AA , 55, 70,75,450,

  control add label, hDlg, 203, string$(10, chr$$(&h2015)) , 55, 80,75,450,

  dialog show modeless hDlg '<<--- for a top dialog to close by right click
  do                              'on task bar icon in Windows 11
    dialog doevents to DialogCount
  loop while DialogCount
end function
Try this
Code:
#compile exe
#dim all

function pbmain() as long
  local hDlg, DialogCount as long
  dialog new 0, "SET center Line Test",,,480,300, %ws_sysmenu, 0 to hDlg

  local AA as wstring

  AA = string$(10, chr$$(&h2015))

  control add label, hDlg, 203, AA , 0, 0,480,300, %ss_center or _
     %ss_centerimage or %ss_left, %ws_ex_left

  dialog show modeless hDlg
  do                             
    dialog doevents to DialogCount
  loop while DialogCount
end function 
Use the 'center' styles as needed.

I used LABEL same size as DIALOG to stay close to post 1 code.

CONTROL ADD LINE is "neater". IMO

Cheers,

((correction - character 151 (decimal) is EM_DASH in ANSI))
Reply
#3
If the goal is to draw a horizontal center line, using repeated em dashes is really relying on a text character as a graphics primitive. That's inherently font-dependent. DDT controls use a default windows font unless you explicitly specify one. If that particular font, font substitution or the way the ANSI character is converted doesn't handle character 151 as expected, you could get an incorrect character or potentially something that looks like a different line... Like Dale said, it's better to draw your own line.
Reply
#4
Thankyou Jules, 

Your post maked me realize that I didn't stress using AS WSTRING, and AS WSTRINGZ strongly enough, even for plain text.

 (CONTROL ADD LINE is probably better in most cases and can also do vertical lines)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)