|
IDL has forward declaration of interface, just like C/C++ has forward declarations, viz:
import "oaidl.idl";
import "ocidl.idl";
[
uuid(D39DD965-FC96-4C0A-AA62-CA3F5F117685),
version(1.0),
helpstring("cccc 1.0 Type Library")
]
library ccccLib
{
interface ITest2;
[
object,
uuid(7CD26371-4A6B-4234-A024-6690A53CA450),
nonextensible,
helpstring("Itest Interface"),
pointer_default(unique)
]
interface Itest : IUnknown
{
HRESULT DoSomething([in] ITest2* c);
};
[
object,
uuid(72a5a7e2-0256-428f-8bb5-42d39096892d),
nonextensible,
helpstring("Itest Interface"),
pointer_default(unique)
]
interface ITest2 : IUnknown
{
HRESULT DoSomething([in]Itest* c);
};
importlib("stdole2.tlb");
[
uuid(F8AAE058-76E9-4F2C-995A-FB5B6565CED6),
helpstring("test Class")
]
coclass test
{
[default] interface Itest;
interface ITest2;
};
}; Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
Thanks for your reply. I have tried this method but fail, because i always use the right idl files generated by atl project wizards, and i failed because i spelt 'Interface IB' other than 'interface IB'.(VS also highlights 'Interface' and 'interface'!).
Regards.
|
|
|
|
|
Hi,
Can I get any sample of how to write a COM component which should be accessible from JScript.
Actually , I am able to write a normal COM (InProc) component and able to invoke from other c++ client. But while trying the same from JScript , unable to invoke it.
I am getting error like automation server cannot create object etc.
Thx,
--Gopi
|
|
|
|
|
COM-component must be inherited from IDispatch
|
|
|
|
|
As mentioned by cariolihome only interface inherited from IDispatch can be access by scripting clients. Additionally, only the default interface marked in the IDL using the [default] attribute inside coclass can be accessed by scripting clients.
|
|
|
|
|
I have a class called CReportEditCtrl derived from CRichEditCtrl which allows me to programmatically insert an embedded object (OLE mini-server) into the document. This is based on code here:
A Rich Edit Control That Displays Bitmaps and Other OLE Objects[^]
Embedding is simple enough:
CComPtr<IRichEditOle> pIRichEditOle = GetIRichEditOle();
CLSID classId;
HRESULT hr = ::CLSIDFromProgID(L"EmbeddedLink.Document", &classId);
if (hr == S_OK)
{
// Get the OLE client site from the container
CComPtr<IOleClientSite> pIOleClientSite;
hr = pIRichEditOle->GetClientSite(&pIOleClientSite);
if (hr != S_OK)
{
return(false);
}
// Get storage from the container
CComPtr<IStorage> pIStorage;
hr = m_pIRichEditOleCallback->GetNewStorage(&pIStorage);
if (hr != S_OK)
{
return(false);
}
// Create an OLE object i.e. the embedded item
CComPtr<IOleObject> pIOleObject;
hr = ::OleCreate(
classId,
IID_IOleObject,
OLERENDER_DRAW,
NULL,
pIOleClientSite,
pIStorage,
(void**)&pIOleObject);
if (hr != S_OK)
{
return(false);
}
CDataObject *pDataObject = new CDataObject;
pDataObject->AddRef();
pDataObject->Populate(strText);
hr = pIOleObject->InitFromData(pDataObject, 0, 0);
pDataObject->Release();
if (hr != S_OK)
{
return(false);
}
REOBJECT reObject;
memset(&reObject, 0, sizeof(reObject));
reObject.cbStruct = sizeof(reObject);
reObject.cp = CharFromPos(point);
reObject.clsid = classId;
reObject.poleobj = pIOleObject;
reObject.polesite = pIOleClientSite;
reObject.pstg = pIStorage;
reObject.dvaspect = DVASPECT_CONTENT;
reObject.dwFlags = REO_INPLACEACTIVE|REO_DYNAMICSIZE;
hr = pIRichEditOle->InsertObject(&reObject);
m_arrayIOleObject.insert(m_arrayIOleObject.end(), pIOleObject.Detach());
}
When I stream out the RTF, it looks great, with embedded objects as expected. When I stream the RTF into a new object of the CReportEditCtrl class, the objects are displayed in the new control, but when I look at process explorer, the mini-server is not running. When I stream out the RTF, each embeddeded object has gone, and has been replaced by its metafile, allowing it to be drawn, but all knowledge of the object has gone. What it going on? It looks as if the CRichEditCtrl instance has not loaded the embedded obejcts when the RTF data was streamed in. I thought the CRichEditCtrl was supposed to handle loading RTF containing embedded objects?
Incidentally, I get the same result with only one CReportEditCtrl instance if I stream out the RTF, stream it back in, and then stream it out again. The embedded objects are lost.
Help appreciated.
|
|
|
|
|
Using the example program:
A Rich Edit Control That Displays Bitmaps and Other OLE Objects
I modified the code so that immediately after streaming data from the RTF file into the rich edit control, it streamed it out from the rich edit control into a second file. The output RTF file is not the same as the original. The embedded Windows Media File object is present in the output file. The other embedded objects are not present, and instead there is a metafile in place of each.
Anyone any idea why some objects streamed out into the RTF file are present only as metafiles?
[Added later]
Okay, I have solved the problem in this post, if not the main problem. The example code contains an RTF with 4 embedded objects including one GIF. Of the non GIF objects, only one corresponds to an OLE server that is registered on my PC. So it seems that if the rich edit control is fed objects for OLE servers which are not registered, it discard all but the metafile so they can be drawn, but nothing more.modified on Saturday, February 27, 2010 7:55 AM
|
|
|
|
|
Never mind. I found a far simpler solution was to represent a link as protected text, ensuring the user could not edit it, but could see the link as simple text. Unfortunately using OLE objects would have meant one application running per link, which is inefficient and, well not good.
|
|
|
|
|
Hi All.
I develope an addon based on MotleyFool; example. User must do login to that, for using its functionality. In IE 8 when adding new tab or opening new IE window, new login is need. This occures beacause new instance of this addon creates.
How I can share any instance between multiple tab or multiple IE win?
Excuse me for weakness of my language.
thanks a'lot.
|
|
|
|
|
use some global object or file mapping object (security issue set it to low) Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
You can use Mutex to check the instance of your addon. After the first time authentication save the status to authenticated in an INI file or in Registry. Check the mutex in each tab for get the status(Any instance is there) of your addon. If your addon is running then check the Authentication status. if authenticated from one of the tabs then login directly without user inputs.
I hope it will help you to over come the existing problem
Good Luck
|
|
|
|
|
How to manage global memory in com ??
|
|
|
|
|
Your question is not very clear, can you explain more of what you are trying to achieve? txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Code it yourself. Allocate in the first instance release it in the last instance.
your question implies that you need a lot of larning. Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Hi Guys,
Good Morning/Evening,
i want to know few basic stuff related com+
1)if a Machine is having COM registerd...how a remote machine can access them who knows only Component name and functions.
2)who is taking care of global memory allocation and deallocation.
3)what is the use tlb file.
Thanksvikas da
|
|
|
|
|
This[^] would be a good place to start. Also you could take a look at some of the articles on COM here on CodeProject. txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Hi all. Show me, please, how to handle this event, to the link opened in same window.
In msdn says that must be replaced by a pointer to IDispatch, but it does not work.
VARIANT * v = &pDispParams->rgvarg[1];
if (v->vt == (VT_BYREF | VT_VARIANT)) v = v->pvarVal;
IDispatch* *pdisp = 0;
if ((v->vt & VT_TYPEMASK) == VT_DISPATCH){
pdisp = (v->vt & VT_BYREF) ? v->ppdispVal : & (v->pdispVal);
if (pdisp[0] != NULL){
pdisp[0]->Release();
}
g_pSite->get_Application(pdisp);
}
Values that come - commented out. What am I doing wrong? Why not this work? How can I solve this problem?
In handler DISPID_NEWWINDOW3 event comes value URL of the new windows, but don't comes other values needed for navigate2, therefore, this solution does not suit me.
Sorry for my english. 
|
|
|
|
|
It's me. I asked the question correctly?
|
|
|
|
|
Hello!Please suggest me COM objects to make a screenshots!I want to use it in my .Net application!
|
|
|
|
|
You can capture the screen using the API call CreateDC(_T("DISPLAY"), 0, 0, 0);
You can create a COM component yourself and put this call in it.
Here is some code that captures the screen for .Net applications - Capture a Screen Shot[^]
|
|
|
|
|
Ok!I'll try it!But here anothere question bubbles up : is it a way to use my COM object in my Silverlight application(will it rise Security exceptions)?
p.s. Thx for quick answer on my previous question 
|
|
|
|
|
Hello all,
I have made an ocx . It includes the Winsock and the Timer controls . But the problem is that when I try to use the ocx in the application on some other computer the application gives error about the using the correct version of the OCX. Now when I place the ".ctl" file along with the ocx , it works fine . Now It is really annoying as i have to install complete visual basic setup on the client PC so that ".ctl" file works with ocx as app does not run only on vb runtime. Please suggest the solution.
|
|
|
|
|
I remember when using VB6 it had a thing about increasing the version number at the slightest opportunity. Maybe this is the same problem? I seem to remember an option in the object to stick with a particular version, pointing the settings at a Version Compatible Component to make this happen comes to mind.
|
|
|
|
|
Hi Guys,
I have been asked a question during a presentation like how can we access a COM comonent from some other box that is not having registry info for the COM.
please help me here
Thanksvikas da
|
|
|
|
|
you should have a look at the RPC invocation methods.
|
|
|
|