|
-
Jul 12th, 2004, 03:04 PM
#1
Thread Starter
Addicted Member
Printing the Window [Resolved]
Ok, I need to know how to print the Window(Form). I have code from Pirate that gives me the Alt + PrintScreen Capture but how do I print that out to the printer?
Code:
private Image GetScreenCapture(bool FullScreen)
{
if (FullScreen)SendKeys.SendWait("{PRTSC 2}");
else SendKeys.SendWait("%{PRTSC}");
IDataObject objData=Clipboard.GetDataObject();
return (Image)objData.GetData(DataFormats.Bitmap);
}
private void button1_Click(object sender, System.EventArgs e)
{
//Take shot !
GetScreenCapture(false);
}
Last edited by jordan23; Jul 13th, 2004 at 07:10 AM.
-
Jul 12th, 2004, 06:41 PM
#2
Sleep mode
See if this can help . It's in VB.NET but still readable .
http://www.vbforums.com/showthread.p...ght=print+form
-
Jul 13th, 2004, 06:40 AM
#3
Thread Starter
Addicted Member
Well, from reading that post it doesn't work on certain controls which so happen to be on my windows. Thanks for the effort though. Isn't there a way to print a .jpg, .bmp, etc...? There has got to be a to print a graphic from .Net without third party controls. I am still searching. Any help would be appreciated.
-
Jul 13th, 2004, 07:01 AM
#4
Sleep mode
-
Jul 13th, 2004, 07:09 AM
#5
Thread Starter
Addicted Member
I did search our forums because VBForums is the best!!! Shameless plug. I figured it out though. Thanks for your help again Pirate. You know pretty soon you are going to be able to start chargin me by the hour.
Code:
private void mnuPrint_Click(object sender, System.EventArgs e)
{
try
{
// Assumes the default printer.
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);
pd.Print();
}
catch(Exception ex)
{
MessageBox.Show("An error occurred while printing", ex.ToString());
}
private void pd_PrintPage(object sender, PrintPageEventArgs ev)
{
// Draw a picture.
ev.Graphics.DrawImageUnscaled(Image.FromFile("C:\\vbforums.jpg"), ev.Graphics.RenderingOrigin);
// Indicate that this is the last page to print.
ev.HasMorePages = false;
}
-
Jul 13th, 2004, 07:17 AM
#6
Sleep mode
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|