You can use PrintWindow
Run first
Code: Select all
OpenWindow(0, 0, 0, 400, 200, "Test", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget| #PB_Window_ScreenCentered)
SetWindowColor(0, #Gray)
ButtonGadget(0, 10, 10, 100, 30, "capture")
EditorGadget(1, 10, 50, 300, 140, #PB_Editor_WordWrap)
SetGadgetText(1, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.")
ImageGadget(2,10,210,400,400,0)
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
Then run
Code: Select all
Prototype.i ptPrintWindow(hWnd, hdc, flags)
OpenLibrary(0, "User32.dll")
PrintWindow.ptPrintWindow = GetFunction(0, "PrintWindow")
Repeat
hwnd = FindWindow_(0,"Test")
Until hwnd
OpenWindow(0, 0, 0, 510, 310, "", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget| #PB_Window_ScreenCentered)
SetWindowColor(0, #Gray)
ButtonGadget(0, 10, 10, 100, 30, "capture")
ImageGadget(2,10,50,410,210,0)
Repeat
event = WaitWindowEvent()
Select event
Case #PB_Event_Gadget
Select EventGadget()
Case 0
CreateImage(0, 406, 230)
hdc = StartDrawing(ImageOutput(0))
PrintWindow(hwnd, hdc,0)
StopDrawing()
SetGadgetState(2,ImageID(0))
EndSelect
EndSelect
Until event = #PB_Event_CloseWindow