Page 1 of 1

Modify SCROLLSTEP of a ScrollAreaGadget in live [Resolved]

Posted: Mon Jan 11, 2010 2:57 pm
by Kwai chang caine
Hello at all

I have create a simple ScrollAreaGadget with a StepValue of scrolling of 100, InsideWidth = 1000 and InsideHeight = 1500

Code: Select all

StepValue = 100
InsideWidth = 1000
InsideHeight = 1500

If OpenWindow(0, 0, 0, 305, 200, "ScrollAreaGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) 
 
 ScrollAreaGadget(0, 10, 10, 290, 120, InsideWidth, InsideHeight, StepValue)
  TextGadget(4,30,30, 230, 20,"Hello !",#PB_Text_Right)
 CloseGadgetList() 
      
 Repeat 
  Select WaitWindowEvent() 
   Case #PB_Event_CloseWindow 
    End 
  EndSelect 

 ForEver 

EndIf
But i want modify this value, in live after creating the ScrollArea

I have try ResizeGadget() but this function don't manage the "Option value" or all the value other the X, Y, Width, Height :(
How can i do for modify, the "StepValueScroll" or the "InsideWidth" and "InsideHeight"

Thanks and good day to you

Re: Modify option of gadget in live

Posted: Mon Jan 11, 2010 3:19 pm
by Arctic Fox
Try SetGadgetAttribute() for the width and height - see the manual for ScrollAreaGadget.
PureBasic Manual wrote:SetGadgetAttribute(): With one of the following attribute:
#PB_ScrollArea_InnerWidth : Changes the width (in pixels) of the contained scrollable area.
#PB_ScrollArea_InnerHeight : Changes the height (in pixels) of the contained scrollable area.
#PB_ScrollArea_X : Changes the current horizontal scrolling position (in pixels).
#PB_ScrollArea_Y : Changes the current vertical scrolling position (in pixels).

Re: Modify option of gadget in live

Posted: Mon Jan 11, 2010 4:07 pm
by Kwai chang caine
Hello ARTIC :D

Ouupps !!! i have search to change this option :

Resultat = ScrollAreaGadget(#Gadget, x, y, Largeur, Hauteur, LargeurZoneInterne, HauteurZoneInterne [, ValeurDeplacement [, Options]])

in the same time i ask to me, how can i change also the other ?

But with SetGadgetAttribute() i don't found how change the "StepScrollValue" (ValeurDeplacement) :oops:

Re: Modify option of gadget in live

Posted: Mon Jan 11, 2010 5:45 pm
by Kwai chang caine
Yes i confirm :oops:

Code: Select all

SetGadgetAttribute(): With one of the following attribute: 
#PB_ScrollArea_InnerWidth : Changes the width (in pixels) of the contained scrollable area.
#PB_ScrollArea_InnerHeight : Changes the height (in pixels) of the contained scrollable area.
#PB_ScrollArea_X : Changes the current horizontal scrolling position (in pixels).
#PB_ScrollArea_Y : Changes the current vertical scrolling position (in pixels).
For that, it's OK 8)

But i don't know, how say in english this option, when i have creating this THREAD
So i have seeing on the US online documentation and see that :

ScrollAreaGadget(#Gadget, x, y, Width, Height, ScrollAreaWidth, ScrollAreaHeight [, ScrollStep [, Flags]])

SetGadgetAttribute() can't change this option ScrollStep :(

Re: Modify SCROLLSTEP of a ScrollAreaGadget in live

Posted: Mon Jan 11, 2010 6:26 pm
by srod
I don't think you can Kwai.

I'd put in a feature request if I were you.

Re: Modify SCROLLSTEP of a ScrollAreaGadget in live

Posted: Tue Jan 12, 2010 3:31 am
by netmaestro
srod wrote:I don't think you can Kwai.
I'm going to pretend I didn't hear that :shock:

It can be managed by setting the initial step value at 0, then handling the stepping in a subclass procedure.

Change the value in the string gadget and test:

Code: Select all

Procedure ScrollAreaProc(hwnd, msg, wparam, lparam)
  oldproc = GetProp_(hwnd, "oldproc")
  stepvalue = GetProp_(hwnd, "stepvalue")
  
  Select msg
    Case #WM_NCDESTROY
      RemoveProp_(hwnd, "oldproc")
      RemoveProp_(hwnd, "stepvalue")
      
    Case #WM_VSCROLL
      If wparam&$FFFF = #SB_LINEDOWN 
        h = GetScrollPos_(hwnd, #SB_VERT)
        SetScrollPos_(hwnd, #SB_VERT,h+stepvalue,1)
      ElseIf wparam & $FFFF = #SB_LINEUP
        h = GetScrollPos_(hwnd, #SB_VERT)
        SetScrollPos_(hwnd, #SB_VERT,h-stepvalue,1)
      EndIf
      
    Case #WM_HSCROLL
      If wparam&$FFFF = #SB_LINERIGHT
        h = GetScrollPos_(hwnd, #SB_HORZ)
        SetScrollPos_(hwnd, #SB_HORZ,h+stepvalue,1)
      ElseIf wparam & $FFFF = #SB_LINELEFT
        h = GetScrollPos_(hwnd, #SB_HORZ)
        SetScrollPos_(hwnd, #SB_HORZ,h-stepvalue,1)
      EndIf
      
  EndSelect   
  ProcedureReturn CallWindowProc_(oldproc, hwnd, msg, wparam, lparam)
EndProcedure


If OpenWindow(0, 0, 0, 550, 550, "ScrollAreaGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

   hwnd = ScrollAreaGadget(0, 10, 10, 500,500, 1000, 1000, 0)
      ButtonGadget  (1, 10, 10, 230, 30,"Button 1")
      ButtonGadget  (2, 80, 100, 230, 30,"Button 2")
      ButtonGadget  (3, 140, 200, 230, 30,"Button 3")
      TextGadget    (4, 200, 300, 230, 20,"This is the content of a ScrollAreaGadget!",#PB_Text_Right)
      TextGadget    (5, 200,400,60,20,"Step Value:")
      StringGadget  (6, 260,400,40,20,"10")
      CloseGadgetList()
      
      SetProp_(hwnd, "oldproc", SetWindowLongPtr_(hwnd, #GWL_WNDPROC, @ScrollAreaProc()))
      SetProp_(hwnd, "stepvalue", 10)
    
    Repeat
      Select WaitWindowEvent()
        Case  #PB_Event_CloseWindow
          End
        Case  #PB_Event_Gadget
          Select EventGadget()
            Case 1
              MessageRequester("Info","Button 1 was pressed!",#PB_MessageRequester_Ok)
            Case 2
              MessageRequester("Info","Button 2 was pressed!",#PB_MessageRequester_Ok)
            Case 3
              MessageRequester("Info","Button 3 was pressed!",#PB_MessageRequester_Ok)
            Case 6
              If EventType() = #PB_EventType_Change 
                SetProp_(GadgetID(0), "stepvalue", Val(GetGadgetText(6)))
              EndIf
          EndSelect
      EndSelect
    ForEver
  EndIf
[edit] I just fell for another srod "free code generator" ruse, didn't I? :evil:

Re: Modify SCROLLSTEP of a ScrollAreaGadget in live

Posted: Tue Jan 12, 2010 10:59 am
by Kwai chang caine
Hello my two favorite MASTERS :D
I'm so proud to see you together for help the poor KCC 8)

For a time, KCC ask a question impossible for the GREAT SROD :shock:
KCC is the champion of impossible answers :mrgreen:
Master NETMAESTRO wrote:I just fell for another srod "free code generator" ruse, didn't I?
Or perhaps you are right :roll:
Perhaps, the GREAT SROD, is so tired to pull his "ball and chain" since several years :oops:
And perhaps, he want give his faithful IDIOT fan , at another MASTER :roll:

Because two of the most great MASTERS of the PB, is sometime not too much, to answer stupid questions of KCC :oops:

So i thanks you very much to your jewel code 8)
The proof why SROD is tired of KCC, KCC copy and paste your jewel....and that not works with him (W2000 v4.40) :oops:
I'm really a mule :oops:

Re: Modify SCROLLSTEP of a ScrollAreaGadget in live

Posted: Tue Jan 12, 2010 11:50 am
by srod
Well I obviously meant that you couldn't do it with PB commands alone.

By setting the scrollstep to zero you are in effect destroying the scrollwheel functionality. You will thus need to alter the subclassing procedure in order to account for this.

Re: Modify SCROLLSTEP of a ScrollAreaGadget in live

Posted: Tue Jan 12, 2010 12:01 pm
by Kwai chang caine
MyMASTER wrote:I'd put in a feature request if I were you.
Like a good student..i have do like you have say :D http://www.purebasic.fr/english/viewtop ... 50#p312050


My MASTER wrote:You will thus need to alter the subclassing procedure in order to account for this.
In the kitchen sink head of KCC your explanation is exactely like that
My MASTER wrote:You will thus need to Chong kwan chin, #%*µ"/12585385 bruce lee bot bling mao tsé toung bong king kong.
SROD...i love you .....you know that.... 8)
But i'm not chinese :(

Re: Modify SCROLLSTEP of a ScrollAreaGadget in live

Posted: Tue Jan 12, 2010 12:21 pm
by srod

Code: Select all

#WHEEL_DELTA = 120

Procedure ScrollAreaProc(hwnd, msg, wparam, lparam)
  oldproc = GetProp_(hwnd, "oldproc")
  stepvalue = GetProp_(hwnd, "stepvalue")
  
  Select msg
    Case #WM_NCDESTROY
      RemoveProp_(hwnd, "oldproc")
      RemoveProp_(hwnd, "stepvalue")
      
    Case #WM_VSCROLL
      If wparam&$FFFF = #SB_LINEDOWN 
        h = GetScrollPos_(hwnd, #SB_VERT)
        SetScrollPos_(hwnd, #SB_VERT,h+stepvalue,1)
      ElseIf wparam & $FFFF = #SB_LINEUP
        h = GetScrollPos_(hwnd, #SB_VERT)
        SetScrollPos_(hwnd, #SB_VERT,h-stepvalue,1)
      EndIf
      
    Case #WM_HSCROLL
      If wparam&$FFFF = #SB_LINERIGHT
        h = GetScrollPos_(hwnd, #SB_HORZ)
        SetScrollPos_(hwnd, #SB_HORZ,h+stepvalue,1)
      ElseIf wparam & $FFFF = #SB_LINELEFT
        h = GetScrollPos_(hwnd, #SB_HORZ)
        SetScrollPos_(hwnd, #SB_HORZ,h-stepvalue,1)
      EndIf
      
  EndSelect   
  ProcedureReturn CallWindowProc_(oldproc, hwnd, msg, wparam, lparam)
EndProcedure


Procedure ScrollAreaPanelProc(hwnd, msg, wparam, lparam)
  Protected zDelta.w, schWnd
  oldproc = GetProp_(hwnd, "oldproc")
  stepvalue = GetProp_(hwnd, "stepvalue")
  
  Select msg
    Case #WM_NCDESTROY
      RemoveProp_(hwnd, "oldproc")
      RemoveProp_(hwnd, "stepvalue")

    Case #WM_MOUSEWHEEL
      ;Obtain the wheel increment in units of #WHEEL_DELTA (120).
        zDelta = wParam>>16&$ffff
        zDelta / #WHEEL_DELTA
      If zDelta
        schWnd = GadgetID(0)
        h = GetScrollPos_(schWnd, #SB_VERT)
        SetScrollPos_(schWnd, #SB_VERT,h-zDelta*stepvalue,1)
      EndIf
      
  EndSelect   
  ProcedureReturn CallWindowProc_(oldproc, hwnd, msg, wparam, lparam)
EndProcedure


If OpenWindow(0, 0, 0, 550, 550, "ScrollAreaGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

   hwnd = ScrollAreaGadget(0, 10, 10, 500,500, 1000, 1000, 0)
      ButtonGadget  (1, 10, 10, 230, 30,"Button 1")
      ButtonGadget  (2, 80, 100, 230, 30,"Button 2")
      ButtonGadget  (3, 140, 200, 230, 30,"Button 3")
      TextGadget    (4, 200, 300, 230, 20,"This is the content of a ScrollAreaGadget!",#PB_Text_Right)
      TextGadget    (5, 200,400,60,20,"Step Value:")
      StringGadget  (6, 260,400,40,20,"10")
      CloseGadgetList()
      
      SetProp_(hwnd, "oldproc", SetWindowLongPtr_(hwnd, #GWL_WNDPROC, @ScrollAreaProc()))
      SetProp_(hwnd, "stepvalue", 10)

      hWnd = FindWindowEx_(hWnd, 0, "PureScrollAreaChild",0)
      SetProp_(hwnd, "oldproc", SetWindowLongPtr_(hwnd, #GWL_WNDPROC, @ScrollAreaPanelProc()))
      SetProp_(hwnd, "stepvalue", 10)

    Repeat
      Select WaitWindowEvent()
        Case  #PB_Event_CloseWindow
          End
        Case  #PB_Event_Gadget
          Select EventGadget()
            Case 1
              MessageRequester("Info","Button 1 was pressed!",#PB_MessageRequester_Ok)
            Case 2
              MessageRequester("Info","Button 2 was pressed!",#PB_MessageRequester_Ok)
            Case 3
              MessageRequester("Info","Button 3 was pressed!",#PB_MessageRequester_Ok)
            Case 6
              If EventType() = #PB_EventType_Change 
                SetProp_(GadgetID(0), "stepvalue", Val(GetGadgetText(6)))
                SetProp_(hWnd, "stepvalue", Val(GetGadgetText(6)))
              EndIf
          EndSelect
      EndSelect
    ForEver
  EndIf


Re: Modify SCROLLSTEP of a ScrollAreaGadget in live

Posted: Tue Jan 12, 2010 12:43 pm
by Kwai chang caine
Thannnnks MASTER !!!!!
KCC have understand this time :mrgreen:

You are really a mother for me 8)

And KCC is so happy, ....that he dance for you the dance of the belly :D

Image

I thanks also NETMAESTRO for this code.
NETMAESTRO not again accustomed to have a mule fan :oops:

He don't know, that when he say to his fan KCC :
"You must walk !!!!" 8)

He is forced to say at KCC
"You must put the left foot before, then after put the right before, and ......you see you walk !!!!" :twisted:

Thousand thanks at you two...KCC is very proud to know you 8)
I wish you a very very good day...and perhaps after....for the new adventures of "KCC in the land of programming"