Using Symbol Fonts on Controls and Graphics


Liberty BASIC won't access symbol fonts like Wingdings with a FONT command. Instead, create the font by API. It is very easy.

Button Demo

Graphicbox Demo

Home

Source Code

Utilities

Internet

Games

Graphics

Media Demos

Snippets

DLL's

API Resources

Freeware

LB 4 Companion

Mastering LB 3

LB Workshop

Game Workshop

Links

Index

BUTTON


'Use a symbol font on a button.
nomainwin

    fontname$ = "Wingdings" + chr$(0)
    height = 48
    Calldll #gdi32, "CreateFontA", height as long,_
        0 as long,  0 as long, 0 as long,_
        0 as long, 0 as long, 0 as long, _
        0 as long,  _SYMBOL_CHARSET as long,_
        0 as long,0 as long, 0 as long, 0 as long, _
        fontname$ as PTR, hFont as long

button #1.b, "C",[quit],UL,10,10,80,80
open "test" for window as #1
    print #1, "trapclose [quit]"

    hButton=hwnd(#1.b)

    calldll #user32,  "SendMessageA", _
        hButton as long, _
        _WM_SETFONT as long,_
        hFont as long, _
        1 as long,_
        result as long

wait
[quit]
    calldll #gdi32, "DeleteObject", hFont as long, r as long
    close #1:END


Graphics

'wingding font in graphicbox
nomainwin

    fontname$ = "Wingdings" + chr$(0)
    height = 48
    Calldll #gdi32, "CreateFontA", height as long,_
        0 as long,  0 as long, 0 as long,_
        0 as long, 0 as long, 0 as long, _
        0 as long,  _SYMBOL_CHARSET as long,_
        0 as long,0 as long, 0 as long, 0 as long, _
        fontname$ as PTR, hFont as long

graphicbox #1.g, 10,10,80,80
open "test" for window as #1
    print #1, "trapclose [quit]"

    hBox=hwnd(#1.g)

calldll #user32, "GetDC",_
    hBox as long, hDC as long

calldll #gdi32,  "SelectObject", _
    hDC as long, _
    hFont as long,_
    oldFont as long

#1.g "down;place 20 60"
#1.g "\C"

wait

[quit]
    calldll #user32, "ReleaseDC",hBox as long,hDC as long, r as long
    calldll #gdi32, "DeleteObject", hFont as long, r as long
close #1:END