How to know the ID of the control who received an event

Posted on 2000-05-13
Last Modified: 2013-11-20

I have placed some ActiveX controls in a Dialog Resource. Those controls have to make some actions when the mouse is over or has clicked on it. I'm planning to use only 1 event handler to accomplish the actions for all controls so I need to know the ID of the control who has thrown the event.

How can I do it?
Thanks in advance

Question by:demarcy
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment

Accepted Solution

VinExpert earned 50 total points
ID: 2807914

Map the PreTranslateMessage(...) message handler to that dialog. And modify the code as

BOOL CMyDlg::PreTranslateMessage(MSG* pMsg)
      if(pMsg->message == WM_MOUSEMOVE)
            CRect rect;
                  AfxMessageBox("Mouse On The Edit Box");
                  return CDialog::PreTranslateMessage(pMsg);
                  AfxMessageBox("Mouse On The List Box");
                  return CDialog::PreTranslateMessage(pMsg);

                  AfxMessageBox("Mouse On The DB Grid Box");
                  return CDialog::PreTranslateMessage(pMsg);

                  AfxMessageBox("Mouse On The OK Button");
                  return CDialog::PreTranslateMessage(pMsg);

      return CDialog::PreTranslateMessage(pMsg);

here I have taken some normal controls and a activex dbgrid control. U can make out by thier ID. But here U R not getting the ID's but, u will know where the mouse is. So u can replace the AfxMessageBox() with Ur function call and their U know the id also as if it says I am in DBGrid, then ID is known as ID_MY_DBGRID.

Hope this helps.


Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question