This WithEvents code is troublesome

S

SamSpade

I have this class that seems to work OK. Note that I supply the actual PD in
the call.

Public Class ImagePrint

Private mPD As Drawing.Printing.PrintDocument

-snip

Public Sub PrintIt(ByVal PD As PrintDocument, ByVal PicImage As Image, ByVal
DocName As String, ByVal Fit As PrintFit, ByVal Center As CenterImage, ByVal
DoPreview As Boolean)

mPD = PD

mImage = PicImage

mFitPage = Fit

mCenterImage = Center

AddHandler PD.PrintPage, AddressOf mPD_PrintPage

PD.DocumentName = DocName

-snip



Created a new class and copied some code from the other class but had to add
the WithEvents because the compler said so. Seems to work OK. It troubles
me that I may be doing something wrong (but in which one). Do you know what
and where??

Public Class RtfPrint

Private WithEvents mPD As Drawing.Printing.PrintDocument

Private RtfBox As RichTextBox

-snip

Public Sub PrintIt(ByVal PD As PrintDocument, ByVal RtfTextBox As
RichTextBox, ByVal DocName As String, ByVal Fit As PrintFit, ByVal Center As
CenterImage, ByVal DoPreview As Boolean)

mPD = PD

RtfBox = RtfTextBox

mFitPage = Fit

mCenterImage = Center

AddHandler PD.BeginPrint, AddressOf mpd_BeginPrint

AddHandler PD.PrintPage, AddressOf mpd_PrintPage

AddHandler PD.EndPrint, AddressOf mpd_EndPrint

PD.DocumentName = DocName

-snip
 
S

SamSpade

I found it.
The compiler was complaining about a Handles I had, not the AddHandler
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top