|
I have a COM object that implements a connection point to fire events. I also have a worker thread that does some task. I pass the thread the pointer of the class that creates the thread, so that it can do calls back into the object. Some of the calls should fire events, but they don't. I'm not sure why....or how to get it to work...ANY ideas?
D.
|
|
|
|
|
Hi,
Events are signaled by calling the Invoke method of an IDispatch interface supplied by container. The interface lives in the apartment of its own thread, which is also the one containing the control itself. To comply with the STA model, we can only safely call this interface's methods from the thread in which it was created. If the control wants to signal an event from a different thread it must Marshal the IDispatch interface into the IStream first and then UnMarshal it. And of course it must call CoInitialize() too.
To Marshal/UnMarshal interface pointers you can use my favorite functions: CoMarshalInterThreadInterfaceInStream(...) and CoGetInterfaceAndReleaseStream(...).
Regards,
Alex Gorev,
Dundas Software.
|
|
|
|
|
Hi,
I want to get the handle of edit box in IE COM..
The edit box that is dynamically created in IE by
tags..
I am not sure that it is a window.
Cause I failed to hook the handle of it in Spy++..
Is that a window?
If it is, how can i get the handle of it?
Any suggestion will be appreciated...
Thanks in advance..
Regardz
-Ray
|
|
|
|
|
how can i call back the errors that i saved in the log file
i need some function to call up the errors and view in textbox or something.
can you help me.
regards
|
|
|
|
|
How can i open and view error.log file ??????
|
|
|
|
|
How to read from an existing excel File from C++/COM.
I am not able to use the existing article to alter it to reading from an existing excel File - reference Article;- MSDN Q192348 & Q216686. This uses automation.
or how to use ADO to read the excel file. Any example if possible would be a greater help.
|
|
|
|
|
How can i make an com object in vb6, that i can use to take text or number or
text and number an save them to file in my hard drive?????
|
|
|
|
|
Hi,
I don't get what exactly the problem is...
Creating a COM object in VB6...? Passing parameters to the method...? Saving data into the file...? Or all of the above?
Can you provide more information on the problem...
Regards,
Alex Gorev,
Dundas Software.
|
|
|
|
|
i'l need to make an com object to handle errors in my softwear like if i get error then i like to do
on error goto saveError and in my com Object i like to say if errornumber <1000 then save errornumber or text or text and number else resume next
|
|
|
|
|
Im developing a Name Space Extension and I found some examples about draging and droping files into the explorer. I did like the examples said, but for I reason I don´t know, the drop works on other explorer different from the one I´m debugging, even droping on the Desktop works. But it doesnt work droping on the three in the same explorer I´m debugging.
Does anyone have any idea why this happens?
|
|
|
|
|
Hi,
Here is the question : I develop a COM component using ATL . In this component I have a method called "BeepMe", from where I want to return a BSTR message , as an out parameter :
BeepMe ([out] BSTR* pbstrMessage)
when I call it from an ASP page (written in Jscript):
var strRet;
Component.BeepMe(strRet);
the strRet is empty .
but, if I declare the pbstrMessage as retval ( BeeepMe([out,retval] BSTR* pbstrMessage) ) , and write :
var strRet = Component.BeepMe();
everithing works fine . The pbstrMessage is propertly initialized in the method ( *pbstrMessage = ::SysAllocString(L"Beep") ), so that isn't the problem.
I know that the VB script interpreter handle the deallocation of memory , and I suppose that is also the ASP case . That is the cause of this behavior ? ( the ASP interpreter free the memory of the returned value ? )
|
|
|
|
|
Hi,
First of all you should use the SysReAllocString instead of SysAllocString. It's not the source of the problem but it's a correct way of doing things. Before assigning a new value to the pointer you must free the data it's pointing to.
STDMETHODIMP CTest::get_Path(BSTR *pVal)
{
if(pVal == NULL)
return E_POINTER;
if(!SysReAllocString(pVal, m_bstrPath))
return E_OUTOFMEMORY;
return S_OK;
}
Your problem is that in VBScript and JScript cannot pass parameters by reference to automation properties or methods. Use return values of properties and methods to return a value instead of using byref parameters for this purpose. This approach limits you to one return value.
Regards,
Alex Gorev,
Dundas Software.
|
|
|
|
|
Hi
I have created a c++ dll which works great in excel 2000, as I launch it as a com add-in, and get access to the IDispatch of the calling instance of excel via OnConnection (IDTExtensibility2).
I would like to be able to launch the dll from excel 97, via an xla (or xll), which is not a problem, but I do not know how to get the IDispatch of the instance of excel that has the xla (or xll) running.
(Excel.Application is no good, as it only finds the first instance of Excel.)
If anyone knows the answer, please let me know
Thanks!
|
|
|
|
|
Hi
I have worked out how to do it from an xla , but if anyone knows how to do the same in an xll please let me know.
From Auto_Open() sub of xla, pass Application to function in DLL
i.e.
in XLA
!declaration of function in DLL
Private Declare Function InitExcel97 Lib "MyDLL.dll" (ByVal app As Object) As Long
Public Sub Auto_Open()
Result = InitExcel97(Application)
…
End Sub
in DLL
extern "C" __declspec( dllexport ) LONG WINAPI InitExcel97(LPDISPATCH Application)
{
long result;
g_pApplication = Application; //global declaration IDispatch* g_pApplication;
theApp.InitializeExcel(); //calls same code as if launched by com addin in Excel2000
….
return result;
}
|
|
|
|
|
Reference Article;- MSDN Q192348 & Q216686. This uses automation.
Regards,
K M Bansal <iclassfactory2@usa.net>
|
|
|
|
|
Hi,
Those examples do not relate to my question, for each example creates its own instance of excel, which it then uses. I want to attach to an existing instance, and using AttachDispatch with Excel.Application, is no solution as it will only find the first instance of excel.
As I mentioned in my prior message, it is easy from a xla, but I would still be curious how to find the correct IDistatch from an xll (or any c++ written application).
For your information, a much better method than proposed in Q192348 is Q186427.
The closest MSDN example to my problem is found in Q190985, but there, Excel is running as a container.
Regards
Leo
|
|
|
|
|
I have dll with two objects. One is CommBand and another is Browser Helper Object. How can i get pointer on my BHO object from my CommBand object ?
|
|
|
|
|
Hi,
The instance of the Browser Helper Object is created each time Internet Explorer starts. You can create an instance of the CommBand object while creating BHO object and then set the internal pointer.
You can also create singleton component, which will be holding the list of the interface pointers to all BHO objects. Each time the BHO object is created it adds the interface pointer to the table. You can also save any additional information you like. Then you can easily access all available interfaces.
Regards,
Alex Gorev,
Dundas Software.
|
|
|
|
|
Hello!! how can i use void pointers in a parameter in a funcion of COM class??
I try this:
..........MyFuncion([out,retval] void * pResult)
and when i compile it CRASHHHHHHHH!!!!!!!!!
please help me...
my email is jsanchez@cie.com.mx
|
|
|
|
|
Hi,
The problem with any kind of pointers is that you can't return or pass it without marshaling the data it points to. If you are using the pointer to the well-known types, such as Long, BSTR, ... the default marshaling can be used. If you use an array of objects or void pointer you must provide additional information for marshalling. Have a look at the length_is() and other array related attributes of the IDL file. You also can return an array of data using a variant with SAFEARRAY. This is the best thing you can do if you are going to use the component in VB.
Regards,
Alex Gorev,
Dundas Software.
|
|
|
|
|
Hi Jafet,
There are several techniques you can use and returning the VOID pointer is not one of them. There is a VERY nice article by Don Box in MSDN explaining your options and advantages/disadvantages.
The name of the article is "OLE Q&A". There are several articles with this name and I add the beginning of the article, so it will be easier to find.
Regards,
Alex Gorev,
Dundas Software.
------------------------------------------------------
"
OLE Q&A
Don Box
Don Box has been working in networking and distributed object systems since 1989. He is currently chronicling the COM lifestyle in book form for Addison Wesley, and gives seminars on OLE and COM across the globe. Don can be reached at dbox@braintrust.com.
QI am using dual interfaces to expose my objects to both C++ and Visual BasicТ clients. Designing the interfaces was relatively painless once I passed simple data types as method parameters. I now need to pass user-defined structures as parameters and can't get it to work. Any suggestions?
....
" -- MSDN.
------------------------------------------------------
----- Original Message -----
From: Jafet Sanchez Rodriguez <jsanchez@cie.com.mx>
To: <alexg@dundas.com>
Sent: Tuesday, July 04, 2000 11:42 AM
Subject: Re: [CodeProject] Re: void* in a parameter in COM function
> Hi Alex!!
> I want to pass a struct from vc to vb ..
>
> struct A
> {
> int a;
> int b;
> float c;
> }
>
> MYSTRUCT A;
>
|
|
|
|
|
guy's please help me with this one as i am new to COM
|
|
|
|
|
I use it:
BSTR sMyBSTR;
sMyBSTR = "Hola que onda!";
CComBSTR sCad;
sCad.Append(sMyBSTR);
|
|
|
|
|
Hi,
Variants store the strings as BSTRs. You can work with BSTR strings using the standard string functions if you convert it using the OLE2A(...) macro.
USES_CONVERSION;
char *p = strstr(OLE2A(m_bstrData), "Data=");
If you have a lot of string operations I recommend you to use the WTL's CString class. It's a light weight template, which duplicate the functionality of the popular MFC's string class.
Regards,
Alex Gorev,
Dundas Software.
|
|
|
|
|
How to add a custom color property entry in PROP_DATA_ENTRY macro - what should be the vt value?
|
|
|
|