键盘光标:
CWnd *pWnd = GetFocus();
if (pWnd == NULL)
;//no focus
else
nID = pWnd->GetDlgCtrlID();//获取键盘光标所在控件的ID
if (pWnd == NULL)
;//no focus
else
nID = pWnd->GetDlgCtrlID();//获取键盘光标所在控件的ID
鼠标光标:
CPoint point;//定义一个用于确定光标位置的位置
GetCursorPos(&point);//获取当前光标的位置,以便使得菜单可以跟随光标
GetCursorPos(&point);//获取当前光标的位置,以便使得菜单可以跟随光标
ScreenToClient(&point);
//得到窗体的控件句柄
CWnd* hControlWnd = (CWnd*)ChildWindowFromPoint(point);
UINT nID = hControlWnd->GetDlgCtrlID();
//得到窗体的控件句柄
CWnd* hControlWnd = (CWnd*)ChildWindowFromPoint(point);
UINT nID = hControlWnd->GetDlgCtrlID();