Filed under: Visual Basic at 13:09:40 On 2006-06-29
This is one of the fastest and smallest method to capture screen.
I am putting this in visual basic to make easily understandable to newbees.
Visual basic timer object reports time 0 seconds for this operation !
Here goes the code.
'API Declarations
Private Declare Function CreateDCAsNull Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, lpDeviceName As Any, lpOutput As Any, lpInitData As Any) As Long
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
'Sub To be called
'For example Use : dumpScreenToPicturebox(picture1)
Public Sub dumpScreenToPicturebox(targetPictureBox As Control)
lngDesktopDC = CreateDCAsNull("DISPLAY", ByVal 0&, ByVal 0&, ByVal 0&)
BitBlt targetPictureBox.hdc, 0, 0, Screen.Width / Screen.TwipsPerPixelX, Screen.Height / Screen.TwipsPerPixelY, lngDesktopDC, 0, 0, vbSrcCopy
End Sub
Hope it was useful !

[Comments :0] [Permalink]
Filed under: Visual Basic at 11:57:45 On 2006-06-14
A few dayz back my friend raghav was working on one ActiveX for company project.
He got stuck at one point where his procedure was changing the value of a variable while using ByRef.( The project is done in Visual Basic)
I also tried to figure out the problem but in vain
.
BTW i never use ByRef in ActiveX control's coz i prefer to use classes most of the time.
Later ,searching this on net i found that whenever you enclose the passed variable in parenthesis Visual basic evaluates this as an expression and your passed variable becomes a ByVal passed variable.
So,
//Code Begin
foo(myInt)
..............................
...............................
Private Sub foo(myVar)
myVar = newValue
End Sub
//Code End
Will not change the value of myInt to newValue.
Rather :
//Code Begin
foo myInt
..............................
...............................
Private Sub foo(myVar)
myVar = newValue
End Sub
//Code End
Will do the Trick
Strange but true 
PS: Anywayz Microsoft has made ByVal as a default method to pass variables in dotNET.
[Comments :1] [Permalink]