oMeta difference FW & FWH?

Postby Antonio Linares » Tue Aug 14, 2007 8:44 am

Marc,

You need to provide a bigger hDC. You could create a "bigger" window and get its hDC:

DEFINE WINDOW oWnd SIZE 4000, 2000

hDC = GetDC( oWnd:hWnd )
... your code
ReleaseDC( oWnd:hWnd, hDC )

oWnd:End()
regards, saludos

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

Postby Marc Vanzegbroeck » Tue Aug 14, 2007 9:58 am

Thanks,

I will try it.

Regards,
Marc
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Postby Marc Vanzegbroeck » Tue Aug 14, 2007 10:19 am

Antonio,

I doesn't work.
The size of the emf-file is still the same...

Here is my testcode
Code: Select all  Expand view
FUNCTION test()
   local hPEN := CreatePen( 0 , 1, 0 )
   local w := getsysmetrics(0) - 10
   local h := getsysmetrics(1) - 68
   nZFactor = 1

   DEFINE WINDOW sWnd FROM 0,0 TO 4000,4000 TITLE 'Test' VSCROLL HSCROLL
   hdc = GetDC( 0 )
   hDCOut := CreateEnhMetaFile(hdc,'tmp.emf','testje')

   MoveTo( hDCOut, 0        , 0 )
   LineTo( hDCOut, 0        ,h      , hPen)

   LineTo( hDCOut, w     ,   h    , hPen)
   LineTo( hDCOut, w     ,   0    , hPen)
   LineTo( hDCOut, 0     ,   0    , hPen)
   LineTo( hDCOut, w     ,   h    , hPen)
   LineTo( hDCOut, w     ,   0    , hPen)
   LineTo( hDCOut, 0     ,   h    , hPen)

   CloseEnhMetaFile( hDCOut )
   ReleaseDC( 0, hdc )

   oMeta := TMetaFile():New( 38, 0, w, h,'tmp.emf',sWnd,CLR_BLACK,CLR_WHITE,h,w )

   ACTIVATE WINDOW sWnd MAXIMIZED ;
   VALID ( sWndOpen := .f. , .t.)

RETURN nil


Regards,
Marc
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Postby Antonio Linares » Tue Aug 14, 2007 10:51 am

Marc,

There are some errors in your code. Please try this:
Code: Select all  Expand view
FUNCTION test()
   local hPEN := CreatePen( 0 , 1, 0 )
   local w := getsysmetrics(0) - 10
   local h := getsysmetrics(1) - 68
   nZFactor = 1

   DEFINE WINDOW sWnd FROM 0,0 TO 4000,4000 TITLE 'Test' VSCROLL HSCROLL
   hdc = GetDC( sWnd:hWnd )
   hDCOut := CreateEnhMetaFile(hdc,'tmp.emf','testje')

   MoveTo( hDCOut, 0        , 0 )
   LineTo( hDCOut, 0        ,h      , hPen)

   LineTo( hDCOut, w     ,   h    , hPen)
   LineTo( hDCOut, w     ,   0    , hPen)
   LineTo( hDCOut, 0     ,   0    , hPen)
   LineTo( hDCOut, w     ,   h    , hPen)
   LineTo( hDCOut, w     ,   0    , hPen)
   LineTo( hDCOut, 0     ,   h    , hPen)

   CloseEnhMetaFile( hDCOut )
   ReleaseDC( sWnd:hWnd, hdc )

   oMeta := TMetaFile():New( 38, 0, w, h,'tmp.emf',sWnd,CLR_BLACK,CLR_WHITE,h,w )

   ACTIVATE WINDOW sWnd MAXIMIZED ;
   VALID ( sWndOpen := .f. , .t.)

RETURN nil
regards, saludos

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

Postby Marc Vanzegbroeck » Tue Aug 14, 2007 12:07 pm

Antonio,

It's the same result...
The size is the same as the screen.

Regards,
Marc
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Postby Marc Vanzegbroeck » Tue Sep 25, 2007 8:57 am

Antonio,

Do you have a solution for creating 'bigger' meta-files.

I allway's get the same size as the screen :(

Marc
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Postby Rossine » Tue Sep 25, 2007 5:33 pm

Hello,

See this sample:

Code: Select all  Expand view
// Testing how to scroll a window with its contents

#include "FiveWin.ch"

#define D_WIDTH           4
#define D_HEIGHT          13

FUNCTION Main()

LOCAL oWnd,oScrWnd
LOCAL cGet0101 := space(10),  ; //Row 1
      cGet0102 := space(10),  ;
      cGet0103 := space(10),  ;
      cGet0104 := space(10),  ;
      cGet0105 := space(10),  ;
      cGet0201 := space(10),  ; //Row 2
      cGet0202 := space(10),  ;
      cGet0203 := space(10),  ;
      cGet0204 := space(10),  ;
      cGet0205 := space(10),  ;
      cGet0301 := space(10),  ; //Row 3
      cGet0302 := space(10),  ;
      cGet0303 := space(10),  ;
      cGet0304 := space(10),  ;
      cGet0305 := space(10),  ;
      cGet0401 := space(10),  ; //Row 4
      cGet0402 := space(10),  ;
      cGet0403 := space(10),  ;
      cGet0404 := space(10),  ;
      cGet0405 := space(10),  ;
      cGet0501 := space(10),  ; //Row 5
      cGet0502 := space(10),  ;
      cGet0503 := space(10),  ;
      cGet0504 := space(10),  ;
      cGet0505 := space(10),  ;
      cGet0601 := space(10),  ; //Row 6
      cGet0602 := space(10),  ;
      cGet0603 := space(10),  ;
      cGet0604 := space(10),  ;
      cGet0605 := space(10),  ;
      cGet0701 := space(10),  ; //Row 7
      cGet0702 := space(10),  ;
      cGet0703 := space(10),  ;
      cGet0704 := space(10),  ;
      cGet0705 := space(10),  ;
      cGet0801 := space(10),  ; //Row 8
      cGet0802 := space(10),  ;
      cGet0803 := space(10),  ;
      cGet0804 := space(10),  ;
      cGet0805 := space(10),  ;
      cGet0901 := space(10),  ; //Row 9
      cGet0902 := space(10),  ;
      cGet0903 := space(10),  ;
      cGet0904 := space(10),  ;
      cGet0905 := space(10),  ;
      cGet1001 := space(10),  ; //Row 10
      cGet1002 := space(10),  ;
      cGet1003 := space(10),  ;
      cGet1004 := space(10),  ;
      cGet1005 := space(10),  ;
      cGet1101 := space(10),  ; //Row 11
      cGet1102 := space(10),  ;
      cGet1103 := space(10),  ;
      cGet1104 := space(10),  ;
      cGet1105 := space(10)

   define window oWnd from 0, 0 TO 25, 70 ;
         title "Scroll Window"            ;
         vscroll hscroll && mdi

   @ 9,17 bitmap file "\fwh\bitmaps\pic1.bmp" of oWnd size 120,148 adjust
   @ 9,32 bitmap file "\fwh\bitmaps\pic2.bmp" of oWnd size 120,148 adjust
   @ 9,47 bitmap file "\fwh\bitmaps\pic3.bmp" of oWnd size 120,148 adjust
   @ 9,62 bitmap file "\fwh\bitmaps\pic4.bmp" of oWnd size 120,148 adjust
   @ 9,77 bitmap file "\fwh\bitmaps\pic5.bmp" of oWnd size 120,148 adjust

   @ 21*13,02*8 say "Customer " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 23*13,02*8 say "P.O. #   " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 25*13,02*8 say "Style No." of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 27*13,02*8 say "Fabrics  " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 29*13,02*8 say "Fob      " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 31*13,02*8 say "Q'TY     " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 33*13,02*8 say "DEL.     " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 35*13,02*8 say "MAKER    " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 37*13,02*8 say "QTA      " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 39*13,02*8 say "SIZE     " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 41*13,02*8 say "Size B/D " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 43*13,02*8 say "REMARKS  " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel

   @ 21*13,17*8 say "Venture  " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 21*13,32*8 say "Sears    " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 21*13,47*8 say "Kohl's   " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 21*13,62*8 say "Kiss     " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 21*13,77*8 say "K-MART   " of oWnd update color CLR_BLACK,CLR_WHITE size 120,26 border pixel

   //-* Row 1
   @ 23*13,17*8 get cGet0101 size 120,26 of oWnd update pixel
   @ 23*13,32*8 get cGet0102 size 120,26 of oWnd update pixel
   @ 23*13,47*8 get cGet0103 size 120,26 of oWnd update pixel
   @ 23*13,62*8 get cGet0104 size 120,26 of oWnd update pixel
   @ 23*13,77*8 get cGet0105 size 120,26 of oWnd update pixel

   //-* Row 2
   @ 25*13,17*8 get cGet0201 size 120,26 of oWnd update pixel
   @ 25*13,32*8 get cGet0202 size 120,26 of oWnd update pixel
   @ 25*13,47*8 get cGet0203 size 120,26 of oWnd update pixel
   @ 25*13,62*8 get cGet0204 size 120,26 of oWnd update pixel
   @ 25*13,77*8 get cGet0205 size 120,26 of oWnd update pixel

   //-* Row 3
   @ 27*13,17*8 get cGet0301 size 120,26 of oWnd update pixel
   @ 27*13,32*8 get cGet0302 size 120,26 of oWnd update pixel
   @ 27*13,47*8 get cGet0303 size 120,26 of oWnd update pixel
   @ 27*13,62*8 get cGet0304 size 120,26 of oWnd update pixel
   @ 27*13,77*8 get cGet0305 size 120,26 of oWnd update pixel

   //-* Row 4
   @ 29*13,17*8 get cGet0401 size 120,26 of oWnd update pixel
   @ 29*13,32*8 get cGet0402 size 120,26 of oWnd update pixel
   @ 29*13,47*8 get cGet0403 size 120,26 of oWnd update pixel
   @ 29*13,62*8 get cGet0404 size 120,26 of oWnd update pixel
   @ 29*13,77*8 get cGet0405 size 120,26 of oWnd update pixel

   //-* Row 5
   @ 31*13,17*8 get cGet0501 size 120,26 of oWnd update pixel
   @ 31*13,32*8 get cGet0502 size 120,26 of oWnd update pixel
   @ 31*13,47*8 get cGet0503 size 120,26 of oWnd update pixel
   @ 31*13,62*8 get cGet0504 size 120,26 of oWnd update pixel
   @ 31*13,77*8 get cGet0505 size 120,26 of oWnd update pixel

   //-* Row 6
   @ 33*13,17*8 get cGet0601 size 120,26 of oWnd update pixel
   @ 33*13,32*8 get cGet0602 size 120,26 of oWnd update pixel
   @ 33*13,47*8 get cGet0603 size 120,26 of oWnd update pixel
   @ 33*13,62*8 get cGet0604 size 120,26 of oWnd update pixel
   @ 33*13,77*8 get cGet0605 size 120,26 of oWnd update pixel

   //-* Row 7
   @ 35*13,17*8 get cGet0701 size 120,26 of oWnd update pixel
   @ 35*13,32*8 get cGet0702 size 120,26 of oWnd update pixel
   @ 35*13,47*8 get cGet0703 size 120,26 of oWnd update pixel
   @ 35*13,62*8 get cGet0704 size 120,26 of oWnd update pixel
   @ 35*13,77*8 get cGet0705 size 120,26 of oWnd update pixel

   //-* Row 8
   @ 37*13,17*8 get cGet0801 size 120,26 of oWnd update pixel
   @ 37*13,32*8 get cGet0802 size 120,26 of oWnd update pixel
   @ 37*13,47*8 get cGet0803 size 120,26 of oWnd update pixel
   @ 37*13,62*8 get cGet0804 size 120,26 of oWnd update pixel
   @ 37*13,77*8 get cGet0805 size 120,26 of oWnd update pixel

   //-* Row 9
   @ 39*13,17*8 get cGet0901 size 120,26 of oWnd update pixel
   @ 39*13,32*8 get cGet0902 size 120,26 of oWnd update pixel
   @ 39*13,47*8 get cGet0903 size 120,26 of oWnd update pixel
   @ 39*13,62*8 get cGet0904 size 120,26 of oWnd update pixel
   @ 39*13,77*8 get cGet0905 size 120,26 of oWnd update pixel

   //-* Row 10
   @ 41*13,17*8 get cGet1001 size 120,26 of oWnd update pixel
   @ 41*13,32*8 get cGet1002 size 120,26 of oWnd update pixel
   @ 41*13,47*8 get cGet1003 size 120,26 of oWnd update pixel
   @ 41*13,62*8 get cGet1004 size 120,26 of oWnd update pixel
   @ 41*13,77*8 get cGet1005 size 120,26 of oWnd update pixel

   //-* Row 11
   @ 43*13,17*8 get cGet1101 size 120,26 of oWnd update pixel
   @ 43*13,32*8 get cGet1102 size 120,26 of oWnd update pixel
   @ 43*13,47*8 get cGet1103 size 120,26 of oWnd update pixel
   @ 43*13,62*8 get cGet1104 size 120,26 of oWnd update pixel
   @ 43*13,77*8 get cGet1105 size 120,26 of oWnd update pixel


   @ 50,20 button "&Ok" size 80,20 of oWnd   ;
      action (MsgInfo("You click OK button!"),oWnd:End())

   @ 50,40 button "&Cancel" size 80,20 of oWnd  ;
      action (MsgInfo("You click Cancel button!"),oWnd:End())

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

RETURN( NIL )

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



...and scroll dialog

Code: Select all  Expand view

// Testing how to scroll a dialog with its contents

#include "FiveWin.ch"

#define D_WIDTH           4
#define D_HEIGHT          13

FUNCTION Main()

LOCAL oDlg
LOCAL cGet0101 := space(10),  ; //Row 1
      cGet0102 := space(10),  ;
      cGet0103 := space(10),  ;
      cGet0104 := space(10),  ;
      cGet0105 := space(10),  ;
      cGet0201 := space(10),  ; //Row 2
      cGet0202 := space(10),  ;
      cGet0203 := space(10),  ;
      cGet0204 := space(10),  ;
      cGet0205 := space(10),  ;
      cGet0301 := space(10),  ; //Row 3
      cGet0302 := space(10),  ;
      cGet0303 := space(10),  ;
      cGet0304 := space(10),  ;
      cGet0305 := space(10),  ;
      cGet0401 := space(10),  ; //Row 4
      cGet0402 := space(10),  ;
      cGet0403 := space(10),  ;
      cGet0404 := space(10),  ;
      cGet0405 := space(10),  ;
      cGet0501 := space(10),  ; //Row 5
      cGet0502 := space(10),  ;
      cGet0503 := space(10),  ;
      cGet0504 := space(10),  ;
      cGet0505 := space(10),  ;
      cGet0601 := space(10),  ; //Row 6
      cGet0602 := space(10),  ;
      cGet0603 := space(10),  ;
      cGet0604 := space(10),  ;
      cGet0605 := space(10),  ;
      cGet0701 := space(10),  ; //Row 7
      cGet0702 := space(10),  ;
      cGet0703 := space(10),  ;
      cGet0704 := space(10),  ;
      cGet0705 := space(10),  ;
      cGet0801 := space(10),  ; //Row 8
      cGet0802 := space(10),  ;
      cGet0803 := space(10),  ;
      cGet0804 := space(10),  ;
      cGet0805 := space(10),  ;
      cGet0901 := space(10),  ; //Row 9
      cGet0902 := space(10),  ;
      cGet0903 := space(10),  ;
      cGet0904 := space(10),  ;
      cGet0905 := space(10),  ;
      cGet1001 := space(10),  ; //Row 10
      cGet1002 := space(10),  ;
      cGet1003 := space(10),  ;
      cGet1004 := space(10),  ;
      cGet1005 := space(10),  ;
      cGet1101 := space(10),  ; //Row 11
      cGet1102 := space(10),  ;
      cGet1103 := space(10),  ;
      cGet1104 := space(10),  ;
      cGet1105 := space(10)

   define dialog oDlg from 0, 0 TO 25, 70 ;
         title "Scroll dialog"            ;
         Style nor( WS_VSCROLL, WS_HSCROLL )

   @ 9,17 bitmap file "\fwh\bitmaps\pic1.bmp" of oDlg size 120,148 adjust
   @ 9,32 bitmap file "\fwh\bitmaps\pic2.bmp" of oDlg size 120,148 adjust
   @ 9,47 bitmap file "\fwh\bitmaps\pic3.bmp" of oDlg size 120,148 adjust
   @ 9,62 bitmap file "\fwh\bitmaps\pic4.bmp" of oDlg size 120,148 adjust
   @ 9,77 bitmap file "\fwh\bitmaps\pic5.bmp" of oDlg size 120,148 adjust

   @ 21*13,02*8 say "Customer " of oDlg update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 23*13,02*8 say "P.O. #   " of oDlg update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 25*13,02*8 say "Style No." of oDlg update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 27*13,02*8 say "Fabrics  " of oDlg update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 29*13,02*8 say "Fob      " of oDlg update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 31*13,02*8 say "Q'TY     " of oDlg update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 33*13,02*8 say "DEL.     " of oDlg update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 35*13,02*8 say "MAKER    " of oDlg update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 37*13,02*8 say "QTA      " of oDlg update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 39*13,02*8 say "SIZE     " of oDlg update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 41*13,02*8 say "Size B/D " of oDlg update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 43*13,02*8 say "REMARKS  " of oDlg update color CLR_BLACK,CLR_WHITE size 120,26 border pixel

   @ 21*13,17*8 say "Venture  " of oDlg update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 21*13,32*8 say "Sears    " of oDlg update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 21*13,47*8 say "Kohl's   " of oDlg update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 21*13,62*8 say "Kiss     " of oDlg update color CLR_BLACK,CLR_WHITE size 120,26 border pixel
   @ 21*13,77*8 say "K-MART   " of oDlg update color CLR_BLACK,CLR_WHITE size 120,26 border pixel

   //-* Row 1
   @ 23*13,17*8 get cGet0101 size 120,26 of oDlg update pixel
   @ 23*13,32*8 get cGet0102 size 120,26 of oDlg update pixel
   @ 23*13,47*8 get cGet0103 size 120,26 of oDlg update pixel
   @ 23*13,62*8 get cGet0104 size 120,26 of oDlg update pixel
   @ 23*13,77*8 get cGet0105 size 120,26 of oDlg update pixel

   //-* Row 2
   @ 25*13,17*8 get cGet0201 size 120,26 of oDlg update pixel
   @ 25*13,32*8 get cGet0202 size 120,26 of oDlg update pixel
   @ 25*13,47*8 get cGet0203 size 120,26 of oDlg update pixel
   @ 25*13,62*8 get cGet0204 size 120,26 of oDlg update pixel
   @ 25*13,77*8 get cGet0205 size 120,26 of oDlg update pixel

   //-* Row 3
   @ 27*13,17*8 get cGet0301 size 120,26 of oDlg update pixel
   @ 27*13,32*8 get cGet0302 size 120,26 of oDlg update pixel
   @ 27*13,47*8 get cGet0303 size 120,26 of oDlg update pixel
   @ 27*13,62*8 get cGet0304 size 120,26 of oDlg update pixel
   @ 27*13,77*8 get cGet0305 size 120,26 of oDlg update pixel

   //-* Row 4
   @ 29*13,17*8 get cGet0401 size 120,26 of oDlg update pixel
   @ 29*13,32*8 get cGet0402 size 120,26 of oDlg update pixel
   @ 29*13,47*8 get cGet0403 size 120,26 of oDlg update pixel
   @ 29*13,62*8 get cGet0404 size 120,26 of oDlg update pixel
   @ 29*13,77*8 get cGet0405 size 120,26 of oDlg update pixel

   //-* Row 5
   @ 31*13,17*8 get cGet0501 size 120,26 of oDlg update pixel
   @ 31*13,32*8 get cGet0502 size 120,26 of oDlg update pixel
   @ 31*13,47*8 get cGet0503 size 120,26 of oDlg update pixel
   @ 31*13,62*8 get cGet0504 size 120,26 of oDlg update pixel
   @ 31*13,77*8 get cGet0505 size 120,26 of oDlg update pixel

   //-* Row 6
   @ 33*13,17*8 get cGet0601 size 120,26 of oDlg update pixel
   @ 33*13,32*8 get cGet0602 size 120,26 of oDlg update pixel
   @ 33*13,47*8 get cGet0603 size 120,26 of oDlg update pixel
   @ 33*13,62*8 get cGet0604 size 120,26 of oDlg update pixel
   @ 33*13,77*8 get cGet0605 size 120,26 of oDlg update pixel

   //-* Row 7
   @ 35*13,17*8 get cGet0701 size 120,26 of oDlg update pixel
   @ 35*13,32*8 get cGet0702 size 120,26 of oDlg update pixel
   @ 35*13,47*8 get cGet0703 size 120,26 of oDlg update pixel
   @ 35*13,62*8 get cGet0704 size 120,26 of oDlg update pixel
   @ 35*13,77*8 get cGet0705 size 120,26 of oDlg update pixel

   //-* Row 8
   @ 37*13,17*8 get cGet0801 size 120,26 of oDlg update pixel
   @ 37*13,32*8 get cGet0802 size 120,26 of oDlg update pixel
   @ 37*13,47*8 get cGet0803 size 120,26 of oDlg update pixel
   @ 37*13,62*8 get cGet0804 size 120,26 of oDlg update pixel
   @ 37*13,77*8 get cGet0805 size 120,26 of oDlg update pixel

   //-* Row 9
   @ 39*13,17*8 get cGet0901 size 120,26 of oDlg update pixel
   @ 39*13,32*8 get cGet0902 size 120,26 of oDlg update pixel
   @ 39*13,47*8 get cGet0903 size 120,26 of oDlg update pixel
   @ 39*13,62*8 get cGet0904 size 120,26 of oDlg update pixel
   @ 39*13,77*8 get cGet0905 size 120,26 of oDlg update pixel

   //-* Row 10
   @ 41*13,17*8 get cGet1001 size 120,26 of oDlg update pixel
   @ 41*13,32*8 get cGet1002 size 120,26 of oDlg update pixel
   @ 41*13,47*8 get cGet1003 size 120,26 of oDlg update pixel
   @ 41*13,62*8 get cGet1004 size 120,26 of oDlg update pixel
   @ 41*13,77*8 get cGet1005 size 120,26 of oDlg update pixel

   //-* Row 11
   @ 43*13,17*8 get cGet1101 size 120,26 of oDlg update pixel
   @ 43*13,32*8 get cGet1102 size 120,26 of oDlg update pixel
   @ 43*13,47*8 get cGet1103 size 120,26 of oDlg update pixel
   @ 43*13,62*8 get cGet1104 size 120,26 of oDlg update pixel
   @ 43*13,77*8 get cGet1105 size 120,26 of oDlg update pixel


   @ 50,20 button "&Ok" size 80,20 of oDlg   ;
      action (MsgInfo("You click OK button!"),oDlg:End())
   @ 50,40 button "&Cancel" size 80,20 of oDlg  ;
      action (MsgInfo("You click Cancel button!"),oDlg:End())

   ACTIVATE dialog oDlg    ;
      ON INIT ( TScrDlg():New(oDlg,1,100,1,400) )

RETURN( NIL )

//============================================================================
// FileName : SCROLL.PRG
// Purpose  :  dialog 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 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
//   ? ::oDlg:oVSCroll=NIL
   if ::oDlg:oVScroll != NIL
//    ? nV1,nV2
      ::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 =================================================

procedure AppSys   // Xbase++ requirement

return



Regards,

Rossine.
Rossine
 
Posts: 344
Joined: Tue Oct 11, 2005 11:33 am

Postby Antonio Linares » Tue Sep 25, 2007 6:17 pm

Marc,

> Do you have a solution for creating 'bigger' meta-files.

We may need to create a larger hDC in memory. Several functions should be used. We are going to review it
regards, saludos

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

Postby Marc Vanzegbroeck » Tue Sep 25, 2007 6:18 pm

Thanks Rossine,

I'ts working very nice.
I will try to 'translate' my program to draw directly to the window and display the drawing instead of painting first to a meta-file and than displaying it.

Regards,
Marc
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Postby Antonio Linares » Tue Sep 25, 2007 8:02 pm

Very good! :-)
regards, saludos

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

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 89 guests