By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,965 Members | 1,457 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,965 IT Pros & Developers. It's quick & easy.

Printer object replacement syntax

P: n/a
We currently are trying our first transformation from VB6 to VB.Net. Of
course, the Printer object is gone, but I'm having trouble finding the
replacement syntax necessary to perform similar actions or set variables.
We are interested in doing this inline (no pop-up dialog box).
Specifically, where how would I replace the following properties/methods of
the old Printer objects.

Printer.NewPage
Printer.TextHeight
Printer.TextWidth
Printer.PaintPicture
Printer.Print
Printer.Line
Printer.EndDoc

Thanks, Tom.

Jul 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"Tom Berry" <tb***@planeteshop.com> schrieb
We currently are trying our first transformation from VB6 to VB.Net.
Of course, the Printer object is gone, but I'm having trouble finding
the replacement syntax necessary to perform similar actions or set
variables. We are interested in doing this inline (no pop-up dialog
box). Specifically, where how would I replace the following
properties/methods of the old Printer objects.

Printer.NewPage
Printer.TextHeight
Printer.TextWidth
Printer.PaintPicture
Printer.Print
Printer.Line
Printer.EndDoc


Maybe this helps:
http://msdn.microsoft.com/library/en...albasicnet.asp
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Jul 21 '05 #2

P: n/a
Thanks for the link. I looked up TextHeight and TextWidth in that
conversion table, and it said "Font parameter of Graphics.Drawstring". When
I type the statement System.Drawing.Graphics. it does not even give
DrawString as a potential selection from the dropdown list of methods and
properties. There are 4 choices, but DrawString isn't one of them. TIA for
any help in this matter.

"Armin Zingler" <az*******@freenet.de> wrote in message
news:uT**************@TK2MSFTNGP12.phx.gbl...
"Tom Berry" <tb***@planeteshop.com> schrieb
We currently are trying our first transformation from VB6 to VB.Net.
Of course, the Printer object is gone, but I'm having trouble finding
the replacement syntax necessary to perform similar actions or set
variables. We are interested in doing this inline (no pop-up dialog
box). Specifically, where how would I replace the following
properties/methods of the old Printer objects.

Printer.NewPage
Printer.TextHeight
Printer.TextWidth
Printer.PaintPicture
Printer.Print
Printer.Line
Printer.EndDoc
Maybe this helps:

http://msdn.microsoft.com/library/en...albasicnet.asp

--
Armin

Jul 21 '05 #3

P: n/a
"Tom Berry" <tb***@planeteshop.com> schrieb
Thanks for the link. I looked up TextHeight and TextWidth in that
conversion table, and it said "Font parameter of
Graphics.Drawstring". When I type the statement
System.Drawing.Graphics. it does not even give DrawString as a
potential selection from the dropdown list of methods and properties.
There are 4 choices, but DrawString isn't one of them. TIA for any
help in this matter.


DrawString is not a shared member, it is an instance member. Means: You need
a graphics object to execute the method. You get the object in the PrintPage
event as a property of the passed argument (e.graphics.drawstring). At the
bottom of the page linked in my previous post is a "Windows Forms
Print support" link leading you to
http://msdn.microsoft.com/library/en...intsupport.asp
There is more information on the PrintDocument object and it's PrintPage
event.

--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Jul 21 '05 #4

P: n/a
Tom,
Printing doesn't really work that way anymore. It works more like the
hDc drawing methods used by C++ before. Having said that you should look at
the example printing items using PrintDocument in the help files. Basically
all page drawing is done inside a PrintPage event of the document. Setting
the HasMorePages property of the PrintPageEventArgs variable to true and
returning will do a new page and then re-enter the event to draw the
following page(s). Setting HasMorePage to false and returning is the
equivalent of Printer.EndDoc. Note that you need to keep track of your
print items outside of the PrintPage event as it gets re-run from the top on
every page.
Text Height/Width are (roughly) equivalent to MeasureString on the
Graphics of the supplied argument (say e for further discussion). So
e.Graphics.MeasureString("The String", theFont, ...) will return a size with
a height/width (see the various overloads for more detail).
e.Graphics.DrawImage is somewhat like PaintPicture, e.Graphics.DrawString is
like Print and e.Graphics.DrawLine is like Line. You will have to supply
Pens, Fonts, and Brushes to these calls.
Normally I initialize all Fonts, and all non-standard Brushes and Pens
as well as the document datastream in the OnBeginPrint of the derived
PrintDocument class and dispose them properly in OnEndPrint. If you want to
handle landscape/portrait switching set the appropriate flag in the
QueryPageSettingsEventArgs (e.PageSettings.Landscape) for the
OnQueryPageSettings event which is performed for each page.

Ron Allen
"Tom Berry" <tb***@planeteshop.com> wrote in message
news:u8**************@TK2MSFTNGP11.phx.gbl...
We currently are trying our first transformation from VB6 to VB.Net. Of
course, the Printer object is gone, but I'm having trouble finding the
replacement syntax necessary to perform similar actions or set variables.
We are interested in doing this inline (no pop-up dialog box).
Specifically, where how would I replace the following properties/methods of the old Printer objects.

Printer.NewPage
Printer.TextHeight
Printer.TextWidth
Printer.PaintPicture
Printer.Print
Printer.Line
Printer.EndDoc

Thanks, Tom.

Jul 21 '05 #5

P: n/a
Thanks for your detailed post and to the other responders with the links to
examples. One of my initial problems is I didn't include an Import to
signify I was interested in the Graphics area of System. Without that
definition, I didn't get the listing of Drawstring as a potential method. I
have no C++ background and haven't used classes that much. Perhaps this new
language should have been called C++.Net. With their reliance on classes,
objects, things like += (which I did use and like from C BTW), this IMO is a
lot closer to C++ than it is to Visual Basic. I think the C++ people are
Microsoft must have made most of the decisions on this language while the VB
people were literally out having lunch or something. I'm just surprised I
don't see semicolons at the end of each line. :-)

"Ron Allen" <rallen@_nospam_src-us.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Tom,
Printing doesn't really work that way anymore. It works more like the
hDc drawing methods used by C++ before. Having said that you should look at the example printing items using PrintDocument in the help files. Basically all page drawing is done inside a PrintPage event of the document. Setting the HasMorePages property of the PrintPageEventArgs variable to true and
returning will do a new page and then re-enter the event to draw the
following page(s). Setting HasMorePage to false and returning is the
equivalent of Printer.EndDoc. Note that you need to keep track of your
print items outside of the PrintPage event as it gets re-run from the top on every page.
Text Height/Width are (roughly) equivalent to MeasureString on the
Graphics of the supplied argument (say e for further discussion). So
e.Graphics.MeasureString("The String", theFont, ...) will return a size with a height/width (see the various overloads for more detail).
e.Graphics.DrawImage is somewhat like PaintPicture, e.Graphics.DrawString is like Print and e.Graphics.DrawLine is like Line. You will have to supply
Pens, Fonts, and Brushes to these calls.
Normally I initialize all Fonts, and all non-standard Brushes and Pens
as well as the document datastream in the OnBeginPrint of the derived
PrintDocument class and dispose them properly in OnEndPrint. If you want to handle landscape/portrait switching set the appropriate flag in the
QueryPageSettingsEventArgs (e.PageSettings.Landscape) for the
OnQueryPageSettings event which is performed for each page.

Ron Allen
"Tom Berry" <tb***@planeteshop.com> wrote in message
news:u8**************@TK2MSFTNGP11.phx.gbl...
We currently are trying our first transformation from VB6 to VB.Net. Of
course, the Printer object is gone, but I'm having trouble finding the
replacement syntax necessary to perform similar actions or set variables. We are interested in doing this inline (no pop-up dialog box).
Specifically, where how would I replace the following properties/methods

of
the old Printer objects.

Printer.NewPage
Printer.TextHeight
Printer.TextWidth
Printer.PaintPicture
Printer.Print
Printer.Line
Printer.EndDoc

Thanks, Tom.


Jul 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.