home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / Src / Ch2 / BkMode.frm (.txt) next >
Encoding:
Visual Basic Form  |  1999-03-23  |  2.3 KB  |  67 lines

  1. VERSION 5.00
  2. Begin VB.Form frmBkMode 
  3.    Caption         =   "BkMode"
  4.    ClientHeight    =   3195
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   4710
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   3195
  10.    ScaleWidth      =   4710
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.Label Label1 
  13.       Alignment       =   2  'Center
  14.       Caption         =   "OPAQUE"
  15.       Height          =   255
  16.       Index           =   1
  17.       Left            =   2400
  18.       TabIndex        =   1
  19.       Top             =   0
  20.       Width           =   2295
  21.    End
  22.    Begin VB.Label Label1 
  23.       Alignment       =   2  'Center
  24.       Caption         =   "TRANSPARENT"
  25.       Height          =   255
  26.       Index           =   0
  27.       Left            =   0
  28.       TabIndex        =   0
  29.       Top             =   0
  30.       Width           =   2295
  31.    End
  32. Attribute VB_Name = "frmBkMode"
  33. Attribute VB_GlobalNameSpace = False
  34. Attribute VB_Creatable = False
  35. Attribute VB_PredeclaredId = True
  36. Attribute VB_Exposed = False
  37. Option Explicit
  38. Private Declare Function SetBkColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor As Long) As Long
  39. Private Declare Function SetBkMode Lib "gdi32" (ByVal hdc As Long, ByVal nBkMode As Long) As Long
  40. Private Declare Function Ellipse Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
  41. Private Const OPAQUE = 2
  42. Private Const TRANSPARENT = 1
  43. Private Sub Form_Load()
  44. Dim i As Integer
  45. Dim j As Integer
  46. Dim start_j As Long
  47. Dim gray As Long
  48.     AutoRedraw = True
  49.     FillStyle = vbDiagonalCross
  50.     ScaleMode = vbPixels
  51.     ' Create a checkerboard background.
  52.     gray = RGB(128, 128, 128)
  53.     For i = Label1(0).Height To ScaleHeight - 1 Step 20
  54.         For j = start_j To ScaleWidth - 1 Step 40
  55.             Line (j, i)-Step(20, 20), gray, BF
  56.         Next j
  57.         start_j = 20 - start_j
  58.     Next i
  59.     ' Draw an ellipse with BkMode = TRANSPARENT.
  60.     SetBkMode hdc, TRANSPARENT
  61.     Ellipse hdc, 10, 25, ScaleWidth / 2 - 5, ScaleHeight - 20
  62.     ' Draw an ellipse with BkMode = OPAQUE.
  63.     SetBkMode hdc, OPAQUE
  64.     SetBkColor hdc, vbWhite
  65.     Ellipse hdc, ScaleWidth / 2 + 5, 25, ScaleWidth - 10, ScaleHeight - 20
  66. End Sub
  67.