Comment faire un imprime écran (Print screen)

parjo - 10 nov. 2001 à 06:24
 int19h - 10 nov. 2001 à 08:39
Comment fait on un imprime écran avec un bouton de commande
Merci à l'avance

1 réponse

Salut

Voila un debut :
Sur un nouveau projet, place une PictureBox et un bouton de Command. Puis tu colles le code suivant :

Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function StretchBlt Lib "gdi32" (ByVal hdc 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 nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long

Private Sub Command1_Click()

Picture1.Cls

' Convertie les dimension de l'ecran en Pixels
wScreen = Screen.Width \ Screen.TwipsPerPixelX
hScreen = Screen.Height \ Screen.TwipsPerPixelY

' Dimension de l'image en pixels
Picture1.ScaleMode = vbPixels
w = Picture1.ScaleWidth
h = Picture1.ScaleHeight

' Trouve le hDC de l'ecran
hdcScreen = GetDC(0)

' On copie l'écran en l'ajustant à la taille de la PictureBox.
StretchBlt Picture1.hdc, 0, 0, w, h, hdcScreen, 0, 0, wScreen, hScreen, vbSrcCopy

End Sub

a+

Int19h
0
Rejoignez-nous