BOOL CTrayIconHooker::Init(CTrayNotifyIcon* pTrayIcon, CWindow* pNotifyWnd) #endif { //Validate our parameters ATLASSERT(pTrayIcon); //must have a valid tray notify instance #ifdef _AFX ATLASSERT(pNotifyWnd && ::IsWindow(pNotifyWnd->GetSafeHwnd())); #else ATLASSERT(pNotifyWnd && pNotifyWnd->IsWindow()); #endif //Hive away the input parameter m_pTrayIcon = pTrayIcon; //Hook the top level frame of the notify window in preference //to the notify window itself. This will ensure that we get //the taskbar created message #ifdef _AFX CWnd* pTopLevelWnd = pNotifyWnd->GetTopLevelFrame(); if (pTopLevelWnd) return SubclassWindow(pTopLevelWnd->operator HWND()); else return SubclassWindow(pNotifyWnd->GetSafeHwnd()); #else CWindow TopLevelWnd = pNotifyWnd->GetTopLevelWindow(); if (TopLevelWnd.IsWindow()) return SubclassWindow(TopLevelWnd.operator HWND()); else return SubclassWindow(pNotifyWnd->m_hWnd); #endif }
LRESULT CButtonST::OnMouseMove(UINT nFlags, CPoint point) { CWindow pWnd; // Active window CWindow pParent; // Window that owns the button DefWindowProc(); // If the mouse enter the button with the left button pressed then do nothing if ((nFlags & MK_LBUTTON) != 0 && !m_bMouseOnButton) { return 0; } // If our button is not flat then do nothing if (!m_bIsFlat) { return 0; }; pWnd = ::GetActiveWindow(); pParent = GetParent(); if ((::GetCapture() != m_hWnd) && ( #ifndef ST_LIKEIE pWnd.IsWindow() && #endif pParent.IsWindow())) { m_bMouseOnButton = true; SetCapture(); Invalidate(); } else { CPoint p2 = point; ClientToScreen(&p2); CWindow wndUnderMouse = ::WindowFromPoint(p2); if (wndUnderMouse && (wndUnderMouse.m_hWnd != m_hWnd)) { // Redraw only if mouse goes out if (m_bMouseOnButton) { m_bMouseOnButton = false; Invalidate(); } // If user is NOT pressing left button then release capture! if (!(nFlags & MK_LBUTTON)) { ReleaseCapture(); } } } return 0; }
HWND CLayoutControl::CalcRect( CWindow wndLayout, LPCRECT prcLayout, LPRECT prc ) { ATLASSERT( wndLayout.IsWindow() ); ATLASSERT( prcLayout != NULL ); ATLASSERT( prc != NULL ); // Retrieve the control's window handle CWindow wndControl = wndLayout.GetDlgItem( m_nID ); ATLASSERT( wndControl.IsWindow() ); // Get the control's current bounds CRect rcOld; wndControl.GetWindowRect(rcOld); wndLayout.ScreenToClient(rcOld); CopyRect( prc, rcOld ); if ( m_nAnchor & LAYOUT_ANCHOR_LEFT ) { prc->left = prcLayout->left + m_rcMargins.left; if ( !(m_nAnchor & LAYOUT_ANCHOR_RIGHT) ) prc->right = prc->left + rcOld.Width(); } if ( m_nAnchor & LAYOUT_ANCHOR_TOP ) { prc->top = prcLayout->top + m_rcMargins.top; if ( !(m_nAnchor & LAYOUT_ANCHOR_BOTTOM) ) prc->bottom = prc->top + rcOld.Height(); } if ( m_nAnchor & LAYOUT_ANCHOR_RIGHT ) { prc->right = prcLayout->right - m_rcMargins.right; if ( !(m_nAnchor & LAYOUT_ANCHOR_LEFT) ) prc->left = prc->right - rcOld.Width(); } if ( m_nAnchor & LAYOUT_ANCHOR_BOTTOM ) { prc->bottom = prcLayout->bottom - m_rcMargins.bottom; if ( !(m_nAnchor & LAYOUT_ANCHOR_TOP) ) prc->top = prc->bottom - rcOld.Height(); } return (HWND) wndControl; }
void OnSetFocus(HWND /*hWndOther*/) { //SetMsgHandled(false); CWindow activeWnd = m_tabbedChildWindow.GetActiveView(); if (activeWnd.IsWindow() && activeWnd.IsWindowVisible()) activeWnd.SetFocus(); int syncRepository = GetIConfig(QUERYBUILDER_CFG)->Get(GLOBAL_SYNCREPOSITORY); if (syncRepository) GetIMainFrame()->SyncTOC(m_dlgview.GetAttribute()); }
LRESULT CChildFrame::OnForwardMsg(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { LPMSG pMsg = (LPMSG)lParam; if (CMDIChildWindowImpl<CChildFrame>::PreTranslateMessage(pMsg) ) return TRUE; CWindow wndActive = GetSplitterPane(SPLIT_PANE_RIGHT); if (wndActive.IsWindow() ) { if ((wndActive == m_wndHexEdit) && m_wndHexEdit.PreTranslateMessage(pMsg) ) { return TRUE; } } return FALSE; }
//The following example attaches an HWND to the CWindow object and //calls CWindow::IsWindow() to verify if the HWND corresponds //to an existing window CWindow myWindow; myWindow.Attach(hWnd); BOOL bWindow = myWindow.IsWindow();