| |

Fortgeschrittene ProgrammierungBild/Screenie Speichern | |  | Autor: Annabelle | Datum: 25.11.05 07:36 |
| Hallo!
Mein Bildschirmschonerproblem ist nun konkretisiert. Ich brauche nur alle paar minuten einen Screenshot des aktuelle geöffnenten Formulares in meiner AccXP Datenbank.
Dazu habe ich folgenden Code genommen:
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"
End Sub
Beispiele für den Aufruf:
' gesamten Bildschirmbereich speichern
Snapshot Me, "d:\bild.bmp"
' Bildschirmausschnitt 100,100 - 500,500 speichern
Snapshot Me, "d:\bild.bmp", 100, 100, 400, 400
______________________________________
Das habe ich so einfach übernommen nur kommt er mit den Funktionen Screen.Width, Height, TwipsPerPixel usw nicht klar, kennt er nicht.
Ich denke das selbe wird bei .ScaleMode passieren.
Nun die Frage: muss ich eine bestimmte Bibliothek (API oder so) einbinden damit er die Befehle erkennt?
Gruß und vielen Dank Anna!
t?tet keine v?gel, wir v?geln auch keine toten!  |  |
 | Sie sind nicht angemeldet! Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.
Einloggen | Neu registrieren |
  |
|
Neu! sevEingabe 3.0 
Einfach stark!
Ein einziges Eingabe-Control für alle benötigten Eingabetypen und -formate, inkl. Kalender-, Taschenrechner und Floskelfunktion, mehrspaltige ComboBox mit DB-Anbindung, ImageComboBox u.v.m. Weitere InfosTipp des Monats Oktober 2025 Matthias KozlowskiUmlaute konvertierenErsetzt die Umlaute in einer Zeichenkette durch die entsprechenden Doppelbuchstaben (aus ä wird ae, usw.) TOP Entwickler-Paket 
TOP-Preis!!
Mit der Developer CD erhalten Sie insgesamt 24 Entwickler- komponenten und Windows-DLLs. Die Einzelkomponenten haben einen Gesamtwert von 1866.50 EUR...
Jetzt nur 979,00 EURWeitere Infos
|