home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 25: Programming / pc_actual_25.iso / Basic / GridOne / setup.EXE / CPREVIEW.CLS < prev    next >
Encoding:
Visual Basic class definition  |  2001-09-09  |  4.2 KB  |  179 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "CPreview"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = False
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = False
  14. Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
  15. Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
  16. '-----------------------------------------------------------------------------
  17. ' This is a part of the BeeGrid ActiveX control.
  18. ' Copyright ⌐ 2000 Stinga
  19. ' All rights reserved.
  20. '
  21. ' You have a right to use and distribute the BeeGrid sample files in original
  22. ' form or modified, provided that you agree that Stinga has no warranty,
  23. ' obligations, or liability for any sample application files.
  24. '-----------------------------------------------------------------------------
  25. Option Explicit
  26.  
  27. Implements ISGDevice
  28.  
  29. Private mDest As PictureBox
  30. Private mPrintBeeGrid As PrintBeeGrid
  31.  
  32. Private hdcmem As Long
  33. Private mhBitmap As Long
  34.  
  35. Private msinTwipsPerPixelX As Single
  36. Private msinTwipsPerPixelY As Single
  37.  
  38. Private Sub Class_Initialize()
  39.    msinTwipsPerPixelX = Screen.TwipsPerPixelX
  40.    msinTwipsPerPixelY = Screen.TwipsPerPixelY
  41. End Sub
  42.  
  43. Private Sub Class_Terminate()
  44.    DeleteMemBitmap
  45.    Set mPrintBeeGrid = Nothing
  46. End Sub
  47.  
  48. Private Sub CreateMemBitmap()
  49.    Dim bm As BITMAP
  50.    Dim rc As RECT, sinWidth!, sinHeight!
  51.    Dim hBrush As Long
  52.    
  53.    DeleteMemBitmap
  54.    
  55.    sinWidth = mPrintBeeGrid.PrinterWidth / Screen.TwipsPerPixelX
  56.    sinHeight = mPrintBeeGrid.PrinterHeight / Screen.TwipsPerPixelY
  57.    
  58.    hdcmem = CreateCompatibleDC(mDest.hdc)
  59.    mhBitmap = CreateCompatibleBitmap(mDest.hdc, sinWidth, sinHeight)
  60.    
  61.    Call GetBmpObject(mhBitmap, 14, bm)
  62.    
  63.    SelectObject hdcmem, mhBitmap
  64.    
  65.    SetRect rc, 0, 0, sinWidth, sinHeight
  66.    
  67.    hBrush = CreateSolidBrush(QBColor(15))
  68.  
  69.    FillRect hdcmem, rc, hBrush
  70.    
  71.    DeleteObject hBrush
  72. End Sub
  73.  
  74. Private Sub DeleteMemBitmap()
  75.    If hdcmem <> 0 Then
  76.       DeleteObject mhBitmap
  77.       DeleteDC hdcmem
  78.    End If
  79.  
  80. End Sub
  81.  
  82.  
  83.  
  84. Private Property Set ISGDevice_Destination(ByVal RHS As Object)
  85.    Set mDest = RHS
  86. End Property
  87.  
  88. Private Property Get ISGDevice_Destination() As Object
  89.    Set ISGDevice_Destination = mDest
  90. End Property
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97. Private Property Get ISGDevice_hDC() As Long
  98.    ISGDevice_hDC = hdcmem
  99. End Property
  100.  
  101. Private Property Let ISGDevice_hDC(ByVal RHS As Long)
  102.    hdcmem = RHS
  103. End Property
  104.  
  105.  
  106. Private Property Set ISGDevice_PrintGrid(ByVal RHS As PrintBeeGrid)
  107.    Set mPrintBeeGrid = RHS
  108. End Property
  109.  
  110. Private Property Get ISGDevice_PrintGrid() As PrintBeeGrid
  111.    Set ISGDevice_PrintGrid = mPrintBeeGrid
  112. End Property
  113.  
  114.  
  115. Private Sub ISGDevice_Paint()
  116.    Dim rc As RECT
  117.    Dim sinWidth!, sinHeight!
  118.    Dim sinDestWidth!, sinDestHeight!
  119.    Dim hBrush As Long
  120.    
  121.    If mDest Is Nothing Then Exit Sub
  122.    
  123.    sinWidth = mPrintBeeGrid.PrinterWidth / Screen.TwipsPerPixelX
  124.    sinHeight = mPrintBeeGrid.PrinterHeight / Screen.TwipsPerPixelY
  125.    
  126.    sinDestWidth = mDest.Width / Screen.TwipsPerPixelX
  127.    sinDestHeight = mDest.Height / Screen.TwipsPerPixelY
  128.    
  129.    SetRect rc, 0, 0, sinDestWidth, sinDestHeight
  130.    
  131.    hBrush = CreateSolidBrush(QBColor(15))
  132.    
  133.    FillRect mDest.hdc, rc, hBrush
  134.  
  135.    DeleteObject hBrush
  136.    
  137.    If mDest.Tag = "ZOOM" Then
  138.       StretchBlt mDest.hdc, 0, 0, sinDestWidth, sinDestHeight, _
  139.          hdcmem, 0, 0, sinWidth, sinHeight, SRCCOPY
  140.    Else
  141.       BitBlt mDest.hdc, 0, 0, sinWidth, sinHeight, _
  142.          hdcmem, 0, 0, SRCCOPY
  143.    End If
  144. End Sub
  145.  
  146. Private Sub ISGDevice_PrintReport()
  147.  
  148.    CreateMemBitmap
  149.    
  150.    mPrintBeeGrid.Printing hdcmem
  151. End Sub
  152.  
  153. Private Property Let ISGDevice_ScaleMode(ByVal RHS As Integer)
  154.  
  155. End Property
  156.  
  157. Private Property Get ISGDevice_ScaleMode() As Integer
  158.  
  159. End Property
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167. Private Property Get ISGDevice_TwipsPerPixelX() As Single
  168.    ISGDevice_TwipsPerPixelX = msinTwipsPerPixelX
  169. End Property
  170.  
  171.  
  172.  
  173.  
  174. Private Property Get ISGDevice_TwipsPerPixelY() As Single
  175.    ISGDevice_TwipsPerPixelY = msinTwipsPerPixelY
  176. End Property
  177.  
  178.  
  179.