15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


HowTo: map events from an ocx placed in a CDialogBar.

Ola Theander -- olathean@kajen.com
Tuesday, November 12, 1996

Environment: VC++ 4.2b, MFC4.2b, Win 95

I have a problem. My application, which is a MDI application,  have a
toolbar based of CDialogBar type. This toolbar is created in
CMainFrame::OnCreate(), and it's a child of it. On this toolbar there is
a standard button (CButton) and an ocx, Microsoft Outline. The problem
is that i can't manage to map the events from the ocx to a function. I
managed to map the messages from the button to a function in CMainFrame,
by simply adding the proper rows to the generated messagemap of
CMainFrame.
But i can't find a similar solution for the ocx. What i did was to
insert a "event sink map" in the CMainFrame, like this:

BEGIN_EVENTSINK_MAP(CMainFrame, CMDIFrameWnd)
    //{{AFX_EVENTSINK_MAP(CMainFrame)
	ON_EVENT(CMainFrame, IDC_TREE, 3 /* DblClick */, OnDblClickTree,
VTS_NONE)
	ON_EVENT(CMainFrame, IDC_TREE, 6 /* Expand */, OnExpandTree, VTS_PI2)
	ON_EVENT(CMainFrame, IDC_TREE, -606 /* MouseMove */, OnMouseMoveTree,
VTS_I2 VTS_I2 VTS_I4 VTS_I4)
	//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

 but it didn't help. I've looked around a bit on the MSDN cd, but sofar
i haven't found anything to solve my problem.
The problem is somewhat that ClassWizard assumes that i want to map the
controls on the dialog template to a class derived from CDialog, which
isn't the case, since i only use the template to create the toolbar.
This means that useing the ordinary mapping functions doesn't work.

If anybody have any kind of tip that could help me solve thisone, i'll
be most grateful.

Kind regards, Ola Theadner



Shiva Shenoy -- shiva@wallop.com
Tuesday, November 12, 1996

Look at MS KB article Q14770: How to Handle Events for OLE
Controls in a Cwnd. It might help you...

-Shiva Shenoy
Wallop Software, Inc

>----------
>From: 	Ola Theander[SMTP:olathean@kajen.com]
>Sent: 	Monday, November 11, 1996 3:37 PM
>To: 	mfc-l@netcom.com
>Subject: 	HowTo: map events from an ocx placed in a CDialogBar.
>
>Environment: VC++ 4.2b, MFC4.2b, Win 95
>
>I have a problem. My application, which is a MDI application,  have a
>toolbar based of CDialogBar type. This toolbar is created in
>CMainFrame::OnCreate(), and it's a child of it. On this toolbar there
>is
>a standard button (CButton) and an ocx, Microsoft Outline. The problem
>is that i can't manage to map the events from the ocx to a function. I
>managed to map the messages from the button to a function in
>CMainFrame,
>by simply adding the proper rows to the generated messagemap of
>CMainFrame.
>But i can't find a similar solution for the ocx. What i did was to
>insert a "event sink map" in the CMainFrame, like this:
>
>BEGIN_EVENTSINK_MAP(CMainFrame, CMDIFrameWnd)
>    //{{AFX_EVENTSINK_MAP(CMainFrame)
>	ON_EVENT(CMainFrame, IDC_TREE, 3 /* DblClick */, OnDblClickTree,
>VTS_NONE)
>	ON_EVENT(CMainFrame, IDC_TREE, 6 /* Expand */, OnExpandTree, VTS_PI2)
>	ON_EVENT(CMainFrame, IDC_TREE, -606 /* MouseMove */, OnMouseMoveTree,
>VTS_I2 VTS_I2 VTS_I4 VTS_I4)
>	//}}AFX_EVENTSINK_MAP
>END_EVENTSINK_MAP()
>
> but it didn't help. I've looked around a bit on the MSDN cd, but sofar
>i haven't found anything to solve my problem.
>The problem is somewhat that ClassWizard assumes that i want to map the
>controls on the dialog template to a class derived from CDialog, which
>isn't the case, since i only use the template to create the toolbar.
>This means that useing the ordinary mapping functions doesn't work.
>
>If anybody have any kind of tip that could help me solve thisone, i'll
>be most grateful.
>
>Kind regards, Ola Theadner
>




| Вернуться в корень Архива |