Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Experts Please Help

Status
Not open for further replies.

scasystems

Programmer
Jan 15, 2003
44
GB
I have created a ProgressBar form. Which raises a Process event. I have tested it and it works fine.
Next stage is to place this form within a Global Multiuse DLL (where I have all standard functions/forms that are to be shared across applications).
So I placed the form in the dll and wrapped a class around it. So Far so good.
Now within another dll ( I have a wrapper around a login form) and placed code on the login form to use the new progress class that checks for any updates to the database (database.upd) which goes through a lengthy processs.
Compiled all the dlls and ran the code hey presto works like a dream.
But when I came to use the progress in another part of the project problems arose which I have nailed down to the event not being caught:-

i.e.

Private withevents Progress as clsProgress

Private Progress_Process()
does not get here
some code....
end

now if instead of referncing the dll but add the dll project to the test project it works.
But referencing the dll the event is never caught. Yet how did it work when placed the same code within another dll

I am at a loss.
 
I'm not sure, but it might have something to do with the fact that it's an application global COM server. I.e. not an actual new instance of the class is generated and the connection point is still connected to some other interface. Something like that.

Try to make it a separate dll first, NOT global, just an ordinary one. See what happens then...


Greetings,
Rick
 
Ok. Herers a complete listing of the frmProgress code , the class that wraps around
the frmProgress (clsProgress) and the test form code:

frmProgress (with dll project)
==============================
'*****************************************************************************
' Public Events
'*****************************************************************************
Public Event Process()
Public Event Cancel()

'*****************************************************************************
' Form Events
'*****************************************************************************
Private Sub Form_Activate()
Static Activated As Boolean
Me.Refresh
If Not Activated Then
Activated = True
' Now this form is visible, call back into the calling
' code so that it may perform whatever action it wants.
RaiseEvent Process
' Now that the action is complete, unload me.
Unload Me
End If
End Sub

Private Sub cmdCancel_Click()
'Need to inform user that the cancel has been clicked
RaiseEvent Cancel
Unload Me
End Sub

'*****************************************************************************
' Public Subs/Functions
'*****************************************************************************
Public Sub MoveBar(ByVal NewValue As Long)
' Ensure that the new progress bar value is not
' greater than the maximum value.
If Abs(NewValue) > Abs(ProgressBar1.Max) Then
NewValue = ProgressBar1.Max
End If
ProgressBar1.Value = NewValue
If cmdCancel.Visible Then DoEvents
End Sub

'*****************************************************************************
' Public Properties
'*****************************************************************************
Public Property Let TitleBarCaption(ByVal NewCaption As String)
Me.Caption = NewCaption
Me.Refresh
End Property

Public Property Let AllowCancel(ByVal IsTrue As Boolean)
If IsTrue Then
cmdCancel.Visible = True
Else
cmdCancel.Visible = False
End If
Me.Refresh
End Property

Public Property Let Maximum(ByVal NewMax As Long)
ProgressBar1.Max = NewMax
End Property

Public Property Let Text(ByVal NewCaption As String)
lblProgress.Caption = NewCaption
Me.Refresh
End Property

Public Property Let ShowProgressBar(ByVal IsTrue As Boolean)
Me.ProgressBar1.Visible = IsTrue
End Property

Public Property Let Animation(ByVal AviFile As Integer)
Select Case AviFile
Case 0
cmdCancel.Left = Me.ScaleLeft + Me.ScaleWidth - cmdCancel.Width - 50
Me.Animation1.Open App.Path & "\FindComp.avi"
Case 1
cmdCancel.Left = Me.ScaleLeft + Me.ScaleWidth - cmdCancel.Width - 50
Me.Animation1.Open App.Path & "\Findfile.avi"
Case 2
Me.Animation1.Open App.Path & "\FileMove.avi"
End Select
Me.Animation1.Play
End Property

clsProgress (Within DLL Project)
=================================
Private WithEvents Progress As frmProgress
'*****************************************************************************
' Public Events
'*****************************************************************************
Public Event Process()
Public Event Cancel()

'*****************************************************************************
' Public Subs/Functions
'*****************************************************************************
Public Sub MoveBar(ByVal NewValue As Long)
Progress.MoveBar NewValue
End Sub

'*****************************************************************************
' Public Properties
'*****************************************************************************
Public Property Let TitleBarCaption(ByVal NewCaption As String)
Progress.Caption = NewCaption
End Property

Public Property Let AllowCancel(ByVal IsTrue As Boolean)
Progress.AllowCancel = IsTrue
End Property

Public Property Let Maximum(ByVal NewMax As Long)
Progress.Maximum = NewMax
End Property

Public Property Let Text(ByVal NewCaption As String)
Progress.Text = NewCaption
End Property

Public Property Let ShowProgressBar(ByVal IsTrue As Boolean)
Progress.ShowProgressBar = IsTrue
End Property

Public Property Let Animation(ByVal AviFile As Integer)
Progress.Animation = AviFile
End Property

Public Sub Show()
Progress.Show vbModal
End Sub

'*****************************************************************************
' Private Events
'*****************************************************************************
Private Sub Class_Initialize()
Set Progress = New frmProgress
End Sub

Private Sub Progress_Cancel()
RaiseEvent Cancel
End Sub

Private Sub Progress_Process()
RaiseEvent Process
End Sub

frmTest (referencing DLL)
==========================
Private WithEvents Progress As clsProgress

Private Sub Form_Load()
Set Progress = New clsProgress
Progress.TitleBarCaption = "Searching..."
Progress.Text = "Some File"
Progress.ShowProgressBar = False
Progress.AllowCancel = True
Progress.Animation = 2
Progress.Show
End Sub

Private Sub Progress_Process()
-------->>>>>>>>> never gets to this point <<<<<<<<<<<<<<<<-----------
Dim I As Integer, J As Integer
For I = 1 To 64000
For J = 1 To 10
Progress.MoveBar I
Next
Next
End Sub

Placed msgBoxes within the clsProgress and know for a fact the Progress_Process()
does raise an event it's just that the frmTest never picks it up.
 
I don't doubt about the events being raised...

As I said, it might be because of it's app global. It might be the event is send to the previous connected interface. I've never used the app global stuff, but I think that it must have someting to do with that....


Greetings,
Rick
 
Ok. Changed DLL to just Multiuse and still get the same result.
Bear in mind that if I load the dll.vbp instead of referincing the dll it works fine
 
I'm sorry, but then I've no idea why it wouldn't work...


Greetings,
Rick
 
Just a desparate long shot . . .
Try naming your events something less generic and Windowese than 'Progress' and 'Process'. Maybe a naming conflict . . . A collegue named a public property 'Date' and had no end of problems.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top