|
i want to expose all of my interfaces to a Vb application, but the vb
application sees nothing except the default interface.
thanx in advance
Z.A
-- modified at 2:11 Friday 24th February, 2006
|
|
|
|
|
Hello zubair_ahmed,
Yes, COM objects will by default expose its "default" interface. However, you can DIM an object of another interface and cast the original COM object to this interface. Doing so is equivalent to performing QueryInterface().
Here is an example :
'' Let's say TestObject supports its default interface
'' plus TestInterface01 and TestInterface02.
Set TestObjectObj = New TestObject
'' Define objects of the 2 desired interfaces...
Dim TestInterface01Ptr As TestInterface01
Dim TestInterface02Ptr As TestInterface02
'' Cast TestObjectObj to the desired interfaces.
'' This action is equivalent to QueryInterface().
Set TestInterface01Ptr = TestObjectObj
Set TestInterface02Ptr = TestObjectObj
'' Use the interfaces' properties and methods as per normal...
TestInterface01Ptr.strProperty = "Hello"
TestInterface01Ptr.Method01
TestInterface02Ptr.longProperty = 101
TestInterface02Ptr.Method01
'' Set the interfaces to nothing is equivalent to Release()'ing
'' the interface pointers.
Set TestInterface01Ptr = nothing
Set TestInterface02Ptr = nothing
Best Regards,
Bio.
|
|
|
|
|
You have to add the IDispatch to all your Interfaces. For further informations see in your documentation how to implement an IDispatch-interface.
|
|
|
|
|
How to catch ActiveX Install or Excute using BHO?
I want detect ActiveX behavior about install, execute, download *.cab ...
help me~
thanks
and sorry about My little English.
|
|
|
|
|
hi,
i Create a application in ATL COM application,( for dll based application)
with simple get and set method for adding 2 nos
which is very similar to the link
http://www.codersource.net/atl_tutorial_events_properties.html[^]
but after build the appliaction i get error as
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlcom.h(1827) : error C2259: 'CComObject<class csimpleobj="">' : cannot instantiate abstract class due to following members:
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlcom.h(1823) : while compiling class-template member function 'long __stdcall ATL::CComCreator<class atl::ccomobject<class="" csimpleobj=""> >::CreateInstance(void *,const struct _GUID &,
void ** )'
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlcom.h(1827) : warning C4259: 'long __stdcall ISimpleObj::total(void)' : pure virtual function was not defined
E:\templqw12\SimpleAtlCom\SimpleAtlCom.h(106) : see declaration of 'total'
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlcom.h(1823) : while compiling class-template member function 'long __stdcall ATL::CComCreator<class atl::ccomobject<class="" csimpleobj=""> >::CreateInstance(void *,const struct _GUID &,
void ** )'
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlcom.h(1827) : error C2259: 'CComObject<class csimpleobj="">' : cannot instantiate abstract class due to following members:
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlcom.h(1823) : while compiling class-template member function 'long __stdcall ATL::CComCreator<class atl::ccomobject<class="" csimpleobj=""> >::CreateInstance(void *,const struct _GUID &,
void ** )'
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlcom.h(1827) : warning C4259: 'long __stdcall ISimpleObj::total(void)' : pure virtual function was not defined
E:\templqw12\SimpleAtlCom\SimpleAtlCom.h(106) : see declaration of 'total'
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlcom.h(1823) : while compiling class-template member function 'long __stdcall ATL::CComCreator<class atl::ccomobject<class="" csimpleobj=""> >::CreateInstance(void *,const struct _GUID &,
void ** )'
SimpleObj.cpp
reply me
send reply
|
|
|
|
|
|
This is because you haven't implemented all the methods of the ISimpleObj interface. Looks like the ISimpleObj::total method.
Steve
|
|
|
|
|
Hi All,
Can Anyone tell me how to implement and export DllRegisterServer from a VB Activex Dll?
I am a complete newbie to VB,sorry about the very basic question.
Thanks and Regards,
Anil
|
|
|
|
|
Can anyone also tell me what the default implementation of this function in VB does?
Thanks,
Anil
|
|
|
|
|
Hello Anil_vvs,
Not possible to implement DllRegisterServer() in a VB ActiveX DLL. It is automatically generated for you by the VB IDE and programmers do not have the option of modifying it.
Bio.
|
|
|
|
|
I create a C++ Powerpoint automation test program following the MSDN article "
How to create an automation project using MFC and a type library" steps.
But get serious trouble when it parses only a single rectange shape in a simple single PPT slide
The proble is always get assertion in "pptApp.put_Visible(false);"
"long nCount = shapepts.get_Count(); "
" long n = gshapes.get_Count(); "
Also I get assertion if I call shape.get_Vertice()
I ugently need the help to solve this problem.
the code is:
#include "stdafx.h"
#include "testPPT.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#include <afxdisp.h>
#include "CPresentation.h"
#include "CApplication.h"
#include "CShapeNode.h"
#include "CSlides.h"
#include "CShapeNodes.h"
#include "CDocumentWindow.h"
#include "CPresentations.h"
#include "CShapes.h"
#include "CPageSetup.h"
#include "CFreeformBuilder.h"
#include "CPictureFormat.h"
#include "CShapeRange.h"
#include "CColorScheme.h"
#include "CMaster.h"
#include "CDesign.h"
#include "CHyperlinks.h"
#include "CActionSetting.h"
#include "CTextFrame.h"
#include "CSlide.h"
#include "CShape.h"
#include "CGroupShapes.h"
#include "CColorFormat.h"
#ifndef POWERPOINT_NOTINSTALLED
#define POWERPOINT_NOTINSTALLED 0
#endif
#ifndef POWERPOINT95
#define POWERPOINT95 1
#endif
#ifndef POWERPOINT97
#define POWERPOINT97 2
#endif
#ifndef POWERPOINT2000
#define POWERPOINT2000 3
#endif
#ifndef POWERPOINT2002
#define POWERPOINT2002 4
#endif
#ifndef POWERPOINT2003
#define POWERPOINT2003 5
#endif
//??????????????????????????????
//The Powerpoint conversion error code -- 2006-02-16, zxing
#define PPTCONV_OK 0 //OK
#define PPTCONV_NOPPT 1 //No Powerpoint installed
#define PPTCONV_NOPPTFILE 2 //No Powerpoint file
#define PPTCONV_PPTNOTRUN 3 //Cannot run powerpoint
#define PPTCONV_WRONGPPTVER 4 //Wrong Powerpoint version
//??????????????????????????????
// The one and only application object
CWinApp theApp;
using namespace std;
const OLECHAR FAR* szPPTProgID[] =
{
OLESTR("PowerPoint.Application.7"), // PowerPoint 95
OLESTR("PowerPoint.Application.8"), // PowerPoint 97
OLESTR("PowerPoint.Application.9"), // powerPoint 2000
OLESTR("PowerPoint.Application.10"), // powerPoint 2002
OLESTR("PowerPoint.Application.11"), // powerPoint 2003
};
long QueryPPTVersion(void)
{
long nRet = POWERPOINT_NOTINSTALLED;
CLSID clsid;
for (long i = POWERPOINT95; i <= POWERPOINT2003; i++ )
{
//Query class ID from system
if (SUCCEEDED(CLSIDFromProgID(szPPTProgID[i-1], &clsid)))
{
return i;
}
}
return nRet;
}
bool PPTStartup(CApplication& pptApp, long nVer, bool bShow, long& nPrevWS)
{
bool bRet = false;
if(nVer < POWERPOINT95 || POWERPOINT2003 < nVer)
{
return bRet;
}
CLSID clsid;
if(!SUCCEEDED(CLSIDFromProgID(szPPTProgID[nVer-1], &clsid)))
{
return false;
}
if(!pptApp.CreateDispatch(clsid))
{
TRACE(_T("Couldn't start PowerPoint and get Application object."));
return bRet;
}
nPrevWS = pptApp.get_WindowState();
if(bShow)
{
pptApp.put_Visible(true);
}
else
{
pptApp.put_Visible(false); //Failed get assertion
}
bRet = true;
return bRet;
}
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
nRetCode = 1;
}
else
{
// TODO: code your application's behavior here.
}
nRetCode = OleInitialize(NULL);
long nVer = QueryPPTVersion();
long nPrevWS;
bool bShow;
CApplication pptApp;
if(!PPTStartup(pptApp, nVer, true, nPrevWS))
{
ASSERT(FALSE);
}
CPresentations pptPresentations = pptApp.get_Presentations() ;
CPresentation pptPresentation;
pptPresentation = pptPresentations.Open(_T("C:\\Dev\\outline.ppt"), FALSE, TRUE, TRUE);
CSlides pptSlides;
pptSlides = pptPresentation.get_Slides();
CSlide crtSlide;
crtSlide = pptSlides.Item(COleVariant((long)1));
CShapes shapes = crtSlide.get_Shapes();
CShape shape;
shape = shapes.Item(COleVariant((long)1));
CShapeNodes shapepts = shape.get_Nodes();
long nCount = shapepts.get_Count(); //Get Assertion
CGroupShapes gshapes = shape.get_GroupItems();
long n = gshapes.get_Count(); //Get Assertion
if(pptPresentation.m_lpDispatch != NULL)
{
pptPresentation.Close();
pptPresentation.ReleaseDispatch();
pptPresentation.m_lpDispatch = NULL;
}
if(pptApp.m_lpDispatch != NULL)
{
pptApp.Quit();
pptApp.ReleaseDispatch();
pptApp.m_lpDispatch = NULL;
}
return nRetCode;
}
|
|
|
|
|
It's my understanding that for every call to CoInitialize() you need a call to CoUninitialize(), at least that's my interpretation of the documents on MSDN. Please look at my code:
cParse::cParse()<br />
{<br />
try<br />
{<br />
CoInitialize(NULL); <br />
short vi = 1;<br />
xls.CreateInstance(__uuidof(clsXL));<br />
xls->Visible(&vi);<br />
} catch(_com_error &e) {<br />
bstrDesc = e.Description();<br />
MessageBox(NULL,_com_util::ConvertBSTRToString(bstrDesc),0,0);<br />
}<br />
}<br />
<br />
cParse::~cParse()<br />
{<br />
try<br />
{<br />
CoInitialize(NULL); <br />
xls->QuitAll();<br />
} <br />
catch(_com_error &e) {<br />
bstrDesc = e.Description();<br />
MessageBox(NULL,_com_util::ConvertBSTRToString(bstrDesc),0,0);<br />
}<br />
CoUninitialize(); <br />
}
If I use it any other way the program crashes. I'm not sure if what I have done is right or wrong (it works), but I would like a better understanding? The commented numbers are to make any replies easier to understand
|
|
|
|
|
CoInitialize is to initialize the com libraries and for setting up the right apartment for the current thread where you are using the com objects.
You need to do this only once for an application. For example in the caase of an MFC application u can call CoInitialize(NULL); in the initinstace and CoUninitialize(); in the ExitInstance.
No need to call this in every class and method.
If u r in a multithreded app then u need to call CoInitialize and CoUninitialize in each thread.
hope this help...mil10
|
|
|
|
|
Thanks for the reply. That is exactly how I thought it should be done, but in my above code, if I remove it from the destructor, the program crashes on exit. I'm having a nightmare trying to debug this since the xls pointer is an AxtiveX VB coded dll. But I am pretty sure the problem is not even in the dll (it only clears some memory).
I will keep trying nonetheless.
|
|
|
|
|
|
MFC is very particular about outstanding COM references when it shuts down. If you're using a STA, you may want to call AfxOleInit() in your CxxxApp::InitInstance() and let MFC take care of uninitialisation rather than explicitly calling CoInitialize(NULL) and CoUninitialize() in your code. Obviously, if things are a little more complicated or you want to support multiple STAs or a MTA, AfxOleInit() will not suffice.
Hope that helps.
|
|
|
|
|
No matter what I do, whenever and however I remove the CoInitialize(NULL); /** 3 **/ from the destructor the program crashes on exit. I cannot for the life of me find out why. I am not using MFC, this is just a regular Win32 application. Also I should point out that this class is initalised in the global scope and no call is made to the destructor.
|
|
|
|
|
Thanks for all your effort guys, after reading my own reply to your posts I realised my error.
I should have created a global pointer to the object, initialise it on WM_INITIALISE and destroy it on WM_CLOSE. It all works perfectly and as it should do now.
|
|
|
|
|
What are the rules that must be followed while passing interface pointers as parameters of a function?
For example ..
I have declared
<br />
ICaptureGraphBuilder *pBuilder;<br />
IGraphBuilder *pGraph;<br />
They both point to NULL initially.
Can i send the above interface pointers as function parametres where they will be created using CoCreateInstance.
I tried to call the following function.
<br />
BuildGraph(pBuilder,pGraph);<br />
whose implementation is as follows
<br />
void BuildGraph(ICaptureBuilder *pCapBuilder, IGraphBuilder *pGraphBuilder){<br />
CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC,<br />
IID_IGraphBuilder, (void **)&pGraphBuilder);<br />
<br />
CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC, <br />
IID_ICaptureGraphBuilder2, (void **)&pCapBuilder);<br />
}<br />
Now with the above function call i create the filter graph manager and capture graph builder.
But the pBuilder and the pGraph in the calling function point to NULL even though the pGraphBuilder and pCapBuilder doenst not point to NULL anymore.
How can i solve this problem?
|
|
|
|
|
Hello !
That won't get you the interface pointer. Because the parameter seems to be 'pass by value' not 'pass by reference/pass by address'. Remove '&' from 'pGraphBuilder' in CoCreateInstance(). This will get the interface pointer in 'pBuilder' address instead of local 'pGraphBuilder' variable ! For more details look into the call by reference (using Pointers to Pointer)...
Malli...
|
|
|
|
|
malli_123 wrote: Remove '&' from 'pGraphBuilder' in CoCreateInstance().
Thank you it worked
-- modified at 7:06 Wednesday 22nd February, 2006
|
|
|
|
|
Hi ,
We all know windows system supports left mouse button drag and drop operation.
And we still can let our own application to support drag and drop operation.
My issue is can we get selected folders or files names before we release the left mouse button. That is to say, can we get selceted folders or files names during Drag&Drop's mouse moving process?
I want to use shell technicology to implement it. Unfortunately, I can get these informations only when I had clicked right mouse button or use left mouse button to move them to target folder,which supports drag&drop operation.
Any advice is welcome!
Thanks,
Welli
|
|
|
|
|
Hi All
I know this is going to seem like a stupid question, but I have to ask it. I have had a look at the articles on this, but don't understand too much.
I am looking for information, as well as the simplist way to create and implement a IE Toolbar. I have looked at the ones done in WTL and don't understand too much, or maybe I just haven't had enough coffee yet. To give you a bit of background so that you can understand where I am coming from, I do development in C/C++ back end programing, ie no Front end dev in C/C++, so no understanding of MFC or WTL. The only front end programming I do is in Delphi. SO I am trying to find a simple implementation/article that will help me build a Google type tooolbar. So any and all pointers would be greatly appreciated.
Whilst we are on the subject if you could also point out some articles on Deskbands that would be great too. If you could maybe also recomend some books on the subject that would be a great help.
Thanks
Vaughan
"I once thought I saw the light at the end of the tunnel, but it was just the light from a torch of some bastard bringing me more work"
|
|
|
|
|
I'm using the IDispatch and IUnknown interface to do some simple word automation, and I need to be able to insert text at given bookmarks. I've gotten as far as gettin a handle to the Bookmarks collection, but I'm not sure where to go from there.
How do I select a given bookmark, then insert some text after it?
Thanks.
|
|
|
|
|
Hi all,
While working with print templates I got into a situation where my JavaScript loaded ActiveX control was not filling my m_spClientSite with a value other than NULL.
After wrestling with it for a while I decided to take a back door. It was necessary for me to access the COM interfaces in my instance of IE so I went to the Running Object Table. I enumerated its contents and was relaxed when I saw 3 IE entries as that was the number of IE windows I had open. Each one had been opened from the other. My problem is that all the IE objects in the ROT have the values of the first IE window opened (unfortunately not the one I wanted).
So my question is: is there a way of access the other IE COM interfaces?
Or even more helpful: what's the procedure when you control hasn't got a useful value in its m_spClientSite.
Thanks loads for any help
Tom
|
|
|
|