ShareVB
Messages postés2676Date d'inscriptionvendredi 28 juin 2002StatutMembreDernière intervention13 janvier 201626 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
ShareVB
Messages postés2676Date d'inscriptionvendredi 28 juin 2002StatutMembreDernière intervention13 janvier 201626 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