ListIconGadget scrollbar width
ListIconGadget scrollbar width
Does anyone know how to get the width in pixels of the vertical scroll bar of a listicongadget? I need to know the width of the listicongadget minus the scroll bar. Thanks in advance.
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
On Windows, you can do it like this:
Code: Select all
width = GetSystemMetrics_(#SM_CXVSCROLL)
BERESHEIT
-
- Enthusiast
- Posts: 628
- Joined: Fri Feb 20, 2009 9:24 am
- Location: Almaty (Kazakhstan. not Borat, but Triple G)
- Contact:
Re: ListIconGadget scrollbar width
i want to make bigger scrollbar more width than standart, but this param make width whole windows scrollbars, but i want to make it with only one my ListIconGadget in my programm. can you help?
Re: ListIconGadget scrollbar width
Hi,
here is an example how to get the default width of a system scrollbar:
Best regards
Uwe
here is an example how to get the default width of a system scrollbar:
Code: Select all
Procedure SystemScrollBarWidth()
;returns the width of a system scrollbar
Protected sb = ScrollBarGadget(#PB_Any, 0, 0, 0, 0, 0, 100, 1, #PB_ScrollBar_Vertical)
Protected width = GadgetWidth(sb, #PB_Gadget_RequiredSize)
FreeGadget(sb)
ProcedureReturn width
EndProcedure
If OpenWindow(0, 0, 0, 400, 300, "Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
Debug SystemScrollBarWidth()
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
EndIf
Uwe
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: ListIconGadget scrollbar width
Fluid Byte worked on this some time back. (It isn't trivial): http://www.purebasic.fr/english/viewtopic.php?p=282837SeregaZ wrote:i want to make bigger scrollbar more width than standart, but this param make width whole windows scrollbars, but i want to make it with only one my ListIconGadget in my programm. can you help?
BERESHEIT
Re: ListIconGadget scrollbar width
Workaround
Hal.ScrollBar gadget needs a lot of work to do for page length
and when it should be visible or not
Have fun
Hal.ScrollBar gadget needs a lot of work to do for page length
and when it should be visible or not
Have fun
Code: Select all
Global Backg
Backg = CreateSolidBrush_($DFFFDD)
Procedure WindowCallback(WindowHandle, Msg, WParam, LParam)
Shared RowHeight
Static LastIndex
Protected Result = #PB_ProcessPureBasicEvents
Select Msg
Case #WM_PAINT
Case #WM_CTLCOLORSCROLLBAR
Result = Backg
Case #WM_HSCROLL
Case #WM_VSCROLL
CurrentIndex = GetGadgetState(3)
SendMessage_(GadgetID(1), #LVM_SCROLL, 0, (CurrentIndex - LastIndex) * RowHeight)
LastIndex = CurrentIndex
EndSelect
ProcedureReturn Result
EndProcedure
LoadFont(0,"Tahoma",10)
If OpenWindow(0, 0, 0, 600, 400, "Custom ListIcon Gadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ContainerGadget(0,10,10,540,364,#PB_Container_BorderLess)
ListIconGadget(1,-1, -1, 600,400, "Column 0", 180,#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect)
CloseGadgetList()
SetGadgetFont(1,FontID(0))
ScrollBarGadget (3, 551 ,11, 40, 364, 0, 100, 30,#PB_ScrollBar_Vertical )
FrameGadget(4,9,9,584,366,"",#PB_Frame_Single)
SetGadgetColor(1,#PB_Gadget_BackColor,$F1FEFD)
SetGadgetColor(1,#PB_Gadget_FrontColor,$F90A01)
AddGadgetColumn(1, 1, "Column 1", 180)
AddGadgetColumn(1, 2, "Column 2", 180)
AddGadgetColumn(1, 3, "Column 3", 150)
For i = 1 To 100
AddGadgetItem(1, -1, "Line " + Str(i) + ", Column 1" + #LF$ + "Line " + Str(i) + ", Column 2")
Next i
NumVisibleRows = SendMessage_(GadgetID(1), #LVM_GETCOUNTPERPAGE, 0, 0)
SetGadgetAttribute(3, #PB_ScrollBar_PageLength, NumVisibleRows)
RowHeight = SendMessage_(GadgetID(1), #LVM_GETITEMSPACING, #True, 0) >> 16
; r.RECT
; r\left = #LVIR_BOUNDS
; SendMessage_(GadgetID(1), #LVM_GETITEMRECT, 0, r)
SetWindowCallback(@WindowCallback())
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
DeleteObject_(BackgroundBrush)
EndIf
Egypt my love
-
- Enthusiast
- Posts: 628
- Joined: Fri Feb 20, 2009 9:24 am
- Location: Almaty (Kazakhstan. not Borat, but Triple G)
- Contact:
Re: ListIconGadget scrollbar width
RASHAD, as i can understand you create near ListIconGadget the external ScrollBarGadget and synchronize them?
so i must to make some reaction for up\down and mouse wheel buttons? and fix showing last element in ListIconGadget? (now it shows 99, not 100. last one can be selected in not see area)
so i must to make some reaction for up\down and mouse wheel buttons? and fix showing last element in ListIconGadget? (now it shows 99, not 100. last one can be selected in not see area)
Re: ListIconGadget scrollbar width
You actually need GetSystemMetrics_(#SM_CXVSCROLL)+GetSystemMetrics_(#SM_CXDRAG)
to get a pixel-perfect scrollbar width. Take a look at the proof below. Only adding these two
together results in NO horizontal scrollbar appearing, because the width of both #SM flags is
just right:
to get a pixel-perfect scrollbar width. Take a look at the proof below. Only adding these two
together results in NO horizontal scrollbar appearing, because the width of both #SM flags is
just right:
Code: Select all
Procedure SystemScrollBarWidth()
;returns the width of a system scrollbar
Protected sb = ScrollBarGadget(#PB_Any, 0, 0, 0, 0, 0, 100, 1, #PB_ScrollBar_Vertical)
Protected width = GadgetWidth(sb, #PB_Gadget_RequiredSize)
FreeGadget(sb)
ProcedureReturn width
EndProcedure
If OpenWindow(0, 0, 0, 640, 270, "Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
test1=SystemScrollBarWidth()
ListIconGadget(1,10,10,200,250,"SystemScrollBarWidth()",200-test1)
For a=1 To 50 : AddGadgetItem(1,-1,Str(a)) : Next
test2=GetSystemMetrics_(#SM_CXVSCROLL)
ListIconGadget(2,220,10,200,250,"#SM_CXVSCROLL",200-test2)
For a=1 To 50 : AddGadgetItem(2,-1,Str(a)) : Next
test3=GetSystemMetrics_(#SM_CXVSCROLL)+GetSystemMetrics_(#SM_CXDRAG)
ListIconGadget(3,430,10,200,250,"#SM_CXVSCROLL+#SM_CXDRAG",200-test3)
For a=1 To 50 : AddGadgetItem(3,-1,Str(a)) : Next
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
EndIf
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
Re: ListIconGadget scrollbar width
- Mouse wheel support
- Keyboard Up & Down support
- Auto dimensions
- Keyboard Up & Down support
- Auto dimensions
Code: Select all
Global Backg,oldCallback
Backg = CreateSolidBrush_($DFFFDD)
Procedure LIcallback(hWnd, uMsg, Wparam, Lparam)
result = CallWindowProc_(oldCallback, hWnd, uMsg, Wparam, Lparam)
Select uMsg
Case #WM_VSCROLL,#WM_MOUSEWHEEL,#WM_KEYDOWN ,#WM_MENUSELECT
SetGadgetState(3, GetScrollPos_(GadgetID(1),#SB_VERT) )
EndSelect
ProcedureReturn result
EndProcedure
Procedure WindowCallback(hWnd, uMsg, WParam, LParam)
Shared RowHeight
Static LastIndex
Protected Result = #PB_ProcessPureBasicEvents
Select uMsg
Case #WM_CTLCOLORSCROLLBAR
Result = Backg
Case #WM_VSCROLL
CurrentIndex = GetGadgetState(3)
SendMessage_(GadgetID(1), #LVM_SCROLL, 0 , (CurrentIndex - LastIndex) * RowHeight)
LastIndex = CurrentIndex
EndSelect
ProcedureReturn Result
EndProcedure
LoadFont(0,"Tahoma",10)
LiconWidth = 580
LiconHeight = 380
ScrollbarWidth = 40
Liscrollwidth = GetSystemMetrics_(#SM_CXVSCROLL)+2
If OpenWindow(0, 0, 0, 600, 400, "Custom ListIcon Gadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ContainerGadget(0,10,10,LiconWidth-ScrollbarWidth,LiconHeight-Liscrollwidth,#PB_Container_BorderLess)
ListIconGadget(1,-1, -1, LiconWidth,LiconHeight, "Column 0", 180,#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect)
CloseGadgetList()
SetGadgetFont(1,FontID(0))
ScrollBarGadget (3, GadgetX(0)+GadgetWidth(0)+1 ,GadgetY(0)+1, ScrollbarWidth, GadgetHeight(0), 0, 100, 30,#PB_ScrollBar_Vertical )
FrameGadget(4,GadgetX(0)-1,GadgetY(0)-1,GadgetWidth(0)+GadgetWidth(3)+4,GadgetHeight(0)+4,"",#PB_Frame_Single)
SetGadgetColor(1,#PB_Gadget_BackColor,$F1FEFD)
SetGadgetColor(1,#PB_Gadget_FrontColor,$F90A01)
AddGadgetColumn(1, 1, "Column 1", 180)
AddGadgetColumn(1, 2, "Column 2", 180)
AddGadgetColumn(1, 3, "Column 3", 150)
For i = 1 To 100
AddGadgetItem(1, -1, "Line " + Str(i) + ", Column 1" + #LF$ + "Line " + Str(i) + ", Column 2")
Next i
NumVisibleRows = SendMessage_(GadgetID(1), #LVM_GETCOUNTPERPAGE, 0, 0)
SetGadgetAttribute(3, #PB_ScrollBar_PageLength, NumVisibleRows)
RowHeight = SendMessage_(GadgetID(1), #LVM_GETITEMSPACING, #True, 0) >> 16
oldCallback = SetWindowLongPtr_(GadgetID(1), #GWL_WNDPROC, @LIcallback())
SetWindowCallback(@WindowCallback())
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
DeleteObject_(Backg)
EndIf
Egypt my love
-
- Enthusiast
- Posts: 628
- Joined: Fri Feb 20, 2009 9:24 am
- Location: Almaty (Kazakhstan. not Borat, but Triple G)
- Contact:
Re: ListIconGadget scrollbar width
by arrows of mouse wheel - we cant reach end of scrollbar, so i thins we need do some like this:
i mean when we see last page - move scrollbar at 100% end.
thanks a lot
i am will spend many time for it, but you is save my time 
Code: Select all
Procedure LIcallback(hWnd, uMsg, Wparam, Lparam)
result = CallWindowProc_(oldCallback, hWnd, uMsg, Wparam, Lparam)
Select uMsg
Case #WM_VSCROLL,#WM_MOUSEWHEEL,#WM_KEYDOWN ,#WM_MENUSELECT
ScrollPos = SetGadgetState(3, GetScrollPos_(GadgetID(1),#SB_VERT) )
if CountGadgetItems(1) - ScrollPos < NumVisibleRows
SetGadgetState(3, GetScrollPos_(GadgetID(1),#SB_VERT) + NumVisibleRows )
else
SetGadgetState(3, GetScrollPos_(GadgetID(1),#SB_VERT) )
endif
EndSelect
ProcedureReturn result
EndProcedure
thanks a lot


-
- Enthusiast
- Posts: 628
- Joined: Fri Feb 20, 2009 9:24 am
- Location: Almaty (Kazakhstan. not Borat, but Triple G)
- Contact:
Re: ListIconGadget scrollbar width
one more left for perfect: now, when you make some select item on ListIconGadget and make some mouse wheel scroll to next page, when this select is hide over border of gadget, after few millisec this page is return to show select. it is some unpleasant jerking (make it fast - select, mouse wheel scroll to next page, release mouse, and this jerking will happen). it is possible for fix?
-
- Enthusiast
- Posts: 628
- Joined: Fri Feb 20, 2009 9:24 am
- Location: Almaty (Kazakhstan. not Borat, but Triple G)
- Contact:
Re: ListIconGadget scrollbar width
i want to make a few scrollbars over pictures. how to set for this scrollbar transparency?
Re: ListIconGadget scrollbar width
Remember to use your image name
Code: Select all
LoadImage(1,?????.bmp) ;Use your image Name
Backg = CreatePatternBrush_(ImageID(1))
Egypt my love
-
- Enthusiast
- Posts: 628
- Joined: Fri Feb 20, 2009 9:24 am
- Location: Almaty (Kazakhstan. not Borat, but Triple G)
- Contact:
Re: ListIconGadget scrollbar width
i see this example, but as i understand - it is for all window, so i need it only for some area... how to explain... hm...
so i have code, it is draw some spectr analize every milisec. so now i have 2 button for set green marker for each collumn. but i want to replace this 2 button by scrollbar. but this scrollbar will cover image and i cant see how this spectr moving. so i want to make transparency for this scrollbars.
so i have code, it is draw some spectr analize every milisec. so now i have 2 button for set green marker for each collumn. but i want to replace this 2 button by scrollbar. but this scrollbar will cover image and i cant see how this spectr moving. so i want to make transparency for this scrollbars.
Code: Select all
Enumeration
#imspektr
#Window_0
#TrackSensiv
#Buttonup01
#Buttondn01
EndEnumeration
Global column,width,height,color
Global Handle
Global TrackSensiv = 200
UsePNGImageDecoder()
x=50
y=10
column=200
width=7
height=200
h=1
color=RGB(243, 248, 252)
sdvig = 20
CreateImage(#imspektr,width,height)
Procedure Stroka() ; Индикация
Dim FFT.f(1024)
;BASS_ChannelGetData(Handle,@FFT(),#BASS_DATA_FFT2048)
For f=2 To column Step 2
Val = Sqr(FFT(f)) * TrackSensiv
StartDrawing(ImageOutput(#imspektr))
Box(0,0,20,height,RGB(14, 102, 212))
Box(0,50,20,5,RGB(0, 200, 0))
Box(0,height-Val,20,Val,color)
StopDrawing()
SetGadgetState(303+f,ImageID(#imspektr))
Next f
EndProcedure
If OpenWindow(#Window_0, 100, 200, 900, 500, "PureBasic Window", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
TrackBarGadget(#TrackSensiv, 850, 4+sdvig, 20, 213, 0, 400, #PB_TrackBar_Vertical)
SetGadgetState(#TrackSensiv, 200)
For f=2 To column Step 2
ImageGadget(303+f, x, y+sdvig, 0, 0, ImageID(#imspektr)) ;
ButtonGadget(1303+f, x, y+sdvig-width-2, width, 10, "")
ButtonGadget(2303+f, x, y+sdvig+200, width, 10, "")
x=x+(width+h)
Next f
SetTimer_(WindowID(#Window_0),100,35,@Stroka())
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case #TrackSensiv
TrackSensiv = GetGadgetState(#TrackSensiv)
EndSelect
EndSelect
Until Event = #PB_Event_CloseWindow
shag = 0
EndIf
End