Afficher un graphics dans une picturebox

astragoth66 Messages postés 31 Date d'inscription lundi 6 juin 2005 Statut Membre Dernière intervention 2 octobre 2005 - 17 août 2005 à 09:56
sebmafate Messages postés 4936 Date d'inscription lundi 17 février 2003 Statut Membre Dernière intervention 14 février 2014 - 17 août 2005 à 10:21
Salut,

voila, j'ai récupéré des classes qui me génére un object de type
graphics, et j'aimerai pouvoir l'afficher dans une picturebox, sauf que
je ne sais pas comment faire.

si cela n'est pas possible, est il possible de l'afficher dans le fond d'une form ???



Merci d'avance pour réponse

@pluche

@str@goth

1 réponse

sebmafate Messages postés 4936 Date d'inscription lundi 17 février 2003 Statut Membre Dernière intervention 14 février 2014 37
17 août 2005 à 10:21
c'est surement pas la meilleur solution, mais essaye ceci :

Ajoute ca :

[DllImport(
"gdi32.dll")]

private
static
extern
bool BitBlt(
IntPtr hdcDest,

int nXDest,

int nYDest,

int nWidth,

int nHeight,
IntPtr hdcSrc,

int nXSrc,

int nYSrc,

int dwRop
);

et procède ainsi :
Graphics gPct = tonPictureBox.CreateGraphics();
PictureBox tonPictureBox = new PictureBox();
Graphics gPct = tonPictureBox.CreateGraphics();
IntPtr pctHdc = gPct.GetHdc();
IntPtr gHdc = g.GetHdc();

BitBlt(pctHdc, 0,0, tonPictureBox.Width, tonPictureBox.Height, gHdc, 0,0, 0xCC0020);
gPct.ReleaseHdc(pctHdc);
g.ReleaseHdc(gHdc);

g est ton objet Graphics.
et 0xCC0020 est la constante SRCCOPY


<HR>
Sébastien FERRAND

Blog : http://blogs.developpeur.org/sebmafate
0
Rejoignez-nous