home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / addons1a / paintfun.frm (.txt) < prev   
Encoding:
Visual Basic Form  |  1999-09-05  |  4.1 KB  |  124 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Click and drag to draw the selected shape"
  4.    ClientHeight    =   3090
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   5220
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   3090
  10.    ScaleWidth      =   5220
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.OptionButton Option3 
  13.       Caption         =   "Ellipse"
  14.       Height          =   615
  15.       Left            =   0
  16.       TabIndex        =   7
  17.       Top             =   1560
  18.       Width           =   975
  19.    End
  20.    Begin VB.OptionButton Option2 
  21.       Caption         =   "line"
  22.       Height          =   615
  23.       Left            =   0
  24.       TabIndex        =   6
  25.       Top             =   960
  26.       Width           =   975
  27.    End
  28.    Begin VB.OptionButton Option1 
  29.       Caption         =   "rectangle"
  30.       Height          =   555
  31.       Left            =   0
  32.       TabIndex        =   5
  33.       Top             =   480
  34.       Width           =   975
  35.    End
  36.    Begin VB.PictureBox Picture1 
  37.       BackColor       =   &H80000009&
  38.       Height          =   2895
  39.       Left            =   960
  40.       ScaleHeight     =   2835
  41.       ScaleWidth      =   4035
  42.       TabIndex        =   0
  43.       Top             =   120
  44.       Width           =   4095
  45.    End
  46.    Begin VB.Label Label4 
  47.       Caption         =   "Label4"
  48.       Height          =   495
  49.       Left            =   2280
  50.       TabIndex        =   4
  51.       Top             =   3240
  52.       Width           =   1215
  53.    End
  54.    Begin VB.Label Label3 
  55.       Caption         =   "Label3"
  56.       Height          =   495
  57.       Left            =   1560
  58.       TabIndex        =   3
  59.       Top             =   3480
  60.       Width           =   1215
  61.    End
  62.    Begin VB.Label Label2 
  63.       Caption         =   "Label2"
  64.       Height          =   495
  65.       Left            =   960
  66.       TabIndex        =   2
  67.       Top             =   3120
  68.       Width           =   1215
  69.    End
  70.    Begin VB.Label Label1 
  71.       Caption         =   "Label1"
  72.       Height          =   495
  73.       Left            =   360
  74.       TabIndex        =   1
  75.       Top             =   3120
  76.       Width           =   1215
  77.    End
  78. Attribute VB_Name = "Form1"
  79. Attribute VB_GlobalNameSpace = False
  80. Attribute VB_Creatable = False
  81. Attribute VB_PredeclaredId = True
  82. Attribute VB_Exposed = False
  83. 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
  84. Private Declare Function Rectangle Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
  85. Dim pressed As Boolean
  86. Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  87. pressed = True               'sets the value of label1 and 2's captions to x and y for later use
  88. Label1.Caption = X
  89. Label2.Caption = Y
  90. End Sub
  91. Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  92. If pressed Then
  93. Label3.Caption = X
  94. Label4.Caption = Y
  95.     If Option1 Then
  96. a = Label1.Caption / 60 * 3.14                      'this is so the rect is off of the cursur
  97. b = Label2.Caption / 60 * 3.14                'take the math out and you'll see what i mean
  98. c = Label3.Caption / 60 * 3.14
  99. d = Label4.Caption / 60 * 3.14
  100. Picture1.BackColor = &HFFFFFF
  101. Call Rectangle(Picture1.hdc, a, b, c, d)
  102.     End If
  103.     If Option2 Then
  104. a = Label1.Caption
  105. b = Label2.Caption
  106. c = Label3.Caption
  107. d = Label4.Caption
  108. Picture1.BackColor = &HFFFFFF
  109. Picture1.Line (a, b)-(c, d)              'this is what draws the line
  110. End If
  111.     If Option3 Then
  112. X1 = Label1.Caption / 60 * 3.14
  113. Y1 = Label2.Caption / 60 * 3.14
  114. X2 = Label3.Caption / 60 * 3.14
  115. Y2 = Label4.Caption / 60 * 3.14
  116. Picture1.BackColor = &H80000009
  117. Call Ellipse(Picture1.hdc, X1, Y1, X2, Y2)        'this is what draws the ellipse
  118. End If
  119. End If
  120. End Sub
  121. Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  122. pressed = False           'stops drawing whatever it was you were drawing
  123. End Sub
  124.