Click here to Skip to main content
15,886,919 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Generalbound combobox... Pin
sabr4916-Apr-08 3:43
sabr4916-Apr-08 3:43 
GeneralRe: bound combobox... Pin
Dave Kreskowiak16-Apr-08 4:13
mveDave Kreskowiak16-Apr-08 4:13 
GeneralRe: bound combobox... Pin
sabr4916-Apr-08 4:54
sabr4916-Apr-08 4:54 
GeneralRe: bound combobox... Pin
Dave Kreskowiak16-Apr-08 8:24
mveDave Kreskowiak16-Apr-08 8:24 
Questionprinting form Pin
asha_s16-Apr-08 0:45
asha_s16-Apr-08 0:45 
GeneralRe: printing form Pin
Zaegra16-Apr-08 1:40
Zaegra16-Apr-08 1:40 
GeneralRe: printing form Pin
asha_s16-Apr-08 6:52
asha_s16-Apr-08 6:52 
GeneralRe: printing form Pin
Steven J Jowett16-Apr-08 4:08
Steven J Jowett16-Apr-08 4:08 
Try this :-

Public Class PrintForm<br />
<br />
    Private _frmForm As Windows.Forms.Form<br />
    Private _imgScreenShot As System.Drawing.Bitmap<br />
<br />
    'API Calls to help generate final screenshot<br />
    Private Declare Auto Function BitBlt Lib "gdi32.dll" _<br />
        (ByVal hdcDest As IntPtr, ByVal nXDest As Integer, _<br />
         ByVal nYDest As Integer, ByVal nWidth As Integer, _<br />
         ByVal nHeight As Integer, ByVal hdcSrc As IntPtr, _<br />
         ByVal nXSrc As Integer, ByVal nYSrc As Integer, _<br />
         ByVal dwRow As System.Int32) As Boolean<br />
<br />
    Public Sub New(ByRef Form As Windows.Forms.Form)<br />
        _frmForm = Form<br />
    End Sub<br />
<br />
    Public Sub Print()<br />
        GetScreen()<br />
        Dim printDialog As New Windows.Forms.PrintDialog<br />
        Dim printDocument As New System.Drawing.Printing.PrintDocument<br />
        AddHandler printDocument.PrintPage, AddressOf printDocument_PrintPage<br />
        printDialog.Document = printDocument<br />
        If printDialog.ShowDialog = Windows.Forms.DialogResult.OK Then<br />
            printDocument.Print()<br />
        End If<br />
    End Sub<br />
<br />
    Public Sub Dispose()<br />
        _imgScreenShot.Dispose()<br />
    End Sub<br />
<br />
    Private Sub GetScreen()<br />
        Const SRCCOPY As Integer = &HCC0020<br />
<br />
        Dim oGraphics As System.Drawing.Graphics = _frmForm.CreateGraphics<br />
        Dim oSize As System.Drawing.Size = _frmForm.Size<br />
<br />
        _imgScreenShot = New System.Drawing.Bitmap(oSize.Width, oSize.Height, oGraphics)<br />
        Dim oGraphics2 As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(_imgScreenShot)<br />
        Dim deviceContext1 As IntPtr = oGraphics.GetHdc<br />
        Dim deviceContext2 As IntPtr = oGraphics2.GetHdc<br />
<br />
        BitBlt(deviceContext2, 0, 0, _frmForm.ClientRectangle.Width, _frmForm.ClientRectangle.Height, deviceContext1, 0, 0, SRCCOPY)<br />
        oGraphics.ReleaseHdc(deviceContext1)<br />
        oGraphics2.ReleaseHdc(deviceContext2)<br />
    End Sub<br />
<br />
    Private Sub printDocument_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)<br />
        Dim oImageToPrint As System.Drawing.Graphics = e.Graphics<br />
        oImageToPrint.DrawImage(_imgScreenShot, 0, 0)<br />
        oImageToPrint.Dispose()<br />
        e.HasMorePages = False<br />
    End Sub<br />
<br />
End Class


Then to print from your form :-

Dim oScreen as New PrintForm(me)<br />
oScreen.Print


Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)

GeneralRe: printing form Pin
asha_s16-Apr-08 6:51
asha_s16-Apr-08 6:51 
GeneralRe: printing form Pin
Steven J Jowett16-Apr-08 12:16
Steven J Jowett16-Apr-08 12:16 
QuestionRe: printing form Pin
asha_s19-Apr-08 8:15
asha_s19-Apr-08 8:15 
GeneralRe: printing form Pin
Steven J Jowett20-Apr-08 11:12
Steven J Jowett20-Apr-08 11:12 
GeneralRe: printing form Pin
asha_s21-Apr-08 0:39
asha_s21-Apr-08 0:39 
GeneralPrinting Problem² [modified] Pin
Zaegra16-Apr-08 0:14
Zaegra16-Apr-08 0:14 
GeneralRe: Printing Problem² Pin
Chinners16-Apr-08 0:55
Chinners16-Apr-08 0:55 
GeneralRe: Printing Problem² Pin
Zaegra16-Apr-08 1:37
Zaegra16-Apr-08 1:37 
QuestionCapture screen as movie Pin
Mohammad Al Hoss15-Apr-08 22:29
Mohammad Al Hoss15-Apr-08 22:29 
GeneralRe: Capture screen as movie Pin
Dave Kreskowiak16-Apr-08 4:04
mveDave Kreskowiak16-Apr-08 4:04 
QuestionHow manage scroll position in listview without using API function. Pin
Coban_15-Apr-08 21:43
Coban_15-Apr-08 21:43 
AnswerRe: How manage scroll position in listview without using API function. Pin
Dave Kreskowiak16-Apr-08 3:59
mveDave Kreskowiak16-Apr-08 3:59 
GeneralRe: How manage scroll position in listview without using API function. Pin
Coban_16-Apr-08 4:42
Coban_16-Apr-08 4:42 
GeneralRe: How manage scroll position in listview without using API function. Pin
Dave Kreskowiak16-Apr-08 12:23
mveDave Kreskowiak16-Apr-08 12:23 
GeneralRe: How manage scroll position in listview without using API function. Pin
Coban_16-Apr-08 20:11
Coban_16-Apr-08 20:11 
GeneralRe: How manage scroll position in listview without using API function. Pin
Dave Kreskowiak17-Apr-08 2:47
mveDave Kreskowiak17-Apr-08 2:47 
GeneralRe: How manage scroll position in listview without using API function. Pin
Coban_17-Apr-08 4:07
Coban_17-Apr-08 4:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.