Printing nightmare...I'm losing my mind!!! 
Author Message
 Printing nightmare...I'm losing my mind!!!

Is there anyone who can explain how to simply send a form's image to
the printer in VB.NET, much like PrintForm did in VB6?  Surely there
must be a way to do this using the .NET framework, as opposed to using
API calls, which may not be available on the client machine, depending
on the OS.

Andrew



Sun, 24 Jul 2005 05:17:36 GMT  
 Printing nightmare...I'm losing my mind!!!
Here's a hint, just adjust it to your needs...

Private Declare Function BitBlt Lib "gdi32.dll" (ByVal hdcDest As IntPtr,
ByVal x As Int32, ByVal y As Int32, ByVal Width As Int32, ByVal Height As
Int32, ByVal hdcSrc As IntPtr, ByVal XSrc As Int32, ByVal YSrc As Int32,
ByVal dwRop As Int32) As Boolean
Private Declare Function GetWindowDC Lib "user32" (ByVal hWnd As IntPtr) As
IntPtr
Private Declare Function ReleaseDC Lib "user32" (ByVal hWnd As IntPtr, ByVal
hDc As IntPtr) As IntPtr

    Dim memImage As New Bitmap(form.Width, form.Height)
    Dim memGraphic As Graphics = Graphics.FromImage(memImage)
    Dim dc1 As IntPtr = GetWindowDC(form.Handle)
    Dim dc2 As IntPtr = memGraphic.GetHdc
    BitBlt(dc2, 0, 0, Me.Size.Width, Me.Size.Height, dc1, 0, 0, &HCC0020)
    ReleaseDC(form.Handle, dc1)
    memGraphic.ReleaseHdc(dc2)

Dim pd as new PrinDocument
pd.Print

On PrinPage event: e.DrawImage (memImage,...)

Dont forget to dispose memimage after use...

HTH

--
Corrado Cavalli [Microsoft MVP]
UGIdotNET - http://www.ugidotnet.org



Sun, 24 Jul 2005 05:41:58 GMT  
 Printing nightmare...I'm losing my mind!!!
I appreciate the response, but this is exactly what I said I was
trying to avoid.  I find it hard to believe that the .NET framework
doesn't support some kind of way to capture part of the screen.  I
want to stay away from API calls, because then I lose my platform
independence.

Andrew



Sun, 24 Jul 2005 22:38:27 GMT  
 Printing nightmare...I'm losing my mind!!!

Quote:
> I appreciate the response, but this is exactly what I said I was
> trying to avoid.  I find it hard to believe that the .NET framework
> doesn't support some kind of way to capture part of the screen.  I
> want to stay away from API calls, because then I lose my platform
> independence.

> Andrew

By definition, a Windows Form is dependent on the Windows Platform.

--
If you don't like lunchmeat, please remove it from my e-mail address to
send me an e-mail



Tue, 26 Jul 2005 06:32:34 GMT  
 Printing nightmare...I'm losing my mind!!!
Don't know Chris. The Mono guys seem to have implemented the Windows Forms
classes on Linux. So they would support Windows Forms but not Windows :-)

HTH

Greg Low
Brisbane, Oztralia


Quote:


> > I appreciate the response, but this is exactly what I said I was
> > trying to avoid.  I find it hard to believe that the .NET framework
> > doesn't support some kind of way to capture part of the screen.  I
> > want to stay away from API calls, because then I lose my platform
> > independence.

> > Andrew

> By definition, a Windows Form is dependent on the Windows Platform.

> --
> If you don't like lunchmeat, please remove it from my e-mail address to
> send me an e-mail



Tue, 26 Jul 2005 15:01:26 GMT  
 Printing nightmare...I'm losing my mind!!!


Quote:
> Don't know Chris. The Mono guys seem to have implemented the Windows
> Forms classes on Linux. So they would support Windows Forms but not
> Windows :-)

Shouldn't they be called Linux Forms?   :)

Chris

--
If you don't like lunchmeat, please remove it from my e-mail address to
send me an e-mail



Tue, 26 Jul 2005 22:38:03 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. URGENT - SetUp Wizard lost it's mind!!!

2. Help - VB has lost its mind

3. Mind.VB initial translation/port of Mind.Forth PD AI

4. A few questions if you don't mind

5. Some More Help if you don't mind

6. Mind's gone blank-Resize form

7. IE won't mind its own business debugging activex control

8. Where's the VB5 WebBrowser control?: Never mind...I found it

9. Can't find installable ISAM - ADO Nightmare!

10. Help !!! VB4 Printing Nightmares

11. Help Me, I'm Losing my Mind, Skipping Code!!!

12. VB4(32) SetUpWizard Problem...Help Me..Dear Lord ..I'm losing My Mind!!!

 

 
Powered by phpBB® Forum Software