|
Chill
It's not really feasible to have 2 DLLs - you can have both, but to my mind it just confuses things too much.
The DLL that uses the COM object (eg. calling OpenReport, etc) should be the same one that provides the events object that implements the IReportEvent interface. The theory is; if you see the following in a type library;
coclass Report {
[default] interface IReport;
interface IDReport;
[default, source] dispinterface IReportEvent;
};
it means that the Report class promises to implement IReport and IDReport, but *not* IReportEvent because that's the one you need to implement and give to the Report instance (you've created) by using the Advise/Unadvise methods mentioned earlier - this is indicated with the 'source' IDL attribute.
So, the code I gave you resembles something to be put in your work DLL and replaces the need for an ATL wrapper DLL that is generated from the type library. You can use the wizard-generated ATL DLL code as a hint to what the SINK_MAP entries should look like ....a handy reference.
As an aside, if you haven't already, use OleView to inspect Crystal's CRAXDDRT20.DLL (or similar) to see what the type library looks like.
Also, get 'ATL Internals' by Brent Rector, Chris Sells - it explains all this stuff much better than I can.
Martin
|
|
|
|
|
I think I'm getting somewhere at last, just two questions I can't seem to figure out, when I try to use DispEventAdvise() function of CMyReportEvents, I get the message that it "must have class/struct/union type" which is obviously because that function does not exist in the class, how do I add the function to the class? Also, I get the message that there is no default constructor available for CMyReportEvents, is there any specific code I need in the constructor or can I use an empty constructor?
Thanks in advance!
|
|
|
|
|
I have worked out where my problem is, I need to declare the ReportEventsImpl properly, I have changed the code to this:
#import "C:\Program Files\Common Files\Crystal Decisions\1.0\Bin\craxddrt20.dll" rename_namespace("cr")
using namespace cr;
const int REPORT_SOURCE_ID = 0;
class CMyReportEvents;
typedef IDispEventSimpleImpl<report_source_id, cmyreportevents,="" &cr::ireportevent=""> ReportEventsImpl;
_ATL_FUNC_INFO OnNoDataInfo = { CC_STDCALL, VT_EMPTY, 1, { VT_PTR | VT_BOOL } };
class CMyReportEvents : public ReportEventsImpl
{
public:
BEGIN_SINK_MAP(CMyReportEvents)
SINK_ENTRY_INFO(REPORT_SOURCE_ID, __uuidof(IReportEvent), 1, OnNoData, &OnNoDataInfo)
END_SINK_MAP()
bool CMyReportEvents()
{
}
void __stdcall OnNoData(VARIANT_BOOL *pCancel)
{
_ASSERT(false);
}
};
I get the error that using "IReportEvent" in the typedef and that "Use of template requires argument list", could you point me in the direction of what I use instead of IReportEvent.
Thanks!
|
|
|
|
|
Hi
It's the declaration of ReportEventsImpl;
typedef IDispEventSimpleImpl ReportEventsImpl;
IDispEventSimpleImpl is a template class, so it requires parameters (source id, class, events IID), like so;
class CMyReportEvents;
typedef IDispEventSimpleImpl<report_source_id, cmyreportevents,
="" &__uuidof(cr::ireportevent)="">
ReportEventsImpl;
(note the forward declaration of CMyReportEvents)
just mail mkoorts@postmaster.co.uk directly and we can take this offline.
Martin
|
|
|
|
|
Any OLE clipboard experts out there? I'm seeing some odd behavior when pasting and embedding an object in Word 2003.
Here's the scenario: in my MFC application, I paste data to the clipboard in a handful of formats - the typical OLE document crew of Embed Source, Object Discriptor, and CF_METAFILEPICT; and a CF_DIB (which seems to have no bearing on the problem). When I paste into Word 2003, an instance of my app is launched, and the embedded data is serialized in. This wouldn't bother me so much if the instance would go away after I close Word. It reeks of a reference counting issue, yes, but I'm wondering why my app is being launched in the first place. The embedded object isn't active, and Word only needs a metafile to render the object's presentation - and the metafile is readily available on the clipboard.
The odd part about this is that no additional app instance is launched when I do the same thing under Word 2000. Any clues as to what's going on here? Is Word '03 looking for a different clipboard format, or otherwise handling clipboard operations differently than Word '00? Of course, my app may be buggy , but there haven't been issues until the '03 suite.
Any help is appreciated.
|
|
|
|
|
I am writing a MFC app that loads and runs external scripts written in VBScript.
To run a script, I instantiate an engine derived from COleDispatchDriver, and then get an interface to VBScript by
hr = CLSIDFromProgID(L"VBScript", &clsid);
This works just fine as long as my scripts contain only native VBScript statements, but I would really like to use the functionality of the WScript object as well, and VBScript apparently doesn't recognize it. I've tried every variation I can think of, like
hr = CLSIDFromProgID(L"WScript", &clsid);
and
hr = m_iActiveScript->AddNamedItem(L"WScript.exe", SCRIPTITEM_ISVISIBLE | SCRIPTITEM_ISSOURCE | SCRIPTITEM_GLOBALMEMBERS);
but nothing seems to work.
Any suggestions?
|
|
|
|
|
Hey,
I was wondering is it possible to modify the way the IDispatch
implements its member/property discovery. eg. modify the way ITypeInfo
works.
I want to be able to populate a collection with property names when
the client uses the object (when it does its discovery).
eg.
Dim objTestATL As GenAdapter.CAttribObj
objTestATL = New...
Now when the client types "objTestATL." they will be given a list of methods/properties
objTestATL.Height = 23
objTestATL.Width = 2
objTestATL.DoSomethingCool()
where height and width are stored in a collection and the method
DoSomethingCool() is defined as normal.
Thoughts and/or Ideas would be great.
Thanks
|
|
|
|
|
Hi
Typically, implementations for IDispatch is driven off a type library (eg. ATL's IDispatchImpl), but since a typelib is static, it won't work for you. Instead you'll have to provide the ITypeInfo implementation yourself. Have a look at CreateDispTypeInfo and see if it'll help you.
HTH
KakVraagSit .... (grappie)
|
|
|
|
|
For that the IDispatchEx was designed. Also the JScript and VBScript asks for that interface if you pass the object into the script engine.
For plain old VB there's a problem, that VB asks only for IDispatch AFAIK. Therefore you have to test, if VB supports the Ex version or go through the pain of manually defining your interface.
Anyway, I think, you have to cast your objects as Object only, because else the VB will store the values it receives during the compilation in the resulting binary - this means, if you changes the number/order of properties you're out of luck.
Don't worry to ask for more
|
|
|
|
|
hai all,
i created an arrow in MFC(exe) i want to export that arrow functioning into an ActiveX component. and i created that control. and i add my ctrl to toolbar, i getting the rectangular dotted lines and in that i arrow is placing but i don't want like that , i want to look like a "line which is provided by Windows".
In the program , i use, OnDraw ( , CRect rcBounds , ,) function , i take the rcBounds and i took two points (starting, ending) to draw the arrow. But , i want only a single point which is mousedown(which is at design time)..
not runtime.
plz Help.
Thanks in advance.
surya prakash
|
|
|
|
|
Hi,
I have an Activex DLL in VB6. I am creating threads within that using CreateThread API. When I try to access it from another application(std exe), it is giving run-time error. The same code works if it is made into a standard exe. Can anyone suggest the solution?
thx in adv.
--sandeep
|
|
|
|
|
I'm working on a plugin system, however I do not want end users to be able to discover what interfaces/coclasses I have implimented in the plugin DLLs.
If I remove the type library from the DLL's resources, will the plugged-into app still function correctly as long as it knows the definitions of the plugins' interfaces at compile-time?
If the plugin DLL does NOT contain a type library in itself, will the app and plugin still function properly?
|
|
|
|
|
The type library in the resources is just included for convenience so that other programmers can view the COM interfaces etc. but does not directly affect the actual interfaces implemented. If you remove this information from the DLLs resource (comment out the lines in the .rc file), the actual interfaces will still function normally.
|
|
|
|
|
Thanks
|
|
|
|
|
I know this very stupid Question ,just want to know which line to comment out in RC File .
Thanks
"I Think this Will Help"
Alok Gupta visit me at http://www.thisisalok.tk
|
|
|
|
|
Near the bottom of the .rc file, you will see a line like this:
1 TYPELIB "myproject.tlb"
If you comment out this line, then the type libary will not be included (assuming that APSTUDIO_INVOKED has not been defined).
If APSTUDIO_INVOKED has been defined, then you will need to comment out the TEXTINCLUDE section higher up in the .rc file which contain a similar TYPELIB line.
|
|
|
|
|
|
Hi..
I have an .ocx that is made with VB6 and which contains an interface to it's functions and properties.
I have used the aximp tool to create a dll file which I reference in my project.
When I try to access some of it's functions or properties I get the errormsg.:
"An unhandled exception of type 'InvalidActiveXStateException' occurred in axinterop.itdcinterfacelib.dll"
But when i set a breakpoint in my code and expands the variabletree for the interfaceobject in the Locals window and then steps forward in the code, it works fine...!!
I guess it has something to do with initzialisation, but I can't find a solution to this...
Please help me...
|
|
|
|
|
I am trying to write an Automation-Server with Borland C++ 6.0. The server has to run a model. The interface contains a method to actualize the state of the model. For this reason the method takes some values as parameters.
HRESULT actualize_model( [in] double value1, [in] double value2 );
There has no value to be to return. The only thing the client has to know is that the passed values has been sucessful processed. In other words the client must be sure that the method has been carried out.
The borland wizard that builds the com server encapsulates the method. The same if I write the client. I call Project->Import Type Library... and the wizard generates some code. All I can see is a Object which contains the following method without an HRESULT:
void actualize_model( double value1, double value2 );
Now my question: How is it possible for the client to recognise that the call has failed? I wonder why there is no exception thrown after a method call while the server is closed.
Andrew
|
|
|
|
|
I don't know how Borland's importing features work, but I do know that Visual C++ creates wrapper code which transforms:
HRESULT Method([in] long v, [out, retval] double* pResult) into
double Method(long v) throw(_com_error) . In other words, it creates code which looks kind of like this:
double WrappingMethod(long v) {
double result;
HRESULT hr = Method(v, &result);
if(FAILED(hr)) throw _com_error(hr);
return result;
} Perhaps the Borland code generates the same kind of code?
In Visual C++, you can tell the compiler not to generate this wrapper code, so that you'll get pure untampered interface definitions. Are there any such options for Borland?
--
I got nasty habits. I take tea at three.
-- Mick Jagger
I blog too now[^]
|
|
|
|
|
Hello,
Any body can pls help me how to pass multiple checkbox values to a ATL COM Dll.am new to ASP.
Thanks.
R.Srihari
|
|
|
|
|
Hello,
I have an unmananged COM object that at one time would send error messages to a text file that was created by using
ofstream outfile;
outfile.open("C:\\WhatHapped.txt");
but, I don't know why it stopped working.
The COM object is used in our asp.net program that is using c# code to grab the com functions.
Could there be something in web.config that isn't allowing the file being created in the COM object?
Thank you,
Bill
|
|
|
|
|
I need to invoke a script function programmatically through c++. I have the relevant html doc and there will be several script tags. I have the collection of tags and loop through them to find the script function. However, when I get to the script element that I know contains the function, the GetIDsOfNames method always returns "Unknown name."
CODE SAMPLE
CComBSTR bstrMember("SCRIPT");
pDoc3->getElementsByTagName(bstrMember, &pEltColl);
long len;
pEltColl->get_length(&len);
for(int i = 0; i < len; i++ )
{
CComPtr<idispatch> pEltDisp = NULL;
hr = pEltColl->item( CComVariant(i), CComVariant(i), &pEltDisp);
if(SUCCEEDED(hr))
{
IHTMLScriptElement* pElem = NULL;
hr = pEltDisp->QueryInterface( IID_IHTMLScriptElement, (void**)&pElem );
IDispatchPtr spDisp( pElem );
if(SUCCEEDED(hr))
{
OLECHAR FAR* bstrMember = L"MyFunction";
DISPID dispid = NULL;
**************Things go wrong here****************************
hr = spDisp->GetIDsOfNames(IID_NULL,&bstrMember,1,
LOCALE_SYSTEM_DEFAULT,&dispid);
if(SUCCEEDED(hr) && dispid )
{
DISPPARAMS dispparams;
memset(&dispparams, 0, sizeof dispparams);
EXCEPINFO excepInfo;
memset(&excepInfo, 0, sizeof excepInfo);
CComVariant vaResult;
UINT nArgErr = (UINT)-1;
//Call JavaScript function
hr = pEltDisp->Invoke(dispid,IID_NULL,0,
DISPATCH_METHOD,&dispparams, &vaResult,&excepInfo,&nArgErr);
}
}
}
}
Suggestions would be welcome
|
|
|
|
|
I tried using the type library for Microsoft Mappoint to generate classes I need to use the activex control on my dialog, but couldn't seem to see any way to make that work. Now I've tried generating classes from the .ocx file, and that seems to give me all the classes I need for what I'm trying to do. However, I have no idea how to actually display the control on my dialog. There's a CMappointCtrl class that was generated, and all I see in the member functions is CreateDispatch(), not a Create() since it's not derived from CWnd. Also, there's a bunch of other classes that came from the .ocx that I would like to use (like CRoute,CMap). How can I use these with the control? Any help is appreciated. thanks
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
no.1 I've disabled all the virus software ,fireware&Internet Assistant
no.2 I've try to import the related item into register and copied dll files to system directory
but the Activex Control can not work still, hot can... how can I do?
<object id="factory" viewastext="" style="display:none"
="" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" codebase="/scriptx/ScriptX.cab#Version=6,1,431,1">
|
|
|
|
|