hey I'm new here and have a big problem with ActiveX
I want to create a snapshot from my .htm,
but the code doesn't work.
could you find any mistakes?
###############
Option Explicit
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 GetDC Lib "user32" ( _
ByVal hWnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" ( _
ByVal hWnd As Long, _
ByVal hdc As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Public Sub Snapshot(oForm As Form, ByVal sFile As String, _
Optional ByVal x As Variant, _
Optional ByVal y As Variant, _
Optional ByVal nWidth As Variant, _
Optional ByVal nHeight As Variant)
Dim hWnd As Long
Dim nDC As Long
Dim oPicBox As Control
hWnd = GetDesktopWindow()
nDC = GetDC(hWnd)
If IsMissing(x) Then x = 0
If IsMissing(y) Then y = 0
If IsMissing(nWidth) Then nWidth = Screen.Width * Screen.TwipsPerPixelX
If IsMissing(nHeight) Then nHeight = Screen.Height * Screen.TwipsPerPixelY
Set oPicBox = oForm.Controls.Add("VB.PictureBox", "myPicTemp")
With oPicBox
.ScaleMode = vbPixels
.Width = oForm.ScaleX(nWidth, vbPixels, oForm.ScaleMode)
.Height = oForm.ScaleY(nHeight, vbPixels, oForm.ScaleMode)
.AutoRedraw = True
BitBlt .hdc, 0, 0, nWidth, nHeight, nDC, x, y, vbSrcCopy
SavePicture .Image, sFile
' DC wieder freigeben
ReleaseDC hWnd, nDC
End With
oForm.Controls.Remove "myPicTemp"
End Sub
Private Sub Command1_Click()
Snapshot Me, "c:\bild.bmp", 100, 100, 400, 400
End Sub
Private Sub Command1_Click()
Snapshot Me, "c:\bild.bmp", 100, 100, 400, 400
End Sub
#########
so one Error with Public at "Sub Screenshot" ? but I do not understand this error
can you help me?