Sorry for the clumsy wording of the question...
I'm pretty sure I saw this question asked and answered before, but I don't even know how to formulate my search intelligently enough to get an answer. I've tried — in vain — all I could think of.
Since words won't come to mind, allow me to use a picture :
How to obtain number of element at top of scrolling window
How to obtain number of element at top of scrolling window
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
"Oh! I see..." replied the blind man.
Re: How to obtain number of element at top of scrolling wind
Hello Blue
Code: Select all
OpenWindow(0,200,200,400,150,"Title", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
TreeGadget(1,0,0,400,150)
For t=1 To 50
AddGadgetItem(1,-1,"item : "+Str(t))
Next
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #WM_NCMOUSEMOVE
Position = SendMessage_(GadgetID(1), #WM_NCHITTEST, 0, DesktopMouseY()<<16 + DesktopMouseX())
Select Position
Case #HTVSCROLL
item = GetScrollPos_(GadgetID(1), #SB_VERT)+1
If item <> olditem
Debug "First Visible Item = " + Str(item)
EndIf
olditem = item
EndSelect
Case #WM_KEYUP
If GetActiveGadget() = 1 And (EventwParam() = 38 Or EventwParam() = 40)
item = GetScrollPos_(GadgetID(1), #SB_VERT)+1
If item <> olditem
Debug "First Visible Item = " + Str(item)
EndIf
olditem = item
EndIf
EndSelect
Until Quit = 1
Egypt my love
Re: How to obtain number of element at top of scrolling wind
RASHAD already posted two examples in this thread from 2013...Blue wrote:I'm pretty sure I saw this question asked and answered before, but I don't even know how to formulate my search intelligently enough to get an answer. I've tried — in vain — all I could think of.
And you posted already a similar question on how to detect the top visible row in a ListViewGadget in this thread. There I posted a cross-platform solution. I reduced the example to Windows-only code and modified it for the TreeGadget:
Code: Select all
Procedure.I GetVisibleTopRow(ListIconID.I)
Protected Item.TVITEM
Item\mask = #TVIF_PARAM
Item\hItem = SendMessage_(GadgetID(ListIconID), #TVM_GETNEXTITEM,
#TVGN_FIRSTVISIBLE, GadgetItemID(ListIconID, 0))
SendMessage_(GadgetID(TreeGadgetID), #TVM_GETITEM, 0, @Item)
ProcedureReturn Item\lParam
EndProcedure
OpenWindow(0, 100, 100, 200, 155, "")
TreeGadget(0, 10, 10, WindowWidth(0) - 20, WindowHeight(0) - 55)
ButtonGadget(1, 10, WindowHeight(0) - 35, WindowWidth(0) - 20, 25,
"Get current top row")
For i = 1 To 50
AddGadgetItem(0, -1, "Item " + Str(i))
Next i
SetWindowTitle(0, "Visible top row: " + Str(GetVisibleTopRow(0) + 1))
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
If EventGadget() = 1
SetWindowTitle(0, "Visible top row: " + Str(GetVisibleTopRow(0) + 1))
EndIf
EndSelect
ForEver
Re: How to obtain number of element at top of scrolling wind
Hello Blue, Having seen your post, I'm interested to know which software you used to show your example with the graphics and text added?
Also, have to say the solutions to your problem are absolutely first class. As it is so often the case in the PureB forum.
Cheers, C87
Also, have to say the solutions to your problem are absolutely first class. As it is so often the case in the PureB forum.
Cheers, C87
If it's falling over......just remember the computer is never wrong!
Re: How to obtain number of element at top of scrolling wind
Thanks Shardik
I did not remember any
I should save my posts and the other forum members posts with the URL.
Bad
Thanks also for your snippet
I did not remember any
I should save my posts and the other forum members posts with the URL.
Bad
Thanks also for your snippet
Egypt my love
Re: How to obtain number of element at top of scrolling wind
Extended version:
Code: Select all
EnableExplicit
Procedure.i GetVisibleFirstTreeItem(TreeGadget.i)
Protected Item.TVITEM
Item\mask = #TVIF_PARAM
Item\hItem = SendMessage_(GadgetID(TreeGadget), #TVM_GETNEXTITEM, #TVGN_FIRSTVISIBLE, GadgetItemID(TreeGadget, 0))
SendMessage_(GadgetID(TreeGadget), #TVM_GETITEM, 0, @Item)
ProcedureReturn Item\lParam
EndProcedure
Procedure.i GetVisibleTreeCount(TreeGadget.i)
ProcedureReturn SendMessage_(GadgetID(TreeGadget), #TVM_GETVISIBLECOUNT, 0, 0)
EndProcedure
Macro SetTitle()
Count = GetVisibleTreeCount(0)
SetWindowTitle(0, "Visible top row: " + Str(GetVisibleFirstTreeItem(0) + 1) + " " + Str(GetVisibleFirstTreeItem(0) + Count))
EndMacro
Define i.i, Count.i
OpenWindow(0, 100, 100, 200, 155, "", #PB_Window_SystemMenu|#PB_Window_SizeGadget)
WindowBounds(0, 200, 155, 200, #PB_Ignore)
TreeGadget(0, 10, 10, WindowWidth(0) - 20, WindowHeight(0) - 55)
ButtonGadget(1, 10, WindowHeight(0) - 35, WindowWidth(0) - 20, 25, "Get current top row")
For i = 1 To 50
AddGadgetItem(0, -1, "Item " + Str(i))
Next i
SetTitle()
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
If EventGadget() = 1
SetTitle()
EndIf
Case #PB_Event_SizeWindow
ResizeGadget(0, 10, 10, #PB_Ignore, WindowHeight(0) - 55)
ResizeGadget(1, 10, WindowHeight(0) - 35, #PB_Ignore, #PB_Ignore)
SetTitle()
EndSelect
ForEver
Re: How to obtain number of element at top of scrolling wind
I think Blue already mentioned it in another thread, it's "FastStone Capture v9". I like to use it, it also works well on very old PCs.C87 wrote:Hello Blue, Having seen your post, I'm interested to know which software you used to show your example with the graphics and text added?
Edit: viewtopic.php?p=537823#p537823
Peter
Re: How to obtain number of element at top of scrolling wind
Thank you to each of you.
With your enlightening contributions, I now have everything I need.
But they illustrate PB's major issue : i don't even have to think anymore!
Others do the thinking for me, and they do it so much better.
Seriously, though, had I searched for the word item instead of element, I would have found what I was looking for.
A special invitation to Shardik : there's a position open as Memory Manager in my brain. It's been vacant for a while now. It's yours for the asking... Meanwhile, your shocking exposé of my old post forced me to rediscover the "View your posts" function at the top right of each page. Very useful. Now, if I can only remember to use it....
With your enlightening contributions, I now have everything I need.
But they illustrate PB's major issue : i don't even have to think anymore!
Others do the thinking for me, and they do it so much better.
Seriously, though, had I searched for the word item instead of element, I would have found what I was looking for.
A special invitation to Shardik : there's a position open as Memory Manager in my brain. It's been vacant for a while now. It's yours for the asking... Meanwhile, your shocking exposé of my old post forced me to rediscover the "View your posts" function at the top right of each page. Very useful. Now, if I can only remember to use it....
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
"Oh! I see..." replied the blind man.
Re: How to obtain number of element at top of scrolling wind
Note to Shardik
Very interesting and imaginative solution, the way you use the window title as a display for the result that you're tracking. That never occurred to me before now, but I can see that, as a fast and dirty solution, it's hard to beat.
Thanks for a very interesting idea.
Very interesting and imaginative solution, the way you use the window title as a display for the result that you're tracking. That never occurred to me before now, but I can see that, as a fast and dirty solution, it's hard to beat.
Thanks for a very interesting idea.
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
"Oh! I see..." replied the blind man.