Scroll issue

Scroll issue

Postby Jeff Barnes » Fri May 22, 2009 12:03 am

Hi,

In my code below I am creating lines in a window.
When I scroll left and right the lines are not being reproduced as they should.

Can someone please tell me where I have gone wrong ?

Code: Select all  Expand view
#include "FiveWin.ch"

Static oWnd, oBrushLine

#define D_WIDTH           4
#define D_HEIGHT          13

Function Main()
   DEFINE BRUSH oBrushLine COLOR nRGB( 0, 0, 0 )

   DEFINE WINDOW oWnd TITLE "TEST" HSCROLL
   ACTIVATE WINDOW oWnd on paint DrawScreen()   ON INIT ( TScrWnd():New(oWnd,1,40,1,70) )
Return Nil 

Function DrawScreen()
   Local nCol := 150, nRow:=100, aRect:={}, n

   //Vert Lines
   for n = 1 to 100
      aRect := {nRow,nCol,600,nCol+1}
      FillRect( oWnd:hDC, aRect, oBrushLine:hBrush)
      nCol +=25
   Next

   //Horiz Lines
   nCol := 0
   for n = 1 to 20
      aRect := {nRow,nCol,nRow+1,1500}
      FillRect( oWnd:hDC, aRect, oBrushLine:hBrush)
      nRow +=25
   Next      
Return Nil


//-------------------------------------------------------------//
CLASS TMyWindow FROM TWindow

   CLASSDATA lRegistered AS LOGICAL

   DATA   bMouseWheel

   METHOD MouseWheel( nKey, nDelta, nXPos, nYPos ) INLINE ;
          If( ::bMouseWheel != nil, Eval( ::bMouseWheel, nKey, nDelta, nXPos, nYPos ),)
   
ENDCLASS  

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

#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 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 )
   ::oWnd:bMouseWheel = { | nKey, nDelta, nXPos, nYPos | If( nDelta < 0, ::oWnd:oVScroll:GoDown(), ::oWnd:oVScroll:GoUp() ) }
RETURN Self


METHOD SetScroll( nV1,nV2,nH1,nH2 ) CLASS TScrWnd
LOCAL aCoors1:={},aCoors2:={}
   //--------------------------------------------------
   //-* 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 := .t. //TRUE
      ::oWnd:oHScroll:bPos      := {|nPos| ::HScrollThumb(nPos) }
      ::oWnd:oHScroll:bTrack    := {|nPos| ::HScrollTrack(nPos) }
   endif
   ::oWnd:Paint()
   //::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 )

//=================================================================
//-* 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 )



 
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: Scroll issue

Postby Jeff Barnes » Fri May 22, 2009 6:39 pm

I have found another issue with scrolling...

oWnd:blClicked = { | ncRow, ncCol, ncFlags | Msginfo(ncCol) }

If I point my mouse at the far right of the window and click (before scrolling) I get the exact same number if I scroll to the end of the window and do the same thing.

Is there a solution for this?
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: Scroll issue

Postby Jeff Barnes » Fri May 22, 2009 11:12 pm

Is there maybe another way to do the scrolling or have I missed something in my code?
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: Scroll issue

Postby Jeff Barnes » Sun May 24, 2009 11:57 am

Can anyone please help me with these 2 issues or should I be looking at another way to do what I want?

1. When scrolling the screen is not refreshing correctly
2. When trying to locate the position of a click, it does not work correctly if window is scrolled
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: Scroll issue

Postby Antonio Linares » Sun May 24, 2009 3:42 pm

Jeff,

Could you provide an overall explanation of what you want to implement ? Thanks,

ScrollWindow() just moves (scrolls) the contents of the window but the mouse coordinates remains the same (its ok) and the painting resposability is up to you. Windows will not paint the new exposed areas. It sends a paint msg to you and you have to properly do it.

A good example would be a browse. We are responsible for doing the scroll and the painting.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41439
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Scroll issue

Postby Jeff Barnes » Sun May 24, 2009 4:51 pm

Hi Antonio,

I am trying to set up a time schedule for a medical records system.
I looked at the date picker class you and Otto worked on but it looks like I would need to make too many changes ... for me it would be easier to start from scratch.

I need to have a variable time range as some offices book appointment times a short as 10 minutes. In this situation, I can't fit it all into one screen (ex: 7:00, 7:10, 7:20 etc ... ). I also need to provide a "week" view and a "month" view.

I am considering going to a listbox type of idea ... it might be easier than drawing the info to the screen.
This way I can change the color of the cell if the time slot is booked.

Any other ideas would be most welcome :-)
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: Scroll issue

Postby Otto » Sun May 24, 2009 7:35 pm

Jeff,
how many offices do you need?
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6092
Joined: Fri Oct 07, 2005 7:07 pm

Re: Scroll issue

Postby Jeff Barnes » Sun May 24, 2009 9:03 pm

Hi Otto,

Right now I am looking at one office per install (there will of course be networked clients).
In the future I would like to have multiple offices connected and allow an exchange of information but this is a distant plan.

I am trying to develop an app that can be used by any doctors office with minimal customization. I plan to have an extensive configuration so the end user can do their own custom setup.

The app will need to have the following:
-Patient Scheduler
-Patient record (visits, prescriptions, history, results etc...)
-Billing module
-HL7 interface

These would be the main modules. There sill be many sub-modules for different areas.

It is going to be a big project and the scheduler is a major part so I was wanting to deal with it first :-)
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: Scroll issue

Postby Otto » Mon May 25, 2009 6:01 am

Hello Jeff,

sorry I used the wrong name (office) - I mean surgerys.
I contact you via private email.
BTW do you use TDATA?

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6092
Joined: Fri Oct 07, 2005 7:07 pm


Return to FiveWin for Harbour/xHarbour

Who is online

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