Re: do pop up boxes stop all events?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




<tadamsmar@xxxxxxxxx> wrote

I checked out the whole vendor code interface. It will generate no
events for me. All I can do is ask for data and wait till I get it,
but I will not have to wait more than 1/100th of a second. And, I
cannot establish 2 data streams for the 2 forms. I must get data for
both forms in one place, or find some way to alternate calls in the
two forms which seems quite difficult.

Perhaps this would work: I create a 3rd form (possibly hidden) that
creates a timer or some other event loop, like a change event that
kicks off itself, and I acquire data from that event loop. Then I pass
the data to the forms from from there.

You could easily handle grabbing data in one place from two different
forms.

For a simple example, add a Timer and a Command button to a new
form, and add a standard module to the project. Paste the code
below into their respective modules and set the project to run from
Sub Main. Then compile and run the program.

In the IDE the Msgbox will halt the updates, but compiled, it will not...

LFS

' [ Form1 code ]
Public Sub Update(Value As Long)
' Show changing Value on title bar
Me.Caption = Value
Me.Refresh
End Sub

Private Sub Form_Load()
Timer1.Interval = 10
Timer1.Enabled = True
End Sub

Private Sub Form_Unload(Cancel As Integer)
Timer1.Enabled = False
Release Me
End Sub

Private Sub Command1_Click()
' Modal call: BGnd doesn't change until after Msgbox closes.
MsgBox Me.Caption, , "Click"
Me.BackColor = QBColor(Rnd * 15)
End Sub

Private Sub Timer1_Timer()
Updates
End Sub


' [ Module1 code ]
Option Explicit
Private Declare Function GetTickCount Lib "kernel32.dll" () As Long

Private OldTick As Long
Private FormA As Form1, FormB As Form1

' Interval between calls to get data
Const INTERVAL As Long = 100 ' milliseconds

Sub Main()
Set FormA = New Form1
FormA.Show
Set FormB = New Form1
FormB.Show
End Sub

Public Sub Updates()
Dim NewTick As Long

NewTick = GetTickCount()
If Abs(OldTick - NewTick) > INTERVAL Then
OldTick = NewTick
' GetData A, B ' The two values
If Not FormA Is Nothing Then
' FormA.Update A
FormA.Update NewTick ' Demo value
End If
If Not FormB Is Nothing Then
' FormB.Update B
FormB.Update NewTick ' Demo value
End If
End If

End Sub

Public Sub Release(Who As Form)

If FormA Is Who Then
Set FormA = Nothing
End If
If FormB Is Who Then
Set FormB = Nothing
End If

End Sub



.


Quantcast