C++ 跨应用程序发送消息
程序员文章站
2022-07-06 16:19:50
...
void CDemoDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
if(point.x >= m_rtCtrl.left && point.x <= m_rtCtrl.right
|| point.y >= m_rtCtrl.top && point.y <= m_rtCtrl.bottom)
{
m_bCapturing = TRUE;
SetCapture();
SetCursor(m_hCursor);
}
CDialogEx::OnLButtonDown(nFlags, point);
}
void CDemoDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
if(m_bCapturing)
{
ReleaseCapture();
m_bCapturing = FALSE;
POINT pt = point;
ClientToScreen(&pt);
m_hwndDest = ::WindowFromPoint(pt);
TCHAR szBuf[MAX_PATH] = {0};
_stprintf(szBuf,_T("0x%.8X"),m_hwndDest);
SetDlgItemText(IDC_EDT_HWND, szBuf);
GetClassName(m_hwndDest,szBuf,MAX_PATH);
SetDlgItemText(IDC_EDT_CLASS,szBuf);
::SendMessage(m_hwndDest,WM_GETTEXT, MAX_PATH,(LPARAM)szBuf);
SetDlgItemText(IDC_EDT_TEXT,szBuf);
}
CDialogEx::OnLButtonUp(nFlags, point);
}
void CDemoDlg::OnBnClickedBtnSettext()
{
// TODO: 在此添加控件通知处理程序代码
CString str;
GetDlgItemText(IDC_EDT_TEXT,str);
::SendMessage(m_hwndDest,WM_SETTEXT,0,(LPARAM)(LPCTSTR)str);
}
void CDemoDlg::OnBnClickedBtnClose()
{
// TODO: 在此添加控件通知处理程序代码
::SendMessage(m_hwndDest,WM_CLOSE,0,0);
}