Results 1 to 6 of 6

Thread: Printing the Window [Resolved]

  1. #1

    Thread Starter
    Addicted Member jordan23's Avatar
    Join Date
    Dec 2002
    Posts
    166

    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.

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    See if this can help . It's in VB.NET but still readable .
    http://www.vbforums.com/showthread.p...ght=print+form

  3. #3

    Thread Starter
    Addicted Member jordan23's Avatar
    Join Date
    Dec 2002
    Posts
    166
    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.

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

  5. #5

    Thread Starter
    Addicted Member jordan23's Avatar
    Join Date
    Dec 2002
    Posts
    166
    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;
    		}

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by jordan23
    You know pretty soon you are going to be able to start chargin me by the hour.
    I wouldn't say no . You wanna my account number...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width