Link to home
Start Free TrialLog in
Avatar of nectarios777
nectarios777Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Print Screen function

Hello all,

I would like to print screen of my pc.
I would like to click a button and save this into my c:\images\

Could anyone please send me the code for this?
I am using vb.net

Thanks
SOLUTION
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal _
  bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Private Const VK_SNAPSHOT = &H2C

Public Sub PrintScreen()
    keybd_event VK_SNAPSHOT, 1, 0, 0
End Sub
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,
You can add this if you want to: (the first sub was already referred to in my first post)
   Public Sub PreviewData()

        ' Prepare and show data
        Me.Focus()
        myScreenshot = GetScreenSnapshot(True)

        Me.Visible = False
        dlgPrintPreview.Document = PreparePrintDocument()
        dlgPrintPreview.ShowDialog()
        Me.Visible = True

    End Sub

    Private Sub Print_PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs)
        On Error GoTo 0
        Dim margins As New Margins(50, 50, 50, 50)
        PrintDocument1.PrinterSettings.DefaultPageSettings.Landscape = True

        PrintDocument1.DefaultPageSettings.Margins = margins
        e.Graphics.DrawImage(myScreenshot, 30, 30, PrintDocument1.DefaultPageSettings.PaperSize.Width - 60, PrintDocument1.DefaultPageSettings.PaperSize.Height - 650)
        e.HasMorePages = False

    End Sub