home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 5 / MasteringVisualBasic5.iso / ch_code / ch06 / trgrid / trgrid.frm (.txt) next >
Encoding:
Visual Basic Form  |  1997-02-20  |  3.4 KB  |  103 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Transparent Drawing"
  4.    ClientHeight    =   4485
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   7245
  8.    ForeColor       =   &H00C0C0C0&
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   4485
  11.    ScaleWidth      =   7245
  12.    StartUpPosition =   3  'Windows Default
  13.    Begin VB.CommandButton Command2 
  14.       Caption         =   "Show Polar Grid"
  15.       BeginProperty Font 
  16.          Name            =   "Tahoma"
  17.          Size            =   9.75
  18.          Charset         =   0
  19.          Weight          =   700
  20.          Underline       =   0   'False
  21.          Italic          =   0   'False
  22.          Strikethrough   =   0   'False
  23.       EndProperty
  24.       Height          =   495
  25.       Left            =   4920
  26.       TabIndex        =   2
  27.       Top             =   3840
  28.       Width           =   2295
  29.    End
  30.    Begin VB.CommandButton Command1 
  31.       Caption         =   "Show Linear Grid"
  32.       BeginProperty Font 
  33.          Name            =   "Tahoma"
  34.          Size            =   9.75
  35.          Charset         =   0
  36.          Weight          =   700
  37.          Underline       =   0   'False
  38.          Italic          =   0   'False
  39.          Strikethrough   =   0   'False
  40.       EndProperty
  41.       Height          =   495
  42.       Left            =   4920
  43.       TabIndex        =   1
  44.       Top             =   3120
  45.       Width           =   2295
  46.    End
  47.    Begin VB.PictureBox Picture1 
  48.       ForeColor       =   &H00E0E0E0&
  49.       Height          =   4215
  50.       Left            =   120
  51.       Picture         =   "TRGrid.frx":0000
  52.       ScaleHeight     =   4155
  53.       ScaleWidth      =   4635
  54.       TabIndex        =   0
  55.       Top             =   120
  56.       Width           =   4695
  57.    End
  58. Attribute VB_Name = "Form1"
  59. Attribute VB_GlobalNameSpace = False
  60. Attribute VB_Creatable = False
  61. Attribute VB_PredeclaredId = True
  62. Attribute VB_Exposed = False
  63. Sub DrawLinearGrid()
  64.     GridLines = 20
  65.     Picture1.AutoRedraw = False
  66.     GridSpaceX = Int(Picture1.ScaleWidth / GridLines)
  67.     GridSpaceY = Int(Picture1.ScaleHeight / GridLines)
  68.     For i = 0 To GridLines + 1
  69.         Picture1.Line (GridSpaceX * i, 0)-(GridSpaceX * i, Picture1.Height - 1)
  70.         Picture1.Line (0, GridSpaceY * i)-(Picture1.Width - 1, GridSpaceY * i)
  71.     Next
  72. End Sub
  73. Sub DrawPolarGrid()
  74.     GridCircles = 20
  75.     Picture1.AutoRedraw = False
  76.     GridRadius = Int(Picture1.ScaleWidth / GridCircles)
  77.     For i = 0 To GridCircles + 1
  78.         Picture1.Circle (Picture1.ScaleWidth / 2, Picture1.ScaleHeight / 2), GridRadius * i
  79.     Next
  80.     Picture1.Line (Picture1.ScaleWidth / 2, 0)-(Picture1.ScaleWidth / 2, Picture1.ScaleHeight)
  81.     Picture1.Line (0, Picture1.ScaleHeight / 2)-(Picture1.ScaleWidth, Picture1.ScaleHeight / 2)
  82. End Sub
  83. Private Sub Command1_Click()
  84.     If Command1.Caption = "Show Linear Grid" Then
  85.         Command1.Caption = "Hide Grid"
  86.         DrawLinearGrid
  87.     Else
  88.         Command1.Caption = "Show Linear Grid"
  89.         Picture1.Refresh
  90.         Picture1.AutoRedraw = False
  91.     End If
  92. End Sub
  93. Private Sub Command2_Click()
  94.     If Command2.Caption = "Show Polar Grid" Then
  95.         Command2.Caption = "Hide Grid"
  96.         DrawPolarGrid
  97.     Else
  98.         Command2.Caption = "Show Polar Grid"
  99.         Picture1.Refresh
  100.         Picture1.AutoRedraw = False
  101.     End If
  102. End Sub
  103.