|
ok - that would imply that the pObj you get back is not your object
does excel manufacture some form of object-site object?
looking at the vba excel docs, your object should also turn up in
OLEObjects container; I would write some code to see if I get the same, or different behaviour
i.e.
Add object to shapes as you are currently doing
then look for it in the OLEObjects container
then QI that object for your interface
modified on Tuesday, May 3, 2011 8:07 PM
|
|
|
|
|
Pleasure to see your reply. Thank you very much!
Some days ago, I find a message at MSDN. It said that if you want to add an OLE object into Excel worksheet, you should call OLEObjects.Add(), not Shapes.AddOLEObject(), because Shapes encapsulate the OLEObject returned by AddOLEObject. So the next operation such as OLEFormat.get_Object() can't get the raw point of the object inserted.
I had tried the way it recommend. But I can't get a OLEObjects from worksheet. I find that the reason of failure is the wrong LANGID parameter. I am trying to find the right parameter for it now. If you can't be success from the code above, you can try to do by this way. And if you know what parameter of LANGID is right, I will be very pleased to know it from you.
Sincerely
There is some white cloud floating on the blue sky. That's the landscape I like.
|
|
|
|
|
The message I get tell me that I should call _WorkSheet.OLEObjects() to get an OLEObjects, then call OLEObjects.Add() to insert my own object. But I get an error whose code is 0x800A03EC. This means I should set the right CultureInfo before calling OLEObjects.Add(). But I can't find any hint to set it besides using .NET framework. Should I using .NET just for this?
I had try to call GetSystemDefaultLCID() and ConvertDefaultLocale() to fix it. But the same error occurred. What shall I do?
There is some white cloud floating on the blue sky. That's the landscape I like.
|
|
|
|
|
I'm afraid I don't know - sorry ...
Things *I* would look at ...
1. What interfaces are being queried from your object during the OLEObjects.Add; do any of those want or return an LCID - if no interfaces are being queried it may be something missing from your type library
2. I would try doing the Shapes.AddObject as before, but then querying the OLEObjects rather than the object shape returns - the docs suggest the object will turn up in both places
3. If neither of those got me anywhere, I'd start looking at the object Shapes.AddObject returned, querying it for standard container interfaces and see if i could get to the 'real' object underneath (IOleContainer for instance)
best of luck
|
|
|
|
|
Sorry, maybe I make you nervous. That's my fault.
1. Nothing output when I call OLEObjects.Add. Maybe it's because I call the Dispatch.Invoke() to add. The reason of I call Dispatch.Invoke() instead of OLEObjects.Add() is that an error of 0x800A03EC always occurred for OLEObjects.Add().
2. I can't get the meaning of your second suggestion. You tell me to query OLEObjects at the object Shapes.AddObject returned?
3. Your meaning is that I should query some container interfaces such as IOleContainer for the object returned by Shapes.AddOLEObject(), isn't it? Why?
By the way, the error of 0x800A03EC isn't means wrong cultureinfo. The correct meaning is that another operation background is executed on the same object. I must make the object such as button lost focus. This is a bug for Office 2003.
Following is the explanation from Microsoft:
http://support.microsoft.com/kb/823988/en-us[^][]
I had try to do as the code provided by Microsoft. But nothing changed.
I hope you can help me in advance. Thank you!
There is some white cloud floating on the blue sky. That's the landscape I like.
|
|
|
|
|
2. make the previous
spShapes->AddOLEObject(ClassType,vEmpty,vEmpty,vtFalse,vEmpty,0,vEmpty,left,top,g_iCtrlInitWidth,g_iCtrlInitHeight);
call, but then look for your object in the OLEObjects() collection
3. Yes - I am assuming that Shape wraps your object in some form of container, so you *might* be able to get to that container, and ask IT for the enclosed object - alternatively, from within your IOleObject, find out what it's clientSite is, and see if that's the object Shape is giving you
|
|
|
|
|
Hi, barneyman.
I had fixed this problem. The reason of problem is that I missed a procedure. The right step is:
1. Get a pointer of OLEFormat with calling Shape.get_OLEFormat()
2. Get a pointer of _OLEObject with calling OLEFormat.get_Object()
3. Get a pointer of Dispatch with calling _OLEObject.get_Object()
4. Convert the Dispatch to my own object's pointer.
Thank you for waste your time to help me. I hope I could get more help from you later! Good luck!
There is some white cloud floating on the blue sky. That's the landscape I like.
|
|
|
|
|
I need to programmatically update/set contents of Mozilla Firefox browser Controls Contents using the IAccessible , IAccessible2
COM Interface MSAA Architecture .
The put_AccValue method in IAccessible Interface gives Return Code Not Implemented .
How do I set text programmatically ?
Can anybody provide some Sample code or reference to links ?
Kamal Jagesia
|
|
|
|
|
Not every program supports IAccessible .
According to what you said, Mozilla Firefox browser Controls Not Implemented it.
|
|
|
|
|
Hi
I just wanted to replace a '%' character in CComBSTR with "%%". But the code does not support CString. The solution should be UNICODE support.
Any methods to perform this operation ?
Thanks In Advance.
Babu
Today is a gift, that's why it is called the present.
|
|
|
|
|
CComBSTR does not have a Replace method, but you could use a temporary CString to make the replacement.
CString cstr(bstr.m_str);
cstr.Replace(L"%", L"%%");
bstr = cstr;
|
|
|
|
|
I have injected my DLL into Mozilla firefox browser. Using this DLL I want to get the IWebBrowserApp Interface , IHtmlDocument2 Interface for the current Active Instance of Mozilla Browser. How do I achieve this ? I do not want to use ATL or MFC .
|
|
|
|
|
I am using OPC client which connects to OPC driver but if the loading takes more than 2 mins it's automatically shutdown the driver please suggest me something.
Tested with other clients also but the same problem persist.
The problem is with CoCreateInstance if it takes more than 2 mins it abort the driver gracefully.
Thanks in advance!!!!
Truth Is The Simplest !!!!
|
|
|
|
|
Are you connecting to a local or remote OPC Server? What is your error code?
|
|
|
|
|
Hi,
I am a COM novice so please bear with me if information is incomplete/incorrect. I have a C++ application interacting with a .NET application through a COM. The C++ application is launched by the .NET application, which received events from the C++ application through COM interface using COleDispatchDriver.InvokeHelper method (described here - http://msdn.microsoft.com/en-us/library/zwx803ex(v=vs.80).aspx[^].
My question is - say my .NET application dies and my C++ application remains alive and tries to send an event to the .NET application through this COM interface, is there any way I can know that .NET application's gone.
Please let me know if you need more information.
Thanks,
Anshuman
|
|
|
|
|
I'm trying to access an an XAudio2 interface (IXAudio2 for example) in C#.
Some background: I'm writing a tool that will allow a sound artist to play back some music (among other things). I require playback of streaming multichannel audio from any location in the file, the tool is written in C#. DirectSound is depricated, XACT can't do this as far as I know, other packages (NAudio and SlimDX) are options but I'd like to stick with what our artists already have installed if possible. That leaves me with xaudio2, but it's not managed.
I've scanned my registry and opened the XAudio2 dll in OLE-COM Object Viewer, as well as several dll inspectors, none list the interfaces in the coclass. I'm following the directions here to access the COM interfaces but I require the IID of interfaces like IXAudio2.
Is there any way of getting this information or am I going down the wrong path all together?
TIA
|
|
|
|
|
I found the answer. The GUID's are supplied in the xaudio2.h header files supplied in the xdk. I feel silly for not looking there earlier, but perhaps this will help someone else with a similar question.
Cheers
|
|
|
|
|
Yes, it did help me, thanks! (in C++, just use the GetClsid() function...)
|
|
|
|
|
I'm trying to do this error-free.
I'm writing context menu shell extension that will navigate current Explorer window through IShellBrowser acquired through IObjectWithSite and so far I have this (omitting unimportant code):
header file
class ATL_NO_VTABLE CShellTarget :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CShellTarget,&CLSID_ShellTarget>,
public IShellExtInit,
public IContextMenu,
public IObjectWithSiteImpl<CShellTarget>
...
private:
CComPtr<IShellBrowser> m_pShellBrowser;
...
};
and here I override SetSite method, but I'm not sure if this code is OK
HRESULT CShellTarget::SetSite(IUnknown *pUnkSite)
{
ATLTRACE("IObjectWithSiteImpl::SetSite\n");
IObjectWithSiteImpl<CShellTarget>::SetSite(pUnkSite);
if (m_spUnkSite!=NULL)
{
CComQIPtr<IServiceProvider>; sp = pUnkSite;
sp->QueryService(SID_SShellBrowser,IID_IShellBrowser,(void**)&m_pShellBrowser);
}
else m_pShellBrowser.Release();
return S_OK;
}
It's hard to find one representative code sample of IObjectWithSite and Google isn't that much helpful.
(btw yea I know about WM_GETISHELLBROWSER hack)
Help is appreciated.
|
|
|
|
|
Hi All,
I have tried to use QueryInterface by using the following code segment.
The COM component had been created by me with two interfaces. The following code works fine with CoCreateInstance function.
When i try to obtain the another interface using "QueryInterface" returns E_NOINTERFACE.
Kindlly help me, by tracking mistake(s) if any.
Thanks,
Ganesamoorthy
HRESULT hr;
IGreet *greetObject;
IGreet2 *greetObject2;
CString strTemp;
hr = CoInitialize(NULL);
if (FAILED(hr) )
return ;
hr = CoCreateInstance(CLSID_Greet2,NULL,CLSCTX_INPROC_SERVER, IID_IGreet2,(void **)&greetObject2);
if (FAILED(hr) )
{
CoUninitialize();
return ;
}
greetObject2->AddRef();
cout << greetObject->Sayhello("Ganesh") << endl;
CComBSTR bstrVal, bstrVal1;
bstrVal1.Append ("Ganesh");
greetObject2->SayHello2(bstrVal1, &bstrVal);
strTemp.Format (_T("%s"), bstrVal);
MessageBox (strTemp);
hr = greetObject2->QueryInterface(IID_IGreet,(void **)&greetObject);
DWORD dw = GetLastError();
if (FAILED(hr) )
{
CoUninitialize();
return ;
}
CoUninitialize();
modified on Thursday, January 27, 2011 5:10 AM
|
|
|
|
|
|
I have a plugin that I'm developing that is used in a COM environment. The issue is, I seem to be able to readily obtain an pointer to a base class of my class, but I'm unable to figure out how to get a pointer to my main class.
Here is my class:
class ATL_NO_VTABLE Plugin :
public CDXBaseNTo1,
public CComCoClass< Plugin, &CLSID_Plugin >,
public IDispatchImpl< IPlugin, &IID_IPlugin, &LIBID_MAINLib >,
#if(_ATL_VER < 0x0300)
public CComPropertySupport< Plugin >,
#endif
public IObjectSafetyImpl2< Plugin >,
public IPersistStorageImpl< Plugin >,
public ISpecifyPropertyPagesImpl< Plugin >,
public IPersistPropertyBagImpl< Plugin >,
public CSFVideoPlugin< PLUGINPROPS >
The CSFVideoPlugin is derived from the ISfExchangeProps< PLUGINPROPS > interface.
Then, in another are of the plugin environment, the Property Page to configure it, I can do the following:
CComQIPtr< ISfExchangeProps< PLUGINPROPS >, &IID_ISfExchangeProps >
pxPlugin( m_ppUnk[ 0 ] );
This part all works fine, and calls into the pxPlugin work fine. When inside a method call there, the debugger shows [ATL::CComContainedObject<Plugin>] as the first "member" of this , so the relationship is known, or so it would seem. But calls like this return a completely bogus pointer:
CComQIPtr< Plugin, &IID_IPlugin >
pxPlugin( m_ppUnk[ 0 ] );
The memory is in the same basic area, but the values are all messed up, and in fact setting them on occasion can/will crashes.
I can't figure out how to query for that CComContainedObject interface. Given that even the debugger has enough information to track it down though, clearly it must be.
Any help would be greatly appreciated. If I haven't provided a piece of information that would be useful, please let me know.
Thanks, CraigL
|
|
|
|
|
Hi friends,
My product have a ATL/COM based C++ service (32 bit). It get registered and run fine on XP 32 bit and Vista 32 bit.
But now I want to run the same on Windows7 64 bit also. I tried to register the service the following way:
1 I did Copy MyService.exe at C:\Windows\SysWOW64.
2 Then executing "C:\Windows\SysWOW64\MyService.exe" -RegServer from Start->Run
3 Then executing "C:\Windows\SysWOW64\MyService.exe" -Service from Start->Run
But my service is not getting registered. While registering it, I don't get any error message. Also I didn't find any entry in event viewer (I saw event viewer first time. Don't know where to see the log about registration of my service). And I didn't find entry for my service at Control Panel\Administrative Tools\Services.
Please advise me how can I register my service?
Thanks in Advance
Regards
|
|
|
|
|
Do not repost the same message in different forum. You send this message in vc++ forum and ATL forum as well.
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
I had been interviewed with a comp .. during course of interview guy asked me question like.
1)How COM and DCOM differ on code level.
2)and what are the advantages of using COM over DCOM
can somebody please explain these..
thanks
vikas da
|
|
|
|
|