[Solved] ListIconGadget() ~ How do I lock the scrollbars?
[Solved] ListIconGadget() ~ How do I lock the scrollbars?
Good morning all,
My application allows the user to scroll around data in a ListIconGadget to select an area.
The user then presses a 'Go' button. At that point I need to lock the grid in position while some other processes happen.
DisableGadget() disrupts the display too much and is ruled out.
Any suggestions or help would be appreciated.
RichardL
My application allows the user to scroll around data in a ListIconGadget to select an area.
The user then presses a 'Go' button. At that point I need to lock the grid in position while some other processes happen.
DisableGadget() disrupts the display too much and is ruled out.
Any suggestions or help would be appreciated.
RichardL
Last edited by RichardL on Thu Aug 17, 2017 3:45 pm, edited 1 time in total.
Re: ListIconGadget() ~ How do I temporarily lock the scrollb
Hi
Edit :Updated
Code: Select all
Global oldliCB,oldhCB,scrollflag
Procedure lihCB(hWnd, uMsg, wParam, lParam)
Select uMsg
Case #WM_LBUTTONDOWN,#WM_LBUTTONDBLCLK
If scrollflag = 1
ProcedureReturn 1
EndIf
EndSelect
ProcedureReturn CallWindowProc_(oldhCB, hWnd, uMsg, wParam, lParam)
EndProcedure
Procedure liCB(hWnd, uMsg, wParam, lParam)
Select uMsg
Case #WM_LBUTTONDOWN,#WM_VSCROLL,#WM_HSCROLL, #WM_MOUSEWHEEL,#WM_KEYDOWN
If scrollflag = 1
ProcedureReturn 1
EndIf
EndSelect
ProcedureReturn CallWindowProc_(oldliCB, hWnd, uMsg, wParam, lParam)
EndProcedure
Procedure sizeCB()
ResizeGadget(2,5,30,WindowWidth(0)-10,WindowHeight(0)-35)
EndProcedure
OpenWindow(0,0,0,320,275,"void",#PB_Window_SystemMenu | #PB_Window_ScreenCentered|#PB_Window_SizeGadget)
ButtonGadget(0,5,5,150,20,"Disable Scroll")
ButtonGadget(1,165,5,150,20,"Enable Scroll")
ListIconGadget(2,5,30,310,240,"Name",280, #PB_ListIcon_MultiSelect|#PB_ListIcon_AlwaysShowSelection)
Header = SendMessage_(GadgetID(2), #LVM_GETHEADER, 0, 0)
For i=1 To 30 : AddGadgetItem(2,-1,"Gadget Item #" + Str(i)) : Next
SetGadgetItemColor(2, -1, #PB_Gadget_FrontColor, $0000FF, 0)
oldliCB = SetWindowLongPtr_(GadgetID(2), #GWL_WNDPROC, @liCB())
oldhCB = SetWindowLongPtr_(header, #GWL_WNDPROC, @lihCB())
BindEvent(#PB_Event_SizeWindow,@sizeCB())
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 0
SetActiveGadget(2)
scrollflag = 1
Case 1
SetActiveGadget(2)
scrollflag = 0
EndSelect
EndSelect
Until Quit = 1
Last edited by RASHAD on Thu Aug 17, 2017 1:44 pm, edited 2 times in total.
Egypt my love
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: ListIconGadget() ~ How do I temporarily lock the scrollb
A simple way is to temporarily make the ListIcon Scrollbars ineffective:
Code: Select all
Enumeration
#Win
#ListIcon
#BtnOff
#BtnOn
EndEnumeration
Procedure Win()
;#-------------
If OpenWindow(#Win, 0, 0, 500, 300, "Temporarily Freeze ListIcon", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(#ListIcon, 0, 0, 500, 250, "Col 0", 100)
AddGadgetColumn(#ListIcon, 1, "Col 1", 100)
AddGadgetColumn(#ListIcon, 2, "Col 2", 100)
AddGadgetColumn(#ListIcon, 3, "Col 3", 100)
AddGadgetColumn(#ListIcon, 4, "Col 4", 100)
AddGadgetColumn(#ListIcon, 5, "Col 5", 100)
AddGadgetColumn(#ListIcon, 6, "Col 6", 100)
AddGadgetColumn(#ListIcon, 7, "Col 7", 100)
AddGadgetColumn(#ListIcon, 8, "Col 8", 100)
ButtonGadget(#BtnOff, 334, 255, 80, 40, "OFF")
ButtonGadget(#BtnOn, 418, 255, 80, 40, "ON")
EndIf
EndProcedure
Procedure Wait()
;#--------------
iExit.i = #False
Repeat
Select WaitWindowEvent(1)
Case #PB_Event_CloseWindow: iExit = #True
Case #PB_Event_Gadget
Select EventGadget()
Case #BtnOff: SendMessage_(GadgetID(#ListIcon), #WM_SETREDRAW, 0, 0)
Case #BtnOn: SendMessage_(GadgetID(#ListIcon), #WM_SETREDRAW, 1, 0)
EndSelect
EndSelect
Until iExit = #True
EndProcedure
Win()
Wait()
End
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: ListIconGadget() ~ How do I temporarily lock the scrollb
Noway
Populate the listicon and use the scrollbar buttons
Populate the listicon and use the scrollbar buttons
Egypt my love
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: ListIconGadget() ~ How do I temporarily lock the scrollb
You are so right Rashad - different behavior when populated (strange).
This trick works though:
[/size] Edited re Rashad's spot
This trick works though:
Code: Select all
;16/08/2017 15:29:49
Enumeration
#Win
#ListIcon
#Image
#BtnOff
#BtnOn
#Mask
EndEnumeration
CreateImage(#Mask, 500, 250, 32, #PB_Image_Transparent)
Procedure Win()
;#-------------
Protected iRow.i, iCol.i
Protected sRow.s
If OpenWindow(#Win, 0, 0, 500, 300, "Temporarily Freeze ListIcon", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(#ListIcon, 0, 0, 500, 250, "Col 0", 100)
ImageGadget(#Image, 0, 0, 500, 250, ImageID(#Mask))
HideGadget(#Image, #True)
AddGadgetColumn(#ListIcon, 1, "Col 1", 100)
AddGadgetColumn(#ListIcon, 2, "Col 2", 100)
AddGadgetColumn(#ListIcon, 3, "Col 3", 100)
AddGadgetColumn(#ListIcon, 4, "Col 4", 100)
AddGadgetColumn(#ListIcon, 5, "Col 5", 100)
AddGadgetColumn(#ListIcon, 6, "Col 6", 100)
AddGadgetColumn(#ListIcon, 7, "Col 7", 100)
AddGadgetColumn(#ListIcon, 8, "Col 8", 100)
ButtonGadget(#BtnOff, 334, 255, 80, 40, "OFF")
ButtonGadget(#BtnOn, 418, 255, 80, 40, "ON")
For iRow = 0 To 99
sRow = ""
For iCol = 0 To 8
sRow = sRow + "Col " + RSet(Str(iCol), 2, "0") + " Row " + RSet(Str(iRow), 2, "0") + #LF$
Next iCol
AddGadgetItem(#ListIcon, -1, sRow)
Next iRow
EndIf
EndProcedure
Procedure Wait()
;#--------------
iExit.i = #False
Repeat
Select WaitWindowEvent(1)
Case #PB_Event_CloseWindow: iExit = #True
Case #PB_Event_Gadget
Select EventGadget()
Case #BtnOff
HideGadget(#Image, #False)
SetWindowPos_(GadgetID(#Image), #HWND_TOP, 0, 0, 0, 0, #SWP_NOMOVE | #SWP_NOSIZE | #SWP_FRAMECHANGED)
Case #BtnOn: HideGadget(#Image, #True)
EndSelect
EndSelect
Until iExit = #True
EndProcedure
Win()
Wait()
End
Last edited by IdeasVacuum on Wed Aug 16, 2017 5:51 pm, edited 2 times in total.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: ListIconGadget() ~ How do I temporarily lock the scrollb
Yes it works but I am not sure about Windows XP as it acts differently with transparency
Wrong code to correct
Wrong code to correct
Code: Select all
SetWindowPos_(GadgetID(#Image), #HWND_TOP , 0, 0, 0, 0, #SWP_NOMOVE | #SWP_NOSIZE | #SWP_FRAMECHANGED)
Egypt my love
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: ListIconGadget() ~ How do I temporarily lock the scrollb
Update for Rashad's code:
Code: Select all
Case #WM_VSCROLL, #WM_HSCROLL, #WM_MOUSEWHEEL
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
- RSBasic
- Moderator
- Posts: 1218
- Joined: Thu Dec 31, 2009 11:05 pm
- Location: Gernsbach (Germany)
- Contact:
Re: ListIconGadget() ~ How do I temporarily lock the scrollb
Update for Rashad's code:
Code: Select all
Case #WM_VSCROLL, #WM_HSCROLL, #WM_MOUSEWHEEL, #WM_KEYDOWN
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: ListIconGadget() ~ How do I temporarily lock the scrollb
I think the ImageGadget mask is the best method because from a User perspective, the ListIcon is completely frozen, you can't scroll inside the list and the scroll bars do not move. So, they see a 'Read only' view and the data can still be changed programmatically.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: ListIconGadget() ~ How do I temporarily lock the scrollb
Gentlemen,
Thank you all for your assistance, it is much appreciated.
I have used Rashad's solution because, most conveniently I already had the necessary callback procedure and flag in place (and the right way up!).
All I needed to do was patch in a few lines from Rashad's example.
The solution is perfect... well almost! Would it be possible to prevent column dragging and resizing as well?
Best regards
RichardL
Thank you all for your assistance, it is much appreciated.
I have used Rashad's solution because, most conveniently I already had the necessary callback procedure and flag in place (and the right way up!).
All I needed to do was patch in a few lines from Rashad's example.
The solution is perfect... well almost! Would it be possible to prevent column dragging and resizing as well?
Best regards
RichardL
Re: ListIconGadget() ~ How do I temporarily lock the scrollb
Hi guys
Previous post updated
Added more control upon ListIcon
Added Header control as well
Previous post updated
Added more control upon ListIcon
Added Header control as well
Egypt my love
Re: [Solved] ListIconGadget() ~ How do I lock the scrollbars
Good afternoon,
Thank you Rashad... that works beautifully!
Best regards
RichardL
Thank you Rashad... that works beautifully!
Best regards
RichardL