Screen Shot sous VB

cs_cyrilp Messages postés 140 Date d'inscription mercredi 4 octobre 2000 Statut Membre Dernière intervention 12 août 2009 - 18 déc. 2001 à 10:36
ZTPdiffusion Messages postés 46 Date d'inscription lundi 16 avril 2001 Statut Membre Dernière intervention 7 mars 2002 - 18 déc. 2001 à 12:46
%-6
Bonjour à tous !

Je souhaiterais pouvoir prendre une "photo d'écran" depuis VB.

Quelqu'un sait comment faire ?
De plus, j'utilise dans mon programme, les fonctions SMTP pour envoyer un mail (sans passer par un client de messagerie) mais comment faire pour envoyer une piece jointe ? (en l'occurence la photo d'écran)

Merci pour votre aide !
CYRIL P.

2 réponses

ZTPdiffusion Messages postés 46 Date d'inscription lundi 16 avril 2001 Statut Membre Dernière intervention 7 mars 2002
18 déc. 2001 à 12:40
Salut

voici la réponse pour le screenshot sous vb

'Pour ce projet il faut : 2 feuilles (form1 et form2)
'Mettre pour form2 : Propriété AUTOREDRAW sur TRUE, BORDERSTYLE sur NONE, VISIBLE sur FALSE, WINDOWSTATE sur MAXIMIZED
'Sur la feuille 1 (form1) mettre 2 boutons (Command1 et Command2)

'Code à mettre dans la Form1

Private Sub Command1_click()

Form1.Visible = False
Dim hwnd&, hdc&
hwnd& = GetDesktopWindow()
hdc& = GetDC(hwnd&)
BitBlt Form2.hdc, 0, 0, Screen.Width / 15, Screen.Height / 15, hdc&, 0, 0, SRCCOPY
DoEvents
SavePicture Form2.Image, App.Path + "\Screenshot.bmp"
Form1.Visible = True
End Sub

Private Sub Command2_Click()
End
End Sub

'Code à mettre dans un module

Public Const SRCCOPY = &HCC0020
Public Const SRCAND = &H8800C6
Public Const SRCINVERT = &H660046

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 GetDesktopWindow Lib "user32" () As Long
Public Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long

La capture d'écran se sauvegarde dans le même répertoire que le projet sous le nom "screenshot.bmp"

Concernant l'envoi de pièces jointes, ça doit être un peu plus difficile mais je cherche

a+ :)
0
ZTPdiffusion Messages postés 46 Date d'inscription lundi 16 avril 2001 Statut Membre Dernière intervention 7 mars 2002
18 déc. 2001 à 12:46
Resalut

Faut vraiment que j'arrête de répondre trop vite

Le DoEvents doit être placé après Form1.Visible = False et non avant SavePicture...

Sinon dans la capture d'écran on verra le Form1

A+ ;)
0
Rejoignez-nous