loaded by Explorer. Your application needs to communicate
with Explorer. I'd suggest the oppiste direction - have your
shell extension talk back to your application. You can register
find the running instance of your application. Check out
RegisterActiveObject/GetActiveObject.
Hi,
This is what I am trying to do. I want to create a shell extension
which implement IExtractImage shell interface to generate thunmnail for
a image. Since the image file is saved and opened from a MFC
application and the shell extension is called by shell, I'm thinking of
using connection point to fire an event to the MFC application from the
Extract function of the shell extension(COM object). And the MFC
application get the event and generate thumbnail of the image and pass
the thumnail handle to the shell extension. So the shell can save the
thumbnail when it save the file.
The thing I am not sure is: is the shell extension a inproc server of
the MFC application? do they have the same address space? If they are
not in the same address space, then the shell extension can't get the
thumbnail generated by the MFC application. Will this approach work?
Here is some of my code:
// IExtractImage::Extract
HRESULT CScribbleExtractor::Extract(HBITMAP* phBmpThumbnail)
{
Fire_OnExtractImage( (LONG*) phBmpThumbnail);
return NOERROR;
}
template <class T>
class CProxy_IExtractEvent : public IConnectionPointImpl<T,
&DIID__IExtractEvent, CComDynamicUnkArray>
{
//Warning this class may be recreated by the wizard.
public:
HRESULT Fire_OnExtractImage(LONG * pHBmpThumbnail)
{
CComVariant varResult;
T* pT = static_cast<T*>(this);
int nConnectionIndex;
CComVariant* pvars = new CComVariant[1];
int nConnections = m_vec.GetSize();
for (nConnectionIndex = 0; nConnectionIndex < nConnections;
nConnectionIndex++)
{
pT->Lock();
CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
pT->Unlock();
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
if (pDispatch != NULL)
{
VariantClear(&varResult);
pvars[0] = pHBmpThumbnail;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
pDispatch->Invoke(0x1, IID_NULL, LOCALE_USER_DEFAULT,
DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
}
}
delete[] pvars;
return varResult.scode;
}
};
Alexander Nickolov wrote:
While I don't know what you need, you can certainly use
connection points. Just be aware that source interfaces
are COM or Automation interfaces and obey the same rules,
e.g. you can't pass C++ objects through them.
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@mvps.org
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"Jenny" <jean.shu@gmail.com> wrote in message
news:1158254375.891874.16240@i42g2000cwa.googlegroups.com...
Hi,
Can I use connection point for this?
Alexander Nickolov wrote:
Expose COM objects from your application that delegate
to the appropriate internal classes to implement the functionality
your extension needs. You can't expose C++ classes through
COM.
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@mvps.org
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"Jenny" <jean.shu@gmail.com> wrote in message
news:1158195977.199042.81250@e3g2000cwe.googlegroups.com...
BTW, the COM component is to implement IExtractImage interface.
Jenny wrote:
Hi,
I need to build a shell extension(COM in proc server) which need to
access the object in MFC application.(e.g CView and CDocument
object).
The shell extension is called by the OS. How to pass these object
to
the ATL COM component? Thanks.