home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / easyx / data1.cab / Example_Files / EX_8 / Form1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-11-03  |  2.8 KB  |  101 lines

  1. VERSION 5.00
  2. Object = "{5A65A9C0-089F-11D2-88AD-0000B45C4CF6}#1.2#0"; "EASYX.OCX"
  3. Begin VB.Form Form1 
  4.    Caption         =   "Form1"
  5.    ClientHeight    =   3195
  6.    ClientLeft      =   60
  7.    ClientTop       =   345
  8.    ClientWidth     =   4680
  9.    Icon            =   "Form1.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   3195
  12.    ScaleWidth      =   4680
  13.    StartUpPosition =   3  'Windows Default
  14.    Begin PROJECTEXLibCtl.EasyX EasyX1 
  15.       Left            =   960
  16.       OleObjectBlob   =   "Form1.frx":014A
  17.       Top             =   120
  18.    End
  19. Attribute VB_Name = "Form1"
  20. Attribute VB_GlobalNameSpace = False
  21. Attribute VB_Creatable = False
  22. Attribute VB_PredeclaredId = True
  23. Attribute VB_Exposed = False
  24. Option Explicit
  25. Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
  26. Const ScreenWidth As Long = 800
  27. Const ScreenHeight As Long = 600
  28. Const HalfScreenHeight As Long = 300
  29. Const HalfScreenWidth As Long = 400
  30. Private Sub Form_Load()
  31. Dim rt As Long
  32. EasyX1.Window = Me.hWnd
  33. rt = EasyX1.InitDirectDraw(ScreenWidth, ScreenHeight, 16)
  34. If rt <> EX_OK Then
  35.     MsgBox "EasyX could not initialize DirectDraw"
  36.     Exit Sub
  37. End If
  38. 'Create the keyboard and acquire it
  39. EasyX1.InitDirectInput
  40. EasyX1.CreateKeyboard
  41. EasyX1.AcquireKeyboard
  42. RunMain
  43. End Sub
  44. Private Sub RunMain()
  45. Dim I As Long
  46. Dim X As Long, Y As Long
  47. Dim YMinus As Boolean
  48. Dim XMinus As Boolean
  49. Dim X2 As Integer
  50. Dim P As Long
  51. Dim ColorIndex As Long
  52.     If I < HalfScreenWidth + 200 Then
  53.         I = I + 4
  54.     End If
  55.     X2 = X2 + 1
  56.     If YMinus Then
  57.         Y = Y - 2
  58.     Else
  59.         Y = Y + 2
  60.     End If
  61.     If XMinus Then
  62.         X = X - 1
  63.     Else
  64.         X = X + 1
  65.     End If
  66.     EasyX1.AcquireKeyboard
  67.     If EasyX1.GetKeyState(EX_ESCAPE) = EX_KEYDOWN Then
  68.         EasyX1.EndDirectX
  69.         Exit Do
  70.     End If
  71.     EasyX1.FillSurface 0, EX_PRIMARYSURFACE
  72.     P = I
  73.     Do While P > 0
  74.         ColorIndex = ColorIndex + 3
  75.         If ColorIndex > 65000 Then ColorIndex = 0
  76.         
  77.         EasyX1.DrawCircle HalfScreenWidth, HalfScreenHeight, I - P, ColorIndex, EX_PRIMARYSURFACE
  78.         P = P - 8
  79.         
  80.     Loop
  81.     'EasyX1.DrawLine X2, HalfScreenHeight - Y, X2, HalfScreenHeight + Y, 255, EX_PRIMARYSURFACE
  82.      
  83.     EasyX1.FlipSurface
  84.     'If I = HalfScreenWidth + 200 Then I = 0
  85. '    If Y > HalfScreenHeight / 2 Then
  86. '        YMinus = True
  87. '    ElseIf Y < 0 Then
  88. '        YMinus = False
  89. '    End If
  90. '    If X > HalfScreenWidth / 2 Then
  91. '        XMinus = True
  92. '    ElseIf X < 0 Then
  93. '        XMinus = False
  94. '    End If
  95. '    If X2 > ScreenWidth Then X2 = 0
  96.     DoEvents
  97.     Sleep 5
  98.         
  99. Unload Me
  100. End Sub
  101.