The WM_PRINT message is sent To a window To request that it draw itself in the specified device context,most commonly in a printer device context.
The BitBlt function performs a bit-block transfer of the color Data corresponding To a rectangle of pixels from the specified source device context into a destination device context.
Code: Select all
Procedure captureGadget(Gadget)
GetWindowRect_(GadgetID(Gadget), @listrect.RECT)
width = listrect\right - listrect\left
height = listrect\bottom - listrect\top
CreateImage(0, width,height, 24)
hdc = StartDrawing(ImageOutput(0))
ResizeGadget(3,10,10,10,10)
SetWindowLongPtr_( GadgetID(3), #GWL_HWNDPARENT,GadgetID(1))
SendMessage_(GadgetID(1),#WM_PRINT,hDC, #PRF_CHILDREN|#PRF_CLIENT|#PRF_NONCLIENT| #PRF_ERASEBKGND)
SetWindowLongPtr_( GadgetID(3), #GWL_HWNDPARENT,WindowID(1))
ResizeGadget(3,20,20,10,10)
UpdateWindow_(GadgetID(1))
StopDrawing()
SetGadgetState(2,ImageID(0))
EndProcedure
Procedure CaptureGadget1(par)
CreateImage(50, 60, 60, 24)
hdc = StartDrawing(ImageOutput(50))
BitBlt_(hdc,0,0,60,60, GetDC_(GadgetID(par)),0,0,#SRCCOPY)
StopDrawing()
SetGadgetState(4,ImageID(50))
EndProcedure
OpenWindow(1, 0, 0, 200, 200, "Capture Gadget", #PB_Window_SystemMenu |#PB_Window_ScreenCentered)
ButtonGadget(1,10,10,60,60,"TEST")
CanvasGadget(3,20,20,10,10)
ImageGadget(2, 10, 100, 60,60,0)
ImageGadget(4, 100, 100, 60,60,0)
SetWindowLong_(GadgetID(1), #GWL_STYLE, GetWindowLong_(GadgetID(1), #GWL_STYLE) | #WS_CLIPSIBLINGS)
SetWindowPos_(GadgetID(1), #HWND_BOTTOM, 0, 0, 0, 0, #SWP_NOSIZE | #SWP_NOMOVE)
captureGadget(1)
CaptureGadget1(1)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow