• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 406
  • Last Modified:

Catching mouse events from a dialog box child control

Urgent!
I would like to be able to catch a left mouse down ( or similar) events from a child control using a handler in the parent dialog box WITHOUT SUBCLASSING child control. For example, if I have a CMyDialog (derived from CDialog) dialog box with CEdit control on it and the user clicks on the edit control, CMyDialog would receive a notification about this event. The possibility to identify which control sent notification is very important.
0
polyanovsky
Asked:
polyanovsky
1 Solution
 
AndyAinscowCommented:
Override the PreTranslateMessage function and check for the mouse event there.
eg.

BOOL CMyDlg::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message == WM_LBUTTONDOWN)
{
//put your stuff here
long nID = ::GetDlgCtrlID(pMsg->hwnd);//this gives you the ID of the control - eg. IDC_EDIT1
}
}
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now