home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code2 / scg_demo / demo.bas < prev    next >
BASIC Source File  |  1993-08-13  |  2KB  |  58 lines

  1. Option Explicit
  2. ' Colors from CONSTANT.TXT
  3. Global Const BLACK = &H0&
  4. Global Const RED = &HFF&
  5. Global Const GREEN = &HFF00&
  6. Global Const YELLOW = &HFFFF&
  7. Global Const BLUE = &HFF0000
  8. Global Const MAGENTA = &HFF00FF
  9. Global Const CYAN = &HFFFF00
  10. Global Const WHITE = &HFFFFFF
  11.  
  12. ' Bezier Constant for approximating conic sections
  13. Global Const BEZCONIC = 551.92
  14. Global Const BEZAUTO = 32760
  15.  
  16. Global Const PI = 3.14159265
  17.  
  18. ' Declaration of the exported function (like a method) for high-quality printing of SCGraphic controls
  19. Declare Sub PrintSCG Lib "scgrphic.vbx" (hCtl As Control, ByVal hDC As Integer, ByVal xOrg As Integer, ByVal yOrg As Integer)
  20.  
  21. ' Compute a color that is an interpolation of two other
  22. ' colors.  The return value is a color that is percent
  23. ' of the way between col1 and col2.
  24. Function BetweenColor (col1 As Long, col2 As Long, percent As Integer)
  25.     Dim R1, G1, B1, R2, G2, B2
  26.     R1 = col1 Mod 256
  27.     G1 = col1 \ 256 Mod 256
  28.     B1 = col1 \ 65536 Mod 256
  29.     R2 = col2 Mod 256
  30.     G2 = col2 \ 256 Mod 256
  31.     B2 = col2 \ 65536 Mod 256
  32.     R1 = R1 + (R2 - R1) * percent / 100
  33.     G1 = G1 + (G2 - G1) * percent / 100
  34.     B1 = B1 + (B2 - B1) * percent / 100
  35.     BetweenColor = RGB(R1, G1, B1)
  36. End Function
  37.  
  38. ' Print a form outline in the center of the page and then
  39. ' print all of the SCGraphic controls on the form
  40. Sub PrintFrm (frm As Form)
  41.     Dim nCtl As Integer
  42.     ' center the form on the page
  43.     Printer.ScaleLeft = -(Printer.Width - frm.Width) / 2
  44.     Printer.ScaleTop = -(Printer.Height - frm.Height) / 2
  45.     Printer.Line (0, 0)-Step(frm.Width - 120, frm.Height - 420), , B  ' adjust Height and Width for title bar and borders if desired
  46.     ' At least one Printer method (such as Line above) must
  47.     ' be used before calling PrintSCG to ensure a valid hDC.
  48.     For nCtl = frm.Controls.Count - 1 To 0 Step -1
  49.         ' Kludge:  Can't figure out how to get the Zorder to
  50.         ' sort overlapping controls, but this reverse control order works for the demo
  51.         If TypeOf frm.Controls(nCtl) Is SCGraphic Then
  52.             PrintSCG frm.Controls(nCtl), Printer.hDC, Printer.ScaleLeft, Printer.ScaleTop
  53.         End If
  54.     Next nCtl
  55.     Printer.EndDoc
  56. End Sub
  57.  
  58.