Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




RaiseEvent Not Firing


I have a program which spawns a child form. The child form creates an object:

(Declares portion of Child module)
Public WithEvents Server1 As CINTComSvr.clsNETSvr

In the child Form.Load sub:
Set Server1 = New CINTComSvr.clsNETSvr

The program uses an acitiveX exe as the "Server".

The Server code (activeX) declares several Events with standard argument variables (Strings and Longs, no optionals or other surprises). The child form contains all the methods for these events.

For clarity, I'll refer to the Child form in the main program as A and the activeX program as B.

The problem:
I can click on a button in A, to call a function in B, which in turn raises an event in A. That works just fine. However, if program B raises an event on it's own, A does not get it. The method in program A never fires.

I know I am missing some principal issue here... Any help regarding general rules would be greatly appreciated.

I'd post more code, but there is just too much to post. I'm hoping that this can be resolved through theory of use. (proper usage anyway)

Thank You




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
RaiseEvent In Class Not Firing
Inside my class i have set an event:

in the declarations:
Public Event GetError(ByRef estring As String, ByRef enumber As Integer)

Then in the Let statement to validate the input:
If Len(vData) = 0 Or IsNull(vData) Then
RaiseEvent GetError("Invalid Input Value", "22")
Else
mvarArgValue = vData
End If


The program is an acitvex, so in my usercontrol, i have:
Dim WithEvents objError As clsCheckArg

Under the initialize sub:
Set objError = New clsCheckArg

Then finally the code to handle the event:
Private Sub objError_GetError(estring As String, enumber As Integer)
MsgBox "Error #" & enumber & ": " & estring, vbDefaultButton1, "Argument Error"
End Sub


I've been working on this simple thing all day, but its just not working. When i go through the code with F8 line by line, it reads the RaiseEvent line but doesn't actually call it, it just goes onto the next line beneath it.

Does anyone know why this is happening?

RaiseEvent
I want to raise an event from a class module. Would I need to put the event in a global module or on a form? I know that in user controls you set the event by saying...

ControlName_EventName Then the Control Name shows up in the right hand box at the top of the screen and the EventName in the left hand (procedure) box.

When I say...
ClassName_EventName it all shows up in the left hand (procedure) box will it still be recognized when the event is raised?

RaiseEvent
Seasons Greetings,

The current project that I am working on requires some of the forms to be subclassed. I have a standard module which contains the Window Procedure function, that handles the messages.

I also have two class modules A and B. Class module A is used to create and later reference new class module B objects. Each item in collection A contains an Object B and a reference to the object.

My problem is; when I receive a message that I am interested in, I would like to raise an event, and handle this event in a form module.

I have tried to keep it short and to the point but I can elaborate if needed.

I look forward to any responses!!

RaiseEvent
I subclassed a control in my usercontrol. Now how do I raise an event thats in the usercontrol module from a difrent module?

Thanx in advance!

RaiseEvent HELP
Im receiving a error message when load the program.
"Event not found", why?


Code:
Private Sub winsocks_DataArrival(Index As Integer, ByVal bytesTotal As Long)

Dim tmp As String
Dim rs_apert As New ADODB.Recordset
Dim rs_prate As New ADODB.Recordset

'On Error GoTo DataArrivalError
'
' Save the amount of data received.
m_lngBytesReceived = m_lngBytesReceived + bytesTotal
'
' Grab the data from the specified Winsock object, and pass it to the parent.
Call winsocks(Index).GetData(tmp)
RaiseEvent DataArrival(Index, tmp)

End Sub

RaiseEvent
I have an ActiveX EXE with a class module in which raises events.
The RaiseEvent Woof() gets fired, but my project, which references this class module does not get the event.
I declare the object with WITHEVENTS and my IDE can see the different events which my class can raise, but when the RAISEEVENT line fires the event is NOT picked up by by client side app....Anyone come across this before???

RaiseEvent
I have a problem. I'm making an ActiveX DLL with a Class. In its code I have this:
VB Code:
Private WithEvents TI As cTrayIcon Public Event pctLeftClick()Public Event pctRightClick()Public Event pctMove()Public Event pctDoubleClick()
TI is a class of my DLL. And I would like to raise the event of the TI to my Standard EXE project.

However, even though the RaiseEvent PictureRightClick gets executed, this code
VB Code:
Private Sub TI_PictureRightClick()    RaiseEvent pctRightClickEnd Sub
never gets executed so my EXE doesn't get the event...

Any ideas?

DLL RaiseEvent
Is it possible to generate an Event from within a DLL? If so can it only be done from a class? And how do I catch it from the calling project? Or is it just easier to use an OCX?

RaiseEvent Help , Please.
Hi,

I have an Activex.exe project I'm working on.

In this project I also have a form , containing most of the code.

This ActiveX.exe project at the end will be an Exe file , called from a standard project.

The problem I have is that I want to be able to RaiseEvent from my Form and not from the Class , I know it is possible , How ?

What I did (but didn't work) :

Code in Form1 :

Public Event Hello()

private sub command1_click()

RaiseEvent Hello

End sub


Code in Class1 :

Public Event Hello()

Dim withevents ObjClass as Form1

Private sub Class_Initialize()

set Objclass = new Form1

End sub

Now I have an object in the Class1 called ObjClass
This object has an Event called Hello :

private sub ObjClass_Hello()

msgbox "Hello"

End sub

In the above code the Event not rise , also I don't have any Errors!

I think it's a bug in Visual Basic ?

Help!!!

Thanks in advance , Moyalt.

RaiseEvent
somebody can explain what exacty make RaiseEvent

thanks

RaiseEvent From Other DLL
Hello!
If I call a dll from my GUI, and that dll calls another dll and that dll makes a raiseevent, how do I get the event up to my GUI??

I reference to the second dll, and I can also see the public events but somehow they are not triggered...

There's is no problem from the first dll to my GUI :O)



TIA

Janus

RaiseEvent
Forgive me if this has been asked many time but I have searched the board and not found a relevent example.

I am new to RaiseEvent and wondered if anyone can give me an example, all I want to do is have 2 forms Form1 has a listbox, Form2 has a textbox and command button. I want to raise an event to put whatever is in the text box into the listbox on Form1 when clicking the command button.

Thank you

Q. Why Would A Sub Include A RaiseEvent?
One of our contractors has left our company, and I have been unlucky enough to inherit his project. He was very experienced with VB6 and earlier, whereas I have only worked with VB.NET (for the last year or so) and C.

A lot of his code looks like this:

Code:
Public Event AddImage()

Private Sub HandleAddImage()
RaiseEvent AddImage()
End Sub

Public Function Add(...) As Layer
....
AddHandler MyLayer.AddImage, AddressOf HandleAddImage()
....
End Function

Public Sub Remove(...)
....
RemoveHandleer MyLayer.AddImage, AddressOf HandleAddImage
....
End Sub
Could someone give me an idea of what this code is supposed to be doing? Is this a good way to write this code? It looks very wordy to me.

Help With RaiseEvent Statement
Hey all,
I am having problems with the UserControl_MouseDown event. When I place "RaiseEvent Click" in the sub, it doesnt fire... Anyone know what could be causeing this?

Here is the code:

Code:
Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim ctl As ddnMultiSelect
Dim lItem As Long
Dim rc As RECT
'
If (m_bDropDownMode) Then
tmrLostMouse.Enabled = False
lItem = plHitTest()
If (lItem > 0) Then
m_tItems(lItem).bChecked = Not (m_tItems(lItem).bChecked)
RaiseEvent Click
Set ctl = ObjectFromPtr(m_ptrOwner)
ctl.fItemChecked(lItem) = m_tItems(lItem).bChecked
m_tItems(lItem).bMouseDown = True
m_tItems(lItem).bMouseOver = True
pPaint
End If
Else
' rest of code....
End If
End Sub

Event/RaiseEvent
I want to use an event to update a progress bar on form1 from module1. What is the proper code to complete this task? I have never used events and the online resources I have found seem a little over my head. I am using VB6.

I call a function on module1 from form1. This function adds files to a zip file. I will use the # of total files vs the # of zipped files for the progress bars value. My problem is I have to call the function first and then update the progress bar from inside of the function back to form1. Can someone help?



Thank You

Problem With RaiseEvent
Hi,
I have a usercontrol that I'm trying to use events in and RaiseEvent.

What I have is a listview on the control and when the selected item is changed I want it to raise the

Event SelectChange(ItemIndex as Integer)

So I do it with
RaiseEvent SelectChange(ListView1.SelectedItem.Index)

But for some reason VB crashes everytime it hits the raiseevent command and I cannot figure out why. I've looked at sample programs with raiseevent used in them and copied they syntax and all exactly the same yet still vb crashes.

Anyone have any clue on how to solve this problem?

Thanks

Datarepeater Raiseevent
Hi there.

My datarepeater is now working. Thankx!
Now I created a command button in my userControl. I associated an event to that button. It gave me a code like this :

Private Sub cmdDelete_Click()
RaiseEvent btnDeleteClick
End Sub

Now How do I put the action code of that event on my form that has the datarepeater. I don't know if this is clear. Thank you.

RaiseEvent Not Triggered
Hello there,

In my struggle to get an ActiveX control implemented I have a problem in catching the RaisEvent.

If I debug the application I can see the ActiveX control is firing the getDepartmentListDone event, but the standard.exe program is not receiving this event. The Msgbox "Test" is not triggered.

Does anybody know what I do wrong??
Thanx!!!


I use the following code:

** class module DepartmentCls (ActiveX control)
Public Event getDepartmentListDone()

Public Sub getDepartmentListDone()

RaiseEvent getDepartmentListDone

End Sub

** module standard.exe
Dim WithEvents Department As DepartmentCls

Private Sub Afdeling_getDepartmentListDone()

MsgBox "Test"

End Sub

RaiseEvent And Module
Hi there,

I want to fire a public class event in my class when a subroutine in a module is ended. I can not figure out how to do this ?
The only way to fire a public class event is within a form or in a class I believe.

Does anybody have a clue how to fire the event from a module?

Many Thanx!!!

Please Help With This RaiseEvent Problem !
Hi,

I recently working on an ActiveX.exe project containing a form (Form1)
and a class module.

I want the Form1 to RaiseEvent to the class, which is possible.

I attached 2 files : project1 & project2 which are the same besides
a small thing that shouldn't change the difference between them - only if it's
if it's a bug in vb (what I think it is).

Project2 works fine and project1 don't! Why ???

Hope ypu can help me resolve that problem.

Thanks in advance , Moyalt.

ps. I've taken this example from the Karl More tutorial on Com
which is in : http://www.vbworld.com/activex/comcourse3/

RaiseEvent Problem , Please !!!
Hi,

I recently working on an ActiveX.exe project containing a form (Form1)
and a class module.

I want the Form1 to RaiseEvent to the class, which is possible.

I attached 2 files : project1 & project2 which are the same besides
a small thing that shouldn't change the difference between them - only if it's
if it's a bug in vb (what I think it is).

Project2 works fine and project1 don't! Why ???

Hope ypu can help me resolve that problem.

Thanks in advance , Moyalt.

ps. I've taken this example from the Karl More tutorial on Com
which is in : http://www.vbworld.com/activex/comcourse3/

RaiseEvent From A Form ?
Hi,

I have an Activex.exe project I'm working on.

In this project I also have a form , containing most of the code.

This ActiveX.exe project at the end will be an Exe file , called from a standard project.

The problem I have is that I want to be able to RaiseEvent from my Form and not from the Class , I know it is possible , How ?

What I did (but didn't work) :

Code in Form1 :

Public Event Hello()

private sub command1_click()

RaiseEvent Hello

End sub


Code in Class1 :

Public Event Hello()

Dim withevents ObjClass as Form1

Private sub Class_Initialize()

set Objclass = new Form1

End sub

Now I have an object in the Class1 called ObjClass
This object has an Event called Hello :

private sub ObjClass_Hello()

msgbox "Hello"

End sub

In the above code the Event not rise , also I don't have any Errors!

I think it's a bug in Visual Basic ?

Help!!!

Thanks in advance , Moyalt.

RaiseEvent Oddity
Hi There,

I'm getting some weird behaviour trapping events within a collection class.

The basic structure is
1. A form with 4 TextBoxes.
2. Each TextBox is referenced WithEvents in a class called clsKey.
3. The referenced TextBox.OnFocus Event is used to raise an event called ActivateKey, which has clsKey.Me as the parameter.
4. Each clsKey is referenced WithEvents in the collection object of a class called clsKeys.

Now here's the thing.  When any of the TextBoxes get the TextBox.OnFocus event raises the ActivateKey event.  However, this event is only trapped in clsKeys if the TextBox is not null.

Here's the code:
|Class clsKey|

Private WithEvents ctlTextBox As TextBox
Public Event ActivateKey(ByVal ActiveKey As clsKey)

Private Sub ctlTextBox_GotFocus()
    RaiseEvent ActivateKey(Me)
End Sub

|Class clsKeys|

Private WithEvents objKey As clsKey
Private objActiveKey As clsKey

Private Sub objKey_ActivateKey(ByVal ActiveKey As clsKey)
    Set objActiveKey = ActiveKey
End Sub


Any ideas anyone?

ADO: RaiseEvent WillConnect
Reference: Microsoft ActiveX Data Objects 2.6 Library

Can anyone tell kindly enlighten me why I get "Compile Error: Event not found" for the following statements? I am hoping it yields control to the main form while ADO is trying to establish a database connection.

Code:Private WithEvents madoConnection As ADODB.Connection

Private Sub madoConnection_WillConnect(ConnectionString As String, UserID As String, Password As String, Options As Long, adStatus As ADODB.EventStatusEnum, ByVal pConnection As ADODB.Connection)
On Error Resume Next

    DoEvents
    RaiseEvent WillConnect(ConnectionString, UserID, Password, Options, adStatus, pConnection)

End Sub

Multithread And RaiseEvent
I make an ActiveX server in mono thread mode (one thread in project settings).

The server is connected to a multithread other COM server that launches multithread events.
This works well and events are encapsulted in only one thread.
My server works in only one thread.

BUT my server raiseevent to its clients.

And here is the problem.

An example :
In example my server is client of server 1 and server for two clients (c1 and c2).

Take the case of my server do this :

Receive two events from server 1
First event enters from server 1 in my server
Raise event to c1
Raise event to c2
Returns to server 1 from its event
Then server 1 event 2 enters and this continues

This is if all works ok but in fact here is how vb works :

Receive two events from server 1
First event enters from server 1 in my server
Raise event to c1 (for event 1 of server 1)
!!! HERE VB SLEEPS THIS THREAD AND LETS THE SECOND EVENT OF SERVER 1 TO ENTER !!!
Second event enters from server 1 in my server
Raise event to c1 (for event 2 of server 1)
!!! HERE VB SLEEPS THIS THREAD AND LETS THE SECOND EVENT OF SERVER 1 TO ENTER !!!
Raise event to c2 (for event 1 of server 1)
Raise event to c2 (for event 2 of server 1)


So as you see (i know it is not simple but i cannot do more) my server becomes somehow multithreading and not mono threadings.

Have you heard any about that ?
Do you know a solution ?

Show From From Within Ocx - Raiseevent
Hi,
I'm going crazy...
I have a usercontrol, and to reduce the number of files I've put one class in it, which will display a form, the user can search the database with that form, and with event, I let the calling program execute the query and pass the values to the form to show.
This works perfectly when I'm working in the project group with the control and a testproject, but as soon as I want to user the binairy ocx, Im getting problems...
The method I call in the class wants a parentform to show the window, I have to pass it as Object... When I run it from within the IDE, I get error 373, which basically means I can't pass an object to the class from within VB, but I can from the exe (and that works perfect...).
I removed the parentform parameter, and I can call it from within VB, which is a must for testing and debugging purposes... but here comes the fun....
The class raises events.. this doesn't work when I run the testproject in VB! :-( It works when I have an exe, but not when I run the same program in VB...
I'm running out of idea's, this sucks hard.. :-(
Anyone any ideas how to work around this bug? (I think it's a huge bug....).
I've written many controls and classes, a couple of them used forms which were located within the control/dll, and it always has worked both in VB as in the exe... Now what am I overlooking here??? :-(((
To give an idea what the class is:
Function Add_Collumn - values are passed to the form in the control where it sets listviews columns
Function Search - the function which will show the form (vbModal)
Friend Function ExectueQuery - the form calls this function, and this function raises the Execute event
Friend function GetRows - form calls the class, class raises an event

I'd say it's not very spectacular or anyhing, no weird API's,just all plain VB functions...
Anyone an idea?
Tnx a lot! :-)

Crazy D :-)
"One ring rules them all"

RaiseEvent And VbModal
I made an activex with VB6 and use RaiseEvent to send event to the client.
I made too a client under vb6 to test my control.

If i have a modal dialog box opened by the activex code then the client don't receive the raised event sent by the control (on a timer scheduler).

WHY ???

RaiseEvent Problems
Hello.
I have notice a problem when using Visual Basic.
I create an ActiveX control (MyUserControl.ocx) that can Raise events in MyApplication.
When MyUserControl.ocx Raise events, I check the 'EventsFrozen' property, to avoid an events loss in MyApplication:

Do
RaiseEvent MessageComeIn()
Loop While EventsFrozen = True

All the events works properly until I tried to cause an event from "Form_Load()"
This causes the EventsFrozen to locked in True state, even so I handle this event. This cause the application to be stuck in infinite loop.
Are you familiar with such a problem ?
Please advice.

Thanks and Regards
Alex

ActiveX Control && RaiseEvent
Hey all,

I have an ActiveX Control Project. The Usercontrol has an event Activate. Now I have some code in a module.

How can I raise the event from the usercontrol from inside a function in the module? I can't seem to find out how to do this. I could simply place the code in the usercontrol, but it would be nicer if it could stay in the module.

Why Can't You RaiseEvent Is Class_Initialise Events?
Why can't you RaiseEvents in Class_Initialise event?

Woka

Using An OCX In A DLL (Accessing Methods) RaiseEvent??? Need Help Please!
Since I'm getting absolutley nowhere on my other thread I'll revise this one with the new info that I know.

I'm creating a web page that utilizes a DLL. I need the DLL to process ZIP files. In order to do that I'm using the AddZIP/AddUNZIP OCX Controls. In order to use those (I think) I need to add a form to drop them on. The problem is when I try to VIEW the zip files (havn't got to unzipping yet ) I can't access that method. It's like it never runs? I can access other properties of the control like "ArchiveName", just not the methods themselves.

Now I've been reading up on the whole RaiseEvent thing but am still unclear. Is that something I need to do here?

I'm totally stumped and am desperate for any kind of lead on what to do next. Any help would be extremely appreciated.

RaiseEvent From A Standard Module...
I am subclassing a window from an AX DLL and I would like to raise events when I get certain messages. However, you can only subclass using a standard module, and can only raiseevents from object modules. There may be an easy work around, but my brain refuses to function, seeing as how I'm at work.

Raiseevent In Class From A Form?
Is it possible to raise andevent of a class from a form in the same project?

Class RaiseEvent Question
Hello,

I was just curious:

Say you set up a file search class to search through sub folders and return each file name that is found by raising an event (FoundFile). Then lets say that you just want to use the class to count the files (which it will do and store the number in a property, so you don't bother to put any code in the FoundFile Event.

If the event is firing with each file found, but there's no code within the FoundFile event, will this still take time to process an event that does nothing ???

In other words, would it be better to provide a setting in the class to prevent the event from being raised if you're not going to provide code for the event, as a way to help speed/performance ???

(Yes I know there are API's etc. for File Searching, I'm just curious about servicing events within computational loops in a class, when you won't always code for the event)

Thanks for any insight !!

RaiseEvent From Form In Dll -strange
Hi guys,
I've got a strange problem. I am using an ActiveX dll from my project that pops up a form. When the user clicks a button on the form, the class in the dll responds to the event and in turn raises another event to which the main project should then respond.

This works in debug mode, ie. when I'm running the dll in another instance of VB, but not when I run from then compiled dll!?!

I'm not sure if this will help, but here's the code:

code in main form:

Code:
' - declaration section -
' Declare setup class and with event
Private m_UBMSetup As UBM_IO.UBMRoutineSetup
Private WithEvents m_WithSetup As UBM_IO.UBMRoutineSetup

' - in form load -
' Initiallize the setup class
Set m_UBMSetup = New UBM_IO.UBMRoutineSetup
' Set the event reference to pick up m_UBMSetup events
Set m_WithSetup = m_UBMSetup

Private Sub m_WithSetup_GetStagePosition(XPos As Single, YPos As Single, ZPos As Single)
' m_WithSetup_GetStagePosition
' Purpose: Responds to async event to get stage coords from OM Scan control
'

' Doesn't get here...



class code:

Code:
' - declaration section -
' Private form variables:
Private m_frmPartSetup As frmPartSetup
Private WithEvents SetupForm As frmPartSetup

' This event is used to poll the hardware for stage location
Public Event GetStagePosition(ByRef XPos As Single, ByRef YPos As Single, ByRef ZPos As Single)


Private Sub SetupForm_RequestPosition(ByRef XPos As Single, ByRef YPos As Single, ByRef ZPos As Single)

Debug.Print "Request position received, firing GetStagePos."
RaiseEvent GetStagePosition(XPos, YPos, ZPos)

' Gets here...
vbInformation
End Sub


sub form code:

Code:
' - declaration section -
' This event is used to poll the hardware for stage location
Public Event RequestPosition(ByRef XPos As Single, ByRef YPos As Single, ByRef ZPos As Single)


Private Function GetStagePosition(XPos As Single, YPos As Single, ZPos As Single) As Boolean
' GetStagePosition method
' Purpose: Reads the stage position by firing an asyncronous event to poll the parent application
' Returns: False if there was an error
'
XPos = -99
YPos = -99
ZPos = -99

' Get the stage coordinates via an asyncronous event call.
RaiseEvent RequestPosition(XPos, YPos, ZPos)

' Check to see if call succeeded
If XPos = -99 And YPos = -99 And ZPos = -99 Then
MsgBox "Could not read the stage coordinates", vbExclamation
GetStagePosition = False
Else
GetStagePosition = True
End If

End Function


Thanks in advance,

Array Unknownlength And Want To Use Its Raiseevent
hi all,

I have a class for ping. Which raises an event when when it completesand then we can see the status of the ping as successfull etc.

Now the thing is I might need to do simultaneous pings etc depending onuser input. So I want to have an array of ping objects which I caninitialize and do the ping when given command. I want to catch theirevents how do I go about this as they will have different names...



Any change in the approach is also welcome . I am not sure of how to dothis.

I guess payal might know about this...

Regards,
Hardik Bati
Conexant Systems
(O) 949 - 483 - 9163
(R) 949 - 644 - 8596

RaiseEvent In External Application?
Can someone give me a simple example of how to raise an event that is located in the form of an exe (activex exe)? The raise event call will be from an activex dll... I think I have to get the window handle and stuff, but Im relatively new to VB so im not quite certain. THanks!

RaiseEvent - It Looks Right... Apparently I'm Missing Something...
All that I am trying to do is raise an event from a class module, and have that event fire on a child form of my mdi app...

In the Class Module
Code:

Public Event MyEvent()

Public Sub Dosomething()
RaiseEvent MyEvent()
End Sub

 

In a Child form
Code:

Public WithEvents mClass as ClassModule

Private Sub Command1_Click(Index As Integer)
mClass.Dosomething
End Sub

Private Sub mClass_MyEvent()
MsgBox "Event Fired"
End Sub



Not having any luck, is there something that i missed as far as having an event fire on a form?

the subroutine in the class runs, no error on the RaiseEvent function, but... the event never fires.

thanks in advance for any suggestions.



Edited by - barke_n on 3/1/2004 9:32:12 PM

RaiseEvent For Array Of Objects
I have a class module (A) that raise events. In my app, I create an array of objects of type class A in a form. VB6 documentation says I cannot do such things:

Dim withevents arrA(4) as A

while i understand (sort of ) the reason behind this (connection and stuff), how else can i capture the events of such array of objects implementation. Currently, i am using a not-so elegant workaround

dim withevents obj1 as A
dim withevents obj2 as A
dim withevents obj3 as A
dim withevents obj4 as A
dim arrA(4) as new A


'''
set obj1 = arrA(0)
set obj2 = arrA(1)
set obj3 = arrA(2)
set obj4 = arrA(3)

where arrA() is the array of objects of type class A. The problem is the array size has to be fixed while i want it dynamic. The events object variables has to be incremented/decremented.

Setting reference for each arrA() element is not too good, because all objects can generate events simultaneously.

Probably an ActiveX control will solve the problem but i am trying to avoid that.

appreciate any help/suggestion.

RaiseEvent From A Class Module
I am trying to use a class module to intercept Clicks on a label and pass the click event to the instantiating Form but am having much bad luck.
Form1 calls the CLabel class to create 6 labels on the form. This works just fine. When I click on any one of the labels, the CLabel class _Click event is entered and attempts to pass the event back to the form using "RaiseEvent" but this does not work. Using debug and traceing, you can see the mLbl_Click event in the Class module is entered and issues the "RaiseEvent" but the form never sees it.
I need help to figure out why.
Here is the code. Very simple.

' This is the code for the form. It requires two command buttons.
'
option Explicit

private mlblTaskLength(6) as CLabel
private withevents myEvent as CLabel
private Sub Command1_Click()
Dim li%, NumberOfLabels
NumberOfLabels = 5
for li% = 0 to NumberOfLabels
set mlblTaskLength(li%) = new CLabel
mlblTaskLength(li%).CallingForm = me
mlblTaskLength(li%).gDrawOnForm "lblT" & li, 500 * li, 0, 300, 1000
next

End Sub

private Sub Command2_Click()
Dim ctl as Control
for Each ctl In me.Controls
If Left(ctl.Name, 4) = "lblT" then _
me.Controls.Remove ctl.Name
next ctl
End Sub

private Sub Form_Load()
set myEvent = new CLabel

End Sub

private Sub myEvent_evLabelClicked(byval Index as Integer)
Debug.print "MyEvent Raised " & Index

End Sub
'
'
'
' This is the Class module. Its name is CLabel.
'
'
option Explicit
private withevents mlbl as Label
private mCallingForm as Form
Event evLabelClicked(byval Index as Integer)

public property let CallingForm(frm as Form)
set mCallingForm = frm
End property

public Sub gDrawOnForm(byval Name$, _
byval Top%, byval Left%, byval Height%, byval Width%)
set mlbl = mCallingForm.Controls.Add("VB.Label", Name$)
set mCallingForm = nothing
mlbl.Visible = true
mlbl.Caption = Name$
mlbl.Move Left, Top, Width, Height
mlbl.BorderStyle = 1
End Sub

private Sub mlbl_Click()
Debug.print mlbl.Name; " mlbl_Clicked Event reached "
RaiseEvent evLabelClicked(CInt(mid(mlbl.Name, 5)))
End Sub




John G

RaiseEvent Statement Is Too Long, How To Divide It?
Hello,

In my program I call an event.
RaiseEvent Edited(.....)
But the line is too long, how can i divide it over several lines?

RaiseEvent From A Form (in And ActiveX Dll Project)
I need to do a RaiseEvent for one of the Class modules in this project I'm working on. The catch is the the class shows a form, and the form needs to interact with the program that called the dll. I'd like to do this through events, but I can't seem to figure out how to RaiseEvent from the form. (BTW, there are several forms and several class modules in the DLL project)

I was thinking that I might need to use a Friend sub to do this. Anybody know if that would work, or a better way to RaiseEvent from a form?

Withevents Event Raiseevent Questions.
Hello, i've recently read about article of Sam. He uses withevents, event and raiseevent in his project. Can anyone explain for me about them? thank you.

RaiseEvent In Custom Control Locks IDE
I'm currently trying to port my VB5 project to VB6. I have loaded the project and even compiled with no problems--it's the runtime errors that are causing me trouble.

I have a custom control written with VB5 which is used in the program. When I run the program and load a form with this custom control on it the program instance and the VB IDE lock up. I can still run other apps, however, the dead IDE plagues the desktop. The only way to restore my system is a hard reset.

I've tracked this problem down to a single line in my custom Numeric Input control code where I raise my custom event when the value has changed ("RaiseEvent ValueChanged"). It doesn't lock every time this event is raised, but it is consistently reproducible. I've checked my Call Stack and it only has a few calls, so I'm assuming I haven't overloaded the stack.

Has anyone run into this problem? Does anyone have an idea what I might look for next? Everything worked fine with VB5.

Thanks.

How To Call RaiseEvent Inside A Subclass WndProc?
Hello,

This is a special case and I've not been able to figure out how to solve it.

I'm doing an ActiveX wrapper of some existing DLL that interfaces with some device. That API provides low-level "events" in form of window messages. To get the events, I have to supply a HWnd value of some window I have to subclass later. In the new WndProc routine, I get the messages and decide what to do, etc.

The problem arises when I try to define top-level events in my wrapper class. I declare my events, create the window and subclass it before pass the handle to the DLL. The subclass routine is in a .BAS module, but for obvious reasons I cannot RaiseEvent there. How could I solve this issue??


Thanks!

RaiseEvent Sends Event To Form Instead Of External App
I want to create an ActiveX DLL. My project contains a class module Foo and a form. I need the form because I have to use an OCX. This component will tell Foo when to raise an event for the external application that is instantiating my class. But for that I need to instantiate Foo in the form, and then the event is raised for the form - and not for the application, as I wanted.

in Foo:

Event Foo1(ByVal Blah As String)

Friend Sub AlertNow()
    RaiseEvent Foo1("blah")
End Sub

--------------------------------

in the form:

Dim Temp As Foo

Set Temp = New Foo
Temp.AlertNow
Set Temp = Nothing

--------------------------------

Can anyone please help me? How can I have the event raised to the external application that is using my DLL?
Thanks,
Zu^2

WithEvents And RaiseEvent In Class Module Help Needed
I want every access of a class module to fire the ViewChange event wich I defined as an event in the class. Do I have to put RaiseEvent in every Let property? Or is there a way to raise the event anytime the class executes a Get?

 What I have now is;
Code:
Public Event ViewChange()

Some private variables
Some constants
multiple Gets and Lets

In my Form_frmMain I have;

Public WithEvents aview As clsDataView
Declarations Etc.

Private Sub cboRecMonth_Click()
    If cboRecMonth.Value <> "" Then
        ARec.Month = cboRecMonth.Column(0)
        aview.ByMonth = True
        aview.ViewMonth = cboRecMonth
        cmdSelectCriteria
    End If
End Sub


So what I want is the assignment to the aview.ByMonth to fire the event. There are a number of controls on this form and so I want a blanket type of event. Know what I mean?

Thanks All,


Scott
The worst thing about wearing glasses is them being on your face.
Nothing is impossible, it just looks that way.

RaiseEvent To HTML/VBScript With Byref Boolean Argument
I have an OCX contained in a HTML page. This OCX raises an event to vbscript with a single Byref Boolean argument:


Code:
Public Event VersionMismatch(Handled As Boolean)

Sub SomeSub()
RaiseEvent VersionMismatch(Handled)
If Not Handled Then
OutputDebugString ("GroDefinitie::VersionMismatch not
processed in HTML script")
End If
End Sub
The piece of VBScript in the HTML page is the following (the name of the object is Definitie):


Code:

<script language="vbscript">
<!--
sub Definitie_VersionMismatch(Handled)
on error resume next
Handled = true
window.navigate("/pam/UnloadCom.html")
end sub
//-->
</script>
But the Handled argument has never been changed after RaiseEvent in my VB code. Handled is alway False. Any ideas? I was unable to find something relevant in MSDN.

Alternatively I could expose a public boolean property which can be set in VBSript so I will never be blocked for ever with this problem.

Regards
jEEm

Handling Errors With RaiseEvent To Stop Current Task
I am using RaiseEvent in a class to handle any input errors. Yet if it comes across an error, and fires the raiseEvent method, it then carries on processing other code.

Is there anyway to make the RaiseEvent kind of completely stop the current process, just like is possible when handling errors with select case statements?

thanks

Copyright 2005-08 www.BigResource.com, All rights reserved