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

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


CFormView not seeing control event

Ed Jennings -- edj@whidbey.com
Tuesday, April 30, 1996

I am using VC++ 4.1 on Win NT 3.51.
I have used Control Wizard to generate an OLE control.
I have used the OLE Events tab of Class Wizard to add the standard
MouseDown stock event to my control.

To make my control container application I have:

  - used AppWizard to generate a SDI application that contains a
    CFormView class 

  - used Insert Component to get VC++ to generate the files with
    the IDispatch wrapper class so my control can be accessed.

  - used the Message Maps tab of Class Wizard to get an event map
    sink and event handler generated for the MouseDown event of
    my control.

Here's what gets inserted in my control container app by Class
Wizard:

  BEGIN_EVENTSINK_MAP(CFv1View, CFormView)
    //{{AFX_EVENTSINK_MAP(CFv1View)
	ON_EVENT(CFv1View, IDC_AC1CTRL1, -605 /* MouseDown */,
                           OnMouseDownAc1ctrl1,
                           VTS_I2 VTS_I2 VTS_I4 VTS_I4)
	//}}AFX_EVENTSINK_MAP
  END_EVENTSINK_MAP()

void CFv1View::OnMouseDownAc1ctrl1(short Button, short Shift, long x, long y) 
{
	// TODO: Add your control notification handler code here
}

The control gets created in the control container app when the user
picks a menu item. This creation is done by calling the wrapper
class Create() which in turn calls CreateControl().

When the cursor is positioned over my control and the mouse is
pressed down my control container application's CFormView's
OnMouseDownAc1ctrl1 function never gets called. I have also tried
making the MouseDown a custom event in my control and this does not
work either. I have verified that the FireMouseDown() is called from
my control when I made the MouseDown a custom event.

Why isn't my control container's OnMouseDownAc1ctrl1() getting
called?

Any suggestions to what I might be doing wrong would be greatly
appreciated.

Thanks.

- Ed

=====================================================
  Ed Jennings               Email : edj@whidbey.com
  Jennings & Associates
  6215 S. Windfall Rd.      Voice : 360-341-3868
  Clinton, WA 98236
=====================================================




Mike Blaszczak -- mikeblas@interserv.com
Wednesday, May 01, 1996

[Mini-digest: 2 responses]

On Tue, 30 Apr 1996, Ed Jennings  wrote:
>I am using VC++ 4.1 on Win NT 3.51.

Thanks.

>Why isn't my control container's OnMouseDownAc1ctrl1() getting
>called?

Maybe you didn't create the control the same ID you used in the EVENT_SINK() 
map.  You said you coded

>	ON_EVENT(CFv1View, IDC_AC1CTRL1, -605 /* MouseDown */,

if you didn't call Create() to make the control to be IDC_AC1CTRL1, MFC will 
not be able to match the event notification from the control to the entry in 
the map.

>Any suggestions to what I might be doing wrong would be greatly
>appreciated.

If you insert your control in the Test Container and use the event log, are 
the events found by the Test Container as you would expect?

>  Clinton, WA 98236

Three weekends ago, I went through that town.  What do the police cars look 
like in that part of Washington?  I never speed, but it's always nice to 
know.

.B ekiM
--
TCHAR szDisc[] = _T("These words are my own; I do not speak for Microsoft.");

-----From: Mark Kramer 

Ed -

Check to make sure that the ID you give the control in the Create()
function is
the same ID that you have in the event map.

Mark





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