Dessiner sur l'écran ou le bureau

cs_MyC Messages postés 94 Date d'inscription lundi 23 septembre 2002 Statut Membre Dernière intervention 22 avril 2003 - 23 déc. 2002 à 08:32
ShareVB Messages postés 2676 Date d'inscription vendredi 28 juin 2002 Statut Membre Dernière intervention 13 janvier 2016 - 23 déc. 2002 à 10:54
Salut,

Comment peut-on dessiner directement sur l'écran ou sur le bureau ?

Merci pour vos idées !

3 réponses

ShareVB Messages postés 2676 Date d'inscription vendredi 28 juin 2002 Statut Membre Dernière intervention 13 janvier 2016 26
23 déc. 2002 à 10:17
salut

pour dessiner sur l'écran il faut utiliser les apis :

deja pour trouver le Device Context de l'écran tu utilises l'api :
Public Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hwnd As Long) As Long

DIm Ecran as long
Ecran = GetDC(0&)

ecran correspond au parametre hDC as long de toutes les apis de dessin :

Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long 'pour un texte
Private Declare Function LineTo Lib "gdi32" Alias "LineTo" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function MoveToEx Lib "gdi32" Alias "MoveToEx" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, lpPoint As POINTAPI) As Long

et toutes les functions "Line and Curve Functions" (description dans MSDN/SDK Platform)

seulement, si tu passes une fenetre sur ton dessin le dessin s'efface

voila

ShareVB
0
cs_MyC Messages postés 94 Date d'inscription lundi 23 septembre 2002 Statut Membre Dernière intervention 22 avril 2003
23 déc. 2002 à 10:29
Merci bcp pour ta réponse, mais peux-tu me donner un exemple concret. Merci !
0
ShareVB Messages postés 2676 Date d'inscription vendredi 28 juin 2002 Statut Membre Dernière intervention 13 janvier 2016 26
23 déc. 2002 à 10:54
salut

tu met ca dans une form avec un commandbutton command1, tu copie ca dans le code de ta form :

Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
Private Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type

Private Sub Command1_Click()
Dim Ecran As Long, P As POINTAPI
Ecran = GetDC(0&)
TextOut Ecran, 50&, 50&, "azerty", 6&
MoveToEx Ecran, 100, 100, P
LineTo Ecran, 200, 200
End Sub

tu cliques sur le bouton et ca t'écrit azerty sur l'écran et ca te dessine une ligne entre (100,100)-(200,200)

pour d'autres fonctions regarde dans MSDN/SDK Platform/Reference : y a toutes les apis windows dont line and curve functions

voila

ShareVB
0
Rejoignez-nous