Skip to main content
guest
Join | Help | Sign In
Liberty BASIC Community Wiki Home
guest| Join | Help | Sign In
Liberty BASIC Community Wiki
  • Wiki Home
  • Recent Changes
  • Pages and Files
  • Members
  • Home
    • Liberty BASIC FAQ
    • Contests
    • Tutorials
    • Science
    • Shared Code
    • Tips
    • DLLs
    • PublicDomainSprites
    • Member Pages
    • Links
    • Sandbox

AccurateText

Edit 0 3 …
  • 0 Tags
    • No tags
  • Notify
  • RSS
  • Backlinks
  • Source
  • Print
  • Export (PDF)
Older Version Newer Version

lbjoseph lbjoseph Jul 10, 2011

=How To Accurately Position Text <span style="font-size: 13px; font-weight: normal; line-height: 19px;">[[user:lbjoseph]]</span>= 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. [[code format="lb"]] WindowWidth = 300 WindowHeight = 350 NoMainWin Open "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 As uLong, 0 As uLong, Result As uLong #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 End Function GetDC(hWnd) CallDLL #user32, "GetDC",hWnd As uLong,GetDC As uLong End Function Sub ReleaseDC hWnd, hDC CallDLL#user32,"ReleaseDC",hWnd As uLong,hDC As uLong,result As Long End Sub [[code]]
Help · About · Pricing · Privacy · Terms · Support · Upgrade
Contributions to https://basic.wikispaces.com/ are licensed under a Creative Commons Attribution Share-Alike 2.5 License. Creative Commons Attribution Share-Alike 2.5 License
Portions not contributed by visitors are Copyright 2018 Tangient LLC
TES: The largest network of teachers in the world
Turn off "Getting Started"
  1. Home
  2. ...
Loading...