05. september 2002 - 10:18
Der er
1 løsning
SendMessage
hejsa Jeg vil godt lave noget sjov med sendmessage som skulle kunne virke til både 98,2000,xp. Er der nogle som kan finde på en god ide til hvad man kunne gøre?? F.eks noget med at ændre noget på et windue, eller nogle proberties....
Annonceindlæg fra SoftwareOne
05. september 2002 - 11:37
#1
Et lille udpluk fra et program jeg har lavet, måske du kan bruge det til noget... (Koden er i MFC) void CInfiltratorDlg::OnLButtonDown(UINT nFlags, CPoint point) { CWnd* pWnd = ChildWindowFromPoint(point); if(pWnd && pWnd->GetSafeHwnd() == m_stcIconHolder.GetSafeHwnd()) { SetCapture(); SetCursor(m_hFindCursor); m_stcIconHolder.SetIcon(m_hBlankIcon); m_bIsCapturing = true; } CDialog::OnLButtonDown(nFlags, point); } void CInfiltratorDlg::OnLButtonUp(UINT nFlags, CPoint point) { if(m_bIsCapturing) { ReleaseCapture(); m_bIsCapturing = false; SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); m_stcIconHolder.SetIcon(m_hFindIcon); } CDialog::OnLButtonUp(nFlags, point); } void CInfiltratorDlg::OnMouseMove(UINT nFlags, CPoint point) { if(m_bIsCapturing) { ClientToScreen(&point); m_strXYPos.Format("X=%ld, Y=%ld", point.x, point.y); m_strWndName = ""; m_strWndHandle = _T(""); m_strWndClass = _T(""); m_pFoundWnd = CWnd::WindowFromPoint(point); m_hFoundWnd = m_pFoundWnd->GetSafeHwnd(); if(m_pFoundWnd) { // Make sure that the window doesn't 'belong' to us if((::GetWindowThreadProcessId(GetSafeHwnd(), NULL)) != (::GetWindowThreadProcessId(m_hFoundWnd, NULL))) { if(m_pFoundWnd && m_pFoundWnd != m_pFoundWnd && ::IsWindow(m_hFoundWnd)) { //m_pFoundWnd->Invalidate(); m_pFoundWnd->UpdateWindow(); m_pFoundWnd->FlashWindow(TRUE); m_pFoundWnd->FlashWindow(FALSE); //::SendMessage(m_hFoundWnd, WM_PAINT, NULL, NULL); } CRect WindowRect; m_pFoundWnd->GetWindowRect(&WindowRect); WindowRect.OffsetRect(-WindowRect.left, -WindowRect.top); m_pFoundWnd->GetDC()->FrameRect(WindowRect, &m_BlackBrush); m_strWndHandle.Format("%ld", m_hFoundWnd); // Get the class name char lpClassName[255]; if(::GetClassName(m_hFoundWnd, lpClassName, 255)) { m_strWndClass = lpClassName; m_strWndClass.MakeUpper(); char szText[255]; ::SendMessage(m_hFoundWnd, WM_GETTEXT, 255, (LPARAM)szText); m_strWndName = szText; /*if(m_strWndClass == "BUTTON") { //((CButton*)m_pFoundWnd)->GetBitmap(); HBITMAP hBmp = ::LoadBitmap(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDB_BITMAP)); ((CButton*)m_pFoundWnd)->SetBitmap(::LoadBitmap(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDB_BITMAP))); }*/ } } UpdateData(false); } } CDialog::OnMouseMove(nFlags, point); } void CInfiltratorDlg::OnSetWindowName() { UpdateData(true); ::SendMessage(m_hFoundWnd, WM_SETTEXT, 0, (LPARAM)(LPCTSTR)m_strWndName); }