Code : Tout sélectionner
Procedure ImprimeFenetreClient(id_fenetre.l)
Protected Hdc.i, id_image.l, id_library.l, Creation_image.l
If GetClientRect_(WindowID(id_fenetre),@rect.rect)
id_image= CreateImage(#PB_Any,rect\right,rect\bottom)
If id_image<> 0
hdc.i=StartDrawing(ImageOutput(id_image))
If hdc
id_library= OpenLibrary(#PB_Any,"User32.dll")
If id_library<>0
If CallFunction(id_library, "PrintWindow", WindowID(id_fenetre), Hdc, #PW_CLIENTONLY)
Creation_image=1
EndIf
CloseLibrary(id_library)
EndIf
EndIf
StopDrawing()
EndIf
EndIf
If Creation_image
If PrintRequester()
If StartPrinting("PureBasic Test")
If StartDrawing(PrinterOutput())
DrawImage(ImageID(id_image), 0, 0)
StopDrawing()
EndIf
StopPrinting()
EndIf
EndIf
EndIf
EndProcedure
#Fenetre=0
#Bouton=0
If OpenWindow(#Fenetre, 0, 0, 240, 240, "ButtonGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(#Bouton, 10, 20, 220, 20, "Imprimer la Fenêtre sans les bords")
Repeat
event.l=WaitWindowEvent()
Select event
Case #PB_Event_Gadget
Select EventGadget()
Case #Bouton
ImprimeFenetreClient(#Fenetre)
EndSelect
EndSelect
Until event = #PB_Event_CloseWindow
EndIf