|
cool, ok that's what i've been doing. now after i implement the connection points i get an error:
BEGIN_CONNECTION_POINT_MAP(Ccrap)
CONNECTION_POINT_ENTRY(IID_IPropertyNotifySink)
CONNECTION_POINT_ENTRY(IID__IcrapEvents)
END_CONNECTION_POINT_MAP()
it says that IID_IcrapEvents is undeclared... any clue about that?
also, when it asked me if i wanted a .dll or exe it also had a Checkbox that asked if you wanted to merge proxy/stub code. Is that necessary?
~Timothy T. Rymer
www.digipen.edu
tim.xpertz.com
|
|
|
|
|
MasterWang wrote:
it says that IID_IcrapEvents is undeclared... any clue about that?
You mean DIID_IcrapEvents
MasterWang wrote:
also, when it asked me if i wanted a .dll or exe it also had a Checkbox that asked if you wanted to merge proxy/stub code. Is that necessary?
No!
|
|
|
|
|
oh! wow, there's that error that i told you before, but yes "Fire_Done()" is there though (woohoo!).
~Timothy T. Rymer
www.digipen.edu
tim.xpertz.com
|
|
|
|
|
and it gives it to me as IID_Iklfasjdf, not DIID_afklj;ds
but when i changed it to DIID, we have no errors. i'm sure i'll post something shortly here on my status.
~Timothy T. Rymer
www.digipen.edu
tim.xpertz.com
|
|
|
|
|
that DIID_YOUROBJECTEvent is defined in "YourObject_i.c".
This is an auto-created file.
Glad to see you get there!
|
|
|
|
|
ok ok, good news/bad news... the good news is that it compiles and fires the events, bad news is that it still crashes...
i'm calling CoInitializeEx() and CoUninit
at the beginning/end of the worker thread,
still testin' and messin' with it.
anything that i forgot about that i should for sure have in there?..
~Timothy T. Rymer
www.digipen.edu
tim.xpertz.com
|
|
|
|
|
All I can do to help you is:
Ask you to test your control in the "ActiveX Control container Test" program.
If it works, look for what you are doing wrong in your client!
By the way, always use the same thread to access your object, ie: do not
access your object from the event handler!
Good luck
|
|
|
|
|
hahahahaha!!!!!!!!! woo hoooooooooooo!!!!!!!!!!!!!!!!!!!!!
yaaaaaaaaaaaaaaaaaaaaaaa-hooooooooooooooooooooooooooooo!!!!!!!!!!!!!!!
oh, hey, it works or whatever.
(trying to keep straight face )
yeah!!!! i think i know why it was botching up when we had identical code.
-When i added the first event to the project, i didnt compile afterwards and i think that's why that IID -> DIID wasnt working properly, and that's why it had never worked. so i just slowly did one thing at a time compiling after i did something else. and it works now! yeah!!!!!
Cool, thanks for being patient with all 4,000 threads in the forum and all!
woooooooooooo hooooooooooooooo!!!!!!!!!!!!!!
Ok there's the One and only God, then there's you! wooooooooo hooooooo!!!
thanks again!!!!! yeah!!!!!!!!!!!!!
~Timothy T. Rymer
www.digipen.edu
tim.xpertz.com
|
|
|
|
|
Nice to see that you believe in the ONLY God.
I am happy for you!
Merry Christmas & Happy new year!
- God bless the World
|
|
|
|
|
haha - well it's nice to know that i'm not the only one now in this field!
~Timothy T. Rymer
www.digipen.edu
tim.xpertz.com
|
|
|
|
|
How the interfaces are internaly designed,what is the exact role of Interface?
Terminater
|
|
|
|
|
Which interfaces?
Are you talking about IUnknown and IDispatch?
Michael
|
|
|
|
|
Hey guys and gals,
I've read some things on MSDN about trying to fire events from an ActiveX Control written in VC++ 6.0, but i just cant seem to get it. Is there any way to raise an event and get it to the main program from a worker thread? Is there any way you can explain this so that i can "comprehend" it? Can i just get some basics on how to do it? and if you do something strange, try to explain it.. (like any MFC Macro stuff cuz i really never use MFC if i dont have to) just do it in steps! 1.2.3.4.5.! <sigh> I'd love to hear a different insight on all of this... it's been bugging me for about a month, and i've been able to work around it, and now it's time to fix it.
SHABBA!!
|
|
|
|
|
It's a lot more complicated that it deserves an article by its own:
1) Yes you can fire even from a different thread but you need to make
sure that your component is MTA and not STA.
2) call CoInitializeEx(NULL, COINIT_MULTITHREADED) in the secondary thread;
and make sure your object is thread safe.
3) Since I have never used MFC to create ActiveX control, I don't know about
MFC Macro stuff for ActiveX.
4) In ATL, the wizard will create template file correctly for you if you
are using MTA or Free Thread marshaling.
This is just to help you start!
Good luck
|
|
|
|
|
it sounds like it would do the trick, but for some reason it wont recognize the header file <objbase.h>
which is where i'm supposed to get it from, and i am also linking to
ole32.lib as well, and it still says that it doesnt recognize the function...
i did use MTA just for the record..
but i also used an MFC ActiveX Control Wizard instead of ATL COM, which i had tried before, but i didnt add a control, so i'm gonna try that...
SHABBA!!
|
|
|
|
|
For your linking problem, I have no clue but as far as calling
CoInitializeEx from all threads that access the ActiveX
control, it should work. In the main thread, call CoInitializeEx in InitInstance(),
don't forget to call CoUninitialize() .
Good luck!
|
|
|
|
|
Hi,
I never succeeded firing Event directly from
Worker thread.
But one work-around way is to use Thread Messages.
You can use PostMessage(...) in your worker thread
to post a message to the main thread.
and in the Message Handler you can fire your Event.
Thanks
Firoz
|
|
|
|
|
i've tried that to no success... i'm gonna try CoInitializeEx(), and if that doesnt work, this is probably the only other way (that i feel like doing) that's not too much work. But i did try it, and it didnt work, i think it's because i didnt have a handle to the Window... and then people said to make an invisible window, and they just stopped. and didnt show you how... so that's where i'm at on that path.
SHABBA!!
|
|
|
|
|
Hi Shabba,
Ooops..I forgot to mention that.
You are right, you need a Window.
The steps are very simple...
...some modifications to your CoClass.
For Creating the Window ...
^^^^^^^^^^^^^^^
1) #include <atlwin.h>
2) Derive your CoClass from CWindowImpl<Your CoClass Name> .
3) DECLARE_WND_CLASS("Your CoClass Name")
4) Implementation for FinalConstruct() and FinalRelease().
In FinalConstruct(), you create the Window. and,
In FinalRelease(), you destroy the Window.
For Handling UserDefined Thread messages ...
^^^^^^^^^^^^^^^^^^^^^^^^^^
5) The MessageMap macro...
BEGIN_MSG_MAP(Your CoClass)
MESSAGE_HANDLER(500, OnUserMessage)
END_MSG_MAP()
6) Implementation for OnUserMessage() handler function.
Now, inside this handler, you can fire your COM Event.
Thats it.
Now in your Worker ThreadProc, whenever you want to fire the event,
use PostMessage(...).
Note: Postmessage needs HWND.
You can do either of this...
1) use HWND_BROADCAST or
2) use the HWND returned when you created the Window (in FinalConstruct()).
eg. ::PostMessage(HWND_BROADCAST,500,0,0);
Firoz
The following sample code may be Helpful...
#ifndef __LAWORKTHR_H_
#define __LAWORKTHR_H_
#include "resource.h"
#include "LAWorkThreadExeCP.h"
#include <atlwin.h>
class ATL_NO_VTABLE CLAWorkThr :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CLAWorkThr, &CLSID_LAWorkThr>,
public IConnectionPointContainerImpl<CLAWorkThr>,
public IDispatchImpl<ILAWorkThr, &IID_ILAWorkThr, &LIBID_LAWORKTHREADEXELib>,
public CProxy_ILAWorkThrEvents< CLAWorkThr >,
public CWindowImpl<CLAWorkThr>
{
public:
CLAWorkThr()
{
}
DECLARE_REGISTRY_RESOURCEID(IDR_LAWORKTHR)
DECLARE_NOT_AGGREGATABLE(CLAWorkThr)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(CLAWorkThr)
COM_INTERFACE_ENTRY(ILAWorkThr)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IConnectionPointContainer)
COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
END_COM_MAP()
BEGIN_CONNECTION_POINT_MAP(CLAWorkThr)
CONNECTION_POINT_ENTRY(DIID__ILAWorkThrEvents)
END_CONNECTION_POINT_MAP()
DECLARE_WND_CLASS("CLAWorkThr")
HRESULT FinalConstruct()
{
HWND hwnd = Create(::GetDesktopWindow(),CWindow::rcDefault,"MyAtlWindow",WS_POPUP);
g_Myhwnd = hwnd;
if (hwnd)
return S_OK;
else
return HRESULT_FROM_WIN32(GetLastError());
}
void FinalRelease()
{
if (m_hWnd != NULL)
{
DestroyWindow();
}
}
BEGIN_MSG_MAP(CLAWorkThr)
MESSAGE_HANDLER(500, OnUserMessage)
END_MSG_MAP()
LRESULT OnUserMessage(UINT uMsg, WPARAM wpar, LPARAM lpar, BOOL& bHandled)
{
Fire_MyEvent();
return 0;
}
public:
STDMETHOD(MyMethod)();
};
#endif //__LAWORKTHR_H_
|
|
|
|
|
I see where you are going with this. Let say you have two threads in your
object (GUI and Worker threads). Your suggestion is to post a message to the
GUI thread then fire the event from the GUI thread. Yes it will work but
can become quite complicate if you have many events. But CoInitializeEx
can do the trick. Again it must be called for in every thread that access your object.
I may write an article how to do this as soon I find the time.
|
|
|
|
|
Hi all,
I recently wrote some code for a company to import contacts into Outlook from an access database. This cannot be done via Import.
My problem is that with the VBA code running at a stupidly slow speed through a macro I decided to use Visual C++ and automate Outlook. It runs much better but I have one problem, how do I add extra user properties to an outlook contact?
The code in VBA is:
Set Prop = c.UserProperties.Add("Yours", olText)
How do you do it in C++ though?
Any help appreciated.
Cheers,
James.
|
|
|
|
|
Hi,
Actually I want to add band objects in my app which hosts Web Browser control. Like IE adds bands objects (to the rebar control), I want to do the same in my app. I have gone thru a lot of topics regarding the band objects and all give ideas about how to develop it but not how to add band objects in my app.
Any help would be highly appreciated.
Thanks,
Perumalla Koteswara Rao, (B.Tech)
Computer Science & Engineering,
Hyderabad, Inida - 500072
|
|
|
|
|
Hi guys.
I have an ATL module with an outgoing dispinterface. I have no problem implementing an sink interface using MFC or ATL.
But now I'm working on a strait C++ project, no MFC and no ATL, where I need to create an sink interface.
Could someone give me some hints on how to implement this? All the information I have been able to find assumes that MFC or ATL is beeing used.
TIA
.Henrik
|
|
|
|
|
Since sink interfaces are dispinterfaces, you will have to implement IDispatch on your object. This also implies you'll have to implement IUnknown, since IDispatch is derived from it. Your version of the Invoke method will basically switch on the dispid of the event, unpack the event parameters from the DISPPARMS struct, and delegate to whatever method you want to be invoked when the event is fired. You will also need code for advising and unadvising the connection point.
So for IUknown, you need an implementation of QueryInterface, AddRef and Release.
For your implementation of IDispatch for the event interface, you can proably take some shortcuts and just implement Invoke, and return E_NOTIMPL from the remaining methods, since the Connection Point would only make use of this method to fire events.
Make sure your object is publicly derived from IDispatch. Your implementation for QueryInterface can then just use a static cast of the this pointer to implement QueryInterface. Look at the ATL code that does this for normal objects for an example.
Good Luck!
|
|
|
|
|
I use ATL COM Appwizard to create ActiveX,
I insert new "full controll" and in the "Stock Properties"
tab I add "Background color" and "Background Style".
when I test ActiveX in "ActiveX control text container"
there were not any propertypage for background color and
background style.
Should I add any code for it?
|
|
|
|