http://www.purebasic.fr/english/viewtop ... =7&t=41537
Das merkwürdige Verhalten von PrintWindow in seinem Beitrag läßt sich mit einem ContainerGadget umgehen.
Ich weiß zwar nicht wozu man das braucht in dieser Form, aber irgendwie interessant.
Und warum Srod #WM_PRINT nicht brauchen kann habe ich auch nicht verstanden.
leicht angepaßter Code von Srod
Code: Alles auswählen
Prototype.i ptPrintWindow(hWnd, hdc, flags)
OpenLibrary(1, "User32.dll")
PrintWindow.ptPrintWindow = GetFunction(1, "PrintWindow")
If OpenWindow(0, 0, 0, 450, 460, "ButtonGadgets", #PB_Window_SystemMenu|#PB_Window_SizeGadget)
ButtonGadget(100, 10, 10, 80, 20, "CLICK!")
ImageGadget(101, 10, 250, 0, 0, 0)
ContainerGadget(#PB_Any, 0,40,320,200)
PanelGadget(1, 0, 0, 320, 200)
AddGadgetItem (1, -1, "Panel 1")
PanelGadget (2, 5, 5, 290, 166)
AddGadgetItem(2, -1, "Sub-Panel 1")
AddGadgetItem(2, -1, "Sub-Panel 2")
AddGadgetItem(2, -1, "Sub-Panel 3")
CloseGadgetList()
AddGadgetItem (1, -1,"Panel 2")
ButtonGadget(3, 10, 15, 80, 24,"Button 1")
ButtonGadget(4, 95, 15, 80, 24,"Button 2")
CloseGadgetList()
CloseGadgetList()
Repeat : EventID = WaitWindowEvent()
If EventID = #PB_Event_Gadget
welcherButton = EventGadget()
If welcherButton = 100
GetWindowRect_(WindowID(0), rcWin.RECT)
width = rcWin\right-rcWin\left
height = rcWin\bottom-rcWin\top
If CreateImage(1, width, height, 24)
hdc = StartDrawing(ImageOutput(1))
If hdc
Box(0, 0, width, height, #White)
PrintWindow(WindowID(0), hdc, 0)
StopDrawing()
EndIf
EndIf
ResizeImage(1, 300, 200)
SetGadgetState(101,ImageID(1))
EndIf
EndIf
Until EventID = #PB_Event_CloseWindow
EndIf