jpmaton
Messages postés67Date d'inscriptionmardi 17 mai 2005StatutMembreDernière intervention26 septembre 2023
-
29 mai 2010 à 10:23
jpmaton
Messages postés67Date d'inscriptionmardi 17 mai 2005StatutMembreDernière intervention26 septembre 2023
-
29 mai 2010 à 16:21
Bonjour,
Je capte une partie d'écran avec l'API GetDC.
La capture est bien envoyée vers la pictureBox picture1.
Mais si je sauve, le fichier BMP est vide
De même que si j'imprime avec "Printer.PaintPicture Picture1.Image, 0, 0" j'ai une page vide aussi.
Il doit me manquer une étape...
Merci de l'aide et bon WE
Jean-paul
' Boutons : Command1 et Picture1
' Code Form1
Private Sub Command1_Click()
Dim x As Integer, y As Integer, nWidth As Integer, nHeight As Integer
Dim dwRop As Long, hSrcDC As Long, hDestDC As Long
Let nWidth = 500 ' largeur capture
Let nHeight = 300 ' hauteur capture
Let xSrc = 0 ' marge gauche non captée
Let ySrc = 0 ' marge haute non captée
Let x = 0 ' marge G dans picturebox ou form
Let y = 0 ' marge Haute dans pictureBox ou form
Let dwRop = SRCCOPY
Let hDestDC = Picture1.hdc
Let hSrcDC = GetDC(0)
Call BitBlt(hDestDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, dwRop)
Call ReleaseDC(0, hSrcDC)
SavePicture Picture1.Image, App.Path & "\test.bmp"
End Sub
' Module1
Public Const SRCCOPY = &HCC0020
Public Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
Public 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
Public Declare Function ReleaseDC Lib "user32" (ByVal hWnd As Long, ByVal hdc As Long) As Long