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"
%IDC_Graphic = 500
Global hDlg,hFontA, hFontB As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "Vertically Align Text",300,300,200,150, %WS_OverlappedWindow To hDlg
Font New "Arial",10,1 To hFontA
Font New "Arial",24,1 To hFontB
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Select Case Cb.Msg
Case %WM_InitDialog
ShowDefaultText
End Select
End Function
Sub ShowDefaultText
Local w,h,Baseline As Long, temp$, TM As TextMetric, hDC As Dword
Baseline = 200 : temp$ = "gWord" 'align to bottom is goal
XPrint Attach Default
XPrint Get DC To hDC
XPrint Line (0,Baseline)-(1500,Baseline)
XPrint Set Font hFontA
GetTextMetrics hDC, TM
h = Baseline - TM.tmHeight + TM.tmDescent
XPrint Set Pos (120,h)
XPrint temp$
XPrint Set Font hFontB
GetTextMetrics hDC, TM
h = Baseline - TM.tmHeight + TM.tmDescent
XPrint Set Pos (500,h)
XPrint temp$
XPrint Close
End Sub
'gbs_01050
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm