How to: Print an Mdifrom?

Hi,

I am using PrintForm Component to print an MdiForm and when I am using the CompatibleModeFullWindow so I will also get the MdiForm header the result are not what I am expecting. The print result shows a part of the MdiForm Parent on top of the MdiForm Child and the bottom part of the MdiChild is choped off. It looks like the focus of the MdiChild is offseted by the MdiParent menubar.

Thanks,

Yogev.




Answer this question

How to: Print an Mdifrom?

  • CarlosAlfaro

    Hi Yogev,

    I believe you have found a bug, the PrintForm component is not accurately finding the bounds of the full window when it is an MDIChild Window.

    You will need to use PowerPacks.Printing.PrintForm.PrintOption.CompatibleModeClientAreaOnly to print the window.

    However if you want to have the window title information printed also a simple work around would be to show a label at the top as a header or at the bottom of the client area as a footer right before the window is printed and hide it immediately after.

    'set up the title label

    lblTitle.AutoSize = False

    lblTitle.Text = "Some Important Information"

    lblTitle.Width = Me.Width

    lblTitle.TextAlign = ContentAlignment.MiddleCenter

    lblTitle.BorderStyle = BorderStyle.FixedSingle

    lblTitle.Dock = DockStyle.Top

    lblTitle.Visible = True

    'refresh the label to ensure it displays correctly

    lblTitle.Refresh()

    'print the form

    Me.PrintForm1.Print(Form1, PowerPacks.Printing.PrintForm.PrintOption.CompatibleModeClientAreaOnly)

    'hide the title label

    lblTitle.Visible = False

    I'm sorry you have run into the problem, thanks very much for letting us know about it. I hope the work around helps

    Do you have a great idea for a new Power Pack Let us know what you want to see us develop to help make Visual Basic 2005 event better by going to http://connect.Microsoft.com/vbasic

    Thanks



  • Sorin Sandu

    I failed to mention this yesterday but as long as you don't have custom graphics that your drawing on the form you can use simply use

    PowerPacks.Printing.PrintForm.PrintOption.FullWindow to print the entire window MDI child.

    For example:

    PrintForm1.Print(Me, PowerPacks.Printing.PrintForm.PrintOption.FullWindow)



  • Jahangeer

    Thank you Jhon I'll make sure to check your sulotion.

    Yogev.



  • How to: Print an Mdifrom?