R
Rosco5737
Guest
Hi all, I am having a little trouble with the print preview dialogue and the print screen command (PRTSC) and looking for a little insight.
I have a Chart from MSChart controls displayed on my application. I want to display this chart in a print preview dialogue so it can be printed. Since I have no idea how to print the chart itself, I am trying to just call print screen and then print the bitmap. Here is my relevant code:
Private Sub MenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem4.Click
'print preview
Dim ppd As New PrintPreviewDialog()
ppd.Document = throughprint
ppd.ShowDialog()
end sub
Private Sub throughprint_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles throughprint.PrintPage
'throughprint printpage
Dim s As SendKeys
Dim timage As Image
s.Send("{PRTSC}")
Dim picdata As IDataObject = Clipboard.GetDataObject()
pimage = picdata.GetData(DataFormats.Bitmap)
e.Graphics.DrawImage(timage, 120, 90)
end sub
The problem is the print preview displays different images every time I call it. For example, it usually with display just the "generating previews" screen that pops up when print preview is selected. Sometimes it shows part of my chart, other times the whole thing. It sometimes layers images on top of each other if print preview is opened a few times. It seems to me to be a timing issue with what and when PRTSC actually gets called. I've tried useing SENDWAIT with the same results. Has anyone had this problem or know the solution; or should be trying something completely different? This post might be related to the post shootsnlad however I can get whatever is displayed on my preview screen to print fine so I'm not sure. Anyway, thanks much...
I have a Chart from MSChart controls displayed on my application. I want to display this chart in a print preview dialogue so it can be printed. Since I have no idea how to print the chart itself, I am trying to just call print screen and then print the bitmap. Here is my relevant code:
Private Sub MenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem4.Click
'print preview
Dim ppd As New PrintPreviewDialog()
ppd.Document = throughprint
ppd.ShowDialog()
end sub
Private Sub throughprint_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles throughprint.PrintPage
'throughprint printpage
Dim s As SendKeys
Dim timage As Image
s.Send("{PRTSC}")
Dim picdata As IDataObject = Clipboard.GetDataObject()
pimage = picdata.GetData(DataFormats.Bitmap)
e.Graphics.DrawImage(timage, 120, 90)
end sub
The problem is the print preview displays different images every time I call it. For example, it usually with display just the "generating previews" screen that pops up when print preview is selected. Sometimes it shows part of my chart, other times the whole thing. It sometimes layers images on top of each other if print preview is opened a few times. It seems to me to be a timing issue with what and when PRTSC actually gets called. I've tried useing SENDWAIT with the same results. Has anyone had this problem or know the solution; or should be trying something completely different? This post might be related to the post shootsnlad however I can get whatever is displayed on my preview screen to print fine so I'm not sure. Anyway, thanks much...