Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,200,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, 100,"Push", 50,10,100,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
If Cb.Msg = %WM_Command And Cb.Ctl = 100 And Cb.CtlMsg = %BN_Clicked Then
Local i,j,k As Single, iDotCol,iCharWidth,iCharHeight As Long, hFont As Dword
i = 12.34
j = 7.2
k = 123.772
iDotCol = 20
Font New "Courier New", 12 To hFont
XPrint Attach Default
XPrint Set Font hFont
XPrint Text Size "a" To iCharWidth, iCharHeight 'get width of a char
XXPrint i, iDotCol, iCharWidth 'value, decimal column, width of a char
XXPrint j, iDotCol, iCharWidth
XXPrint k, iDotCol, iCharWidth
XPrint Close
End If
End Function
Sub XXPrint(value As Single, iDotCol As Long, iCharWidth As Long)
Local temp As String, x,y As Single, dPos As Long
temp = Str$(value) 'Format$(value,"#.")
dPos = InStr(temp$,".")
XPrint Get Pos To x,y
x = (iDotCol - (Len(temp$) - dPos -1)) * iCharWidth
XPrint Set Pos (x,y)
XPrint temp
End Sub
'gbs_01046
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm