MCL Form Print Component-VBForums
Results 1 to 20 of 20

Thread: MCL Form Print Component

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    1,993

    MCL Form Print Component

    One of the most common questions is "how can I print / print preview my form"? This is quite easily done by getting the form to "draw itself" on the printed page but this is often unsatisfactory because:
    * The location of components on the form may not be where you want them on the printed page
    * Text is drawn at screen resolution
    * Every control is drawn (e.g. buttons, the form border etc.)

    The attached component addresses the problem in a different manner.
    What you do is drop a FormPrintHelperComponent component onto your form an it extends each control with a bunch of new properties (look in the properties window for each control in the section named "MCL Form Print Helper"). You then set these to indicate:
    * Whether the control should be printed
    * Whether to print it as Text, Image or Owner Drawn
    * The boundary rectangle to print it in
    * The vertical / horizontal alignment within that area
    * Font and background/foreground colour to use etc.

    You can then preview the result in design time (the component has a smart tag menu) and preview or print it at run time.

    Additionally if you set the print mode for a control to be "owner drawn" the control will raise an event when the form is being printed to allow you to print the form however you feel ...

    (This is an early release - I'm going to add the niceties of grid printing and multi-page printing etc. at a later release)
    Attached Images Attached Images  
    Last edited by Merrion; May 9th, 2007 at 07:30 AM.

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    1,993

    Re: MCL Form Print Component

    New release - now has a PageSetup and PrinterSettings method which brings up the respective dialog boxes to allow the user to view or change the page and printer settings at run time.
    Last edited by Merrion; Jun 13th, 2007 at 12:01 PM. Reason: removed old attachment...

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    1,993

    Re: MCL Form Print Component

    New release with multi page printing - basically you can decide at design time how many logical pages to turn your form into and then use the extended properties on each control to set which page(s) it prints on.

    Options are:
    • Print on every page
    • Print on odd pages
    • print on even pages
    • print on selected pages - which in turn has an array of boolean that you set to True for the page you want to print the control on.
    Last edited by Merrion; Apr 20th, 2008 at 05:10 AM.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    1,993

    Re: MCL Form Print Component

    Oops - found a bug:

    When you are printing an RTF box in RTF mode and you preview it more than once or preview then print it the RTF box doesn't print the second time. The fix is to change the RTFControlPrintSetting class thus:-
    Code:
    #Region "NewLogicalPage"
        Public Overrides Sub NewLogicalPage()
            If _RichTextBoxPrintMethod = RichTextBoxPrintMethods.PlainText Then
                With Me.RichTextBoxControl
                    _CurrentLine = 0
                    _Lines = .Lines
                    _TotalLines = _Lines.Length
                End With
            Else
                _CurrentChar = 0
                _TotalChars = Me.RichTextBoxControl.TextLength
            End If
        End Sub
    #End Region
    Last edited by Merrion; Nov 2nd, 2009 at 01:35 AM.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    1,993

  6. #6
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    515

    Re: MCL Form Print Component

    Outstanding Merrion. Now when are we going to be able to add custom header/footer to rtb contents ? Eagerly awaiting...

  7. #7
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    515

    Re: MCL Form Print Component

    Just a small not to say that Merrion's videos do not play on Firefox(yet). Use IE.

  8. #8
    Lively Member
    Join Date
    Jan 2009
    Posts
    77

    Re: MCL Form Print Component

    A link to it would be nice

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    1,993

    Re: MCL Form Print Component

    Current version is always on CodePlex...old version s have been removed as they just cause confusion.

  10. #10
    Lively Member
    Join Date
    Jan 2009
    Posts
    77

    Re: MCL Form Print Component

    Ok, thanks

  11. #11
    Lively Member
    Join Date
    Jan 2009
    Posts
    77

    Re: MCL Form Print Component

    Will i be able to use my own Print Preview form with this?

    Thanks

  12. #12

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    1,993

    Re: MCL Form Print Component

    Not out of the box, no.

    You can change/extend the component yourself to customise the print preview screen if you wish

  13. #13
    Lively Member
    Join Date
    Jan 2009
    Posts
    77

    Re: MCL Form Print Component

    Thanks , what language is the code, is it C++?

  14. #14

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    1,993

    Re: MCL Form Print Component

    It is coded in VB.Net
    (A C# version also exists on the same site)

  15. #15
    Lively Member
    Join Date
    Jan 2009
    Posts
    77

    Re: MCL Form Print Component

    Please will you send me an example of how to use this just to print a richtextbox and header and footer labels.

    Thanks

  16. #16

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    1,993

    Re: MCL Form Print Component

    There is this worked example of a rich text box

    Start with that then add a hidden label to yoru form for header and footer and add that to the set of controls being printed.

    Bish-bash-bosh - job done

  17. #17
    Lively Member
    Join Date
    Jan 2009
    Posts
    77

    Re: MCL Form Print Component

    I give up on this control

  18. #18

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    1,993

    Re: MCL Form Print Component

    Good to hear.

    Anyone with more ambition should look into the updated documentation on the CodePlex documentation page

  19. #19
    Lively Member
    Join Date
    Jan 2009
    Posts
    77

    Re: MCL Form Print Component

    Sorry...,

    Im checking that link out now

  20. #20

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    1,993

    Re: MCL Form Print Component

    I'm looking to extend/enhance this control to do grids - question though: in general do you have your on-screen grid laid out the way you'd expect the printed grid to come out or should I work on an totally separate layout/format system?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.