Print Preview ActiveX Active Users: 17 / Visits Today: 17
Highest Active Users: 17
Print Preview ActiveX
Home | Profile | Register | Active Topics | Members | Search | FAQ | RSS
 All Forums
 Print Preview
 Tips & Tricks
 VB Routine: paraTextFit

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert Email Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

   Insert a File

Check here to subscribe to this topic.
   

T O P I C    R E V I E W
wbgookin Posted - 11/20/2004 : 02:33:52
Here's a routine I use to fit a paraText to a specified area. It uses the paraTextHeight routine I posted to calculate the height, and then shrinks the font if the text is too big. It only reduces, but changing it to enlarge wouldn't be too hard. Anyway, it works for me, but your mileage may vary!


Public Sub paraTextFit(prn As PrintPreview5.Preview, paraString As String, xPos As Variant, yPos As Variant, paraWidth As Variant, paraHeight As Variant)
    'Variables:
    'prn is the previously defined preview control
    'paraString is the string you want to send to paraText
    'xPos is the x position that you want to send to paraText
    'yPos is the y position that you want to send to paraText
    'paraWidth is the width you want to send to paraText
    'paraHeight is the height you want to send to paraText
    
    'startSize is the initial font size
    'stepSize is the amount to shift the font
    Dim startSize As Integer
    Dim stepSize As Integer

    'Set the initial values
    startSize = prn.FontSize
    stepSize = 0

    'Loop through, comparing the height of the paraText to the desired height.
    'If it is too high, reduce the font size and try again.
    'Limit to a font size of 1, or it will get messed up.
    Do While (paraTextHeight(prn, paraString, paraWidth) > prn.C_Twips(paraHeight)) And stepSize < startSize - 1
        stepSize = stepSize + 1
        prn.FontSize = startSize - stepSize
    Loop

    'Now, the font is okay (or as close to it as possible, with a size=1).
    'Print the paratext at the currentX and currentY values
    prn.ParaText paraString, xPos, yPos, paraWidth

    'Set the font size back to the beginning size
    prn.FontSize = startSize
End Sub

Print Preview ActiveX © Mandix Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000 Version 3.4.02