That works perfectly, but in my case the inner size is larger than the outer size - how to Center?#PB_ScrollArea_Center : If the inner size is smaller than the outer one,
then the inner area is automatically centered.
Center ScrollArea scroll bars
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Center ScrollArea scroll bars
From the Help:
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Center ScrollArea scroll bars
Code: Select all
SetGadgetAttribute(gadget,#PB_ScrollArea_Y,(inner_Y-outer_Y)/2)
SetGadgetAttribute(gadget,#PB_ScrollArea_X,(inner_X-outer_X)/2)
Egypt my love
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Center ScrollArea scroll bars
Rashad!
I was playing with:
SendMessage_(GadgetID(#MyScrlArea), #WM_VSCROLL, #SB_THUMBTRACK, 0)
....and you have a PB solution. Thankyou!
I was playing with:
SendMessage_(GadgetID(#MyScrlArea), #WM_VSCROLL, #SB_THUMBTRACK, 0)
....and you have a PB solution. Thankyou!
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Center ScrollArea scroll bars
Hmm - turns out that a tweak is needed. I have applied a tweak that looks right.......
Code: Select all
Enumeration
#Win
#Panel
#Scrl
#Canv
#Temp
EndEnumeration
If OpenWindow(#Win, 0, 0, 700, 650, "ScrollArea scrollbar positions", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ScrollBarGadget(#Temp, 0, 0, 0, 0, 0, 100, 100, #PB_ScrollBar_Vertical)
iScrlBarW = GadgetWidth(#Temp, #PB_Gadget_RequiredSize)
FreeGadget(#Temp)
SetWindowColor(#Win, RGB(240,240,240))
PanelGadget(#Panel, 1, 1, 698, 648)
AddGadgetItem(#Panel, -1, "Tab 0")
ScrollAreaGadget(#Scrl, 5, 40, 376, 570, 1000, 1000, 10, #PB_ScrollArea_BorderLess | #PB_ScrollArea_Center)
CanvasGadget(#Canv, 0, 0, 1000, 1000, #PB_Canvas_Container)
CloseGadgetList() ;#Canv
CloseGadgetList() ;#Scrl
StartDrawing(CanvasOutput(#Canv))
Box(0, 0, GadgetWidth(#Canv), GadgetHeight(#Canv), RGB(192,192,192))
LineXY(500, 0, 500, 1000, RGB(200,000,000))
LineXY( 0, 500, 1000, 500, RGB(200,000,000))
DrawingMode(#PB_2DDrawing_Outlined)
Box(332, 235, 336, 530, RGB(000,000,200))
StopDrawing()
SetGadgetAttribute(#Scrl, #PB_ScrollArea_X, ((1000 - 376) / 2) + (iScrlBarW / 2))
SetGadgetAttribute(#Scrl, #PB_ScrollArea_Y, ((1000 - 570) / 2) + (iScrlBarW / 2))
Repeat
Until WaitWindowEvent(1) = #PB_Event_CloseWindow
EndIf
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Center ScrollArea scroll bars
Right on
Suit all cases (Hal or Val scroll bar not exist)
Suit all cases (Hal or Val scroll bar not exist)
Code: Select all
Enumeration
#Win
#Panel
#Scrl
#Canv
#Temp
EndEnumeration
If OpenWindow(#Win, 0, 0, 700, 650, "ScrollArea scrollbar positions", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SetWindowColor(#Win, RGB(240,240,240))
PanelGadget(#Panel, 1, 1, 698, 648)
AddGadgetItem(#Panel, -1, "Tab 0")
ScrollAreaGadget(#Scrl, 5, 40, 376, 570, 1000, 1000, 10, #PB_ScrollArea_BorderLess | #PB_ScrollArea_Center)
CanvasGadget(#Canv, 0, 0, 1000, 1000, #PB_Canvas_Container)
CloseGadgetList() ;#Canv
CloseGadgetList() ;#Scrl
StartDrawing(CanvasOutput(#Canv))
Box(0, 0, GadgetWidth(#Canv), GadgetHeight(#Canv), RGB(192,192,192))
LineXY(500, 0, 500, 1000, RGB(200,000,000))
LineXY( 0, 500, 1000, 500, RGB(200,000,000))
DrawingMode(#PB_2DDrawing_Outlined)
Box(332, 235, 336, 530, RGB(000,000,200))
StopDrawing()
SetGadgetAttribute(#Scrl, #PB_ScrollArea_X, 1000)
hpos = GetGadgetAttribute(#Scrl, #PB_ScrollArea_X)
SetGadgetAttribute(#Scrl, #PB_ScrollArea_Y, 1000)
vpos = GetGadgetAttribute(#Scrl, #PB_ScrollArea_Y)
SetGadgetAttribute(#Scrl, #PB_ScrollArea_X, hpos/2)
SetGadgetAttribute(#Scrl, #PB_ScrollArea_Y, vpos/2)
Repeat
Until WaitWindowEvent(1) = #PB_Event_CloseWindow
EndIf
Egypt my love
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Center ScrollArea scroll bars
That's excellent Rashad - it really should be part of the built-in PB function.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Center ScrollArea scroll bars
+1 (if Fred sees this).IdeasVacuum wrote:it really should be part of the built-in PB function.