You might have noticed that Liberty BASIC doesn't do a very a good job positioning text where you specify in a graphics box. The following sample demonstrates a few simple API calls necessary to fix this behavior.
WindowWidth=300WindowHeight=350NoMainWinOpen"Font Problems"For Graphics_NF_NSB As#g
#g "Down; Fill Blue; Flush"#g "Color Black; Backcolor White"#g "font arial 100"
dc = GetDC(hwnd(#g))CallDLL#gdi32,"SetTextAlign", dc AsuLong,0AsuLong, Result AsuLong#g "Place 100 100"#g "|X"#g "posxy x y"
temp$ ="X"#g "stringwidth? temp$ width"
fontRoughHeight = y-100#g "color red; size 10; set ";x;" ";y-fontRoughHeight
#g "color green; size 10; set ";x;" ";y
#g "color yellow; size 10; set ";x+width;" ";y
#g "trapclose [quit]"Call ReleaseDC hwnd(#g), dc
Wait[quit]close#g
EndFunction GetDC(hWnd)CallDLL#user32,"GetDC",hWnd AsuLong,GetDC AsuLongEndFunctionSub ReleaseDC hWnd, hDC
CallDLL#user32,"ReleaseDC",hWnd AsuLong,hDC AsuLong,result AsLongEndSub
How To Accurately Position Text -
lbjoseph
You might have noticed that Liberty BASIC doesn't do a very a good job positioning text where you specify in a graphics box. The following sample demonstrates a few simple API calls necessary to fix this behavior.