Okay, you twisted my arm!
The following is quite crude (being a quick hack) and probably does not do what you are after. However, it may get you started if you decide to try and work with a ScrollArea's inner container directly. I basically blt an image directly to this container. Note how I subclass, not the scroll-area, but it's inner container. Note also the #WM_ERASEBKGND message handler which removes all default erasing from the container as performed by Windows itself. We can do this because my paint handler paints the resized image to the
entire client area of the container. If this was not the case then I would also have to undertake some custom erasing. To avoid flicker you would erase only those parts of the container not being painted upon. I also add the #WS_CLIPCHILDREN style to the scroll area.
Result = no flicker when scrolling the image.
This is very inefficient and sloppy code for a number of reasons, not the least of which is the fact that I blt the entire image whenever painting is required. In a proper app I would take steps to blt only that part of the image matching the invalidated portion of the client area etc.
As I say though, it may help.
Code: Select all
Procedure SubClassProc(hWnd, uMsg, wParam, lParam)
Protected result, oldProc, ps.PAINTSTRUCT, width, height, hdcNew, oldImage
oldproc = GetProp_(hWnd, "oldproc")
Select uMsg
Case #WM_NCDESTROY
RemoveProp_(hwnd, "oldproc")
result = CallWindowProc_(oldproc, hWnd, uMsg, wParam, lParam)
Case #WM_ERASEBKGND
result = 1
Case #WM_PAINT
hdc = BeginPaint_(hWnd, ps)
If hdc
hdcNew = CreateCompatibleDC_(hdc)
If hdcNew
width = GetGadgetAttribute(0, #PB_ScrollArea_InnerWidth)
height = GetGadgetAttribute(0, #PB_ScrollArea_InnerHeight)
ResizeImage(0, width, height)
oldImage = SelectObject_(hdcNew, ImageID(0))
BitBlt_(hdc, 0, 0, width, height, hdcNew, 0, 0, #SRCCOPY)
SelectObject_(hdcNew, oldImage)
DeleteDC_(hdcNew)
EndIf
EndPaint_(hWnd, ps)
EndIf
Default
result = CallWindowProc_(oldproc, hWnd, uMsg, wParam, lParam)
EndSelect
ProcedureReturn result
EndProcedure
ww = 512
wh = 384
zoom = 16
CreateImage(0, ww, wh)
If OpenWindow(0, 0, 0, ww, wh, "ScrollAreaGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered|#PB_Window_SizeGadget)
hwnd = ScrollAreaGadget(0, 0, 0, ww,wh, 256*zoom, 192*zoom, 3, #PB_ScrollArea_Raised)
CloseGadgetList()
SetWindowLongPtr_(hWnd, #GWL_STYLE, GetWindowLongPtr_(hWnd, #GWL_STYLE)|#WS_CLIPCHILDREN)
hWnd = FindWindowEx_(hWnd, 0, "PureScrollAreaChild",0)
SetProp_(hWnd, "oldproc", SetWindowLongPtr_(hWnd, #GWL_WNDPROC, @SubClassProc()))
Repeat: Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
**EDIT : if you are looking for a good way of zooming images etc. then I would recommend that you take a look at enhanced metafiles. They are easy to use and very very useful in this kind of situation.

I may look like a mule, but I'm not a complete ass.