Alfons: ActiveX Control

Beitrag lesen

hey..
habe eine Problem mit dem Snapshot Script...
hab es in VB so eingebunden:

##########################################
Option Explicit

' Benötigte API-Deklarationen
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

' Screenshot eines bestimmten Bildschirmausschnitts erstellen
' und als Bitmap in einer Datei abspeichern
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

' Handle des Windows-Desktop
  hWnd = GetDesktopWindow()

' Zugang zum Device-Context
  nDC = GetDC(hWnd)

' Position und Größe des Bildschirmausschnitts
  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

' temporäre PictureBox erstellen
  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)

' Snapshot in PictureBox blitten
    .AutoRedraw = True
    BitBlt .hdc, 0, 0, nWidth, nHeight, nDC, x, y, vbSrcCopy

' Bild abspeichern
    SavePicture .Image, sFile

' DC wieder freigeben
    ReleaseDC hWnd, nDC
  End With

' Control wieder entfernen
  oForm.Controls.Remove "myPicTemp"

MsgBox "Hello world", , "Message"

End Sub

Sub MainBut_Click()
Snapshot Me,

End Sub

################################

funktioniert so nicht! vielleicht hat jemand eine Idee!
der compiler merkert wegen Public Sub Snapshot rum..
aber die funlktion muss ja Public sein!

bei Private kommt beim ausführen.. runtime error 13