home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 16 / CD_ASCQ_16_0994.iso / news / 4611 / fw16d.ins / SOURCE / CLASSES / PRINTPV.PRG < prev    next >
Text File  |  1994-05-28  |  2KB  |  89 lines

  1. // Printer Preview - FiveWin Class
  2. // FiveWin Reporting tools
  3.  
  4. #include "FiveWin.ch"
  5.  
  6. #define COLOR_WINDOW         5
  7. #define COLOR_WINDOWTEXT     8
  8.  
  9. #define MM_ISOTROPIC         7
  10. #define MM_ANISOTROPIC       8
  11.  
  12. static lRegistered := .f.
  13.  
  14. //----------------------------------------------------------------------------//
  15.  
  16. CLASS TPrintPV FROM TControl
  17.  
  18.    DATA    nMinPage, nMaxPage
  19.    DATA    nViewWidth, nViewHeight
  20.  
  21.    METHOD  ReDefine( bPaint, nMinPage, nMaxPage, nViewWidth, nViewHeight,;
  22.                      nId, oWnd, nClrFore, nClrBack ) CONSTRUCTOR
  23.  
  24.    METHOD  HandleEvent( nMsg, nWParam, nLParam )
  25.  
  26.    METHOD  Paint()
  27.  
  28. ENDCLASS
  29.  
  30. //----------------------------------------------------------------------------//
  31.  
  32. METHOD ReDefine( bPaint, nMinPage, nMaxPage, nViewWidth, nViewHeight,;
  33.                  nId, oWnd, nClrFore, nClrBack ) CLASS TPrintPV
  34.  
  35.    DEFAULT nClrFore := GetSysColor( COLOR_WINDOWTEXT ),;
  36.            nClrBack := GetSysColor( COLOR_WINDOW )
  37.  
  38.    ::nId         = nId
  39.    ::oWnd        = oWnd
  40.    ::nMinPage    = nMinPage
  41.    ::nMaxPage    = nMaxPage
  42.    ::nViewWidth  = nViewWidth
  43.    ::nViewHeight = nViewHeight
  44.  
  45.    ::bPainted    = bPaint
  46.  
  47.    if ! lRegistered
  48.       ::Register( nOr( CS_VREDRAW, CS_HREDRAW, CS_GLOBALCLASS ) )
  49.       lRegistered = .t.
  50.    endif
  51.  
  52.    ::SetColor( nClrFore, nClrBack )
  53.  
  54.    oWnd:DefControl( Self )
  55.  
  56. return nil
  57.  
  58. //----------------------------------------------------------------------------//
  59.  
  60. METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS TPrintPV
  61.  
  62.    if nMsg == WM_PAINT        // We want to paint ourselves
  63.       ::BeginPaint()          // all controls non-standard must do this
  64.       ::Paint()
  65.       ::EndPaint()
  66.       return 0
  67.    endif
  68.  
  69. return Super:HandleEvent( nMsg, nWParam, nLParam )
  70.  
  71. //----------------------------------------------------------------------------//
  72.  
  73. METHOD Paint() CLASS TPrintPV
  74.  
  75.    local oRect := ::GetRect()
  76.  
  77.    SetMapMode( ::hDC, MM_ISOTROPIC )
  78.  
  79.    SetWindowExt( ::hDC, ::nViewWidth, ::nViewHeight )
  80.    SetViewportExt( ::hDC, oRect:nRight, oRect:nBottom )
  81.  
  82.    if ::bPainted != nil
  83.       Eval( ::bPainted, Self )
  84.    endif
  85.  
  86. return nil
  87.  
  88. //----------------------------------------------------------------------------//
  89.