It is currently Mon Nov 20, 2017 1:13 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: [Solved] ListIconGadget() ~ How do I lock the scrollbars?
PostPosted: Wed Aug 16, 2017 9:47 am 
Offline
Enthusiast
Enthusiast

Joined: Sat Sep 11, 2004 11:54 am
Posts: 531
Location: UK
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


Last edited by RichardL on Thu Aug 17, 2017 3:45 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: ListIconGadget() ~ How do I temporarily lock the scrollb
PostPosted: Wed Aug 16, 2017 2:39 pm 
Offline
Addict
Addict

Joined: Sun Apr 12, 2009 6:27 am
Posts: 2842
Hi
Code:
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


Edit :Updated

_________________
Egypt my love


Last edited by RASHAD on Thu Aug 17, 2017 1:44 pm, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: ListIconGadget() ~ How do I temporarily lock the scrollb
PostPosted: Wed Aug 16, 2017 3:42 pm 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5686
Location: Wales, UK
A simple way is to temporarily make the ListIcon Scrollbars ineffective:
Code:
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: ListIconGadget() ~ How do I temporarily lock the scrollb
PostPosted: Wed Aug 16, 2017 3:53 pm 
Offline
Addict
Addict

Joined: Sun Apr 12, 2009 6:27 am
Posts: 2842
Noway
Populate the listicon and use the scrollbar buttons :wink:

_________________
Egypt my love


Top
 Profile  
Reply with quote  
 Post subject: Re: ListIconGadget() ~ How do I temporarily lock the scrollb
PostPosted: Wed Aug 16, 2017 5:25 pm 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5686
Location: Wales, UK
You are so right Rashad - different behavior when populated (strange).

This trick works though:
Code:
;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
Edited re Rashad's spot

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Last edited by IdeasVacuum on Wed Aug 16, 2017 5:51 pm, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: ListIconGadget() ~ How do I temporarily lock the scrollb
PostPosted: Wed Aug 16, 2017 5:45 pm 
Offline
Addict
Addict

Joined: Sun Apr 12, 2009 6:27 am
Posts: 2842
Yes it works but I am not sure about Windows XP as it acts differently with transparency

Wrong code to correct
Code:
SetWindowPos_(GadgetID(#Image), #HWND_TOP , 0, 0, 0, 0,  #SWP_NOMOVE | #SWP_NOSIZE | #SWP_FRAMECHANGED)

_________________
Egypt my love


Top
 Profile  
Reply with quote  
 Post subject: Re: ListIconGadget() ~ How do I temporarily lock the scrollb
PostPosted: Wed Aug 16, 2017 6:23 pm 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5686
Location: Wales, UK
Update for Rashad's code:
Code:
Case #WM_VSCROLL, #WM_HSCROLL, #WM_MOUSEWHEEL

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: ListIconGadget() ~ How do I temporarily lock the scrollb
PostPosted: Thu Aug 17, 2017 7:45 am 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 377
Location: Berlin and Ibiza
Update for Rashad's code:
Code:
Case #WM_VSCROLL, #WM_HSCROLL, #WM_MOUSEWHEEL, #WM_KEYDOWN

_________________
ImageImageImageImage


Top
 Profile  
Reply with quote  
 Post subject: Re: ListIconGadget() ~ How do I temporarily lock the scrollb
PostPosted: Thu Aug 17, 2017 10:09 am 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5686
Location: Wales, UK
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: ListIconGadget() ~ How do I temporarily lock the scrollb
PostPosted: Thu Aug 17, 2017 12:25 pm 
Offline
Enthusiast
Enthusiast

Joined: Sat Sep 11, 2004 11:54 am
Posts: 531
Location: UK
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


Top
 Profile  
Reply with quote  
 Post subject: Re: ListIconGadget() ~ How do I temporarily lock the scrollb
PostPosted: Thu Aug 17, 2017 1:39 pm 
Offline
Addict
Addict

Joined: Sun Apr 12, 2009 6:27 am
Posts: 2842
Hi guys
Previous post updated
Added more control upon ListIcon
Added Header control as well

_________________
Egypt my love


Top
 Profile  
Reply with quote  
 Post subject: Re: [Solved] ListIconGadget() ~ How do I lock the scrollbars
PostPosted: Thu Aug 17, 2017 3:47 pm 
Offline
Enthusiast
Enthusiast

Joined: Sat Sep 11, 2004 11:54 am
Posts: 531
Location: UK
Good afternoon,

Thank you Rashad... that works beautifully!

Best regards
RichardL


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye