|
Can you post some of the problematic code? Usually that error happens when you try to use use new to create an ATL class, which is the wrong way to do it, but you said you're using CreateInstance.
Does the class have a BEGIN_COM_MAP()/END_COM_MAP() section?
--Mike--
http://home.inreach.com/mdunn/
your with and
|
|
|
|
|
Sound similar to an error I have made when initially typing code.
Many times I do not declare the pointer to the COM object as a pointer and it gives the error you state.
THis is correct:
IXMLDOMDocument *pXML = NULL;
hr = CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER,
IID_IXMLDOMDocument2, (void**)&pXML); // Check the return value, hr...
ASSERT(SUCCEEDED(hr) && pXML!=NULL);
This is not:
IXMLDOMDocument pXML = NULL; << this line produces the error not the next!
hr = CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER,
IID_IXMLDOMDocument2, (void**)&pXML); // Check the return value, hr...
ASSERT(SUCCEEDED(hr) && pXML!=NULL);
Michael A Barnhart
mabtech@swbell.net
|
|
|
|
|
Thank you sir.
And I would like to thank everybody tried to help me. The problem is that I was trying to use the COM component as a smart pointers, but there were not.
Thank you all again.
Shadi Al-Kahwaji
|
|
|
|
|
[client]->[com]->[DLL] function calls
[DLL]->[com] window message
[com]->[client] function retvals and events
I have a com object where i load a DLL,
i want to recive windows message to the com from the dll
is that possible?
Christer
|
|
|
|
|
wasn't my answer adequate enough?
Norm Almond
Chief Technical Architect
FS Walker Hughes Limited
|
|
|
|
|
Sorry im new to this side so i could`t find the page.
Christer
|
|
|
|
|
Has anyone here ever seen this error.
"fatal error C1084: Cannot read type library file: 'TLBs\astm.tlb': Error loading type library/DLL."
I really have no idea what is going on. I get that when doing a regual #import statement. We designed the TLB. The tlb file was just compiled with no errors. It isn't a sharing violation since i made a complete copy of the file just for use in this application. The TLB file comes from a ATL/COM project. If anyone has seen this and knows whats going on please help. I have tried everything i can think of. There doesn't seem to be much of anything on the internet about it and there is NOTHING of MSDN about it.
Any help is greatly appreciated.
Joseph Dempsey
jdempsey@cox.rr.com
Joseph.Dempsey@thermobio.com
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."
--anonymous
|
|
|
|
|
try by importing it from your com dll or exe modules, as these also contain the type library ?
i.e. #import "astm.dll"
|
|
|
|
|
I already have the IDispatch pointer of an ActiveX control. Can someone tell me how to get the following information from my code?
1. The type of a property, given the dispid of the property.
2. The type of the return value and the types of parameters of a method, given the dispid of the method .
I need specific information/suggestion, instead of book names or URLs. Thanks.
|
|
|
|
|
You can get just about any sort of information you could possibly want about a dispatch interface through its ITypeInfo interface. Call IDispatch::GetTypeInfoCount to verify that the object supports the ITypeInfo interface (1 if it does, 0 otherwise), then call IDispatch::GetTypeInfo to get the ITypeInfo interface. Take a look at ITypeInfo::GetFuncDesc to get info about the parameters and return type of a function member of an IDispatch interface (given its id), and ITypeInfo::GetVarDesc to get info about a variable member of an IDispatch interface, including its type (given its id).
|
|
|
|
|
Thanks. But which field of the returned structures (FUNCDESC, VARDESC, ELEMDESC, PARAMDESC, etc.) is the type?
|
|
|
|
|
Well, properties are actually function calls in dispatch interfaces. Variables would be things like the symbolic constants of an enum declaration. It's a little bit messy, but once you've got the ITypeInfo for an interface, you can iterate through the functions of the interface like this:
// First off, get the type attributes
TYPEATTR* pTypeAttr = NULL;
FUNCDESC* pFuncDesc = NULL;
pTypeInfo->GetTypeAttr(&pTypeAttr); // Should be dispatch
// Now you can iterate the functions in the interface
for(int j=0; j < pTypeAttr->cFuncs; j++)
{
pTypeInfo->GetFuncDesc(j, &pFuncDesc);
printf("\ncParams = %i", pFuncDesc->cParams);
printf("\ncParamsOpt = %i", pFuncDesc->cParamsOpt);
// The type of function invokation
switch(pFuncDesc->invkind)
{
// A "normal" function
case INVOKE_FUNC: printf("\ninvkind = INVOKE_FUNC"); break;
// A property
case INVOKE_PROPERTYGET: printf("\ninvkind = INVOKE_PROPERTYGET"); break;
case INVOKE_PROPERTYPUT: printf("\ninvkind = INVOKE_PROPERTYPUT"); break;
case INVOKE_PROPERTYPUTREF: printf("\ninvkind = INVOKE_PROPERTYPUTREF"); break;
}
// The return type of the function
switch(pFuncDesc->elemdescFunc.tdesc.vt)
{
case VT_EMPTY: printf("\nelemdescFunc.tdesc.vt = VT_EMPTY // Not specified."); break;
case VT_NULL: printf("\nelemdescFunc.tdesc.vt = VT_NULL // SQL-style Null."); break;
case VT_I2: printf("\nelemdescFunc.tdesc.vt = VT_I2 // 2-byte signed int."); break;
case VT_I4: printf("\nelemdescFunc.tdesc.vt = VT_I4 // 4-byte-signed int."); break;
case VT_R4: printf("\nelemdescFunc.tdesc.vt = VT_R4 // 4-byte real."); break;
case VT_R8: printf("\nelemdescFunc.tdesc.vt = VT_R8 // 8-byte real."); break;
<etc...>
}
// Parameter types of a function
// Parameter type of a function
k = 0;
while(k < pFuncDesc->cParams)
{
vt = (VARENUM)pFuncDesc->lprgelemdescParam[k].tdesc.vt;
k++;
}
pTypeInfo->ReleaseFuncDesc(pFuncDesc);
}
pTypeInfo->ReleaseTypeAttr(pTypeAttr);
The "return type" will be the type of the property in question. The FUNCDESC will contain a memid, use this to identify the function/property in question as it is defined in the interface. More than one function may map to a given memid, for instance, a propertyput and a propertyget would map to a single property on an interface, bu will nevertheless show up twice when iterating the functions through the ITypeInfo interface. If all you want is the type of each property, you could create a map<long, varenum=""> and fill it up while traversing the functions of the interface. Then, later:
long memid;
VARENUM vt = return_types[memid];
Or something similar. Unfortunately, the type info mechanism doesn't give you a way to get info for a given member id, so you have to iterate through all of them for a given interface and make your own map. The array FUNCDESC::lprgelemdescParam should have the parameter types accepted by the function.
|
|
|
|
|
|
I try to use gdi+ lib in my atl projects. but when i did it, i found that the function gdiplusshutdown is always failed when i want to exit the program. how can i do it?
|
|
|
|
|
hello gurus,
How do i set the homepage in IE? i would also like to display my own error pages and expedite search. Is this possible? Pl. send me any useful links to articles etc. I'm using VC.
TIA.
I'm an alien, I'm an alien
it's a beautiful life....
Bush
|
|
|
|
|
Well setting the default homepage is simple enough. I just add the relevant registry entries.But what about displaying custom error pages? Do I actually have to write a psuedo proxy of somesort?
I'm an alien, I'm an alien
it's a beautiful life....
Bush
|
|
|
|
|
Hello, everybody.
I've got the ActiveX that runs in IE (look at http://www.sochi.ru/confa/stone/defaulte.asp if interested).
Now if I even upload a newer version of ActiveX, IE doesn't detect that and runs an old version from its cache. How can I enable IE to automatically detect and nownload new versions?
|
|
|
|
|
Hi, I'm a begginner with activeX, but I'm not so bad whit MFC. For now I have a good book to learn ActiveX, but I'm unable to insert any of them in a CView...
So the first step was to learn: ActiveX, make you're own and know how it work
but I'm searching: ActiveX --> the next step how to create it in you're MFC document/view application dynamicaly
by the way my activeX is a control, so It must be displayed
thanks
Remi Morin
Rmorin@Operamail.com
Remi.Morin@Lyrtech.com
|
|
|
|
|
Hi to Myself,
it look like anybody is able to answer me so I will (because I've find) so
To create a ActiveX in a CView (just to create it to make it work properly... maybe later)
First add a CWnd member in you'r class
class MyView : public CView
{
CWnd m_ActiveXControl;
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD
afx_msg void OnSize(UINT nType, int cx, int cy);
DECLARE_MESSAGE_MAP()
};
then in the create function you must create you'r activeX control. The CWnd is the wrapper for you'r active X so you do that way :
BOOL CTestViewAsAContainerView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
BOOL Ok;
dwStyle |= WS_CLIPCHILDREN;
Ok = CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
Ok &= m_ControlWrapper.CreateControl("MYACTIVEX.MyActiveXCtrl.1",
"",
WS_VISIBLE,
CRect(0,0,100,100),
this,
5000,
NULL,
FALSE,
NULL);
return Ok;
}
then the on_size to size if
void CTestViewAsAContainerView::OnSize(UINT nType, int cx, int cy)
{
CRect r;
CView::OnSize(nType, cx, cy);
GetClientRect(&r);
if(!r.IsRectEmpty())
{
m_ControlWrapper.MoveWindow(&r);
}
}
so that it's
thanks to myself
hehehehe,
Remi Morin
Rmorin@Operamail.com
Remi.Morin@Lyrtech.com
|
|
|
|
|
Hi
I have developed some GUI controls using ATL/COM for Windows CE. (eg Enhanced Edit control).
Each control has an IDispatch interface for properties (Eg IEnhancedEdit).
It also has a corresponding dispinterface for Events. (eg _IEnhancedEditEvents)
I also have some interfaces derived from IUnknown, but they are in the background as far as users are concerned.
My customers will use this control under VB.
My question is:
How do I go about adding new properties, methods, events without the user having to recreate the control from scratch. That is how can I upgrade existing controls with minimum user angst?
My understanding is that there exists an 'interface contract', that once specified, cannot be broken.
What are my options?
TIA
Andrew McGrath
lost, somewhere in Germany....
|
|
|
|
|
Yes there is a contract specified by the COM rules that once you publish an interface it can't change (or at least are not supposed to). If you need to upgrade, add new feaures (bugs);) then you need to create another interface and publish it.
IInterfaceOne : IUnknown
IInterfaceTwo : IInterfaceOne
|
|
|
|
|
The basic rule of COM says, In COM, once you "publish" an interface contract by shipping a component, the contract is immutable—it cannot be changed in any way. You can not add. You can not delete. You can not modify.
But, when you open Microsoft Word 97/98 and Microsoft Word 2000 's .OLB files, you will see that for extending the interfaces, they have added methods to the old interfaces. For example, in MS Word 2000 they have added methods in Application interface, and all the other interfaces. Why So? I feel the right approach is to add new interface if you want to extend an interface. Can somebody tell me its' reason??
|
|
|
|
|
I have been reading through Essential COM by Don Box and I found the Win API calls CoGetTreatAsClass and CoTreatAsClass which effectively allow you to add to the original interface by in fact using a second newer interface.
I am not sure if this is what has occurred with the MS Office OLBs but it appears to be a way to achieve the equivalent.
Andrew McGrath
lost, somewhere in Germany....
|
|
|
|
|
Your information was useful. Thanks.
I read Don Box as well. Can you tell me from where can I get more details about class emulation, and how to implement it?
|
|
|
|
|
Hi,
I am developing activeX control in VC++.
My control is built with usage of two other OCX files so I pack three OCX files and INF file in one single CAB file.
It is being placed on the web page with CODEBASE tag and class id of my control.
It works fine but I need to get USER_LOGON to verify user's permissions to access database (this is INTRANET application)
to get user login I am using VBScript:
<%
full_user_id = Request.ServerVariables ("LOGON_USER")
Response.Write full_user_id
i=InStrRev(full_user_id,"\",-1,vbTextCompare)
if i>0 then
user_login = Right(full_user_id,len(full_user_id)-i)
else
user_login = full_user_id
end if
%>
and i get the proper string in 'user_login'
the question is - how can I pass this user_login variable to my C++ code ?
i would guess by setting :
<param name="web_user_name" value="<%" response.write="" user_login="" %="" />>
Am I on the right track ? Does anyone know how to pass USER_LOGON variable from the html page to activex control's code (VC++) ?
thank you
|
|
|
|
|