|
-
Sep 5th, 2024, 06:49 PM
#9
Re: VB6 - How to Raise Events from late-bound objects (declared generically As Object
 Originally Posted by VanGoghGaming
You get the parameter types from the variant array of parameters. Each variant contains type information in the first two bytes (retrievable by the VarType function). As for the parameter names, they are not saved anywhere so you cannot retrieve them. VB6 does not allow named parameters for events, like this for example:
Code:
Public Event DummyEvent(sName As String)
RaiseEvent DummyEvent(sName:="Disgruntled") ' You can't used named parameters when raising events (syntax error in IDE)
Also it is not required to return the values of "ByRef" parameters but you lose functionality if you skip that part. For example you have no way to know if some parameters have been changed in the event procedure if you don't send them back to the caller. The new version (updated in the first post above) checks if the parameters have been changed before sending them back.
I've already mentioned this in the code comments if you read them. Standard EXEs don't include a "TypeLib", so it's more complicated to retrieve function names (only works for "Public" methods of classes anyway). ActiveX projects (EXE, DLL and OCX) include their TypeLibs in the compiled file which makes it possible to retrieve the names of events.
I have updated the ZIP file in the first post above to fix the bug that you found as well as another bug (when using events with array parameters). Also this new version includes a way to choose between raising NamedEvents with strong typed parameters as well as a GenericEvent with a variant array of parameters. The choice is up to the you.
For many years, I have been studying how to quickly extract the parameter names in the event.Now it's finally solved. Thank you very much for your help.If you are writing a simple VBS scripting tool. Quick code intelligence hints are needed, and such a feature is very useful.When we need to dynamically load any com DLL or OCX,We need to implement his event feedback dynamically.Can you study it and convert this method to 64-bit?
For VBA, VBS, twinbasic, freebasic
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|