Jump to content
Fivewin Brasil

ajuda com scroll automático em tela com infinitos gets...


fluna

Recommended Posts

Pessoal, preciso de ajuda para colocar um scroll nessa Dialog... quem se habilita?


*****************************************
Function EditCell( )
*****************************************

*
* USE CLIENTES // abrir qualquer arquivo que tenha mais de 30 campos para fazer um scroll automático...
*
*
oGet := {}
cGet := {}

estr := DbStruct()
For i=1 to Len(estr)
       estr[i,1] := Upper( Substr( estr[i,1], 1, 1 ) ) + Lower( Substr( estr[i,1], 2 ) )
End

nMax := Len(estr)

DEFINE DIALOG xDlg FROM 1,5 TO 44,100 TITLE Alias()

nLin := 0.5
oGet := Array(nMax)
For i=1 to nMax
      @ nLin,1 say estr[i,1] of xDlg
      nLin+=0.86
End

nCtn:=0
nLin:=-0.5
For i=1 to nMax
      nLin+=1
      nCtn++
      cGet:=field(i)
      @ nLin,5 get oGet[i] var &cGet of xDlg
End

ACTIVATE DIALOG xDlg CENTERED
return nil
Link to comment
Share on other sites


// Testing how to scroll a dialog with its contents

// with support for different DPIs thanks to Ramesh Babu !

#include "FiveWin.ch"

*#define d_width 4

*#define d_height 18

#define LOGPIXELSX 88

STATIC d_width := 4, d_height := 13

FUNCTION Main()

LOCAL oDlg, oScrDlg

local hDC := GetDC( 0 )

DEFINE DIALOG oDlg RESOURCE "dlgComScroll" ;

TITLE "Scroll dialog" ;

STYLE nOR( WS_VSCROLL, WS_HSCROLL )

oDlg:bMouseWheel = { | nKey, nDelta, nXPos, nYPos | MouseWheel( nKey, nDelta, nXPos, nYPos, oScrDlg ) }

ACTIVATE DIALOG oDlg ;

ON INIT ( Set_D_Height(), oScrDlg := TScrDlg():New( oDlg, 1, 65, 1, 70), oDlg:SetSize( 560, 550 ), oDlg:Center() )

RETURN( NIL )

function MouseWheel( nKey, nDelta, nXPos, nYPos, oScrDlg )

local oVScroll := oScrDlg:oDlg:oVScroll

if nDelta < 0

oVScroll:GoDown()

else

oVScroll:GoUp()

endif

oScrDlg:VScroll()

return nil

//============================================================================

// FUNCTION : Set_D_Height()

// Purpose : To Set new d_height for the Scroll bar

//============================================================================

PROCEDURE Set_D_Height()

LOCAL nDpi := GetCurrentDpi()

d_height := (nDpi * 13 / 96)

RETURN

//============================================================================

// FUNCTION : GetCurrentDpi()

// Purpose : To Get the Windows Current DPI Setting

//============================================================================

FUNCTION GetCurrentDpi()

local hDc := GetDc(0)

local nDpi := GetDeviceCaps( hDC, LOGPIXELSX )

nDpi := GetDeviceCaps( hDC, LOGPIXELSX )

MsgInfo( LTRIM(STR(nDpi))+" DPI" )

ReleaseDC( 0, hDC )

RETURN nDpi

//============================================================================

// FileName : SCROLL.PRG

// Purpose : dialog Scroll Class

// Author : Eric Yang

// Update History :

// Date Contents

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

// 1997.02.01

// 2006.29.12 By Rossini - Brasil

//============================================================================

#include "FiveWin.ch"

#ifndef TRUE

#define TRUE .T.

#define FALSE .F.

#endif

CLASS TScrDlg

DATA oDlg

DATA nVPos, nHPos

METHOD New( oDlg,nV1,nV2,nH1,nH2 ) CONSTRUCTOR

METHOD SetScroll( nV1,nV2,nH1,nH2 )

//-*------------------------------------------------------------

METHOD VScroll()

METHOD VScrollThumb()

METHOD VScrollTrack()

METHOD VScrollPgDown()

METHOD VScrollPgUp()

//-*-----------------------------

METHOD HScroll()

METHOD HScrollThumb()

METHOD HScrollTrack()

METHOD HScrollPgDown()

METHOD HScrollPgUp()

ENDCLASS

METHOD New( oDlg,nV1,nV2,nH1,nH2 ) CLASS TScrDlg

::nVPos := 0

::nHPos := 0

::oDlg := oDlg

::SetScroll( nV1,nV2,nH1,nH2 )

RETURN Self

METHOD SetScroll( nV1,nV2,nH1,nH2 ) CLASS TScrDlg

LOCAL aCoors1:={},aCoors2:={}

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

//-* Vertical Scroll Bar

if ::oDlg:oVScroll != NIL

::oDlg:oVScroll:SetRange( nV1,nV2 )

::nVPos := ::oDlg:oVScroll:GetPos()

::oDlg:oVScroll:bGoDown := {|| ::VScroll() }

::oDlg:oVScroll:bGoUp := {|| ::VScroll() }

::oDlg:oVScroll:bPageUp := {|| ::VScrollPgUp() }

::oDlg:oVScroll:bPageDown := {|| ::VScrollPgDown() }

::oDlg:oVScroll:bGoTop := {|| ::VScroll() }

::oDlg:oVScroll:bGoBottom := {|| ::VScroll() }

::oDlg:oVScroll:nPgStep := 10

//::oDlg:oVScroll:lReDraw := TRUE

::oDlg:oVScroll:bPos := {|nPos| ::VScrollThumb(nPos) }

::oDlg:oVScroll:bTrack := {|nPos| ::VScrollTrack(nPos) }

endif

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

//-* Horizontal Scroll Bar

if ::oDlg:oHScroll != NIL

::oDlg:oHScroll:SetRange( nH1,nH2 )

::nHPos := ::oDlg:oHScroll:GetPos()

::oDlg:oHScroll:bGoDown := {|| ::HScroll() }

::oDlg:oHScroll:bGoUp := {|| ::HScroll() }

::oDlg:oHScroll:bPageUp := {|| ::HScrollPgUp() }

::oDlg:oHScroll:bPageDown := {|| ::HScrollPgDown() }

::oDlg:oHScroll:bGoTop := {|| ::HScroll() }

::oDlg:oHScroll:bGoBottom := {|| ::HScroll() }

::oDlg:oHScroll:nPgStep := 10

//::oDlg:oHScroll:lReDraw := TRUE

::oDlg:oHScroll:bPos := {|nPos| ::HScrollThumb(nPos) }

::oDlg:oHScroll:bTrack := {|nPos| ::HScrollTrack(nPos) }

endif

* ::oDlg:bKeyChar := {|nKey,nFlags| ScrollKey(nKey) }

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

RETURN( NIL )

/*

STATIC FUNCTION ScrollKey(nKey)

MsgInfo( "Key : "+str(nKey,10) )

//if nKey == K_ENTER

// goMainDlg:End()

// lRetVal := TRUE

//endif

RETURN( NIL )

*/

//=================================================================

//-* Vertical Scroll Bar

METHOD VScroll() CLASS TScrDlg

LOCAL nNewPos

if ::nVPos >= ::oDlg:oVScroll:nMin ;

.and. ::nVPos <= ::oDlg:oVScroll:nMax

nNewPos := ::oDlg:oVScroll:GetPos()

SysRefresh()

ScrollWindow( ::oDlg:hWnd, 0, ;

( ::nVPos-nNewPos )*d_height, ;

0 , GetClientRect(::oDlg:hWnd) )

::nVPos := nNewPos

endif

RETURN( NIL )

METHOD VScrollThumb(nNewPos) CLASS TScrDlg

if ::nVPos >= ::oDlg:oVScroll:nMin ;

.and. ::nVPos <= ::oDlg:oVScroll:nMax

::oDlg:oVScroll:SetPos(nNewPos)

SysRefresh()

ScrollWindow( ::oDlg:hWnd, 0, ;

(::nVPos - nNewPos )*d_height, ;

0 , GetClientRect(::oDlg:hWnd) )

::nVPos := nNewPos

endif

RETURN( NIL )

METHOD VScrollTrack(nNewPos) CLASS TScrDlg

if ::nVPos >= ::oDlg:oVScroll:nMin ;

.and. ::nVPos <= ::oDlg:oVScroll:nMax

::oDlg:oVScroll:SetPos(nNewPos)

SysRefresh()

ScrollWindow( ::oDlg:hWnd, 0, ;

(::nVPos - nNewPos )*d_height, ;

0 , GetClientRect(::oDlg:hWnd) )

::nVPos := nNewPos

endif

RETURN( NIL )

METHOD VScrollPgDown() CLASS TScrDlg

LOCAL nNewPos

if ::nVPos < ::oDlg:oVScroll:nMax

nNewPos := ::nVPos + ::oDlg:oVScroll:nPgStep

nNewPos := iif(nNewPos > ::oDlg:oVScroll:nMax, ::oDlg:oVScroll:nMax, nNewPos)

SysRefresh()

ScrollWindow( ::oDlg:hWnd, 0, ;

( ::nVPos - nNewPos )*d_height, ;

0 , GetClientRect(::oDlg:hWnd) )

::nVPos := nNewPos

endif

RETURN( NIL )

METHOD VScrollPgUp() CLASS TScrDlg

LOCAL nNewPos

if ::nVPos > ::oDlg:oVScroll:nMin

nNewPos := ::nVPos - ::oDlg:oVScroll:nPgStep

nNewPos := iif(nNewPos < ::oDlg:oVScroll:nMin,::oDlg:oVScroll:nMin,nNewPos)

SysRefresh()

ScrollWindow( ::oDlg:hWnd, 0, ;

( ::nVPos - nNewPos )*d_height, ;

0 , GetClientRect(::oDlg:hWnd) )

::nVPos := nNewPos

endif

RETURN( NIL )

//=================================================================

//-* Horizontal Scroll Bar

METHOD HScroll() CLASS TScrDlg

LOCAL nNewPos

if ::nHPos >= ::oDlg:oHScroll:nMin ;

.and. ::nHPos <= ::oDlg:oHScroll:nMax

nNewPos := ::oDlg:oHScroll:GetPos()

SysRefresh()

ScrollWindow( ::oDlg:hWnd, ;

(::nHPos - nNewPos )*d_width,0, ;

0 , GetClientRect(::oDlg:hWnd) )

::nHPos := nNewPos

endif

RETURN( NIL )

METHOD HScrollThumb(nNewPos) CLASS TScrDlg

if ::nHPos >= ::oDlg:oHScroll:nMin ;

.and. ::nHPos <= ::oDlg:oHScroll:nMax

::oDlg:oHScroll:SetPos(nNewPos)

SysRefresh()

ScrollWindow( ::oDlg:hWnd, ;

(::nHPos - nNewPos )*d_width,0, ;

0 , GetClientRect(::oDlg:hWnd) )

::nHPos := nNewPos

endif

RETURN( NIL )

METHOD HScrollTrack(nNewPos) CLASS TScrDlg

if ::nHPos >= ::oDlg:oHScroll:nMin ;

.and. ::nHPos <= ::oDlg:oHScroll:nMax

::oDlg:oHScroll:SetPos(nNewPos)

SysRefresh()

ScrollWindow( ::oDlg:hWnd, ;

(::nHPos - nNewPos )*d_width,0, ;

0 , GetClientRect(::oDlg:hWnd) )

::nHPos := nNewPos

endif

RETURN( NIL )

METHOD HScrollPgDown() CLASS TScrDlg

LOCAL nNewPos

if ::nHPos < ::oDlg:oHScroll:nMax

nNewPos := ::nHPos + ::oDlg:oHScroll:nPgStep

nNewPos := iif(nNewPos > ::oDlg:oHScroll:nMax, ::oDlg:oHScroll:nMax, nNewPos)

SysRefresh()

ScrollWindow( ::oDlg:hWnd, ;

( ::nHPos - nNewPos )*d_width,0, ;

0 , GetClientRect(::oDlg:hWnd) )

::nHPos := nNewPos

endif

RETURN( NIL )

METHOD HScrollPgUp() CLASS TScrDlg

LOCAL nNewPos

if ::nHPos > ::oDlg:oHScroll:nMin

nNewPos := ::nHPos - ::oDlg:oHScroll:nPgStep

nNewPos := iif(nNewPos < ::oDlg:oHScroll:nMin,::oDlg:oHScroll:nMin,nNewPos)

SysRefresh()

ScrollWindow( ::oDlg:hWnd, ;

( ::nHPos - nNewPos )*d_width,0, ;

0 , GetClientRect(::oDlg:hWnd) )

::nHPos := nNewPos

endif

RETURN( NIL )

//=* End of File =================================================

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...