|
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
|
|
|
|
|
How do I change the initial size of the AX(COleControl) in the VC++ (or VB) resource editor when it's first time dropped onto the form/dialog?
GetViewExtent or GetNaturalExtent doesn't seem to be called...
|
|
|
|
|
First client creates an instance of a remote COM object via CoCreateInstanceEx, then calls one of its method remotely. In that method, assume Checker(), some information of the client is checked to see if he has the right to access things on Server further. If OK, the Checker() will create an instance of another COM object named CoreServer, and transfer the pointer to one of its Interface back to Client. How can I finish the procedure with DCOM library? I think there maybe 3 ways for the Checker() to create and transfer:
1.CoCreateInstance
2.CoCreateInstanceEX
3.Moniker
but no way seems work
please help me, thanks.
|
|
|
|
|
Hi,
I'm a VB programmer who is trying to convert an old C console application to a C++ ATL COM DLL for use with a VB GUI.
My code basically allows the client to set a filename and then call a function which launches a private function in a seperate thread and returns immediately.
My private function then trundles along, raising events to inform the client of it's progress along the way.
All sounds good so far, unfortunately my code doesn't work, all my properties, methods, variables and so on were created by wizards.
Here is my implementation file (Asynch.cpp):
#include "stdafx.h"
#include "AsynchEg.h"
#include "Asynch.h"
// Required for _beginthread and _endthread - do not remove
#include "process.h"
#include "comdef.h"
STDMETHODIMP CAsynch::RequestNewThread()
{
// Begin a new thread and start the _NewThread function
_beginthread(_NewThread, 0, (void*)(this));
return S_OK;
}
void CAsynch::_NewThread(void* pCaller)
{
FILE *file;
BSTR wfilename;
char nfilename[256];
LPSTR filename;
// Cast the passed void pointer to a CAsynch object
CAsynch* pAsynch = (CAsynch*) pCaller;
// Convert the FileName property to a character array for use in fopen
pAsynch->get_FileName(&wfilename);
WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, wfilename, -1, nfilename, sizeof nfilename
, NULL, NULL);
filename = nfilename;
// Open the file
if((file = fopen(filename, "rb")) == 0)
{
// TODO: Raise error
}
else
{
// Close the file
fclose(file);
// Tell the calling object to raise it's ThreadDone event
pAsynch->Fire_ThreadDone();
}
// End this thread
_endthread();
}
// Returns the FileName property
STDMETHODIMP CAsynch::get_FileName(BSTR *pVal)
{
// Populate the pointer with the private variable
*pVal = m_FileName;
return S_OK;
}
// Sets the FileName property
STDMETHODIMP CAsynch::put_FileName(BSTR newVal)
{
// Copy the new value to the private variable
_bstr_t NewBSTR;
NewBSTR.Assign(newVal);
m_FileName = NewBSTR.copy();
return S_OK;
}
If I run my VB exe then I get a memory exception.
If I run the C++ end in debug then I get an access violation on the Invoke line of the Fire_ThreadDone function.
If I run VB in debug mode my code works and my event is raised.
What is going on?
If you need a copy of my projects (VC++6 and VB6) then mail me and I'll send you a copy.
Also, can anyone tell me how to raise run time errors to my VB client?
Any consttuctive criticism / advice is greatly appreciated.
Best Regards,
Rob Brown
|
|
|
|
|
I'm a VB programmer who is trying to convert an old C console application to a C++ ATL COM DLL for use with a VB GUI.
Good luck, you'll need
I've done async multithreaded programming in VB, and believe me: it's ugly, and for seasoned C++ COM programmers. MS says: "VB clients are monothreaded."
Well, you'll face 2 main problems, and I would start learning this topics to acomplish this:
- Building a message loop.
- Synchronizing Win32 objects: Events
- marshalling interface pointers between threads
If you fail to use them, your code will hang, or your code will cause a GPF.
Tip: You'll need another thread that creates the object and stay forever in a message pump.
Furor fit laesa saepius patientia
|
|
|
|
|
I've created an ATL COM - dll - MFC Supported with the AppWizard and I added a function that return a CString.
Now I want access to this function from another application to do it I type the next code.
In the ATL COM
...
__declspec(dllexport) CString GetEncodedText(CString p_sPlainText);
...
In the other application
...
hDLL = AfxLoadLibrary("BabMD5.dll");
if (hDLL != NULL) {
typedef CString (CALLBACK *ENCODETEXT)(CString);
ENCODETEXT p_encodeText = (ENCODETEXT)GetProcAddress( hDLL, _T("GetEncodedText"));
if ( p_encodeText != NULL) { // -> NEVER GET HERE
strEncoded = (*p_encodeText)( strPlain );
}
AfxFreeLibrary( hDLL);
}
...
Anybody knows what's happen? Why I can't get the function?
Thanks in advance
|
|
|
|
|