- •Лекция 13
- •XTimers.Vbp 5
- •Обзор задачи Coffee Sample Application
- •XTimers.Vbp
- •XTimerSupport.Bas
- •Private Type xtimerinfo ' Hungarian xti
- •Public Sub TimerProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal idEvent As Long, ByVal lngSysTime As Long)
- •If maxti(intCt).BlnReentered Then Exit Sub
- •Public Sub EndTimer(ByVal xt As xTimer)
- •Public Sub Scrub()
- •Public Property Get Interval() As Long
- •Public Property Let Interval(ByVal NewInterval As Long)
- •Public Sub RaiseTick()
- •Private Sub Class_Terminate()
- •MtCoffee.Vbp modMt.Bas Option Explicit
- •Public glngGlobalData As Long
- •Coffee.Bas
- •Option Explicit
- •Private Declare Function timeGetTime Lib "winmm.Dll" () As Long
- •Private mlngIterations As Long
- •Public Property Get NumberOnThread() As Long
- •Public Sub StartLongTask(ByVal Iterations As Long)
- •Public Function GetCoffeeOnSameThread() As Coffee
- •Public Function GetCoffeeOnNewThread() As Coffee
- •If blnCancel Then
- •Coffee.Cls Option Explicit Private Declare Function timeGetTime Lib "winmm.Dll" () As Long
- •Private mlngIterations As Long
- •Public Property Get NumberOnThread() As Long
- •Public Sub StartLongTask(ByVal Iterations As Long)
- •Public Function GetCoffeeOnSameThread() As Coffee
- •Public Function GetCoffeeOnNewThread() As Coffee
- •If blnCancel Then
- •Public Property Get CoffeeMonitor() As CoffeeMonitor
- •If gCoffeeMonitor Is Nothing Then
- •CoffeeMonitor.Cls Option Explicit
- •Private WithEvents mwXTimer As xTimer
- •Event CoffeeReady() Private Sub Class_Initialize()
- •Private Sub Class_Terminate()
- •Private Sub mwXTimer_Tick()
- •Connector2.Cls Option Explicit
- •Public Property Get CoffeeMonitor2() As CoffeeMonitor2
- •CoffeeMonitor2 Option Explicit
- •Private maicnClients() As iCoffeeNotify
- •Public Sub TellMeReady(ByVal icn As iCoffeeNotify)
- •Public Sub CeaseCallBacks(ByVal icn As iCoffeeNotify)
- •Private Sub mwXTimer_Tick()
- •ICoffeeNotify.Cls
- •Public ThreadId As Long
- •Private Sub mwCoffee_Progress(ByVal PercentDone As Single, Cancel As Boolean)
- •Private Sub cmdCallBacks_Click()
- •Private Sub cmdMt_Click()
- •Private Sub Form_Unload(Cancel As Integer)
- •Private Sub mwcmnEvents_CoffeeReady()
- •FrmThread.Frm
- •Private Sub cmdCancel_Click()
- •Private Sub cmdShortOnly_Click()
- •Private Sub cmdShortLong_Click()
- •Private Sub cmdNLong_Click()
- •Private Sub cmdXThread_Click()
- •Private Sub cmdIDs_Click()
- •Private Sub tmrShort_Timer()
Лекция 13
Построение собственных серверов автоматизации средствами VB6
Обзор задачи Coffee Sample Application 3
XTimers.Vbp 5
XTimerSupport.bas 5
Const MAXTIMERINCREMEMT = 5 5
Private Type XTIMERINFO ' Hungarian xti 5
Declare Function KillTimer Lib "user32" (ByVal hWnd As Long, ByVal nIDEvent As Long) As Long 6
Private maxti() As XTIMERINFO 6
Private mintMaxTimers As Integer 6
Public Function BeginTimer(ByVal xt As XTimer, ByVal Interval As Long) 6
Public Sub TimerProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal idEvent As Long, ByVal lngSysTime As Long) 7
Public Sub EndTimer(ByVal xt As XTimer) 8
Public Sub Scrub() 8
XTimer.cls 9
Option Explicit 9
Private mlngTimerID As Long 9
Private mlngInterval As Long 9
Private mblnEnabled As Boolean 9
Event Tick() 9
Friend Property Get TimerID() As Long 9
Public Property Get Enabled() As Boolean 9
Public Property Let Enabled(ByVal NewValue As Boolean) 9
Public Property Get Interval() As Long 10
Public Property Let Interval(ByVal NewInterval As Long) 10
Public Sub RaiseTick() 11
Private Sub Class_Terminate() 11
MTCoffee.vbp 11
modMT.bas 11
Option Explicit 11
Public glngGlobalData As Long 12
Coffee.bas 12
Option Explicit 12
Private Declare Function timeGetTime Lib "winmm.dll" () As Long 12
Private mlngIterations As Long 12
Private WithEvents mwXTimer As XTimer 12
Event Progress(ByVal PercentDone As Single, ByRef Cancel As Boolean) 12
Event Complete(ByVal Canceled As Boolean) 12
Public Property Get ThreadID() As Long 12
Public Property Get NumberOnThread() As Long 13
Public Sub StartLongTask(ByVal Iterations As Long) 13
Public Function GetCoffeeOnSameThread() As Coffee 13
Public Function GetCoffeeOnNewThread() As Coffee 13
Public Function CallAnotherCoffee(ByVal cfe As Coffee) As Double 14
Private Sub Class_Initialize() 14
Private Sub Class_Terminate() 14
Private Sub mwXTimer_Tick() 15
Private Sub LongTask() 15
Coffee.cls 16
Option Explicit 16
Private Declare Function timeGetTime Lib "winmm.dll" () As Long 16
Private mlngIterations As Long 16
Private WithEvents mwXTimer As XTimer 16
Event Progress(ByVal PercentDone As Single, ByRef Cancel As Boolean) 16
Event Complete(ByVal Canceled As Boolean) 16
Public Property Get ThreadID() As Long 16
Public Property Get NumberOnThread() As Long 16
Public Sub StartLongTask(ByVal Iterations As Long) 17
Public Function GetCoffeeOnSameThread() As Coffee 17
Public Function GetCoffeeOnNewThread() As Coffee 17
Public Function CallAnotherCoffee(ByVal cfe As Coffee) As Double 18
Private Sub Class_Initialize() 18
Private Sub Class_Terminate() 18
Private Sub mwXTimer_Tick() 18
Private Sub LongTask() 19
Coffee2.vbp 20
Module1.bas 20
Option Explicit 20
Public gCoffeeMonitor As CoffeeMonitor 20
Public gCoffeeMonitor2 As CoffeeMonitor2 20
Connector.cls: 20
Option Explicit 20
Public Property Get CoffeeMonitor() As CoffeeMonitor 20
CoffeeMonitor.cls 20
Option Explicit 21
Private WithEvents mwXTimer As XTimer 21
Event CoffeeReady() 21
21
Private Sub Class_Initialize() 21
Private Sub Class_Terminate() 22
Private Sub mwXTimer_Tick() 22
Connector2.cls 22
Option Explicit 22
Public Property Get CoffeeMonitor2() As CoffeeMonitor2 22
CoffeeMonitor2 22
Option Explicit 23
Const ICN_ARRAYINCREMENT = 10 23
Private maicnClients() As ICoffeeNotify 23
Private mlngMaxClients As Long 23
Private WithEvents mwXTimer As XTimer 23
Private Sub Class_Initialize() 23
Private Sub Class_Terminate() 24
Public Sub TellMeReady(ByVal icn As ICoffeeNotify) 24
Public Sub CeaseCallBacks(ByVal icn As ICoffeeNotify) 25
Private Sub mwXTimer_Tick() 25
ICoffeeNotify.cls 26
Option Explicit 26
Public Sub CoffeeReady() 26
Public Property Get NotifyID() As Long 26
Public Property Let NotifyID(ByVal NewValue As Long) 26
CoffeeWatch2.vbp. 26
Module1.bas 26
Option Explicit 27
Declare Function timeGetTime Lib "winmm.dll" () As Long 27
Sub Main() 27
CoffeeTracker.cls 27
Option Explicit 27
Public ThreadID As Long 27
Public Size As Long 27
Public ID As String 27
Private WithEvents mwCoffee As Coffee 27
Private mlngStart As Long 27
Public Property Get Coffee() As Coffee 27
Public Property Set Coffee(ByVal NewValue As Coffee) 27
Private Sub mwCoffee_Complete(ByVal Canceled As Boolean) 28
Private Sub mwCoffee_Progress(ByVal PercentDone As Single, Cancel As Boolean) 28
NotifyMe.cls 28
Option Explicit 28
Implements ICoffeeNotify 28
Private mlngNotifyID As Long 28
Private Sub ICoffeeNotify_CoffeeReady() 29
Private Property Let ICoffeeNotify_NotifyID(ByVal RHS As Long) 29
Private Property Get ICoffeeNotify_NotifyID() As Long 29
Form1.frm 29
Option Explicit 29
Private WithEvents mwcmnEvents As CoffeeMonitor 29
Private mcctEvents As Connector 29
Private mcm2CallBacks As CoffeeMonitor2 29
Private mNotifyMe As New NotifyMe 29
Private Sub cmdEvents_Click() 29
Private Sub cmdCallBacks_Click() 30
Private Sub cmdMT_Click() 30
Private Sub Form_Unload(Cancel As Integer) 31
Private Sub mwcmnEvents_CoffeeReady() 31
frmThread.frm 31
Private Sub cmdCancel_Click() 32
Private Sub cmdShortOnly_Click() 32
Private Sub cmdShortLong_Click() 32
Private Sub cmdNLong_Click() 32
Private Sub cmdXThread_Click() 33
Private Sub cmdIDs_Click() 33
Private Sub Form_Load() 34
Private Sub Text1_KeyPress(KeyAscii As Integer) 34
Private Function NewKey() As String 34
Private Function NewTracker(ByVal ThreadID As Long, _ 34
Private Sub tmrShort_Timer() 35