V
Vladimir Chtchetkine
Somehow no ListBox events are coming to me. I'm pretty sure that I register
for them right (basically it's the same code that I use for other types of
events that ARE coming) but for ListBox I get nothing. Is there anything
special that is need to subscribe to control events (comparing with other
Outlook objects)? Just in case here is source code (sorry for C++ and the
amount, but I exhausted all ideas and really need some help)
extern _ATL_FUNC_INFO OnFormListBoxBeforeDragOverInfo;
extern _ATL_FUNC_INFO OnFormListBoxBeforeDropOrPasteInfo;
extern _ATL_FUNC_INFO OnFormListBoxChangeInfo;
extern _ATL_FUNC_INFO OnFormListBoxClickInfo;
extern _ATL_FUNC_INFO OnFormListBoxDblClickInfo;
class ATL_NO_VTABLE COutlFormListBoxEvents :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<COutlFormListBoxEvents,
&CLSID_OutlFormListBoxEvents>,
public IDispatchImpl<IOutlFormListBoxEvents,
&IID_IOutlFormListBoxEvents, &LIBID_BrOutlLibLib, 1, 0>,
public
IDispEventSimpleImpl<1,COutlFormListBoxEvents,&__uuidof(MSFORMS::MdcListEven
ts)>
{
typedef IDispEventSimpleImpl<1,COutlFormListBoxEvents,
&__uuidof(MSFORMS::MdcListEvents)> COutlokEvents;
//---------------------------------------------------------------------
// Constructor and destructor
public:
COutlFormListBoxEvents();
~COutlFormListBoxEvents();
//---------------------------------------------------------------------
// ATL stuff
public:
DECLARE_REGISTRY_RESOURCEID(IDR_OUTLFORMLISTBOXEVENTS)
DECLARE_NOT_AGGREGATABLE(COutlFormListBoxEvents)
BEGIN_COM_MAP(COutlFormListBoxEvents)
COM_INTERFACE_ENTRY(IOutlFormListBoxEvents)
COM_INTERFACE_ENTRY2(IDispatch, IOutlFormListBoxEvents)
END_COM_MAP()
BEGIN_SINK_MAP(COutlFormListBoxEvents)
SINK_ENTRY_INFO(1,__uuidof(MSFORMS::MdcListEvents), 0x00000003,
OnFormListBoxBeforeDragOver, &OnFormListBoxBeforeDragOverInfo)
SINK_ENTRY_INFO(1,__uuidof(MSFORMS::MdcListEvents), 0x00000004,
OnFormListBoxBeforeDropOrPaste, &OnFormListBoxBeforeDropOrPasteInfo)
SINK_ENTRY_INFO(1,__uuidof(MSFORMS::MdcListEvents), 0x00000002,
OnFormListBoxChange, &OnFormListBoxChangeInfo)
SINK_ENTRY_INFO(1,__uuidof(MSFORMS::MdcListEvents), 0xfffffd9e,
OnFormListBoxClick, &OnFormListBoxClickInfo)
SINK_ENTRY_INFO(1,__uuidof(MSFORMS::MdcListEvents), 0xfffffda7,
OnFormListBoxDblClick, &OnFormListBoxDblClickInfo)
END_SINK_MAP()
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct();
void FinalRelease();
//---------------------------------------------------------------------
// Operations
public:
// Initialize object
HRESULT Initialize( MSFORMS::IMdcList* pListBox, class
COutlFormListBoxEventsCallback* pCallbackObj )
{
ATLASSERT(pListBoxCtl&&pCallbackObj);
m_spListBoxCtl = pListBoxCtl;
HRESULT hr =
COutlokEvents:ispEventAdvise((IDispatch*)m_spListBoxCtl);
REPORTHR(hr);
if( hr == S_OK )
{
m_pCallbackObj = pCallbackObj;
}
else
{
m_spListBoxCtl = NULL;
}
return hr;
}
//---------------------------------------------------------------------
// Interface
public:
// Stop event hooking
STDMETHOD(StopHooking)();
//---------------------------------------------------------------------
// Event handlers
protected:
void __stdcall OnFormListBoxBeforeDragOver( IUnknown* Cancel,
IUnknown* Data, float X, float Y, fmDragState DragState, IUnknown* Effect,
short Shift);
void __stdcall OnFormListBoxBeforeDropOrPaste( IUnknown* Cancel,
fmAction Action, IUnknown* Data, float X, float Y, IUnknown* Effect, short
Shift);
void __stdcall OnFormListBoxChange();
void __stdcall OnFormListBoxClick();
void __stdcall OnFormListBoxDblClick( IUnknown* Cancel);
protected:
CComPtr<MSFORMS::IMdcList> m_spListBoxCtl; // ListBox
object
COutlFormListBoxEventsCallback* m_pCallbackObj; // Callback
implementation
};
OBJECT_ENTRY_AUTO(__uuidof(OutlFormListBoxEvents), COutlFormListBoxEvents)
for them right (basically it's the same code that I use for other types of
events that ARE coming) but for ListBox I get nothing. Is there anything
special that is need to subscribe to control events (comparing with other
Outlook objects)? Just in case here is source code (sorry for C++ and the
amount, but I exhausted all ideas and really need some help)
extern _ATL_FUNC_INFO OnFormListBoxBeforeDragOverInfo;
extern _ATL_FUNC_INFO OnFormListBoxBeforeDropOrPasteInfo;
extern _ATL_FUNC_INFO OnFormListBoxChangeInfo;
extern _ATL_FUNC_INFO OnFormListBoxClickInfo;
extern _ATL_FUNC_INFO OnFormListBoxDblClickInfo;
class ATL_NO_VTABLE COutlFormListBoxEvents :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<COutlFormListBoxEvents,
&CLSID_OutlFormListBoxEvents>,
public IDispatchImpl<IOutlFormListBoxEvents,
&IID_IOutlFormListBoxEvents, &LIBID_BrOutlLibLib, 1, 0>,
public
IDispEventSimpleImpl<1,COutlFormListBoxEvents,&__uuidof(MSFORMS::MdcListEven
ts)>
{
typedef IDispEventSimpleImpl<1,COutlFormListBoxEvents,
&__uuidof(MSFORMS::MdcListEvents)> COutlokEvents;
//---------------------------------------------------------------------
// Constructor and destructor
public:
COutlFormListBoxEvents();
~COutlFormListBoxEvents();
//---------------------------------------------------------------------
// ATL stuff
public:
DECLARE_REGISTRY_RESOURCEID(IDR_OUTLFORMLISTBOXEVENTS)
DECLARE_NOT_AGGREGATABLE(COutlFormListBoxEvents)
BEGIN_COM_MAP(COutlFormListBoxEvents)
COM_INTERFACE_ENTRY(IOutlFormListBoxEvents)
COM_INTERFACE_ENTRY2(IDispatch, IOutlFormListBoxEvents)
END_COM_MAP()
BEGIN_SINK_MAP(COutlFormListBoxEvents)
SINK_ENTRY_INFO(1,__uuidof(MSFORMS::MdcListEvents), 0x00000003,
OnFormListBoxBeforeDragOver, &OnFormListBoxBeforeDragOverInfo)
SINK_ENTRY_INFO(1,__uuidof(MSFORMS::MdcListEvents), 0x00000004,
OnFormListBoxBeforeDropOrPaste, &OnFormListBoxBeforeDropOrPasteInfo)
SINK_ENTRY_INFO(1,__uuidof(MSFORMS::MdcListEvents), 0x00000002,
OnFormListBoxChange, &OnFormListBoxChangeInfo)
SINK_ENTRY_INFO(1,__uuidof(MSFORMS::MdcListEvents), 0xfffffd9e,
OnFormListBoxClick, &OnFormListBoxClickInfo)
SINK_ENTRY_INFO(1,__uuidof(MSFORMS::MdcListEvents), 0xfffffda7,
OnFormListBoxDblClick, &OnFormListBoxDblClickInfo)
END_SINK_MAP()
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct();
void FinalRelease();
//---------------------------------------------------------------------
// Operations
public:
// Initialize object
HRESULT Initialize( MSFORMS::IMdcList* pListBox, class
COutlFormListBoxEventsCallback* pCallbackObj )
{
ATLASSERT(pListBoxCtl&&pCallbackObj);
m_spListBoxCtl = pListBoxCtl;
HRESULT hr =
COutlokEvents:ispEventAdvise((IDispatch*)m_spListBoxCtl);
REPORTHR(hr);
if( hr == S_OK )
{
m_pCallbackObj = pCallbackObj;
}
else
{
m_spListBoxCtl = NULL;
}
return hr;
}
//---------------------------------------------------------------------
// Interface
public:
// Stop event hooking
STDMETHOD(StopHooking)();
//---------------------------------------------------------------------
// Event handlers
protected:
void __stdcall OnFormListBoxBeforeDragOver( IUnknown* Cancel,
IUnknown* Data, float X, float Y, fmDragState DragState, IUnknown* Effect,
short Shift);
void __stdcall OnFormListBoxBeforeDropOrPaste( IUnknown* Cancel,
fmAction Action, IUnknown* Data, float X, float Y, IUnknown* Effect, short
Shift);
void __stdcall OnFormListBoxChange();
void __stdcall OnFormListBoxClick();
void __stdcall OnFormListBoxDblClick( IUnknown* Cancel);
protected:
CComPtr<MSFORMS::IMdcList> m_spListBoxCtl; // ListBox
object
COutlFormListBoxEventsCallback* m_pCallbackObj; // Callback
implementation
};
OBJECT_ENTRY_AUTO(__uuidof(OutlFormListBoxEvents), COutlFormListBoxEvents)