Aca dejo scroll.c sin WARNING.
- Code: Select all Expand view
// Modificado por José - para desplegar las barras de scroll proporcionales (tipo W95/98/2000)
// Modified by Manuel Mercado for TSBrowse, last update: February 27th, 2002
#include <WinTen.h> // set proper path if needed
#include <Windows.h>
#ifndef __HARBOUR__
#include <ClipApi.h> // set proper path if needed
#else
#include <hbapi.h>
#endif
#ifndef __FLAT__
#ifndef __HARBOUR__
typedef struct
{
DWORD cbSize ;
DWORD fMask ;
long nMin ;
long nMax ;
DWORD nPage ;
long nPos ;
long nTrackPos ;
} SCROLLINFO ;
typedef SCROLLINFO FAR * LPSCROLLINFO ;
#define SIF_RANGE 1
#define SIF_PAGE 2
#define SIF_POS 4
#define SIF_DISABLENOSCROLL 8
#define SIF_TRACKPOS 16
#endif
#endif
//----------------------------------------------------------------------------//
static BOOL SetScrInfo( HWND hWnd, int nScrollBar, LPSCROLLINFO si, BOOL lRedraw)
{
#ifndef __HARBOUR__
typedef BOOL ( WINAPI * FN )( HWND, int, LPSCROLLINFO, BOOL ) ;
FN p = ( FN ) GetProcAddress( GetModuleHandle( "USER" ), "SetScrollInfo" ) ;
if( p )
return ( p( ( HWND ) hWnd, nScrollBar, si, lRedraw ) ) ;
else
return ( FALSE ) ;
#else
return SetScrollInfo( hWnd, nScrollBar, si, lRedraw ) ;
#endif
}
//----------------------------------------------------------------------------//
#ifdef __HARBOUR__
HB_FUNC ( SETSCROLLRANGE ) // ( hWnd, nFlags, nMin, nMax, lRepaint, lDisable, l32Bit )
#else
CLIPPER SETSCROLLR( PARAMS ) // ANGE()
#endif
{
SCROLLINFO si ;
si.cbSize = sizeof( si ) ;
si.fMask = SIF_RANGE ;
#ifndef __HARBOUR__
si.nMin = _parni( 3 ) ;
si.nMax = _parni( 4 ) ;
if (_parl(6))
si.fMask = SIF_RANGE + SIF_DISABLENOSCROLL ;
if (_parl(7))
_retl( SetScrInfo( ( HWND ) _parnl( 1 ), _parni( 2 ), &si, _parl( 5 ) ) ) ;
else // NT does not support SetScrollInfo() API function
_retni( SetScrollRange( ( HWND ) _parnl( 1 ), // its hWnd
_parni( 2 ), // Scroll Bar flags
_parni( 3 ), // Min
_parni( 4 ), // Max
_parl( 5 ) ) ) ; // ReDraw
#else
si.nMin = hb_parni( 3 ) ;
si.nMax = hb_parni( 4 ) ;
if (hb_parl(6))
si.fMask = SIF_RANGE + SIF_DISABLENOSCROLL ;
if (hb_parl(7))
hb_retl( SetScrInfo( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ), &si, hb_parl( 5 ) ) ) ;
else // NT does not support SetScrollInfo() API function
hb_retni( SetScrollRange( ( HWND ) hb_parnl( 1 ), // its hWnd
hb_parni( 2 ), // Scroll Bar flags
hb_parni( 3 ), // Min
hb_parni( 4 ), // Max
hb_parl( 5 ) ) ) ; // ReDraw
#endif
}
//----------------------------------------------------------------------------//
#ifdef __HARBOUR__
HB_FUNC ( SETSCROLLPOS ) // ( HWND, NFLAGS, NPOS, LREPAINT, LDISABLE, L32BIT )
#else
CLIPPER SETSCROLLP( PARAMS ) // OS
#endif
{
SCROLLINFO si;
#ifndef __HARBOUR__
si.cbSize = sizeof( si );
si.fMask = SIF_POS;
si.nPos = _parni( 3 );
if (_parl(5))
si.fMask = SIF_POS + SIF_DISABLENOSCROLL ;
if ( _parl( 6 ) )
_retl( SetScrInfo( ( HWND ) _parnl( 1 ), _parni( 2 ), &si, _parl( 4 ) ) ) ;
else // NT does not support SetScrollInfo() API function
_retl( SetScrollPos( ( HWND ) _parnl( 1 ), // its hWnd
_parni( 2 ), // Scroll Bar flags
_parni( 3 ), // new Position
_parl( 4 ) ) ) ; // repaint
#else
si.cbSize = sizeof( si );
si.fMask = SIF_POS;
si.nPos = hb_parni( 3 );
if (hb_parl(5))
si.fMask = SIF_POS + SIF_DISABLENOSCROLL ;
if ( hb_parl( 6 ) )
hb_retl( SetScrInfo( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ), &si, hb_parl( 4 ) ) ) ;
else // NT does not support SetScrollInfo() API function
hb_retl( SetScrollPos( ( HWND ) hb_parnl( 1 ), // its hWnd
hb_parni( 2 ), // Scroll Bar flags
hb_parni( 3 ), // new Position
hb_parl( 4 ) ) ) ; // repaint
#endif
}
//----------------------------------------------------------------------------//
#ifdef __HARBOUR__
HB_FUNC ( GETSCROLLRANGE )
#else
CLIPPER GETSCROLLR( PARAMS ) // ANGE
#endif
{
int iMin = 0, iMax = 0 ;
#ifdef __FLAT__
#ifndef __HARBOUR__
#define _storni( x, y, z ) STORNI( x, params, y, z )
#endif
#endif
#ifndef __HARBOUR__
GetScrollRange( ( HWND ) _parnl( 1 ), // its hWnd
_parni( 2 ), // Scroll bar flags
&iMin,
&iMax ) ;
_reta( 2 ) ; // { nMin, nMax }
_storni( iMin, -1, 1 ) ;
_storni( iMax, -1, 2 ) ;
#else
GetScrollRange( ( HWND ) hb_parnl( 1 ), // its hWnd
hb_parni( 2 ), // Scroll bar flags
&iMin,
&iMax ) ;
hb_reta( 2 ) ; // { nMin, nMax }
hb_storni( iMin, -1, 1 ) ;
hb_storni( iMax, -1, 2 ) ;
#endif
}
//----------------------------------------------------------------------------//
#ifdef __HARBOUR__
HB_FUNC ( GETSCROLLPOS ) // ( HWND, NFLAGS )
#else
CLIPPER GETSCROLLP( PARAMS ) // OS
#endif
{
#ifndef __HARBOUR__
_retni( GetScrollPos( ( HWND ) _parnl( 1 ), // its hWnd
_parni( 2 ) ) ) ; // Scroll bar flags
#else
hb_retni( GetScrollPos( ( HWND ) hb_parnl( 1 ), // its hWnd
hb_parni( 2 ) ) ) ; // Scroll bar flags
#endif
}
//----------------------------------------------------------------------------//
#ifdef __HARBOUR__
HB_FUNC ( SETSCROLLINFO ) // ( HWND, NFLAGS, NSIZE, LREDRAW, LSHOWDISABLED )
#else
CLIPPER SETSCROLLI( PARAMS ) // NFO()
#endif
{
SCROLLINFO si;
si.cbSize = sizeof( si );
si.fMask = SIF_PAGE ;
#ifndef __HARBOUR__
si.nPage = _parni( 3 );
if ( _parl( 5 ) )
si.fMask += SIF_DISABLENOSCROLL ;
_retl( SetScrInfo( ( HWND ) _parnl( 1 ), _parni( 2 ), &si, _parl( 4 ) ) ) ;
#else
si.nPage = hb_parni( 3 );
if ( hb_parl( 5 ) )
si.fMask += SIF_DISABLENOSCROLL ;
hb_retl( SetScrInfo( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ), &si, hb_parl( 4 ) ) ) ;
#endif
}
//----------------------------------------------------------------------------//