Posts: 11
Threads: 3
Joined: 05.09.2025
#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
Posts: 96
Threads: 11
Joined: 27.05.2024
03.09.2026, 04:07
(This post was last modified: 03.09.2026, 05:22 by Dale Yarker.)
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))
Posts: 41
Threads: 5
Joined: 27.05.2024
04.09.2026, 04:19
(This post was last modified: 04.09.2026, 04:20 by Jules Marchildon.)
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.
Posts: 96
Threads: 11
Joined: 27.05.2024
04.09.2026, 06:42
(This post was last modified: 04.09.2026, 06:48 by Dale Yarker.)
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)
Posts: 11
Threads: 3
Joined: 05.09.2025
07.09.2026, 20:54
(This post was last modified: 07.09.2026, 21:17 by Robert Alvarez.)
'same for GRAPHIC LINE and XPRINT LINE
#COMPILE EXE
GLOBAL hDlg AS LONG
FUNCTION PBMAIN() AS LONG
DIALOG NEW 0, "SET center Line Test",,,200,200, %WS_SYSMENU, 0 TO hDlg
LOCAL V1, V2 AS SINGLE
'V1=94 'TWO LINE
'V1=95 'THREE LINE
V1=95.2 'FOUR LINE
'remark out 2 or 3 line for v1 94 ,95
CONTROL ADD LABEL, hDlg, 203,"4444" , 55, 50,75,12, 'FOUR LINE
CONTROL ADD LABEL, hDlg, 203,"3333" , 55, 60,75,12, 'THREE LINE
CONTROL ADD LABEL, hDlg, 203,"2222" , 55, 70,75,12 , 'TWO LINE
CONTROL ADD LABEL, hDlg, 203,"1111" , 55, 80,75,12,
CONTROL ADD LINE, hDlg, 203,"" , 50, V1,27,1, '%SS_BLACKFRAME
CONTROL ADD LABEL, hDlg, 203,"3333" , 55, 100,75,12,
DIALOG SHOW MODAL hDlg
END FUNCTION
'could also use _ key and change the Y LOCATION
#COMPILE EXE
FUNCTION PBMAIN() AS LONG
LOCAL hDlg, hFontTerminal AS LONG 'OEM CharSet = %OEM_CHARSET = 255
DIALOG NEW 0, "SET center Line Test",,,200,200, %WS_SYSMENU, 0 TO hDlg
LOCAL V1 AS SINGLE
V1=70
CONTROL ADD LABEL, hDlg, 203,"ABC" , 55, 60,100,12
CONTROL ADD LABEL, hDlg, 204,"___" , 55, V1,100,12
CONTROL ADD LABEL, hDlg, 205,"GHJ" , 55, 90,100,12
DIALOG SHOW MODAL hDlg
END FUNCTION
Posts: 96
Threads: 11
Joined: 27.05.2024
08.09.2026, 06:44
(This post was last modified: 08.09.2026, 07:08 by Dale Yarker.)
Code: 'same for GRAPHIC LINE and XPRINT LINE
#compile exe
global hDlg as long
function pbmain() as long
dialog new 0, "SET center Line Test",,,200,200, %ws_sysmenu, 0 to hDlg
local V1, V2 as single
'V1=94 'TWO LINE
'V1=95 'THREE LINE
V1=95.2 'FOUR LINE
'Positons and sizes are integers (specifically LONGs).
'So 95 and 95.2 are both 95 due to truncation when
'setting a float to an integral.
'
'remark out 2 or 3 line for v1 94 ,95
'
'!!!!!!!!!!!!!!!!! you did not use style %SS_CENTER on the LABELs !!!!!!!!!!!!!
'%ss_center centers the text within the width of the label
control add label, hDlg, 203,"4444" , 55, 50,75,12,%ss_center 'FOUR LINE
control set color hDlg, 203, -1, %rgb_yellow 'just to show center of what
control add label, hDlg, 203,"3333" , 55, 60,75,12,%ss_center 'THREE LINE
control add label, hDlg, 203,"2222" , 55, 70,75,12, %ss_center , 'TWO LINE
control add label, hDlg, 203,"1111" , 55, 80,75,12, %ss_center
'
'position of LINE is position of LABEL plus half width of LABEL
'minus half width of LINE
control add line, hDlg, 206,"" , 55+(75/2)-(27/2), V1,27,1, %ss_blackframe
control add label, hDlg, 203,"3333" , 55, 100,75,12,%ss_center
dialog show modal hDlg
end function
Code: 'could also use _ key and change the Y LOCATION
#compile exe
function pbmain() as long
local hDlg, hFontTerminal as long 'OEM CharSet = %OEM_CHARSET = 255
dialog new 0, "SET center Line Test",,,200,200, %ws_sysmenu, 0 to hDlg
local V1 as single
V1=70
'
'!!!!!!!!!!!!!!! again no %SS_CENTER style !!!!!!!!!!
'To place exactly in center of DIALOG takes arithmetic on LABEL position
'similar as shown in previous post for LINE
control add label, hDlg, 203,"ABC" , 55, 60,100,12, %ss_center
control add label, hDlg, 204,"___" , 55, V1,100,12, %ss_center
control set color hDlg, 204, -1, %rgb_yellow
control add label, hDlg, 205,"GHJ" , 55, 90,100,12, %ss_center
dialog show modal hDlg
end function
If you, or anyone, will run your EXE on Windows 11 you should use DIALOG SHOW MODELESS as discussed a couple of posts back.
**********************************
Albert, I used two "New Reply"s, but forum merged them. I tried as two to separate the different problems. Not a useful feature IMO.
Cheers
|