|
1. Well, you can marshal only the COM interfaces, not normal classes. If I understood it correctly - the CBridge is a part of COM A . Then I'll keep the marshaling details inside the CBridge and call the CBridge methods as usual. When there's a need to return pointer to COM B from CBridge , it should be already marshaled.
2. No. The COM subsystem writes everything he needs inside the CoMarshal...
3. The third parameter is a pointer to pointer to the interface you want to unmarshal - this is the result of all the pain - marshaled interface . You have to simply:
IMyInterface* ipInterface = NULL;<br />
CoUnmarshal( stream, RIID, (void**)&ipInterface );<br />
if( ok && ipInterface )<br />
ipInterface->Method();
4. as any other pointer. The process is somehow transparent - the marshaled pointer looks exactly the same, only pointing to diferent object (some internal stuff of COM).
Only I would add, is that if you need behavior marshal once, unmarshal more times, you have to look at the GIT (as someone in thread mentioned). The read from IStream inside CoUnmarshal is destructive and you cannot use the IStream any more.
As the marshaling stuff is quite complicated, don't worry to ask more
|
|
|
|
|
In addition to the geo_m's explanation, check this link[^] in MSDN.
Using the GIT is the easiest method, IMHO.
rechi
|
|
|
|
|
Hello,
I have a web browser control in my dialog and I want to resize the control to fit the html inside.
First of all, is it actually possible to get the size of the document/top frame?
There is only one frame in the document and I'm hoping to read it's height and width properties, but I've been trying to drill down to the Frame but I keep getting an error. I've checked a lot of the newsgroups and I think I'm going through the IE DOM correctly. I'd appreciate any help.
Thanks,
John
IDispatch* spDispatch = NULL;
IHTMLDocument* m_spDoc1 = NULL;
IHTMLDocument2* m_spDoc2 = NULL;
IHTMLFramesCollection2* m_pFrames = NULL;
HRESULT hr = NULL;
spDispatch = m_browser.GetDocument();
spDispatch ->QueryInterface (IID_IHTMLDocument, (void**)&m_spDoc1);
m_spDoc1->QueryInterface(IID_IHTMLDocument2, (void**)&m_spDoc2);
m_spDoc2->get_frames(&m_pFrames);
//the following code was taken from an example
//which iterates through the frames
/ but since my page has just one frame, frameCount returns 0
//and since it is zero based I'm presuming this is correct
LONG framesCount;
m_pFrames->get_length(&framesCount);
for( long i=0; i <= framesCount; i++)
{
VARIANT varIdx;
varIdx.vt=VT_UINT;
VARIANT varResult;
varIdx.lVal=i;
VariantInit(&varResult);
hr = m_pFrames ->item(&varIdx, &varResult);
if (SUCCEEDED(hr)) // always fails here
|
|
|
|
|
Found some code on the newsgroups
Here[^]
|
|
|
|
|
error C2440: 'type cast' : cannot convert from 'const struct _GUID' to 'long'
regards
|
|
|
|
|
can you perhaps supply the code where it goes wrong.
|
|
|
|
|
return GetPredefinedStrings(UUID_BorderConstants , pcaStringsOut, pcaCookiesOut);
it says this on the first parameter..
regards
|
|
|
|
|
Seems to me you are placing a GUID in a long (figures), but the first parameter of GetPredefinedStrings must be a DISPID, which is the id you attach to a method of an interface. Like:
[id(1)] SomeMethod([in]BSTR bstrCrappyString)
the DISPID in this case is 1.
Does this answer your question?
|
|
|
|
|
oops..
exactly..my mistake
Thanks.
|
|
|
|
|
Hi, I have an application with some COM objects. Now I want to expose some of these objects the way excel does.
For example:
<br />
Worksheets("sheet1").Range("A1").value = value<br />
Does anyone know how excel exposes these Sheet objects?
|
|
|
|
|
Derive your interfaces from IDispatch if you want to be automation compatible. In Excel case the interface probably has a method called "Worksheets" which takes a BSTR param and returns a Range object :
IExcelInterface::Worksheets(BSTR sheet) : Range;
The object Range implements an interface IRange, which has a range method :
IRange::Range(BSTR range) : Value;
The value object has a property named "value".
... and so on.
All you need to do is to expose your application object model ( COM object hierarchy ) to the automation clients ( scripts, binaries, etc ).
|
|
|
|
|
Take a look at Using Standard Objects[^] and below. Intend the "Worksheets" instead of "Documents" there.
With best wishes,
Vita
|
|
|
|
|
Thanx! This seems to be really usefull info.
|
|
|
|
|
Hi All,
When I try instantiating a component from within a queued component (c# .net BTW), the component won't instantiate and the message moves to the dead queue.
If I remove the code and just print a message box it works,
If I add the code to another non COM+ project it works fine,
I reckon it's a security thing, I'm getting an unspecified error!!!
Any help would be appreciated.
Thanks,
Cian
|
|
|
|
|
Hi,
I am trying to do drag and drop to explorer with my own IDataObject implementation.
I tried the MFC class COleDataSource at first. It was quite convenient yet not good enough because it does not support IAsyncOperation. That made the main thread freeze during the D&D operation. So I tended to implement IDataObject by myself.
However, none of the samples I found did delayed rendering with IDataObject, neither is there any documentation over that topic. I post the question on MS groups but got no response.
A google search only hit 14 pages. Only 1 out of that 14 pages helped a little
http://www.parsian.ath.cx/books/0-7897-0844-2/ch14.htm
Seems like OLE is using a hidden window to handle the render request. But how do I do the same thing by myself?
Can anybody throw me some light?
Thanks a lot
|
|
|
|
|
;PDear all,
I am developing an application for Windows NT/2000/XP in which I want to create a folder whose size should not exceed 5MB. And should promt for error if data exceeds 5MB
Is there any way to fix size of folder ?
( I know that there is ICopyHook for this but i donot know much about ATL COM)
Please comment!
|
|
|
|
|
Ideally, you would implement ICopyHook in an ATL/COM object and use the callback in conjunction with shell folder notifications. this should work for your application.
|
|
|
|
|
Can you send some sample code for this ??
|
|
|
|
|
I've been getting this error from time to time:
ASP 0177 The component is configured to use synchronization and a thread has timed out waiting to enter the context.
Is anybody familiar with this error message?
Would appreciate any help
Thanx!
|
|
|
|
|
;PDear all,
I am developing an application for Windows NT/2000/XP in which I want to create a folder whose size should not exceed 5MB. And should promt for error if data exceeds 5MB
Is there any way to fix size of folder ?
( I know that there is ICopyHook for this but i donot know much about ATL COM)
Please comment!
|
|
|
|
|
I am new to COM. I have been trying to incorporate the WebBrowser control into an MFC program. I have been using as an example and article from MSDN -http://www.microsoft.com/mind/0798/webbrowser.asp.
In this example VBScript is used. I have been trying to use JavaScript instead. I am unable to change a value with a COM method when I pass a value from Javascript;
IN VBSCRIPT:
sub get_property_value_onclick()
i=window.external.get_propert(property_name.value, value)
if i<>0 then
property_value.value=value
MsgBox property_name.value & " = " & value, 0, "Successfully retrieved property"
else
MsgBox "Cound not find value for property '" & property_name.value & "'", 0 , ""
end if
end sub
In Javascript:
function get_property_value_onclick(namevalue,value)
{
var value = "test";
var i = window.external.get_property(property_name.value,value)
if (i != 0)
{
property_value.value=value;
var strMsg;
strMsg = "Successfully retrieved property:" + property_name.value + " = " + value ;
alert( strMsg);
}
else
{
var strMsg;
strMsg = "Could not retrieve" + property_name.value + " = " + value ;
alert( strMsg);
}
}
The COM Method:
HRESULT my_application::get_property(LCID lcid,
WORD wFlags,
DISPPARAMS* pdispparams,
VARIANT* pvarResult,
EXCEPINFO* pexcepinfo,
UINT* puArgErr)
{
if (wFlags & DISPATCH_METHOD)
{
if (pdispparams->cArgs!=2)
{
return DISP_E_BADPARAMCOUNT;
}
// force to string
VARIANT arg1;
VariantInit(&arg1);
HRESULT hr=VariantChangeType(&arg1,
&pdispparams->rgvarg[1],
0,
VT_BSTR);
if (FAILED(hr))
{
*puArgErr=1;
return hr;
}
string str;
com_util::bstr2string(arg1.bstrVal,str);
// try to find element
string2variant_map::iterator it=propertymap.find(str);
if (it==propertymap.end())
{
if (pvarResult)
{
V_VT(pvarResult) =VT_BOOL;
V_BOOL(pvarResult)=FALSE;
return S_OK;
}
if (!pexcepinfo)
{
return E_INVALIDARG;
}
// raise exception
memset(pexcepinfo,0,sizeof(EXCEPINFO));
pexcepinfo->wCode =1001;
pexcepinfo->bstrSource =SysAllocString(L"WebBrowser Demo");
pexcepinfo->bstrDescription =SysAllocString(L"No entry for the key");
return DISP_E_EXCEPTION;
}
hr = VariantCopy(pdispparams->rgvarg[0].pvarVal,&(*it).second);
if (pvarResult)
{
V_VT(pvarResult) =VT_BOOL;
V_BOOL(pvarResult)=TRUE;
}
return S_OK;
}
return DISP_E_MEMBERNOTFOUND;
}
The function VariantCopy(pdispparams->rgvarg[0].pvarVal,&(*it).second);
returns a bad varibale HRESULT. Bu tit works OK in VBSCRIPT. Any idea on how to solve this?
thanks,
RAM_MR
|
|
|
|
|
I have an MFC application with an atl object. Now I want to know if a user started the application or if the application was started by the scum, so I can (amongst others) deside whether to show or hide the windows of the application. Anyone knows how to do this ?
|
|
|
|
|
Never mind, I already found what I was looking for: AfxOleGetUserCtrl().
|
|
|
|
|
Hi, I need to create a new Activex control by sub classing another Activex control. This will retain all the old functionality plus some other functions can also be added, i have tried doing it through the MFC ATL wizard, but that only create a wrapper araound it. Also MFC's ActiveX control wizard does seem to support sub classing of some MS standard controls only.
if you have a way to acheive this then please do help.
Mayank Goyal
|
|
|
|
|
Hi, I have an MFC application on which I want to put a COM interface so other applications can interface with my application. I succeeded in doing this, but now I have several object that can be created from outside my application. What I want is to provide a single object that creates the other objects. Can (and if so, how?) I shield these objects so they can not be created from outside my own application ?
|
|
|
|