# Override mouse events MapWinGis.ocx and Windows C++ application

**URL:** <https://mapwindow.discourse.group/t/override-mouse-events-mapwingis-ocx-and-windows-c-application/1233>\
**Category:** MapWinGIS\
**Created:** [February 8, 2022, 10:09am UTC](https://mapwindow.discourse.group/t/override-mouse-events-mapwingis-ocx-and-windows-c-application/1233 "2022-02-08T10:09:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mariusz](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@Mariusz](https://mapwindow.discourse.group/u/Mariusz)\
**Post date:** [February 8, 2022, 10:09am UTC](https://mapwindow.discourse.group/t/override-mouse-events-mapwingis-ocx-and-windows-c-application/1233/1 "2022-02-08T10:09:55Z")

</div>

Hello

Is it possible to override in c++ application mouse events?  
or even get selected layer, shape id, etc.?

example:

> **[MapWinGIS: EditAttributes.cs](https://www.mapwindow.org/documentation/mapwingis4.9/_edit_attributes_8cs-example.html)**
>
> MapWinGIS.ocx is used to provide GIS and mapping functionality to any Windows Forms based custom software application.

I see  
MapEvents.MouseDownEvent += …  
How does it in the c++ app?  
Do I have to catch MousEvents by myself in the c++ app?

Best Regards

---

<div class="post-metadata">

**Author:** ![jerryfaust](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/jerryfaust/32/378_2.png) [@jerryfaust](https://mapwindow.discourse.group/u/jerryfaust)\
**Post date:** [February 8, 2022, 7:10pm UTC](https://mapwindow.discourse.group/t/override-mouse-events-mapwingis-ocx-and-windows-c-application/1233/2 "2022-02-08T19:10:21Z")

</div>

Hello @Mariusz, and welcome.

Note that you will have to set the [SendMouseDown](https://www.mapwindow.org/documentation/mapwingis4.9/group __map__ interaction.html#gabdd3a82d13432eef94d063439ea3de91), SendMouseMove, and SendMouseUp properties = True for the OCX to generate mouse events.

Beyond that, what framework are you using in c++? Are you using MFC? Whatever framework you are using to load the OCX should expose the Map events for you to hook them.

Hope that helps.  
Regards,  
Jerry.

---

<div class="post-metadata">

**Author:** ![Mariusz](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@Mariusz](https://mapwindow.discourse.group/u/Mariusz)\
**Post date:** [February 9, 2022, 7:22am UTC](https://mapwindow.discourse.group/t/override-mouse-events-mapwingis-ocx-and-windows-c-application/1233/3 "2022-02-09T07:22:05Z")

</div>

Hello @jerryfaust

Thank you for your answer

Yes, I’m using MFC.

And I see now the CDMap class has not any Send… function.  
So it can be created without these functions?

In VS 2017 I have a “Cannot find coclass for interface \_DMapEvents” error  
But in VS 2019 it is created and looks like DMap class  
BOOL CDMapEvents::Create(…), CDMapEvents::MouseMove(…) etc.

The map is created by:  
mapWinGis.Create(NULL, WS\_VISIBLE, mapRect, this, IDC\_MAP);  
When I try to create CDMapEvents same way its fails.

Best Regards
