Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Varying Font Width Experiment

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Varying Font Width Experiment

    ' varying font width experiment.
    ' font width can only increase in integer steps - if you did not know.
    '
    ' best regards,
    '
    ' erik christensen ------ april 5 2004 ------ e.chr@email.dk
    '
    ' inspired by this link:
    ' http://www.powerbasic.com/support/pb...ad.php?t=10025
    Code:
    #compile exe
    #register none
    #dim all
    #include "win32api.inc"
    '
    callback function dialcallback
        local i!, hfont&, hdc&, ps as paintstruct, lpsz as asciiz * 300
        select case cbmsg
            case %wm_paint
                hdc = beginpaint(cbhndl, ps)
                for i = 2.499 to 14 step 0.5!
                    hfont = createfont(-20,i,0,0,400,0,0,0,0,3,2,1,82,"arial")
                    selectobject hdc, hfont
                    lpsz="this is arial font height -20, width" +using$("###.#",i)
                    textout hdc, 10,(i-3)*46, lpsz, byval len(lpsz)
                    deleteobject hfont
                next
                endpaint cbhndl, ps
                releasedc cbhndl, hdc
        end select
    end function
    '
    function pbmain
        local hform&,rc as rect
        systemparametersinfo %spi_getworkarea,byval 0, byval varptr(rc),byval 0
        dialog new 0, "changing font width experiment:   font width can only increase in integer steps!",,,0,0,%ds_modalframe or %ws_caption or %ws_sysmenu or %ds_center or %ws_clipchildren,0 to hform&
        movewindow hform&,rc.nleft,rc.ntop,rc.nright-rc.nleft,rc.nbottom-rc.ntop,%true
        dialog show modal hform&, call dialcallback
    end function
    ------------------




    [this message has been edited by erik christensen (edited april 06, 2004).]

  • #2
    ' This example changes font width and height simultaneously.
    '
    ' Best Regards,
    '
    ' Erik Christensen ------ April 6, 2004 ------ e.chr@email.dk
    Code:
    #COMPILE EXE
    #REGISTER NONE
    #DIM ALL
    #INCLUDE "win32api.inc"
    '
    CALLBACK FUNCTION DialCallBack
        LOCAL i&, j&, k&, hFont&, hDC&, Ps AS PAINTSTRUCT, lpsz AS ASCIIZ * 300
        SELECT CASE CBMSG
            CASE %WM_PAINT
                hDC = BeginPaint(CBHNDL, Ps)
                FOR i = 3 TO 22
                    j = -34 + i
                    hFont = CreateFont(j,i,0,0,400,0,0,0,0,3,2,1,82,"Arial")
                    SelectObject hDC, hFont
                    lpsz="This is Arial font height"+USING$("####",j)+", width" +USING$("###",i)
                    TextOut hDC, 10, k, lpsz, BYVAL LEN(lpsz)
                    k = k + ABS(j) + 5
                    DeleteObject hFont
                NEXT
                EndPaint CBHNDL, Ps
                ReleaseDC CBHNDL, hDC
        END SELECT
    END FUNCTION
    '
    FUNCTION PBMAIN
        LOCAL hForm&,rc AS RECT
        SystemParametersInfo %SPI_GETWORKAREA,BYVAL 0, BYVAL VARPTR(rc),BYVAL 0
        DIALOG NEW 0, "Increasing Font Width and Decreasing Font Height Simultaneously.",,,0,0,%DS_MODALFRAME OR %WS_CAPTION OR %WS_SYSMENU OR %DS_CENTER OR %WS_CLIPCHILDREN,0 TO hForm&
        MoveWindow hForm&,rc.nLeft,rc.nTop,rc.nRight-rc.nLeft,rc.nBottom-rc.nTop,%TRUE
        DIALOG SHOW MODAL hForm&, CALL DialCallBack
    END FUNCTION
    ------------------

    Comment

    Working...
    X