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
%IDC_Button = 501
Global hDlg, hDC, hFontA, hFontB As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "Vertically Align Text",300,300,200,150, %WS_OverlappedWindow To hDlg
Control Add Graphic, hDlg, %IDC_Graphic, "", 0,0,200,150, %WS_Border
Graphic Attach hDlg, %IDC_Graphic
Graphic Get DC To hDC
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
Baseline = 80 : temp$ = "gWord" 'align to bottom is goal
Graphic Line (0,Baseline)-(200,Baseline)
Graphic Set Font hFontA
Graphic Text Size temp$ To w,h
GetTextMetrics hDC, TM
h = Baseline - h + TM.tmDescent
Graphic Set Pos (20,h)
Graphic Print temp$
Graphic Set Font hFontB
Graphic Text Size temp$ To w,h
GetTextMetrics hDC, TM
h = Baseline - h + TM.tmDescent
Graphic Set Pos (80,h)
Graphic Print temp$
End Sub
'gbs_01005
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm