Thanks RainUK,
But I my problem is something else and is much simpler then what u thought.I'll explain u in detail.:
I have a VB activeX exe which raises an event with a Recordset(of ADO) having some some records picked from the database. Now my requirement is to handle that raised event in a VC++ component. I cannot change that VB ActiveX exe as it part of the existing system which is raising this event to all other VB clients . I want to introduce a VC client which can also handle the same event.
I tried raising an event with VB activeX dll and handling in VC it is working fine but I am not been able to do the same with VB active X exe and handling it in VC.
Now if you can help me in this......
Main Topics
Browse All Topics





by: RainUKPosted on 2002-07-25 at 01:50:01ID: 7176650
What sort of data do you want to pass between the two exe's. If it is simply a pair of long values, then you could just Broadcast Windows messages. I did a similar thing between a C++ DLL and a VB Client application.
indowsEven tMsgFromC+ +") indowsEven tMsgToC++" )
PROC,lpPre vWndProc) ).
_SENDNOTIF YMESSAGE + BSD_IGNORECURRENTTASK,lngR ecipients, lngEventMsgToC++App, wParam, lParam)
indowsEven tMsgToC++" )
indowsEven tMsgFromC+ +")
LICATIONS + BSM_ALLDESKTOPS);
_SENDNOTIF YMESSAGE,l pdwRecipie nts,uEvent MsgFromC++ App,wParam ,lParam)
In both your applications you will register a windows message:
In VB app:-
lngEventMsgFromC++App = RegisterWindowMessage("MyW
lngEventMsgToC++App = RegisterWindowMessage("MyW
Now you will also have to subclass this applications messages using (using APIs SetWindowLong(Hwnd,GWL_WND
So in the WindowProc API you will have something like this:
If uMsg = lngEventMsgFromC++App Then
' This windows message has been fired by your C++ App
' so deal with it here, you can pass two parameters
' wParam and lParam, so you will have to design your
' own method of deciphering what you send in the event
End If
Now to raise an event in your VB program so that your C++ program will receive an event you will need to use the API
BroadcastSystemMessage(BSF
I use this because it is system wide and my VB app was an NT service.
Now in your C++ application you will have to do the same (Select case the windows messages to the app)to receive messages, you must also register the same two windows message in your C++ app:
UINT uEventMsgToC++App
UINT uEventMsgFromC++App
uEventMsgToC++App = RegisterWindowMessage("MyW
and when you want to raise an event to the VB app, you could use the following sub routine:
VOID BroadcastEvent(long wParam, long lParam)
{
DWORD dwRec = 0;
DWORD *lpdwRecipients = NULL;
uEventMsgFromC++App = RegisterWindowMessage("MyW
dwRec = static_cast<DWORD>(BSM_APP
lpdwRecipients = &dwRec;
BroadcastSystemMessage(BSF
}
---------- Hope this may have sparked some ideas ------