Tpanel with scroll

Tpanel with scroll

Postby Silvio » Wed Aug 06, 2008 8:42 pm

I made some modifies to Tpanel to ad a vertical scroll but it also not run ok I not Know How make MouseMove method to move the pages
I hope help of community and of Antonio

Code: Select all  Expand view
// TPanel Class. Mainly used for Automatic Alignment techniques

#include "FiveWin.ch"

#ifdef __XPP__
   #define Super ::TControl
   #define New   _New
#endif

#define COLOR_BTNFACE   15
#define WM_ERASEBKGND   20


//----------------------------------------------------------------------------//
static WM_RESETPOS

CLASS TPanel FROM TControl

   DATA lVScroll     // add by silvio

   CLASSDATA lRegistered AS LOGICAL

   METHOD New( nTop, nLeft, nBottom, nRight, oWnd,lVScroll ) CONSTRUCTOR
   METHOD HandleEvent( nMsg, nWParam, nLParam )  // add by silvio
   METHOD EraseBkGnd( hDC )

   METHOD Paint()
   METHOD Display() INLINE ::BeginPaint(), ::Paint(), ::EndPaint()

   METHOD Notify( nIdCtrl, nPtrNMHDR ) INLINE ::oWnd:Notify( nIdCtrl, nPtrNMHDR )

   METHOD SpostaControlli( nStep)   // BY EMG

ENDCLASS

//----------------------------------------------------------------------------//

METHOD New( nTop, nLeft, nBottom, nRight, oWnd,lVScroll ) CLASS TPanel

   DEFAULT nTop := 0, nLeft := 0, nBottom := 100, nRight := 100,;
           oWnd := GetWndDefault() , lVScroll := .f.

   ::nTop    = nTop
   ::nLeft   = nLeft
   ::nBottom = nBottom
   ::nRight  = nRight
   ::oWnd    = oWnd
   ::nStyle  = nOr( WS_CHILD, WS_VISIBLE )
   ::lDrag   = .f.
   ::nClrPane = GetSysColor( COLOR_BTNFACE )
    ::lVScroll  := lVScroll   // add by silvio

   #ifdef __XPP__
      DEFAULT ::lRegistered := .f.
   #endif

   ::Register()

   if ! Empty( ::oWnd:hWnd )
      ::Create()
      ::oWnd:AddControl( Self )
   else
      ::oWnd:DefControl( Self )
   endif
   ::oWnd:oLeft = Self   // add by silvio
   oself = Self
   ::oVScroll := TScrollBar():WinNew( ,,, .t., self )   // add by silvio
  * ::oVScroll:SetRange(0,0)                             // add by silvio


    ::oVScroll:SetRange( 1, 10 )
    ::oVScroll:nPgStep = 1

    ::oVScroll:bGoUp     = { || ::SpostaControlli( 30 ) }
    ::oVScroll:bGoDown   = { || ::SpostaControlli(-30 ) }
    ::oVScroll:bPageUp   = { || ::SpostaControlli( 30 ) }
    ::oVScroll:bPageDown = { || ::SpostaControlli(-30 ) }


return Self

//----------------------------------------------------------------------------//

METHOD Paint() CLASS TPanel

   local nTop, nLeft, nHeight, nWidth, nBevel

   local nMinTop    := int(::nHeight / 2)      // add by silvio
   local nMaxBottom := int(::nHeight / 2)      // add by silvio

     // add by silvio
    if ::lVScroll

      nLen := len( ::aControls )

      for n := 1 to nLen
         if IsWindowVisible( ::aControls[n]:hWnd )
            nMinTop    := min( WndTop( ::aControls[n]:hWnd ), nMinTop )
            nMaxBottom := max( WndTop( ::aControls[n]:hWnd )+ ::aControls[n]:nHeight, nMaxBottom )
         endif
      next

      if nMinTop < 0 .or. nMaxBottom > ::nHeight
         ::oVScroll:SetRange( 0, 10 )
      else
         ::oVScroll:SetRange( 0, 0 )
      endif

   endif
   ///////////

   if ::oClient != NIL .and. (nBevel := ::oClient:nClientBevel) > 0
      nBevel  -= 1
      nTop    := nBevel
      nLeft   := nBevel
      nHeight := ::nHeight - nBevel - 1
      nWidth  := ::nWidth - nBevel - 1
      if ::oTop != NIL
         nTop += ::oTop:nHeight
      endif
      if ::oBottom != NIL
         nHeight -= ::oBottom:nHeight
      endif
      if ::oLeft != NIL
         nLeft += ::oLeft:nWidth
      endif
      if ::oRight != NIL
         nWidth -= ::oRight:nWidth
      endif
      WndBoxIn(::hDC, nTop, nLeft, nHeight, nWidth)
   endif




   RETURN NIL

//----------------------------------------------------------------------------//

   METHOD HandleEvent( nMsg, nWParam, nLParam )  CLASS TPanel     // add by silvio
   local n, nLen
   do case
   case nMsg == WM_ERASEBKGND
      return 1
   case nMsg == WM_RESETPOS
      nLen := len( ::aControls )
      for n := 1 to nLen
         ::aControls[n]:Move(0,0,,,.t.)
      next
      ::oVScroll:SetPos(0)
      ::Refresh()
   endcase
   return Super:HandleEvent( nMsg, nWParam, nLParam )

//----------------------------------------------------------------------------//

METHOD EraseBkGnd( hDC ) CLASS TPanel

   if ::oWnd != nil .and. IsAppThemed() .and. ;
      Upper( ::oWnd:ClassName() ) $ "TFOLDER,TREBAR,TGROUP,TPANEL"
      DrawPBack( ::hWnd, hDC )
      return 1
   endif

return Super:EraseBkGnd( hDC )

//----------------------------------------------------------------------------//

    METHOD SpostaControlli(nStep)   CLASS TPanel
    LOCAL i

    FOR i = 1 TO LEN( ::aControls )
        ::aControls[ i ]:Move( ::aControls[ i ]:nTop + nStep, ::aControls[ i ]:nLeft )
    NEXT

    oDlg:Refresh()

    RETURN NIL













it run ok but I cannot move the pages ...any help ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Tpanel with scroll

Postby Patrick Mast » Thu Aug 07, 2008 10:47 am

Silvio wrote:I made some modifies to Tpanel to ad a vertical scroll but it also not run ok I not Know How make MouseMove method to move the pages

Interesting idea!

Patrick
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 82 guests