Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
I got some unresolved problem in defined Scrollbar
Message
 
 
À
03/04/2002 19:33:16
Lu Ping
Zhuhai Tec Co.
Zhuhai, Chine
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Divers
Thread ID:
00640662
Message ID:
00640831
Vues:
17
>I define my scroll bar .It is made by shapes.It is all Ok except that when the scrollbar page move into the bottom of the scrollbar ,the objects in the same container as the scrollbar does not show them all,just a little part of the most bottom object is still invisible.So check the code ,but I cant find any logical problem.Do I calculate the wrong percent for the scrollbar page and scrollbar.Below is my part code:
>   PROCEDURE CheckScrollBar
>         IF VARTYPE(This.nHorizontalPercent) = 'L'
>            This.nHorizontalPercent = 1
>         ENDIF
>         IF VARTYPE(This.nVerticalPercent ) = 'L'
>            This.nVerticalPercent = 1
>         ENDIF
>         *----- Calculate the Height ,Width of the objects  Area in the container class
>         oControl = .NULL.
>
>         FOR EACH oControl IN This.Parent.Controls
>
>               This.nMostTop = MAX(oControl.Top + oControl.Height ,This.nMostTop)
>               This.nMostLeft = MAX(oControl.Left + oControl.Width ,This.nMostLeft )
>
>         ENDFOR
>         *---- Calculate the percent for the scrollbar page
>         *---- And this percent value is used as the portion for objects area
>         *---- When move the scroll page
>         *---- corner bar is 20 height and 20 width ,the container  subtract 20 then
>         *---- get scrollbar  height or width
>
>         This.nHorizontalPercent =  (This.Parent.Width - 20) / This.nMostLeft
>         This.nVerticalPercent =  (This.Parent.Height - 20) / This.nMostTop
>
>         *--- Decide if the container class need scrollbar ,and if need
>         *--- Calculate the type
>         nResult = 0
>         IF This.nHorizontalPercent < 1
>            nResult = nResult + 1
>         ENDIF
>         IF This.nVerticalPercent < 1
>            nResult = nResult + 2
>         ENDIF
>         RETURN nResult
>     ENDPROC
>
>    *---- This is the class for VerticalScrollBar
>DEFINE CLASS VerticalScrollBar As container
>
>    BackColor = 12615808
>    BorderColor = RGB(255,255,255)
>    Width = 20
>    *---- scroll bar page percent
>    nPercent = 0
>    *---- the delta distance for mouse position and scroll bar page position
>    nMouseDis = 0
>    *---- the object reference for manage the scrollbar
>    oFrameManage = .NULL.
>    *---- scroll bar page
>    ADD OBJECT shpSlider As SliderShape
>
>    PROCEDURE Init
>       LPARAMETERS toFrameManage ,tnPercent
>       This.nPercent = tnPercent
>       This.oFrameManage = toFrameManage
>       This.Position(tnPercent)
>       This.Visible = .T.
>    ENDPROC
>    PROCEDURE Position
>       LPARAMETERS tnPercent
>       This.Height = This.Parent.Height - 20
>       This.Left = This.Parent.Width - This.Width
>       This.Top = 0
>       *---- scroll bar page
>        WITH This.shpSlider
>          .Left = 2
>          .Top = 2
>          .Width = This.Width - 4
>          .Height = This.Height * tnPercent
>          .BackColor = This.BorderColor  - 10
>          .Bordercolor = This.BackColor
>        ENDWITH
>    ENDPROC
>    PROCEDURE shpSlider.MouseDown
>       LPARAMETERS nButton ,nShift ,nX ,nY
>	       IF nButton = 1
>	          This.Tag = "MOUSEDOWN"	
>	          This.Parent.nMouseDis = nY - This.Parent.Top - This.Top
>	       ENDIF
>    ENDPROC
>
>    PROCEDURE shpSlider.MouseMove
>       LPARAMETERS nButton ,nShift ,nX ,nY
>	       IF This.Tag = "MOUSEDOWN"
>	         DO CASE
>	         CASE  (nY + This.Height - This.Parent.nMouseDis ;
>                         - This.Parent.Top) >= This.Parent.Height
>	              This.Top = This.Parent.Height - This.Height
>
>	         CASE (nY - This.Parent.nMouseDis - This.Parent.Top) <= 0
>	              This.Top = 0
>	         OTHERWISE
>	              This.Top = nY - This.Parent.nMouseDis - This.Parent.Top
>	       ENDCASE
>	      ENDIF
>    ENDPROC
>    PROCEDURE shpSlider.MouseUP
>       LPARAMETERS nButton ,nShift ,nX ,nY
>	       IF This.Tag = "MOUSEDOWN"
>	          This.Tag = "MOUSEUP"
>	       ENDIF
>    ENDPROC
>    *---- Release the reference of scrollbar manage object
>    PROCEDURE Destroy
>        This.oFrameManage = .NULL.
>    ENDPROC
>ENDDEFINE
>
>*---- the define for scrollbar page class
>DEFINE CLASS SliderShape As Shape
>      PROCEDURE Left_Assign
>           LPARAMETERS tnLeft
>           IF This.Tag = "MOUSEDOWN"	
>	           nDis = (tnLeft - This.Left) / This.Parent.nPercent
>	
>	           *---- If is not a object
>	           IF VARTYPE(This.Parent.oFrameManage.oTarget) = 'O' ;
>                       AND NOT ISNULL(This.Parent.oFrameManage.oTarget)
>	              This.Parent.oFrameManage.oTarget.Left =;
>                          This.Parent.oFrameManage.oTarget.Left - nDis
>	           ELSE
>	              FOR EACH oObject IN This.Parent.Parent.Controls
>	                  IF NOT INLIST(UPPER(oObject.Class) ,"BARBLOCK";
>                                  ,"HORIZONTALSCROLLBAR" ,"VERTICALSCROLLBAR")
>	                     oObject.Left = oObject.Left - nDis
>	                  ENDIF
>	              ENDFOR
>	           ENDIF
>           ENDIF
>           This.Left = tnLeft
>      ENDPROC
>      PROCEDURE Top_Assign
>           LPARAMETERS tnTop
>           IF This.Tag = "MOUSEDOWN"	
>	           nDis = (tnTop - This.Top) / This.Parent.nPercent	
>	           *---- if is not a object
>	           IF VARTYPE(This.Parent.oFrameManage.oTarget) = 'O';
>                        AND NOT ISNULL(This.Parent.oFrameManage.oTarget)
>	              This.Parent.oFrameManage.oTarget.Top =;
>                          This.Parent.oFrameManage.oTarget.Top - nDis
>	           ELSE
>	              FOR EACH oObject IN This.Parent.Parent.Controls
>	                  IF NOT INLIST(UPPER(oObject.Class) ,"BARBLOCK" ,;
>                                   "HORIZONTALSCROLLBAR" ,"VERTICALSCROLLBAR")
>
>	                     oObject.Top =  oObject.Top - nDis
>	                  ENDIF
>	              ENDFOR
>	           ENDIF
>           ENDIF
>           This.Top = tnTop
>      ENDPROC
>ENDDEFINE
>
>Is the formula "nDis = (tnTop - This.Top) / This.Parent.nPercent" right?
>nDis is the delta distance for objects area.

You can use < pre > < /pre > tags (no spaces) to preserve code formatting.
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform