How to Access Container from within an ActiveX Control!

A

Ahmad

hi!

i have an activex control for Word. i want to send Printing command to
my Container(Word) to print itself at specific location from within my
ActiveX (My be on clicking some context menu item.) is it possible to
do that. if so then plz help me.

A sample code will help a lot.

Thanks in advance.

Ahmad Jalil Qarshi
 
I

Igor Tandetnik

Ahmad said:
i have an activex control for Word. i want to send Printing command to
my Container(Word) to print itself at specific location from within my
ActiveX (My be on clicking some context menu item.) is it possible to
do that. if so then plz help me.

Try IOleClientSite::GetContainer, then query for Word's document object
interface (whatever that might be, I'm not familiar with Word's object
model).
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
 
A

Ahmad

Thanks Igor!
i have done following:

IOleClientSite *pClientSite = NULL;
this->GetClientSite(&pClientSite);
CComPtr<IOleContainer> pContainer;
HRESULT hr = pClientSite->GetContainer(&pContainer);
if (hr == S_OK)
{
CComQIPtr<MSWord::_Application> spApp(pContainer);
ATLASSERT(spApp);
}

hr is S_OK, so my if condition executes. but when i QI for interface
pointer of _Application, spApp gets nothing.
i think i m somewhere wrong. might be at QI. so Plz give me hand to
overcome this problem.

Thanks.

Ahmad Jalil Qarshi
 
I

Igor Tandetnik

Ahmad said:
Thanks Igor!
i have done following:

IOleClientSite *pClientSite = NULL;
this->GetClientSite(&pClientSite);
CComPtr<IOleContainer> pContainer;
HRESULT hr = pClientSite->GetContainer(&pContainer);
if (hr == S_OK)
{
CComQIPtr<MSWord::_Application> spApp(pContainer);
ATLASSERT(spApp);
}

Try with the document interface, not application interface. _Document
perhaps?
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
 
A

Ahmad

Isn't it possible to get the _Application pointer of MS Word using this
_Document Pointer which i have gotten in my ActiveX control.

I have tried this one.

CComQIPtr<MSWord::_Document> spDoc(pContainer);
ATLASSERT(spDoc);
MSWord::_ApplicationPtr spApp = spDoc->GetApplication();

but not able to get the _ApplicationPtr.

Thanks

Ahmad Jalil Qarshi
 
I

Igor Tandetnik

Ahmad said:
Isn't it possible to get the _Application pointer of MS Word using
this _Document Pointer which i have gotten in my ActiveX control.

I have tried this one.

CComQIPtr<MSWord::_Document> spDoc(pContainer);
ATLASSERT(spDoc);
MSWord::_ApplicationPtr spApp = spDoc->GetApplication();

but not able to get the _ApplicationPtr.

Like I said, I am not specifically familiar with Word's object model.
I'm afraid I cannot help you any further, sorry.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
 
S

Sun Cetification

Hello,

Could you tell me how can I learn ActiveX, OLE to understand clearly all of them ?

What books should I learn ?

Looking forward for your help.

Thanking you in advance for positive responses.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top