Click here to Skip to main content
15,921,660 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralApplication terminated itself while running Pin
Member 46394826-Aug-04 18:47
Member 46394826-Aug-04 18:47 
GeneralRe: Application terminated itself while running Pin
Colin Angus Mackay26-Aug-04 20:02
Colin Angus Mackay26-Aug-04 20:02 
GeneralTimer stops automatically Pin
Member 46394826-Aug-04 18:45
Member 46394826-Aug-04 18:45 
GeneralRe: Timer stops automatically Pin
Dave Kreskowiak27-Aug-04 3:05
mveDave Kreskowiak27-Aug-04 3:05 
GeneralPrinting the current Screen Pin
megadith26-Aug-04 8:30
megadith26-Aug-04 8:30 
GeneralRe: Printing the current Screen Pin
Anonymous26-Aug-04 10:35
Anonymous26-Aug-04 10:35 
GeneralRe: Printing the current Screen Pin
megadith26-Aug-04 11:40
megadith26-Aug-04 11:40 
GeneralRe: Printing the current Screen Pin
Anonymous26-Aug-04 12:07
Anonymous26-Aug-04 12:07 
'Here is one that will print the titlebar too..


Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents btnPrintForm As System.Windows.Forms.Button
<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
Me.btnPrintForm = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'btnPrintForm
'
Me.btnPrintForm.Location = New System.Drawing.Point(88, 216)
Me.btnPrintForm.Name = "btnPrintForm"
Me.btnPrintForm.Size = New System.Drawing.Size(136, 24)
Me.btnPrintForm.TabIndex = 0
Me.btnPrintForm.Text = "Button1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.btnPrintForm)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)

End Sub

#End Region
' create a printing component
Private WithEvents pd As Printing.PrintDocument
' storage for form image
Dim formImage As Bitmap
' create API prototype
Private Declare Function BitBlt Lib "gdi32.dll" Alias _
"BitBlt" (ByVal hdcDest As IntPtr, _
ByVal nXDest As Integer, ByVal nYDest As _
Integer, ByVal nWidth As Integer, _
ByVal nHeight As Integer, ByVal _
hdcSrc As IntPtr, ByVal nXSrc As Integer, _
ByVal nYSrc As Integer, _
ByVal dwRop As System.Int32) As Long

' Callback from PrintDocument component to
' do the actual printing
Private Sub pd_PrintPage(ByVal sender As Object, _
ByVal e As System.Drawing.Printing.PrintPageEventArgs) _
Handles pd.PrintPage
e.Graphics.DrawImage(formImage, 100, 100)
End Sub

Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
' create an instance of the PrintDocument component
pd = New Printing.PrintDocument
Me.StartPosition = FormStartPosition.CenterScreen
End Sub

Private Sub btnPrintForm_Click(ByVal sender As _
System.Object, ByVal e As System.EventArgs) _
Handles btnPrintForm.Click
' initiate the printdocument component
GetFormImage()
pd.Print()
End Sub
Private Sub GetFormImage()
Dim g As Graphics = Me.CreateGraphics()
Dim s As Size = Me.Size
formImage = New Bitmap(s.Width, s.Height, g)
Dim mg As Graphics = Graphics.FromImage(formImage)
Dim dc1 As IntPtr = g.GetHdc
Dim dc2 As IntPtr = mg.GetHdc
' added code to compute and capture the form
' title bar and borders
Dim widthDiff As Integer = _
(Me.Width - Me.ClientRectangle.Width)
Dim heightDiff As Integer = _
(Me.Height - Me.ClientRectangle.Height)
Dim borderSize As Integer = widthDiff \ 2
Dim heightTitleBar As Integer = heightDiff - borderSize
BitBlt(dc2, 0, 0, _
Me.ClientRectangle.Width + widthDiff, _
Me.ClientRectangle.Height + heightDiff, dc1, _
0 - borderSize, 0 - heightTitleBar, 13369376)

g.ReleaseHdc(dc1)
mg.ReleaseHdc(dc2)
End Sub

End Class
Generalproblem in programming with modem Pin
antiem26-Aug-04 6:38
antiem26-Aug-04 6:38 
GeneralRe: problem in programming with modem Pin
Anonymous26-Aug-04 8:09
Anonymous26-Aug-04 8:09 
GeneralRe: problem in programming with modem Pin
antiem27-Aug-04 6:06
antiem27-Aug-04 6:06 
GeneralSimple form question Pin
Swifty2126-Aug-04 6:15
Swifty2126-Aug-04 6:15 
GeneralRe: Simple form question Pin
Jim Matthews26-Aug-04 7:05
Jim Matthews26-Aug-04 7:05 
QuestionHow do parse Html images using VB? Pin
Nabah26-Aug-04 4:27
Nabah26-Aug-04 4:27 
Generaladding checkbutton to datagrid(very urgent) Pin
saranbala25-Aug-04 22:59
saranbala25-Aug-04 22:59 
GeneralRe: adding checkbutton to datagrid(very urgent) Pin
Anonymous26-Aug-04 8:18
Anonymous26-Aug-04 8:18 
GeneralProblem With Script Pin
Anonymous25-Aug-04 22:36
Anonymous25-Aug-04 22:36 
GeneralRe: Problem With Script Pin
Dave Kreskowiak26-Aug-04 2:53
mveDave Kreskowiak26-Aug-04 2:53 
GeneralRe: Problem With Script Pin
Anonymous27-Aug-04 0:08
Anonymous27-Aug-04 0:08 
Generalneed help! :( Pin
Member 90460525-Aug-04 15:04
Member 90460525-Aug-04 15:04 
GeneralRe: need help! :( Pin
Anonymous25-Aug-04 15:26
Anonymous25-Aug-04 15:26 
QuestionHow do I access URL from within the code in VB(not .NET) Pin
JM9325-Aug-04 13:46
JM9325-Aug-04 13:46 
AnswerRe: How do I access URL from within the code in VB(not .NET) Pin
Anonymous25-Aug-04 16:02
Anonymous25-Aug-04 16:02 
Questiondata between grids??? Pin
mittalpa25-Aug-04 12:35
mittalpa25-Aug-04 12:35 
AnswerRe: data between grids??? Pin
Jim Matthews26-Aug-04 5:04
Jim Matthews26-Aug-04 5:04 

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.