Imprime PictureBox / Frame

tiblay Messages postés 60 Date d'inscription mercredi 9 novembre 2005 Statut Membre Dernière intervention 6 janvier 2009 - 13 nov. 2007 à 15:44
tiblay Messages postés 60 Date d'inscription mercredi 9 novembre 2005 Statut Membre Dernière intervention 6 janvier 2009 - 13 nov. 2007 à 21:00
Bonjour a tous,

Voila je tourne en rond depuis 2 jours.

J'ai un Frame qui contient 2 MsChart et un Grid.  Le Frame a une dimension pour etre imprime sur une feuille, vous voyez ou je vais....  Mon probleme et que je ne peut pas imprimer un Frame......  J'ai essaye de mettre les objets dans un PictureBox, mais pas mieux. 

En bref je veut imprimer un Frame ou un PictureBox qui contient des objets

Pour le moment j'essaye de copier l'image du Frame dans un Picture1, qui est invisible et ensuite de l'imprime,  J'essaye meme de voir le resultat en passant par le presse papier, mais l'image est toujour GRIS.......

Merci de m'aider

----------- CODE ---------

FrameHDC = GetDC(frameGraph.hwnd)

BitBlt Picture1.hDC, 0, 0, frameGraph.Width, frameGraph.Width, FrameHDC, 0, 0, vbSrcCopy

Picture1.Picture = Picture1.Image

Clipboard.Clear
Clipboard.SetData Picture1.Picture

Printer.Orientation = 2
Printer.PaintPicture Picture1.Image, 0, 0, Picture1.Width, Picture1.Height
Printer.EndDoc

------------  Declaration  --------------
Private Declare Function BitBlt Lib "gdi32" _
    (ByVal hDCDest As Long, ByVal XDest As Long, _
    ByVal YDest As Long, ByVal nWidth As Long, _
    ByVal nHeight As Long, ByVal hDCSrc As Long, _
    ByVal xSrc As Long, ByVal ySrc As Long, _
    ByVal dwRop As Long) As Long

Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long

1 réponse

tiblay Messages postés 60 Date d'inscription mercredi 9 novembre 2005 Statut Membre Dernière intervention 6 janvier 2009
13 nov. 2007 à 21:00
Bonjour a tous,

J'ai trouve ce code et ca fonctionne.  Je ne connaisais pas le SendMessage, tres interresant....

Bonne journee

----------- CODE -----------------

    With picGraph
        ar = .AutoRedraw
 
        .AutoRedraw = True
    
        Printer.Orientation = 2
            
        Printer.Print
    
        rv = SendMessage(.hwnd, WM_PAINT, .hDC, 0)
        rv = SendMessage(.hwnd, WM_PRINT, .hDC, PRF_CHILDREN Or PRF_CLIENT Or PRF_OWNED)
    
        .Picture = .Image
    
        Printer.PaintPicture .Picture, 0, 0
        Printer.EndDoc
    
        picGraph.Line (0, 0)-(.ScaleWidth, .ScaleHeight), .BackColor, BF
    
        .AutoRedraw = ar
    End With

----------- Declaration --------------
Private Declare Function SendMessage Lib "user32.dll" Alias _
   "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
   ByVal wParam As Long, ByVal lParam As Long) As Long

Private Const WM_PAINT = &HF
Private Const WM_PRINT = &H317
Private Const PRF_CLIENT = &H4&                 ' Draw the window's client area
Private Const PRF_CHILDREN = &H10&           ' Draw all visible child
Private Const PRF_OWNED = &H20&               ' Draw all owned windows
0
Rejoignez-nous