• Welcome to Valhalla Legends Archive.
 

Passing user defined type in object module event

Started by UserLoser, July 03, 2006, 12:53 PM

Previous topic - Next topic

UserLoser

I have an event, i.e.:


Public Event OnClanMemberInformation(ByVal Cookie As Long, ByVal Status As Byte, ByVal ClanName As String, ByVal Rank As Byte, ByVal DateJoined As Variant)


Now I want DateJoined to be a filetime, but obviously you cannot do that.  In my handler:


Private Sub RecvClanMemberInformation()
    Dim Cookie As Long
    Dim Status As Byte, Rank As Byte
    Dim ClanName As String
    Dim DateJoined As FileTime
    'Get cookie
    Cookie = ParseBuffer.NextDword
    'Get status
    Status = ParseBuffer.NextByte
    'If status equals zero, user is not in a clan
    If (Status <> 0) Then
        'Get clan name
        ClanName = ParseBuffer.NextString
        'Get rank
        Rank = ParseBuffer.NextByte
        'Get date joined filetime
        DateJoined.LowDateTime = ParseBuffer.NextDword
        DateJoined.HighDateTime = ParseBuffer.NextDword
    End If
    'Throw event
    RaiseEvent OnClanMemberInformation(Cookie, Status, ClanName, Rank, DateJoined)
End Sub


What's the best way to go about raising an event including a filetime? I have variant there in the event declaration only so it will compile...I suppose I could make a filetime class but that seems kinda stupid...maybe maybe not

Eric

In the past, I've always just passed a pointer to the structure.

UserLoser

Quote from: Lord[nK] on July 03, 2006, 12:58 PM
In the past, I've always just passed a pointer to the structure.

Hmm, that'd work but I think it'd be too messy for what my goal is in the long run.  Thanks, but since my only UDT I'm dealing with is a filetime, I'm just going to create a filetime class.  Thought of some nifty ideas for it too

Ringo

Use a public object module, rather than a private one, then just pass the udt byref?
Or if you want to keep it a private object, then I would do as lord said, and pass the position of the variable in memory with VarPtr() or somthing.

TheMinistered

The only way to have a public object module, is to locate your class inside an ActiveX DLL project.  However, there are two ways to pass this:

1) Their way via VarPtr, which is quite dirty and ugly
2) Use the FRIEND modifier on the function you wish to pass the FILETIME struct, and of course you must pass byref!

Sigh, do I have to explain VB SYNTAX too? n00bs! :)

Ringo

Quote from: TheMinistered on July 13, 2006, 04:21 PM
The only way to have a public object module, is to locate your class inside an ActiveX DLL project. 
My bad, alot of my projects these days are ActiveX exe's, rather than standard ones, where public objects are not an issue.
What i ment by "If you want to keep it as a private object", was so people cant referance the exe and use the class.

Cool @ the Friend modifier, I didnt know about that :P

TheMinistered

I don't really understand why most of your projects are activex executables... you only need activex exes for certain things... but i'm sure you have valid reasoning... hmm ;p