Scroll Window Problem

Post Reply
User avatar
Eroni
Posts: 71
Joined: Fri Jul 21, 2006 7:15 pm
Location: Criciuma/SC Brazil
Contact:

Scroll Window Problem

Post by Eroni »

Dears

I thinked that this problem was fixed in fwh 7.5, but no, any suggestions?

Eroni

Code:
#include "FiveWin.ch"

#define D_WIDTH 4
#define D_HEIGHT 13

FUNCTION Main()

LOCAL oWnd,oScrWnd, oBar
define window oWnd from 0, 0 TO 25, 70 ;
title "Scroll Window" ;
vscroll hscroll ;
MENU BuildMenu()

@ 001,001 BUTTONBAR oBar 3D SIZE oWnd:nRight-oWnd:nLeft,50 BUTTONSIZE 48 ,48 OF oWnd // here button bar

ACTIVATE WINDOW oWnd ;
ON INIT ( TScrWnd():New(oWnd,1,40,1,70) ) ;

RETURN( NIL )

function BuildMenu()
LOCAL oMenu

MENU oMenu
MENUITEM "&File"
MENU
MENUITEM "&Open"
MENUITEM "&Close"
MENUITEM "&Save"
MENUITEM "&End"
ENDMENU
ENDMENU

return oMenu

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


//============================================================================
// FileName : SCROLL.PRG
// Purpose : Windows Scroll Class
// Author : Eric Yang
// Update History :
// Date Contents
// ---------- ---------------------------------------------------------------
// 1997.02.01
//
//============================================================================
#include "FiveWin.ch"

#ifndef TRUE
#define TRUE .T.
#define FALSE .F.
#endif

CLASS TScrWnd

DATA oWnd
DATA nVPos,nHPos

METHOD New( oWnd,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( oWnd,nV1,nV2,nH1,nH2 ) CLASS TScrWnd
::nVPos := 0
::nHPos := 0
::oWnd := oWnd
::SetScroll( nV1,nV2,nH1,nH2 )
RETURN Self


METHOD SetScroll( nV1,nV2,nH1,nH2 ) CLASS TScrWnd
LOCAL aCoors1:={},aCoors2:={}
//--------------------------------------------------
//-* Vertical Scroll Bar
// ? ::oWnd:oVSCroll=NIL
if ::oWnd:oVScroll != NIL
// ? nV1,nV2
::oWnd:oVScroll:SetRange( nV1,nV2 )
::nVPos := ::oWnd:oVScroll:GetPos()
::oWnd:oVScroll:bGoDown := {|| ::VScroll() }
::oWnd:oVScroll:bGoUp := {|| ::VScroll() }
::oWnd:oVScroll:bPageUp := {|| ::VScrollPgUp() }
::oWnd:oVScroll:bPageDown := {|| ::VScrollPgDown() }
::oWnd:oVScroll:bGoTop := {|| ::VScroll() }
::oWnd:oVScroll:bGoBottom := {|| ::VScroll() }
::oWnd:oVScroll:nPgStep := 10
//::oWnd:oVScroll:lReDraw := TRUE
::oWnd:oVScroll:bPos := {|nPos| ::VScrollThumb(nPos) }
::oWnd:oVScroll:bTrack := {|nPos| ::VScrollTrack(nPos) }
endif
//--------------------------------------------------
//-* Horizontal Scroll Bar
if ::oWnd:oHScroll != NIL
::oWnd:oHScroll:SetRange( nH1,nH2 )
::nHPos := ::oWnd:oHScroll:GetPos()
::oWnd:oHScroll:bGoDown := {|| ::HScroll() }
::oWnd:oHScroll:bGoUp := {|| ::HScroll() }
::oWnd:oHScroll:bPageUp := {|| ::HScrollPgUp() }
::oWnd:oHScroll:bPageDown := {|| ::HScrollPgDown() }
::oWnd:oHScroll:bGoTop := {|| ::HScroll() }
::oWnd:oHScroll:bGoBottom := {|| ::HScroll() }
::oWnd:oHScroll:nPgStep := 10
//::oWnd:oHScroll:lReDraw := TRUE
::oWnd:oHScroll:bPos := {|nPos| ::HScrollThumb(nPos) }
::oWnd:oHScroll:bTrack := {|nPos| ::HScrollTrack(nPos) }
endif
//::oWnd: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 TScrWnd
LOCAL nNewPos
if ::nVPos >= ::oWnd:oVScroll:nMin ;
.and. ::nVPos <= ::oWnd:oVScroll:nMax
nNewPos := ::oWnd:oVScroll:GetPos()
SysRefresh()

ScrollWindow( ::oWnd:hWnd, 0, ;
( ::nVPos-nNewPos )*D_HEIGHT, ;
0 , GetClientRect(::oWnd:hWnd) )
::nVPos := nNewPos
endif
RETURN( NIL )

METHOD VScrollThumb(nNewPos) CLASS TScrWnd
if ::nVPos >= ::oWnd:oVScroll:nMin ;
.and. ::nVPos <= ::oWnd:oVScroll:nMax
::oWnd:oVScroll:SetPos(nNewPos)
SysRefresh()
ScrollWindow( ::oWnd:hWnd, 0, ;
(::nVPos - nNewPos )*D_HEIGHT, ;
0 , GetClientRect(::oWnd:hWnd) )
::nVPos := nNewPos
endif
RETURN( NIL )

METHOD VScrollTrack(nNewPos) CLASS TScrWnd
if ::nVPos >= ::oWnd:oVScroll:nMin ;
.and. ::nVPos <= ::oWnd:oVScroll:nMax
::oWnd:oVScroll:SetPos(nNewPos)
SysRefresh()
ScrollWindow( ::oWnd:hWnd, 0, ;
(::nVPos - nNewPos )*D_HEIGHT, ;
0 , GetClientRect(::oWnd:hWnd) )
::nVPos := nNewPos
endif
RETURN( NIL )

METHOD VScrollPgDown() CLASS TScrWnd
LOCAL nNewPos
if ::nVPos < ::oWnd:oVScroll:nMax
nNewPos := ::nVPos + ::oWnd:oVScroll:nPgStep
nNewPos := iif(nNewPos > ::oWnd:oVScroll:nMax, ::oWnd:oVScroll:nMax, nNewPos)
SysRefresh()
ScrollWindow( ::oWnd:hWnd, 0, ;
( ::nVPos - nNewPos )*D_HEIGHT, ;
0 , GetClientRect(::oWnd:hWnd) )
::nVPos := nNewPos
endif
RETURN( NIL )

METHOD VScrollPgUp() CLASS TScrWnd
LOCAL nNewPos
if ::nVPos > ::oWnd:oVScroll:nMin
nNewPos := ::nVPos - ::oWnd:oVScroll:nPgStep
nNewPos := iif(nNewPos < ::oWnd:oVScroll:nMin,::oWnd:oVScroll:nMin,nNewPos)
SysRefresh()
ScrollWindow( ::oWnd:hWnd, 0, ;
( ::nVPos - nNewPos )*D_HEIGHT, ;
0 , GetClientRect(::oWnd:hWnd) )
::nVPos := nNewPos
endif
RETURN( NIL )

//=================================================================
//-* Horizontal Scroll Bar
METHOD HScroll() CLASS TScrWnd
LOCAL nNewPos
if ::nHPos >= ::oWnd:oHScroll:nMin ;
.and. ::nHPos <= ::oWnd:oHScroll:nMax
nNewPos := ::oWnd:oHScroll:GetPos()
SysRefresh()
ScrollWindow( ::oWnd:hWnd, ;
(::nHPos - nNewPos )*D_WIDTH,0, ;
0 , GetClientRect(::oWnd:hWnd) )
::nHPos := nNewPos
endif
RETURN( NIL )

METHOD HScrollThumb(nNewPos) CLASS TScrWnd
if ::nHPos >= ::oWnd:oHScroll:nMin ;
.and. ::nHPos <= ::oWnd:oHScroll:nMax
::oWnd:oHScroll:SetPos(nNewPos)
SysRefresh()
ScrollWindow( ::oWnd:hWnd, ;
(::nHPos - nNewPos )*D_WIDTH,0, ;
0 , GetClientRect(::oWnd:hWnd) )
::nHPos := nNewPos
endif
RETURN( NIL )

METHOD HScrollTrack(nNewPos) CLASS TScrWnd
if ::nHPos >= ::oWnd:oHScroll:nMin ;
.and. ::nHPos <= ::oWnd:oHScroll:nMax
::oWnd:oHScroll:SetPos(nNewPos)
SysRefresh()
ScrollWindow( ::oWnd:hWnd, ;
(::nHPos - nNewPos )*D_WIDTH,0, ;
0 , GetClientRect(::oWnd:hWnd) )
::nHPos := nNewPos
endif
RETURN( NIL )

METHOD HScrollPgDown() CLASS TScrWnd
LOCAL nNewPos
if ::nHPos < ::oWnd:oHScroll:nMax
nNewPos := ::nHPos + ::oWnd:oHScroll:nPgStep
nNewPos := iif(nNewPos > ::oWnd:oHScroll:nMax, ::oWnd:oHScroll:nMax, nNewPos)
SysRefresh()
ScrollWindow( ::oWnd:hWnd, ;
( ::nHPos - nNewPos )*D_WIDTH,0, ;
0 , GetClientRect(::oWnd:hWnd) )
::nHPos := nNewPos
endif
RETURN( NIL )

METHOD HScrollPgUp() CLASS TScrWnd
LOCAL nNewPos
if ::nHPos > ::oWnd:oHScroll:nMin
nNewPos := ::nHPos - ::oWnd:oHScroll:nPgStep
nNewPos := iif(nNewPos < ::oWnd:oHScroll:nMin,::oWnd:oHScroll:nMin,nNewPos)
SysRefresh()
ScrollWindow( ::oWnd:hWnd, ;
( ::nHPos - nNewPos )*D_WIDTH,0, ;
0 , GetClientRect(::oWnd:hWnd) )
::nHPos := nNewPos
endif
RETURN( NIL )

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

procedure AppSys // Xbase++ requirement

return
User avatar
Ugo
Posts: 283
Joined: Sat Oct 15, 2005 6:40 am
Location: Turin, Italy

Re: Scroll Window Problem

Post by Ugo »

Eroni wrote:Dears

I thinked that this problem was fixed in fwh 7.5, but no, any suggestions?
Hi Eroni,

with FWHX 7.04, xHb 0.99.71 and Windows Vista Business work well.
Ciao, best regards,
Ugo
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

With FWH 7.07 and Vista Ultimate 32 bits is working fine:
Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Eroni
Posts: 71
Joined: Fri Jul 21, 2006 7:15 pm
Location: Criciuma/SC Brazil
Contact:

Post by Eroni »

Antonio,

Do you tested try scroll window clicking vertical scroll bar?

When I try scroll window, scroll button bar too.

Regards

Eroni
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Eroni,

> When I try scroll window, scroll button bar too.

Yes, but thats a normal behavior as the button bar is a child of the main window

You may use a MDI main window where the buttonbar is and then implement the scroll window on a MDICHILD window
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Eroni
Posts: 71
Joined: Fri Jul 21, 2006 7:15 pm
Location: Criciuma/SC Brazil
Contact:

Post by Eroni »

Is possible post a sample how do this?

Eroni
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Here you have you sample modified:

Code: Select all

#include "FiveWin.ch" 

#define D_WIDTH 4 
#define D_HEIGHT 13 

static oWndMain

function Main()

   local oBar

   DEFINE WINDOW oWndMain TITLE "MDI sample" ;
      MENU BuildMenu() MDI

   DEFINE BUTTONBAR oBar 3D BUTTONSIZE 48, 48 OF oWndMain // here button bar 
   
   ACTIVATE WINDOW oWndMain MAXIMIZED
   
return nil   

FUNCTION Child() 

LOCAL oWnd,oScrWnd
define window oWnd from 0, 0 TO 25, 70 ; 
title "Scroll Window" ; 
vscroll hscroll MDICHILD OF oWndMain

TScrWnd():New( oWnd, 1, 40, 1, 70 ) 

RETURN( NIL ) 

function BuildMenu() 
LOCAL oMenu 

MENU oMenu 
MENUITEM "&Child Window"
MENU 
MENUITEM "&Open" ACTION Child()
MENUITEM "&Close" 
MENUITEM "&Save" 
MENUITEM "&End" 
ENDMENU 
ENDMENU 

return oMenu 

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


//============================================================================ 
// FileName : SCROLL.PRG 
// Purpose : Windows Scroll Class 
// Author : Eric Yang 
// Update History : 
// Date Contents 
// ---------- --------------------------------------------------------------- 
// 1997.02.01 
// 
//============================================================================ 
#include "FiveWin.ch" 

#ifndef TRUE 
#define TRUE .T. 
#define FALSE .F. 
#endif 

CLASS TScrWnd 

DATA oWnd 
DATA nVPos,nHPos 

METHOD New( oWnd,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( oWnd,nV1,nV2,nH1,nH2 ) CLASS TScrWnd 
::nVPos := 0 
::nHPos := 0 
::oWnd := oWnd 
::SetScroll( nV1,nV2,nH1,nH2 ) 
RETURN Self 


METHOD SetScroll( nV1,nV2,nH1,nH2 ) CLASS TScrWnd 
LOCAL aCoors1:={},aCoors2:={} 
//-------------------------------------------------- 
//-* Vertical Scroll Bar 
// ? ::oWnd:oVSCroll=NIL 
if ::oWnd:oVScroll != NIL 
// ? nV1,nV2 
::oWnd:oVScroll:SetRange( nV1,nV2 ) 
::nVPos := ::oWnd:oVScroll:GetPos() 
::oWnd:oVScroll:bGoDown := {|| ::VScroll() } 
::oWnd:oVScroll:bGoUp := {|| ::VScroll() } 
::oWnd:oVScroll:bPageUp := {|| ::VScrollPgUp() } 
::oWnd:oVScroll:bPageDown := {|| ::VScrollPgDown() } 
::oWnd:oVScroll:bGoTop := {|| ::VScroll() } 
::oWnd:oVScroll:bGoBottom := {|| ::VScroll() } 
::oWnd:oVScroll:nPgStep := 10 
//::oWnd:oVScroll:lReDraw := TRUE 
::oWnd:oVScroll:bPos := {|nPos| ::VScrollThumb(nPos) } 
::oWnd:oVScroll:bTrack := {|nPos| ::VScrollTrack(nPos) } 
endif 
//-------------------------------------------------- 
//-* Horizontal Scroll Bar 
if ::oWnd:oHScroll != NIL 
::oWnd:oHScroll:SetRange( nH1,nH2 ) 
::nHPos := ::oWnd:oHScroll:GetPos() 
::oWnd:oHScroll:bGoDown := {|| ::HScroll() } 
::oWnd:oHScroll:bGoUp := {|| ::HScroll() } 
::oWnd:oHScroll:bPageUp := {|| ::HScrollPgUp() } 
::oWnd:oHScroll:bPageDown := {|| ::HScrollPgDown() } 
::oWnd:oHScroll:bGoTop := {|| ::HScroll() } 
::oWnd:oHScroll:bGoBottom := {|| ::HScroll() } 
::oWnd:oHScroll:nPgStep := 10 
//::oWnd:oHScroll:lReDraw := TRUE 
::oWnd:oHScroll:bPos := {|nPos| ::HScrollThumb(nPos) } 
::oWnd:oHScroll:bTrack := {|nPos| ::HScrollTrack(nPos) } 
endif 
//::oWnd: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 TScrWnd 
LOCAL nNewPos 
if ::nVPos >= ::oWnd:oVScroll:nMin ; 
.and. ::nVPos <= ::oWnd:oVScroll:nMax 
nNewPos := ::oWnd:oVScroll:GetPos() 
SysRefresh() 

ScrollWindow( ::oWnd:hWnd, 0, ; 
( ::nVPos-nNewPos )*D_HEIGHT, ; 
0 , GetClientRect(::oWnd:hWnd) ) 
::nVPos := nNewPos 
endif 
RETURN( NIL ) 

METHOD VScrollThumb(nNewPos) CLASS TScrWnd 
if ::nVPos >= ::oWnd:oVScroll:nMin ; 
.and. ::nVPos <= ::oWnd:oVScroll:nMax 
::oWnd:oVScroll:SetPos(nNewPos) 
SysRefresh() 
ScrollWindow( ::oWnd:hWnd, 0, ; 
(::nVPos - nNewPos )*D_HEIGHT, ; 
0 , GetClientRect(::oWnd:hWnd) ) 
::nVPos := nNewPos 
endif 
RETURN( NIL ) 

METHOD VScrollTrack(nNewPos) CLASS TScrWnd 
if ::nVPos >= ::oWnd:oVScroll:nMin ; 
.and. ::nVPos <= ::oWnd:oVScroll:nMax 
::oWnd:oVScroll:SetPos(nNewPos) 
SysRefresh() 
ScrollWindow( ::oWnd:hWnd, 0, ; 
(::nVPos - nNewPos )*D_HEIGHT, ; 
0 , GetClientRect(::oWnd:hWnd) ) 
::nVPos := nNewPos 
endif 
RETURN( NIL ) 

METHOD VScrollPgDown() CLASS TScrWnd 
LOCAL nNewPos 
if ::nVPos < ::oWnd:oVScroll:nMax 
nNewPos := ::nVPos + ::oWnd:oVScroll:nPgStep 
nNewPos := iif(nNewPos > ::oWnd:oVScroll:nMax, ::oWnd:oVScroll:nMax, nNewPos) 
SysRefresh() 
ScrollWindow( ::oWnd:hWnd, 0, ; 
( ::nVPos - nNewPos )*D_HEIGHT, ; 
0 , GetClientRect(::oWnd:hWnd) ) 
::nVPos := nNewPos 
endif 
RETURN( NIL ) 

METHOD VScrollPgUp() CLASS TScrWnd 
LOCAL nNewPos 
if ::nVPos > ::oWnd:oVScroll:nMin 
nNewPos := ::nVPos - ::oWnd:oVScroll:nPgStep 
nNewPos := iif(nNewPos < ::oWnd:oVScroll:nMin,::oWnd:oVScroll:nMin,nNewPos) 
SysRefresh() 
ScrollWindow( ::oWnd:hWnd, 0, ; 
( ::nVPos - nNewPos )*D_HEIGHT, ; 
0 , GetClientRect(::oWnd:hWnd) ) 
::nVPos := nNewPos 
endif 
RETURN( NIL ) 

//================================================================= 
//-* Horizontal Scroll Bar 
METHOD HScroll() CLASS TScrWnd 
LOCAL nNewPos 
if ::nHPos >= ::oWnd:oHScroll:nMin ; 
.and. ::nHPos <= ::oWnd:oHScroll:nMax 
nNewPos := ::oWnd:oHScroll:GetPos() 
SysRefresh() 
ScrollWindow( ::oWnd:hWnd, ; 
(::nHPos - nNewPos )*D_WIDTH,0, ; 
0 , GetClientRect(::oWnd:hWnd) ) 
::nHPos := nNewPos 
endif 
RETURN( NIL ) 

METHOD HScrollThumb(nNewPos) CLASS TScrWnd 
if ::nHPos >= ::oWnd:oHScroll:nMin ; 
.and. ::nHPos <= ::oWnd:oHScroll:nMax 
::oWnd:oHScroll:SetPos(nNewPos) 
SysRefresh() 
ScrollWindow( ::oWnd:hWnd, ; 
(::nHPos - nNewPos )*D_WIDTH,0, ; 
0 , GetClientRect(::oWnd:hWnd) ) 
::nHPos := nNewPos 
endif 
RETURN( NIL ) 

METHOD HScrollTrack(nNewPos) CLASS TScrWnd 
if ::nHPos >= ::oWnd:oHScroll:nMin ; 
.and. ::nHPos <= ::oWnd:oHScroll:nMax 
::oWnd:oHScroll:SetPos(nNewPos) 
SysRefresh() 
ScrollWindow( ::oWnd:hWnd, ; 
(::nHPos - nNewPos )*D_WIDTH,0, ; 
0 , GetClientRect(::oWnd:hWnd) ) 
::nHPos := nNewPos 
endif 
RETURN( NIL ) 

METHOD HScrollPgDown() CLASS TScrWnd 
LOCAL nNewPos 
if ::nHPos < ::oWnd:oHScroll:nMax 
nNewPos := ::nHPos + ::oWnd:oHScroll:nPgStep 
nNewPos := iif(nNewPos > ::oWnd:oHScroll:nMax, ::oWnd:oHScroll:nMax, nNewPos) 
SysRefresh() 
ScrollWindow( ::oWnd:hWnd, ; 
( ::nHPos - nNewPos )*D_WIDTH,0, ; 
0 , GetClientRect(::oWnd:hWnd) ) 
::nHPos := nNewPos 
endif 
RETURN( NIL ) 

METHOD HScrollPgUp() CLASS TScrWnd 
LOCAL nNewPos 
if ::nHPos > ::oWnd:oHScroll:nMin 
nNewPos := ::nHPos - ::oWnd:oHScroll:nPgStep 
nNewPos := iif(nNewPos < ::oWnd:oHScroll:nMin,::oWnd:oHScroll:nMin,nNewPos) 
SysRefresh() 
ScrollWindow( ::oWnd:hWnd, ; 
( ::nHPos - nNewPos )*D_WIDTH,0, ; 
0 , GetClientRect(::oWnd:hWnd) ) 
::nHPos := nNewPos 
endif 
RETURN( NIL ) 
Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Eroni
Posts: 71
Joined: Fri Jul 21, 2006 7:15 pm
Location: Criciuma/SC Brazil
Contact:

Post by Eroni »

Antonio, thank you so much !

Regards,
Eroni
Post Reply