dll for vb6 & automatic function calls

omart

Member
Joined
Jul 6, 2008
Messages
13
Programming Experience
1-3
I am using .net 2003,creating a dll to be used with a vb 6 program(i did not create).
the creator of the vb6 app will use my dll, and write some code for their app

1) when they instiate my dll, i want something to happen automatically
2) when a certain form in the vb6 app is closed i want something to happen.

is there an event listener i can program into my dll so these things happen, without the vb6 programmer having to call them explicitly?

or do i have to write them as sub procedures, and tell the programmer when certain things should be called?
 
I would suggest the latter of the 2 because it's easier however you can use the Win32 API in order to locate the caption of the window you want to react to and have your dll monitor as to whether that window has closed or not. You do it by calling

VB.NET:
Expand Collapse Copy
'Get the desktop window
hWndDesktop = GetDesktopWindow()
        
' It's first child is the 1st top level window
hwnd& = GetWindow(hWndDesktop, GW_CHILD)
    
'Now get the caption of the Window
sWinText = Space(255)
RetVal = GetWindowText(hwnd, sWinText, 255)
sWinText = Trim$(left$(sWinText, RetVal))

While sWinText <> "My form caption I am looking for"
        'Get the next Window
        hwnd& = GetWindow(hwnd&, GW_HWNDNEXT)
        
        If hwnd = 0 Then
          Exit Do
        End If 'hwnd = 0
        
        sWinText = Space(255)
        RetVal = GetWindowText(hwnd, sWinText, 255)
        sWinText = Trim$(left$(sWinText, RetVal))
End While
As for the initiate you can write code that goes into the NEW() method of your class.
 
Ok, thanks for pointing me in the right direction, now i will mess around with it
 
Back
Top