It is currently Sat Mar 06, 2021 3:53 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Create scrollable areas for Gadgets easily...
PostPosted: Thu Sep 05, 2002 11:37 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by freak.

Hi all,

To help Terry, and becourse i wanted to have this feature, too
i've played around with Scrollbar controls, and this is what came
out of it:

Please let me know, if something doesn't work.
(tested with Win98se and WinXP)

Timo
Code:
; ------------------------------------------------------------------------------------
; ScrollGadget:
;
; Makes scrollable Areas that can contain Gadgets, and other Controls.
; by Timo Harter
;
;
; Usage:
; *************************
; OpenScrollGadget(x, y, Width, Height, SizeX, SizeY, Flags, WindowID)
;
; x        = X Position of the Area
; y        = Y Position of the Area
; Width    = Width of Area
; Height   = Height of Area
; SizeX    = Width of the Virtual Area that can be scrolled
; SizeY    = Height of the Virtual Area that can be scrolled
; Flags    = Can be one or more of those Values (combine them with '|')
;
;           #ScrollBar_ScrollH     Shows a horizontal Scrollbar
;           #ScrollBar_ScrollV     Shows a vertical Scrollbar
;           #ScrollBar_Border      Draw a Border around the scrolling Area
;           #ScrollBar_ThickBorder Draw a thick border
;
; WindowID = ID of parent window (use WindowID() to get it)
;
; CloseScrollGadget()  Call this, when you finished putting Gadgets in the Scroll Area
;                      If this Command isn't called, all following Gadgets are put inside the Scroll Area
;
; Note:
; ***********
;
; * Positions of Gadgets drawn inside a ScrollGadget are relative to the Position of the ScrollGadget, not to
;   the Main Window.
;
; * You can create as much ScrollGadgets as you want.
;
; * To create a ScrollGadget in another ScrollGadget, use the Handle returned by the first ScrollGadget as
;   WindowID for the other ScrollGadget.
;
; * To create a ScrollGadget inside a PanelGadget, create a Frame3dGadget() like this:
;   hFrame.l = Frame3DGadget(), and use hFrame as WindowID for the ScrollGadget.
;   You'll need to make the ScrollGadget 20 pixel smaller that the Frame3dGadget in order to
;   see the Scrollbars.
;
; * For more information, see the Example below.
 
 
; ------------------------------------------------------------------------------------
; This is initial Stuff, copy it to the beginning of your code.
; ------------------------------------------------------------------------------------
 
Structure ScrollGadgetInfo
  ScrollBars.l
  *Previous.l
  hParent.l
  hPB.l
  hMainWin.l
  hWindow.l
  hScrollV.l
  hScrollH.l
  Height.l
  Width.l
  SizeX.l
  SizeY.l
  PosX.l
  PosY.l
EndStructure
 
NewList ScrollGadgets.ScrollGadgetInfo()
AddElement(ScrollGadgets())
 
Declare OpenScrollGadget(x, y, Width, Height, SizeX, SizeY, Flags, WindowID)
Declare CloseScrollGadget()
Declare WindowCallback(WindowID, Message, wParam, lParam)
 
#ScrollBar_ScrollH = 1
#ScrollBar_ScrollV = 2
#ScrollBar_Border = 4
#ScrollBar_ThickBorder = 8
 
; ------------------------------------------------------------------------------------
; End of initial code, following is a short example.
; ------------------------------------------------------------------------------------
 
 
 
 
 
If OpenWindow(0, 0, 0, 500, 500, #PB_Window_SystemMenu, "Scrollbar Example") = 0    ; Create Window
  MessageRequester("","Windowerror!",0)
  End
EndIf
 
CreateGadgetList(WindowID())                                    ; create some Gadgets
ButtonGadget(1, 10, 10, 140, 20, "Not scrolled Button!")
ButtonGadget(2, 160, 10, 100, 20, "Another Button!")
 
hScr.l = OpenScrollGadget(10, 40, 465, 400, 550, 700, #ScrollBar_ScrollH | #ScrollBar_ScrollV | #ScrollBar_Border, WindowID())
                                                                ; creat ScrollGadget with Border
 
  For i = 1 To 10                                               ; just some other Gadgets
    ButtonGadget(i+2, 20, i*70-60, 140, 25, "Button Number "+Str(i+2))
  Next i
   
  OpenScrollGadget(200, 100, 80, 30, 250, 0, #ScrollBar_ScrollH, hScr.l)  ; a scrollGadget inside a ScrollGadget
   
    ButtonGadget(13, 0, 0, 250, 30, "A Loooooooooooooooooong Gadget!")
   
  CloseScrollGadget()                                                     ; close the Gadget
   
CloseScrollGadget()
 
ButtonGadget(14, 10, 465, 100, 25, "not Scrolled")                        ; this Button will not be scrolled

 
 
Repeat                                                                   ; main Loop
  Event = WaitWindowEvent()
  If Event = #PB_EventGadget
    MessageRequester("Event","Button Number "+Str(EventGadgetID())+" pushed!",#MB_ICONINFORMATION)
  EndIf
Until Event = #PB_EventCloseWindow
End
 
 
 
 
 
; ------------------------------------------------------------------------------------
; These are needed Procedures, put them at the End of your code, or in an IncludeFile
; ------------------------------------------------------------------------------------
 
Procedure OpenScrollGadget(x, y, Width, Height, SizeX, SizeY, Flags, WindowID)
  Protected WinFlag.l, Previous.l, *pointer, ScrollBars.l
  If SizeX  WindowID()
    SetWindowLong_(WindowID,#GWL_WNDPROC,GetWindowLong_(WindowID(),#GWL_WNDPROC))
  EndIf
  ScrollGadgets()\ScrollBars = ScrollBars
  ProcedureReturn ScrollGadgets()\hWindow
EndProcedure
 
 
Procedure CloseScrollGadget()
  Protected *poiner.l, ScrollBars.l
  ScrollBars = ScrollGadgets()\ScrollBars - 1
  If ScrollBars > 0
    UseGadgetList(ScrollGadgets()\hPB)
  Else
    UseGadgetList(ScrollGAdgets()\hMainWin)
  EndIf
  *pointer = ScrollGadgets()\Previous
  ChangeCurrentElement(ScrollGadgets(), *pointer)
  ScrollGadgets()\ScrollBars = ScrollBars
EndProcedure
 
 
Procedure WindowCallback(WindowID, Message, wParam, lParam)
  Result = #PB_ProcessPureBasicEvents
  Select Message
    Case #WM_HSCROLL
      If lParam  #NULL
         ResetList(ScrollGadgets())
         Repeat: ne = NextElement(ScrollGadgets())
         Until ScrollGadgets()\hScrollH = lParam Or ne = #FALSE
         wLow = PeekW(@wParam)
         wHi  = PeekW(@wParam+2)
         Select wLow
           Case #SB_LEFT: ScrollGadgets()\PosX = 0
           Case #SB_RIGHT: ScrollGadgets()\PosX = ScrollGadgets()\SizeX
           Case #SB_LINELEFT: ScrollGadgets()\PosX + 10
           Case #SB_LINERIGHT: ScrollGadgets()\PosX - 10
           Case #SB_PAGELEFT: ScrollGadgets()\PosX + ScrollGadgets()\Width
           Case #SB_PAGERIGHT: ScrollGadgets()\PosX - ScrollGadgets()\Width
           Case #SB_THUMBPOSITION: ScrollGadgets()\PosX = -wHi
           Case #SB_THUMBTRACK: ScrollGadgets()\PosX = -wHi
         EndSelect
         SetWindowPos_(ScrollGadgets()\hWindow, 0, ScrollGadgets()\PosX, ScrollGadgets()\PosY, 0, 0, #SWP_NOACTIVATE | #SWP_NOOWNERZORDER | #SWP_NOSIZE | #SWP_NOZORDER | #SWP_SHOWWINDOW)         
         SetScrollPos_(ScrollGadgets()\hScrollH, #SB_CTL, -ScrollGadgets()\PosX, #TRUE)
         result = 0
       EndIf
    Case #WM_VSCROLL
      If lParam  #NULL
         ResetList(ScrollGadgets())
         Repeat: ne = NextElement(ScrollGadgets())
         Until ScrollGadgets()\hScrollV = lParam Or ne = #FALSE
         wLow = PeekW(@wParam)
         wHi  = PeekW(@wParam+2)
         Select wLow
           Case #SB_TOP: ScrollGadgets()\PosY = 0
           Case #SB_BOTTOM: ScrollGadgets()\PosY = ScrollGadgets()\SizeY
           Case #SB_LINEUP: ScrollGadgets()\PosY + 10
           Case #SB_LINEDOWN: ScrollGadgets()\PosY - 10
           Case #SB_PAGEUP: ScrollGadgets()\PosY + ScrollGadgets()\Height
           Case #SB_PAGEDOWN: ScrollGadgets()\PosY - ScrollGadgets()\Height
           Case #SB_THUMBPOSITION: ScrollGadgets()\PosY = -wHi
           Case #SB_THUMBTRACK: ScrollGadgets()\PosY = -wHi
         EndSelect
         SetWindowPos_(ScrollGadgets()\hWindow, 0, ScrollGadgets()\PosX, ScrollGadgets()\PosY, 0, 0, #SWP_NOACTIVATE | #SWP_NOOWNERZORDER | #SWP_NOSIZE | #SWP_NOZORDER | #SWP_SHOWWINDOW)
         SetScrollPos_(ScrollGadgets()\hScrollV, #SB_CTL, -ScrollGadgets()\PosY, #TRUE)
         result = 0
       EndIf
    Default
  EndSelect
  ProcedureReturn Result
EndProcedure
 
; -----------------------------------------------------------------------------------


--------------------------------
Programming today is a race between software engineers striving to build bigger and
better idiot-proof programs and the universe trying to produce bigger and better idiots.

...So far, the universe is winning.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Sep 08, 2002 9:31 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by freak.

Hi again,


I just wanted to say, that i changed the Code above, becourse the
support for Panelgadgets didn't work. I also fixed another small
bug in the code.

So i anyone of you uses it, please replace your old code with the
one above (initial stuff and Procedures!)


Here's another Example of using it inside a Panelgadget:
Code:
If OpenWindow(0, 0, 0, 540, 560, #PB_Window_SystemMenu, "Scrollbar Example") = 0    ; Create Window
  MessageRequester("","Windowerror!",0)
  End
EndIf
 
CreateGadgetList(WindowID())   
PanelGadget(1, 10, 10, 520, 540)
  AddGadgetItem(1, -1, "Panel 1")

  hFrame.l = Frame3DGadget(2, 10, 10, 500, 500, "", 2)
 
  hScr.l = OpenScrollGadget(0, 0, 480, 480, 550, 700, #ScrollBar_ScrollH | #ScrollBar_ScrollV, hFrame)
                                                                ; creat ScrollGadget
 
    For i = 1 To 10                                               ; just some other Gadgets
      ButtonGadget(i+2, 20, i*70-60, 140, 25, "Button Number "+Str(i+2))
    Next i
   
    OpenScrollGadget(200, 100, 80, 30, 250, 0, #ScrollBar_ScrollH, hScr.l)  ; a scrollGadget inside a ScrollGadget
     
      ButtonGadget(13, 0, 0, 250, 30, "A Loooooooooooooooooong Gadget!")
   
    CloseScrollGadget()                                                     ; close the Gadget
   
  CloseScrollGadget()

  AddGadgetItem(1, -1, "Panel 2")
  AddGadgetItem(1, -1, "Panel 3")
 

Repeat                                                                   ; main Loop
  Event = WaitWindowEvent()
  If Event = #PB_EventGadget And EventGadgetID()  1
    MessageRequester("Event","Button Number "+Str(EventGadgetID())+" pushed!",#MB_ICONINFORMATION)
  EndIf
Until Event = #PB_EventCloseWindow
End


Timo

--------------------------------
Programming today is a race between software engineers striving to build bigger and
better idiot-proof programs and the universe trying to produce bigger and better idiots.

...So far, the universe is winning.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Oct 10, 2002 6:40 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by TerryHough.

This doesn't complile under vs3.40. Gets a "This structure is already declared" error. Removing the structure definition leads to more problems. I haven't gotten past them yet. :cry:

Terry


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Oct 10, 2002 8:02 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by cor.

>This doesn't complile under vs3.40. Gets a "This structure is >already declared" error. Removing the structure definition leads to >more problems. I haven't gotten past them yet.

Same problem as above.

WIN 98 SE.

Compiled with 3.40

Using Windows 98 SE
Registered PB version : 3.40 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Oct 10, 2002 8:18 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by Paul.

If someone uses a structure that is already declared, just rename it :)

Change ScrollInfo to ScrollInfo2 or something.


----------
Visit the PB Resources Site at http://www.reelmediaproductions.com/pb


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Oct 10, 2002 8:44 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by freak.

The problem, is that there is now a different built-in Structure that
wasn't there before.

In fact, the other one was there before, I even used it in this code.
The problem is, now Structures are case insesitive, and now SCROLLINFO and ScrollInfo
means the same,

You just need to change the Structure name to something like ScrollGadgetInfo,
and then change this line
NewList ScrollGadgets.ScrollInfo() (located right under the Structure)
to
NewList ScrollGadgets.ScrollGadgetInfo() ,
that's all.

(I also changed that in the source above, so it should work now.)

Timo


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Oct 10, 2002 9:24 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by TerryHough.

Thanks Timo,

I should have read the History a bit closer. :)

Terry


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Oct 12, 2002 4:44 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by tinman.

Hi freak,

nice code. I guess it's not meant to have some of the typos though (e.g. Prevoius instead of Previous)? There is another one, but it was a while ago that I found them.

Thanks.

Update: I notice you posted again to this thread, but I guess you just updated the source a bit. The typos are still there, basically all the lines with the text "Previous: ChangeCurrentElement" are bugged. The curse of CutNPaste ;p

--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.30)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Feb 05, 2003 5:46 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by GPI.

freedimension (from http://www.pure-board.de/) has modified the code:
(and i correct a little error, so the window now redraw in WIN98, if the size is changed)


Code:
; ########################################################################################################
; ScrollGadget by freedimension based on the work by freak (January 2003)
; ########################################################################################################


; ########################################################################################################
;- ENGLISH Manual
; First of all I want to thank "Freak" for his superb code-pattern, on which this work is based.
;
; The ScrollGadget can be used like any other Gadget except that it has its own GadgetID
; that does not interfere with the IDs of other Gadgets.
; One of his strengths is the possibility to place other Gadgets (even ScrollGadgets) inside
; the ScrollGadget. To do so, just create the Gadgets after the creation of the ScrollGadget.
; After all Gadgets are placed in the ScrollGadget you have to Close it with the
; CloseScrollGadget() Command. All Gadgets created afterwards are placed outside of the ScrollGadget.

; CreateScrollGadget(Scroll_ID, x, y, Width, Height, SizeX, SizeY, Flags, WindowID)
; ---------------------------------------------------------------------------------
; Scroll_ID   : The User defined ID of the ScrollGadget (to be used with SetScrollGadget() )
; x, y     : The Position on the Parent-Window
; Width, Height : The Dimensions of the ScrollGadgets (including ScrollBars and Borders)
; SizeX, SizeY : The Dimensions of the scrollable ClientArea of the Gadget
; Flags     : Here you can characterize the look of the ScrollGadget
; WindowID   : The Window Handle of the Parent-Window (to which the ScrollGadget should belong)

; Options for the Flags-Parameter:
;  #ScrollBar_NoScrollH  : In no case a horizontal ScrollBar will be displayed
;  #ScrollBar_NoScrollV  :  -"-    vertical      -"-
;  #ScrollBar_Border   : Gives the ScrollArea a thin (2D) Border
;  #ScrollBar_ThickBorder :    -"-      a thick 3D-Border
;  #ScrollBar_Left    : The vertical ScrollBar will be displayed on the left Side
;  #ScrollBar_Top     : The horizontal ScrollBar will be displayed on the Top
; ---------------------------------------------------------------------------------

; SetScrollGadget(Scroll_ID, X, Y, Width, Height, ClientW, ClientH)
; -----------------------------------------------------------------
; Scroll_ID   : The User defined ID of the ScrollGadget (defined on creation)
; X, Y     : The new Position on the Parent-Window *
; Width, Height : The new Dimensions of the ScrollGadget *
; SizeX, SizeY : The new Dimensions of the ClientArea *
;
; * Old Values can be taken on by setting the Parameter to -1
; -----------------------------------------------------------------

; CloseScrollGadget()
; -------------------
; This Function has to be called to finish the creation of the ScrollGadget.
; Gadgets created in between are placed inside of the ScrollGadget.
; -------------------
; ########################################################################################################


; ########################################################################################################
;- DEUTSCHE Anleitung
; Zu allererst möchte ich "Freak" danken für sein hervorragendes Code-Beispiel auf welchem ich
; diesen Code aufgebaut habe.
;
; Das ScrollGadget wird wie jedes andere Gadget auch benutzt, es hat benutzt jedoch eine eigene
; GadgetID so das es hier nicht zu Ãœberschneidungen mit den IDs anderer Gadgets kommen kann.
; Eine der Stärken der ScrollGadgets ist die Möglichkeit, weitere Gadgets (sogar ScrollGadgets
; sind möglich) innerhalb des ScrollGadgets zu platzieren. Dazu müssen nur diese Gadgets nach dem
; Erzeugen des ScrollGadgets erzeugt werden. Sind sämtliche Gadgets innerhalb des ScrollGadgets
; erstellt, muß das ScrollGadget mittels CloseScrollGadget() geschlossen werden. Alle Gadgets welche
; danach erzeugt wurden, werden ausserhalb des ScrollGadgets platziert.

; CreateScrollGadget(Scroll_ID, x, y, Width, Height, SizeX, SizeY, Flags, WindowID)
; ---------------------------------------------------------------------------------
; Scroll_ID   : Die Benutzerdefinierte ID des ScrollGadget (wird zusammen mit SetScrollGadget() benutzt)
; x, y     : Die Position des übergeordneten Fensters
; Width, Height : Höhe und Breite des ScrollGadgets (dies schließt die Bildlaufleisten und Rahmen mit ein)
; SizeX, SizeY : Die Höhe und Breite des scrollbaren Bereichs.
; Flags     : Einige Optionen zum Steuern des Aussehens des ScrollGadgets (s.u.)
; WindowID   : Das Handle des Fensters in welchem das ScrollGadgets erstellt werden soll

; Options for the Flags-Parameter:
;  #ScrollBar_NoScrollH  : Eine horizontale Bildlaufleiste wird auf keinen Fall dargestellt
;  #ScrollBar_NoScrollV  : Eine vertikale          -"-
;  #ScrollBar_Border   : Gibt dem scrollbaren Bereich eine dünne (2D) Begrenzungslinie
;  #ScrollBar_ThickBorder :        -"-      einen dicken 3D-Rahmen
;  #ScrollBar_Left    : Die vertikale Bildlaufleiste wird auf der linken Seite dargestellt
;  #ScrollBar_Top     : Die horizontale Bildlaufleiste wird oberhalb des scrollbaren Bereichs
;              dargestellt
; ---------------------------------------------------------------------------------

; SetScrollGadget(Scroll_ID, X, Y, Width, Height, ClientW, ClientH)
; -----------------------------------------------------------------
; Scroll_ID   : Die benutzerdefinierte ID des ScrollGadget (welche bei der Erzeugung angegeben wurde)
; X, Y     : Die neue Position auf dem übergeordneten Fenster *
; Width, Height : Die neue Höhe und Breite des ScrollGadgets *
; SizeX, SizeY : Die neue Höhe und Breite des scrollbaren Bereichs *
;
; * Die alten Werte können übernommen werden wenn hier jeweils -1 übergeben wird
; -----------------------------------------------------------------

; CloseScrollGadget()
; -------------------
; Diese Funktion muss aufgerufen werden um die Erstellung des ScrollGadgets abzuschließen.
; Gadgets welche zwischen der Erzeugung und dem Abschluß erzeugt wurden, werden innerhalb
; des ScrollGadgets dargestellt.
; -------------------
; ########################################################################################################


; ########################################################################################################
;- ScrollInfo2
Structure ScrollInfo2
;##### Fixed Data #####
 *Previous.l
 Scroll_ID.l
 ;Window Handles
 hEnv.l  ; Envelope Window
 hPB.l    ; Window
 hWindow.l
 hScrollV.l
 hScrollH.l
 ;Flags for the Look and Feel of the ScrollGadget
 Flags.l

;##### Variable Data #####
 ;Position of the ScrollGadget on Parent Window
 X.l
 Y.l

 ;Size of the ScrollGadget (including the ScrollBars and Borders)
 Width.l
 Height.l
 
 ;Position of the ClientArea in Envelope Window
 PosX.l
 PosY.l

 ;Minimum Size of ClientArea
 ClientW.l
 ClientH.l
 ;Actual Size of ClientArea (May differ when PageSize  -1 : ScrollGadgets()\X = X : Else : X = ScrollGadgets()\X : EndIf
 If Y  -1 : ScrollGadgets()\Y = Y : Else : Y = ScrollGadgets()\Y : EndIf
 If ClientW  -1 : ScrollGadgets()\ClientW = ClientW : Else : ClientW = ScrollGadgets()\ClientW : EndIf
 If ClientH  -1 : ScrollGadgets()\ClientH = ClientH : Else : ClientH = ScrollGadgets()\ClientH : EndIf
 If Width -1 : ScrollGadgets()\Width = Width : Else : Width = ScrollGadgets()\Width : EndIf
 If Height-1 : ScrollGadgets()\Height = Height : Else : Height = ScrollGadgets()\Height : EndIf


 If(ClientW > (Width - (2 * BorderW))) And (Flags & #ScrollBar_NoScrollH = 0) : sbHActive.b = #TRUE : Else : sbHActive.b = #FALSE : EndIf
 If(ClientH > (Height - (2 * BorderH))) And (Flags & #ScrollBar_NoScrollV = 0) : sbVActive.b = #TRUE : Else : sbVActive.b = #FALSE : EndIf
 If(sbHActive) And (Flags & #ScrollBar_NoScrollV = 0)
  If(ClientH > (Height - (2 * BorderH) ) - ScrollBarH) : sbVActive = #TRUE : Else : sbVActive = #FALSE : EndIf
 EndIf
 If(sbVActive) And (Flags & #ScrollBar_NoScrollH = 0)
  If(ClientW > (Width - (2 * BorderW) ) - ScrollBarW) : sbHActive = #TRUE : Else : sbHActive = #FALSE : EndIf
 EndIf
 If sbVActive
  If(Flags & #ScrollBar_Left)>0 : XEnvW = X + ScrollBarW : XScr = X : Else : XEnvW = X : XScr = X + Width - ScrollBarW : EndIf
  WEnvW = Width - ScrollBarW
 Else : XEnvW = X : XScr = X : WEnvW = Width : EndIf
 If sbHActive
  If(Flags & #ScrollBar_Top)>0 : YEnvW = Y + ScrollBarH : YScr = Y : Else : YEnvW = Y : YScr = Y + Height - ScrollBarH : EndIf
  HEnvW = Height - ScrollBarH
 Else : YEnvW = Y : YScr = Y : HEnvW = Height : EndIf
 ScrollGadgets()\VisW = WEnvW - 2*BorderW : ScrollGadgets()\VisH = HEnvW - 2*BorderH
 
 If (ClientW  #NULL
    ResetList(ScrollGadgets())
    Repeat
     ne = NextElement(ScrollGadgets())
    Until (ScrollGadgets()\hScrollH = lParam) Or (ne = #FALSE)
    wLow = PeekW(@wParam)
    wHi = PeekW(@wParam+2) - 1
    Select wLow
     Case #SB_LINELEFT: ScrollGadgets()\PosX + 10
       If(ScrollGadgets()\PosX > 0) : ScrollGadgets()\PosX = 1 : EndIf
     Case #SB_LINERIGHT: ScrollGadgets()\PosX - 10
       If(ScrollGadgets()\PosX  0) : ScrollGadgets()\PosX = 1 : EndIf
     Case #SB_PAGERIGHT: ScrollGadgets()\PosX - ScrollGadgets()\Width
       If(ScrollGadgets()\PosX  #NULL
    ResetList(ScrollGadgets())
    Repeat: ne = NextElement(ScrollGadgets())
    Until ScrollGadgets()\hScrollV = lParam Or ne = #FALSE
    wLow = PeekW(@wParam)
    wHi = PeekW(@wParam+2) - 1
    Select wLow
     Case #SB_LINEUP
      ScrollGadgets()\PosY + 10
      If(ScrollGadgets()\PosY > 0) : ScrollGadgets()\PosY = 1 : EndIf
     Case #SB_LINEDOWN
      ScrollGadgets()\PosY - 10
      If(ScrollGadgets()\PosY  0) : ScrollGadgets()\PosY = 1 : EndIf
     Case #SB_PAGEDOWN
      ScrollGadgets()\PosY - ScrollGadgets()\Height
      If(ScrollGadgets()\PosY < (-(ScrollGadgets()\SizeY - ScrollGadgets()\VisH) ) )
       ScrollGadgets()\PosY = - (ScrollGadgets()\SizeY - ScrollGadgets()\VisH)
      EndIf
     Case #SB_THUMBPOSITION : ScrollGadgets()\PosY = -wHi
     Case #SB_THUMBTRACK : ScrollGadgets()\PosY = -wHi
    EndSelect
    SetWindowPos_(ScrollGadgets()\hWindow, 0, ScrollGadgets()\PosX, ScrollGadgets()\PosY, 0, 0, #SWP_NOACTIVATE | #SWP_NOOWNERZORDER | #SWP_NOSIZE | #SWP_NOZORDER | #SWP_SHOWWINDOW)
    SetScrollPos_(ScrollGadgets()\hScrollV, #SB_CTL, -ScrollGadgets()\PosY, #TRUE)
    result = 0
   EndIf
 EndSelect
 ProcedureReturn Result
EndProcedure



PII 333, 256MB, Asus TNT2Ultra 32MB, AWE Gold 64 4MB


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Apr 14, 2003 10:57 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by BalrogSoft.

Hi...

I reply this message because i need this code snippet but i tryed to change the range of the scroll bars when it is already created, but i cant do it correctly, anyone knows how can chage the range of the scroll bar?

bye, Balrog Soft.

Balrog Soft
Amiga and PC Coder
http://www.balrogsoftware.com
[url]mailto:balrog@balrogsoftware.com[/url]


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Apr 15, 2003 5:21 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by GPI.

if found a little bug in the Window-callback.

When you have a split-gadget in the window, the Splitgadget move the scrollarea :)

The problem ist
Code:
Repeat: ne = NextElement(ScrollGadgets())
    Until ScrollGadgets()\hScrollV = lParam Or ne = #FALSE


Even when it found out, that the Scroll-id isn't the changed bar.

Code:
Repeat: ne = NextElement(ScrollGadgets())
Until ScrollGadgets()\hScrollV = lParam Or ne = #FALSE
if ne#false
.
.
.
endif

(This code is twice in the Window-Callback)

PII 333, 256MB, Asus TNT2Ultra 32MB, AWE Gold 64 4MB


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 14 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