Curious PrintWindow_() behaviour!
Posted: Mon Mar 22, 2010 8:07 pm
Has anyone any experience with the PrintWindow_() api function?
I ask because, well, take the following for example. Run it and PrintWindow_() is used to make an image of one window which it places within the centered window. No problems. However, uncomment the commented ButtonGadget() line and, on my system, the PanelGadget no longer gets added to the image!
Just wondering if anyone has come across this kind of thing before, and if so, can advise on a likely workaround?
Thanks.
I ask because, well, take the following for example. Run it and PrintWindow_() is used to make an image of one window which it places within the centered window. No problems. However, uncomment the commented ButtonGadget() line and, on my system, the PanelGadget no longer gets added to the image!
Code: Select all
Prototype.i ptPrintWindow(hWnd, hdc, flags)
OpenLibrary(1, "User32.dll")
PrintWindow.ptPrintWindow = GetFunction(1, "PrintWindow")
If OpenWindow(0, 0, 0, 400, 400, "ButtonGadgets", #PB_Window_SystemMenu|#PB_Window_SizeGadget)
; ButtonGadget(0, 10, 10, 80, 20, "CLICK!") ;Uncomment and PrintWindow_() does not work as expected!
PanelGadget(1, 0, 40, 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()
SetGadgetState(1, 1)
OpenWindow(1, 0, 0, 600, 600, "PrintWindow_()", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
GetWindowRect_(WindowID(0), rcWin.RECT)
width = rcWin\right-rcWin\left
height = rcWin\bottom-rcWin\top
SetActiveWindow(0)
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
ScrollAreaGadget(20, 10, 10, 600, 600, width, height, 20, #PB_ScrollArea_BorderLess)
ImageGadget(10, 0, 0, width, height, ImageID(1))
CloseGadgetList()
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

Thanks.