home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Programmer'…arterly (Limited Edition) / Visual_Basic_Programmers_Journal_VB-CD_Quarterly_Limited_Edition_1995.iso / code / ch18code / calc.cls < prev    next >
Encoding:
Text File  |  1995-07-31  |  3.5 KB  |  151 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "Application"
  6. Attribute VB_Creatable = True
  7. Attribute VB_Exposed = True
  8. ' Option Private Module
  9. ' Internal flag used by AlwayOnTop property.
  10. Private mbAlwaysOnTop As Boolean
  11.  
  12. ''''''''''''''''''''''''''''''''''''''''''''
  13. ' CALC.EXE Application Class
  14. '
  15. ' Application Object
  16. '
  17. ' Property: Value
  18. '
  19. ' Methods : Add
  20. '           Subtract
  21. '           Multiply
  22. '           Divide
  23. '           Sum
  24. '           Activate
  25. '
  26.  
  27. ''''''''''''''''''''''''''''''''''''''''''''
  28. ' Property
  29.  
  30. ''''''''''''''''''''''''''''''''''''''''''''
  31. ' The Value Property
  32. '   Access:    Read/Write
  33. '   Data type: Single
  34. '
  35. ' Returns the value in the Readout Textbox
  36. Public Property Get Value() As Single
  37.     Value = Val(Calculator.Readout.Caption)
  38. End Property
  39.  
  40. ' Sets the value in the Readout text box.
  41. Public Property Let Value(sValue As Single)
  42.     Input_Change sValue
  43. End Property
  44.  
  45. ''''''''''''''''''''''''''''''''''''''''''''
  46. ' The AlwaysOnTop Property
  47. '   Access:    Read/Write
  48. '   Data type: Boolean
  49. '
  50. ' Determines whether or not the calculator
  51. ' is displayed as an always-on-top window.
  52. Public Property Get AlwaysOnTop() As Boolean
  53.     AlwaysOnTop = mbAlwaysOnTop
  54. End Property
  55.  
  56. Public Property Let AlwaysOnTop(bSetting As Boolean)
  57.     If bSetting Then
  58.         SetWindowPos Calculator.hWnd, _
  59.             HWND_TOPMOST, _
  60.             0, 0, 0, 0, _
  61.             SWP_NOSIZE Or SWP_NOMOVE _
  62.             Or SWP_NOACTIVATE Or SWP_SHOWWINDOW
  63.         mbAlwaysOnTop = True
  64.     Else
  65.         SetWindowPos Calculator.hWnd, _
  66.             HWND_NOTOPMOST, _
  67.             0, 0, 0, 0, _
  68.             SWP_NOSIZE Or SWP_NOMOVE _
  69.             Or SWP_NOACTIVATE
  70.         mbAlwaysOnTop = False
  71.     End If
  72. End Property
  73.  
  74. '''''''''''''''''''''''''''''''''''''''''''''
  75. ' Methods
  76.  
  77. '''''''''''''''''''''''''''''''''''''''''''''
  78. ' Add Method
  79. Public Sub Add()
  80.     Input_Change "+"
  81. End Sub
  82.  
  83. '''''''''''''''''''''''''''''''''''''''''''''
  84. ' Subtract Method
  85. Public Sub Subtract()
  86.     Input_Change "-"
  87. End Sub
  88.  
  89. '''''''''''''''''''''''''''''''''''''''''''''
  90. ' Multiply Method
  91. Public Sub Multiply()
  92.     Input_Change "*"
  93. End Sub
  94.  
  95. '''''''''''''''''''''''''''''''''''''''''''''
  96. ' Divide Method
  97. Public Sub Divide()
  98.     Input_Change "/"
  99. End Sub
  100.  
  101. '''''''''''''''''''''''''''''''''''''''''''''
  102. ' Sum Method
  103. Public Sub Sum()
  104.     Input_Change "="
  105. End Sub
  106.  
  107. '''''''''''''''''''''''''''''''''''''''''''''
  108. ' Activate Method
  109. Public Sub Activate()
  110.     AppActivate Calculator.Caption
  111. End Sub
  112.  
  113. ' Added for Application class methods.
  114. ' Permits access to operator click events.
  115. Private Sub Input_Change(Item)
  116.     Dim i As Integer
  117.     Dim strStroke As String
  118.     For i = 1 To Len(Item)
  119.         strStroke = Mid(Item, i, 1)
  120.         Select Case strStroke
  121.             Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
  122.                 Calculator.Number_Click Val(strStroke)
  123.             Case "."
  124.                 Calculator.Decimal_Click
  125.             Case "+"
  126.                 Calculator.Operator_Click 1
  127.             Case "-"
  128.                 Calculator.Operator_Click 3
  129.             Case "*"
  130.                 Calculator.Operator_Click 2
  131.             Case "/"
  132.                 Calculator.Operator_Click 0
  133.             Case "="
  134.                 Calculator.Operator_Click 4
  135.         End Select
  136.      Next i
  137. End Sub
  138.  
  139. Public Sub foopublic()
  140.     MsgBox "public"
  141. End Sub
  142.  
  143. Sub fooreg()
  144.     MsgBox "regular"
  145. End Sub
  146.  
  147. Private Sub fooprivate()
  148.     MsgBox "private"
  149. End Sub
  150.  
  151.