Cheok Yan Cheng
Cheok Yan Cheng

Reputation: 42700

Get mouse clicked component

Current, I have a parent CWnd, which is displaying many other child CWnds. All my message handling job are being done in parent CWnd, as I do not have access to child CWnds' code.

I wish to know which child CWnds is being clicked.

I can detect the right click

afx_msg void OnContextMenu(
   CWnd* pWnd,
   CPoint pos 
);

pWnd will be the clicked child window.

However, how about left click? I know I can get the mouse coordinate, and perform some calculation accordingly to iterate through see which child CWnds falll into the point. However, I just don't want to go through all this. I which I can have something like.

CWnd* childWind = mouseEvent.getParent();

Upvotes: 0

Views: 287

Answers (1)

Cheok Yan Cheng
Cheok Yan Cheng

Reputation: 42700

CWnd* me = ChildWindowFromPoint(point);

Upvotes: 1

Related Questions