Hello Forum.
I tried to place a WindowedScreen inside a ScrollArea-Gadget with larger dimensions as the visible part of the ScrollAreaGadget.
It seems that it is not possible to scroll the ScreenArea in this Gadget so, my question: Is it possible to change the offset on the ScrollAreaGadget ?
Windowed screen inside a ScrollArea Gadget?
Re: Windowed screen inside a ScrollArea Gadget?
Code: Select all
SetGadgetAttribute() with one of the following attribute:
#PB_ScrollArea_X : Changes the current horizontal scrolling position (in pixels).
#PB_ScrollArea_Y : Changes the current vertical scrolling position (in pixels).
Re: Windowed screen inside a ScrollArea Gadget?
Unfortunately, this does not change the offset of the windowed screen. Its offset is still at x:0 y:0.
Tranquil
Re: Windowed screen inside a ScrollArea Gadget?
If you are a Windows user
Code: Select all
InitSprite()
Procedure WndProc(hwnd, uMsg, wParam, lParam)
result = #PB_ProcessPureBasicEvents
Select uMsg
Case #WM_HSCROLL
Select wParam & $FFFF
Case #SB_LINELEFT
Result = GetScrollPos_(hwnd, #SB_HORZ)
If Result >= 1
SetScrollPos_(hwnd, #SB_HORZ,Result-1,1)
ScrollWindowEx_(hwnd,1,0,0,0,0,0,#SW_ERASE| #SW_INVALIDATE|#SW_SCROLLCHILDREN)
EndIf
Case #SB_LINERIGHT
Result = GetScrollPos_(hwnd, #SB_HORZ)
If Result <= 999
SetScrollPos_(hwnd, #SB_HORZ,Result+1,1)
ScrollWindowEx_(hwnd,-1,0,0,0,0,0,#SW_ERASE| #SW_INVALIDATE|#SW_SCROLLCHILDREN)
EndIf
Case #SB_THUMBTRACK
Result2 =GetScrollPos_(hwnd, #SB_HORZ)
Result = (wParam >> 16 & $FFFF)
If Result >= 0
SetScrollPos_(hwnd, #SB_HORZ,Result,1)
ScrollWindowEx_(hwnd,Result2-Result,0,0,0,0,0,#SW_ERASE|#SW_INVALIDATE| #SW_SCROLLCHILDREN)
ElseIf Result <= 1000
SetScrollPos_(hwnd, #SB_HORZ,Result,1)
ScrollWindowEx_(hwnd,Result-Result2,0,0,0,0,0,#SW_ERASE|#SW_INVALIDATE| #SW_SCROLLCHILDREN)
EndIf
EndSelect
Case #WM_VSCROLL,#WM_MOUSEWHEEL
Select wParam & $FFFF
Case #SB_LINEUP
Result = GetScrollPos_(hwnd, #SB_VERT)
If wParam >> 16 & $FFFF <= 120 And Result >= 1
SetScrollPos_(hwnd, #SB_VERT,Result-1,1)
ScrollWindowEx_(hwnd,0,1,0,0,0,0,#SW_ERASE| #SW_INVALIDATE|#SW_SCROLLCHILDREN)
ElseIf wParam >> 16 & $FFFF > 120 And Result <= 999
SetScrollPos_(hwnd, #SB_VERT,Result+1,1)
ScrollWindowEx_(hwnd,0,-1,0,0,0,0,#SW_ERASE| #SW_INVALIDATE|#SW_SCROLLCHILDREN)
EndIf
;
Case #SB_LINEDOWN
Result = GetScrollPos_(hwnd, #SB_VERT)
If Result <= 999
SetScrollPos_(hwnd, #SB_VERT,Result+1,1)
ScrollWindowEx_(hwnd,0,-1,0,0,0,0,#SW_ERASE| #SW_INVALIDATE|#SW_SCROLLCHILDREN)
EndIf
Case #SB_THUMBTRACK
Result2 =GetScrollPos_(hwnd, #SB_VERT)
Result = (wParam >> 16 & $FFFF)
If Result >= 0
SetScrollPos_(hwnd, #SB_VERT,Result,1)
ScrollWindowEx_(hwnd,0,Result2-Result,0,0,0,0,#SW_ERASE|#SW_INVALIDATE| #SW_SCROLLCHILDREN)
ElseIf Result <= 1000
SetScrollPos_(hwnd, #SB_VERT,Result,1)
ScrollWindowEx_(hwnd,0,Result-Result2,0,0,0,0,#SW_ERASE|#SW_INVALIDATE| #SW_SCROLLCHILDREN)
EndIf
EndSelect
Case #WM_KEYDOWN ,#WM_MENUSELECT
Select wParam
Case #VK_LEFT
Result = GetScrollPos_(hwnd, #SB_HORZ)
If Result >= 1
SetScrollPos_(hwnd, #SB_HORZ,Result-1,1)
ScrollWindowEx_(hwnd,1,0,0,0,0,0,#SW_ERASE| #SW_INVALIDATE|#SW_SCROLLCHILDREN)
EndIf
Case #VK_RIGHT
Result = GetScrollPos_(hwnd, #SB_HORZ)
If Result <= 999
SetScrollPos_(hwnd, #SB_HORZ,Result+1,1)
ScrollWindowEx_(hwnd,-1,0,0,0,0,0,#SW_ERASE| #SW_INVALIDATE|#SW_SCROLLCHILDREN)
EndIf
Case #VK_UP
Result = GetScrollPos_(hwnd, #SB_VERT)
If Result >= 1
SetScrollPos_(hwnd, #SB_VERT,Result-1,1)
ScrollWindowEx_(hwnd,0,1,0,0,0,0,#SW_ERASE| #SW_INVALIDATE|#SW_SCROLLCHILDREN)
EndIf
Case #VK_DOWN
Result = GetScrollPos_(hwnd, #SB_VERT)
If Result <= 999
SetScrollPos_(hwnd, #SB_VERT,Result+1,1)
ScrollWindowEx_(hwnd,0,-1,0,0,0,0,#SW_ERASE| #SW_INVALIDATE|#SW_SCROLLCHILDREN)
EndIf
Case #VK_PRIOR
Result = GetScrollPos_(hwnd, #SB_VERT)
If Result >= 1
SetScrollPos_(hwnd, #SB_VERT,Result-50,1)
ScrollWindowEx_(hwnd,0,50,0,0,0,0,#SW_ERASE| #SW_INVALIDATE|#SW_SCROLLCHILDREN)
EndIf
Case #VK_NEXT
Result = GetScrollPos_(hwnd, #SB_VERT)
If Result <= 999
SetScrollPos_(hwnd, #SB_VERT,Result+50,1)
ScrollWindowEx_(hwnd,0,-50,0,0,0,0,#SW_ERASE| #SW_INVALIDATE|#SW_SCROLLCHILDREN)
EndIf
EndSelect
EndSelect
ProcedureReturn result
EndProcedure
Min = 0
Max = 2000
OpenWindow(0,0,0,800,600,"Scroll Window Client Area",#PB_Window_SystemMenu| #WS_HSCROLL| #WS_VSCROLL| #PB_Window_ScreenCentered| #PB_Window_MaximizeGadget| #PB_Window_SizeGadget)
SetWindowColor(0,$000000)
SetScrollRange_(WindowID(0),#SB_VERT,Min,Max,1)
SetScrollRange_(WindowID(0),#SB_HORZ,Min,Max,1)
OpenWindowedScreen(WindowID(0),0,0,2000,2000)
CreateSprite(0, 20, 20)
If StartDrawing(SpriteOutput(0))
Box(0, 0, 20, 20, RGB(255, 0, 155))
Box(5, 5, 10, 10, RGB(155, 0, 255))
StopDrawing()
EndIf
SetWindowCallback(@WndProc())
direction = 2
Repeat
; It's very important to process all the events remaining in the queue at each frame
;
Repeat
Event = WindowEvent()
Select Event
Case #PB_Event_Gadget
If EventGadget() = 0
End
EndIf
Case #PB_Event_CloseWindow
End
EndSelect
Until Event = 0
FlipBuffers()
ClearScreen(RGB(0, 0, 0))
DisplaySprite(0, x, x)
x + direction
If x > 140 : direction = -2 : EndIf
If x < 0 : direction = 2 : EndIf
Delay(1)
ForEver
Egypt my love
Re: Windowed screen inside a ScrollArea Gadget?
Hey RASHAD!
This is exactly what I'm was searching for! THANK YOU VERY MUCH MATE!!
Never thought that it is that complex to just scroll the WindowedScreen.
Shouldn't this be handled by PB by default?
This is exactly what I'm was searching for! THANK YOU VERY MUCH MATE!!
Never thought that it is that complex to just scroll the WindowedScreen.
Shouldn't this be handled by PB by default?
Tranquil
Re: Windowed screen inside a ScrollArea Gadget?
Hi Tranquil
I just got a thought ,tried it and it works
It maybe much simpler for you
PB 5.22 x86 - Win 8.1 x64
Have fun
I just got a thought ,tried it and it works
It maybe much simpler for you
PB 5.22 x86 - Win 8.1 x64
Have fun
Code: Select all
InitSprite()
OpenWindow(0,0,0,800,600,"",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
MDIGadget(0,-10,-40,810,640,0,0)
AddGadgetItem(0,1,"Test")
OpenWindowedScreen(WindowID(1),0,0,2000,2000)
CreateSprite(0, 20, 20)
If StartDrawing(SpriteOutput(0))
Box(0, 0, 20, 20, RGB(255, 0, 155))
Box(5, 5, 10, 10, RGB(155, 0, 255))
StopDrawing()
EndIf
ResizeWindow(1,0,0,2000,2000)
direction = 2
Repeat
; It's very important to process all the events remaining in the queue at each frame
;
Repeat
Event = WindowEvent()
Select Event
Case #PB_Event_Gadget
If EventGadget() = 0
End
EndIf
Case #PB_Event_CloseWindow
End
EndSelect
Until Event = 0
FlipBuffers()
ClearScreen(RGB(0, 0, 0))
DisplaySprite(0, x, x)
x + direction
If x > 140 : direction = -2 : EndIf
If x < 0 : direction = 2 : EndIf
Delay(1)
ForEver
Egypt my love
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Windowed screen inside a ScrollArea Gadget?
Very nicely done Rashad - I thought it probably couldn't be done
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Windowed screen inside a ScrollArea Gadget?
Hi IdeasVacuum
Thanks
I still prefer method #1, It is so clean even it is complicated somehow
Thanks
I still prefer method #1, It is so clean even it is complicated somehow
Egypt my love