//**************************************************************************************** void CBCGPToolbarSystemMenuButton::OnDblClick (CWnd* pWnd) { if (CBCGPToolBar::IsCustomizeMode ()) { return; } ASSERT (pWnd != NULL); ////////////////////////////////////////////// // Make sure to close the popup menu and // find the MDI frame correctly. //-------------------------------------------- OnCancelMode (); CFrameWnd* pParentFrame = BCGPGetParentFrame (pWnd); if(pParentFrame != NULL && pParentFrame->IsKindOf (RUNTIME_CLASS (CMiniDockFrameWnd))) { pParentFrame = (CFrameWnd*) pParentFrame->GetParent (); } CMDIFrameWnd* pMDIFrame = DYNAMIC_DOWNCAST (CMDIFrameWnd, pParentFrame); if (pMDIFrame != NULL) { CMDIChildWnd* pChild = pMDIFrame->MDIGetActive (); ASSERT_VALID (pChild); BOOL bCloseIsDisabled = FALSE; CMenu* pSysMenu = pChild->GetSystemMenu (FALSE); if (pSysMenu != NULL) { MENUITEMINFO menuInfo; ZeroMemory(&menuInfo,sizeof(MENUITEMINFO)); menuInfo.cbSize = sizeof(MENUITEMINFO); menuInfo.fMask = MIIM_STATE; pSysMenu->GetMenuItemInfo (SC_CLOSE, &menuInfo); bCloseIsDisabled = ((menuInfo.fState & MFS_GRAYED) || (menuInfo.fState & MFS_DISABLED)); } if (!bCloseIsDisabled) { pChild->SendMessage (WM_SYSCOMMAND, SC_CLOSE); } } //-------------------------------------------- ////////////////////////////////////////////// }
//********************************************************************************** void CToolPalette::OnSize(UINT nType, int cx, int cy) { CBCGPBaseToolBar::OnSize (nType, cx, cy); if (IsCustomizeMode () && !m_bLocked) { OnCancelMode (); } if (!m_bInUpdateShadow) { AdjustLocations (); } }
void Window::SetEnabled(bool enabled) { AssertThread(); if (enabled == this->enabled) return; if (!enabled) /* cancel dragging before disabling this Window */ OnCancelMode(); this->enabled = enabled; Invalidate(); }
void TopWindow::CancelMode() { OnCancelMode(); }
LRESULT Window::OnMessage(HWND _hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_CREATE: OnCreate(); return 0; case WM_DESTROY: OnDestroy(); return 0; case WM_SIZE: OnResize({LOWORD(lParam), HIWORD(lParam)}); return 0; case WM_MOUSEMOVE: if (OnMouseMove(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), wParam)) return 0; break; case WM_LBUTTONDOWN: if (OnMouseDown(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) { /* true returned: message was handled */ ResetUserIdle(); return 0; } break; case WM_LBUTTONUP: if (OnMouseUp(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) { /* true returned: message was handled */ ResetUserIdle(); return 0; } break; case WM_LBUTTONDBLCLK: if (!double_clicks) /* instead of disabling CS_DBLCLKS (which would affect all instances of a window class), we just translate WM_LBUTTONDBLCLK to WM_LBUTTONDOWN here; this even works for built-in window class such as BUTTON */ return OnMessage(_hWnd, WM_LBUTTONDOWN, wParam, lParam); if (OnMouseDouble(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) { /* true returned: message was handled */ ResetUserIdle(); return 0; } break; #ifdef WM_MOUSEWHEEL case WM_MOUSEWHEEL: if (OnMouseWheel(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), GET_WHEEL_DELTA_WPARAM(wParam))) { /* true returned: message was handled */ ResetUserIdle(); return 0; } break; #endif case WM_KEYDOWN: if (OnKeyDown(wParam)) { /* true returned: message was handled */ ResetUserIdle(); return 0; } break; case WM_KEYUP: if (OnKeyUp(wParam)) { /* true returned: message was handled */ ResetUserIdle(); return 0; } break; case WM_CHAR: if (OnCharacter((TCHAR)wParam)) /* true returned: message was handled */ return 0; break; case WM_COMMAND: if (OnCommand(LOWORD(wParam), HIWORD(wParam))) { /* true returned: message was handled */ ResetUserIdle(); return 0; } break; case WM_CANCELMODE: OnCancelMode(); /* pass on to DefWindowProc(), there may be more to do */ break; case WM_SETFOCUS: OnSetFocus(); /* pass on to DefWindowProc() so the underlying window class knows it's focused */ break; case WM_KILLFOCUS: OnKillFocus(); /* pass on to DefWindowProc() so the underlying window class knows it's not focused anymore */ break; case WM_TIMER: if (OnTimer(*(WindowTimer *)wParam)) return 0; break; case WM_PAINT: if (custom_painting) { PaintCanvas canvas(*this); OnPaint(canvas, canvas.get_dirty()); return 0; } break; case WM_GETDLGCODE: if (OnKeyCheck(wParam)) return DLGC_WANTMESSAGE; break; } if (message >= WM_USER && message <= 0x7FFF && OnUser(message - WM_USER)) return 0; return OnUnhandledMessage(_hWnd, message, wParam, lParam); }
//*********************************************************************************************************** BOOL CBCGPBaseVisualCtrl::PreTranslateMessage(MSG* pMsg) { switch (pMsg->message) { case WM_KEYDOWN: case WM_SYSKEYDOWN: case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: case WM_MBUTTONDOWN: case WM_LBUTTONUP: case WM_RBUTTONUP: case WM_MBUTTONUP: case WM_NCLBUTTONDOWN: case WM_NCRBUTTONDOWN: case WM_NCMBUTTONDOWN: case WM_NCLBUTTONUP: case WM_NCRBUTTONUP: case WM_NCMBUTTONUP: case WM_MOUSEMOVE: if (m_pToolTip->GetSafeHwnd () != NULL) { m_pToolTip->RelayEvent(pMsg); } } switch (pMsg->message) { case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: case WM_MBUTTONDOWN: if (pMsg->hwnd == GetSafeHwnd()) { if (!m_bIsPopup) { SetFocus(); } CPoint pt (BCG_GET_X_LPARAM(pMsg->lParam), BCG_GET_Y_LPARAM(pMsg->lParam)); if (OnMouseDown(pMsg->message == WM_LBUTTONDOWN ? 0 : pMsg->message == WM_RBUTTONDOWN ? 1 : 2, pt)) { #if !defined _BCGPCHART_STANDALONE if (CBCGPPopupMenu::GetActiveMenu() != NULL && ::IsWindow (CBCGPPopupMenu::GetActiveMenu()->m_hWnd)) { CBCGPPopupMenu::GetActiveMenu()->SendMessage (WM_CLOSE); } #endif SetCapture(); m_bIsCaptured = TRUE; StartClickAndHold(); return TRUE; } } break; case WM_LBUTTONUP: case WM_RBUTTONUP: case WM_MBUTTONUP: if (pMsg->hwnd == GetSafeHwnd()) { CPoint pt (BCG_GET_X_LPARAM(pMsg->lParam), BCG_GET_Y_LPARAM(pMsg->lParam)); OnMouseUp(pMsg->message == WM_LBUTTONUP ? 0 : pMsg->message == WM_RBUTTONUP ? 1 : 2, pt); if (m_bIsCaptured) { ReleaseCapture(); m_bIsCaptured = FALSE; } StopClickAndHold(); } break; case WM_LBUTTONDBLCLK: case WM_RBUTTONDBLCLK: case WM_MBUTTONDBLCLK: if (pMsg->hwnd == GetSafeHwnd()) { CPoint pt (BCG_GET_X_LPARAM(pMsg->lParam), BCG_GET_Y_LPARAM(pMsg->lParam)); OnMouseDblClick(pMsg->message == WM_LBUTTONDBLCLK ? 0 : pMsg->message == WM_RBUTTONDBLCLK ? 1 : 2, pt); } break; case WM_MOUSEWHEEL: { CPoint pt (BCG_GET_X_LPARAM(pMsg->lParam), BCG_GET_Y_LPARAM(pMsg->lParam)); CWnd* pWnd = CWnd::FromHandle (pMsg->hwnd); if (pWnd != NULL) { pWnd->ScreenToClient(&pt); } if (OnMouseWheel(pt, HIWORD(pMsg->wParam))) { if (m_pToolTip->GetSafeHwnd () != NULL) { m_pToolTip->Pop(); } return TRUE; } } break; case WM_MOUSEMOVE: { CPoint pt (BCG_GET_X_LPARAM(pMsg->lParam), BCG_GET_Y_LPARAM(pMsg->lParam)); OnMouseMove(pt); if (!m_bIsTracked) { m_bIsTracked = TRUE; TRACKMOUSEEVENT trackmouseevent; trackmouseevent.cbSize = sizeof(trackmouseevent); trackmouseevent.dwFlags = TME_LEAVE; trackmouseevent.hwndTrack = GetSafeHwnd(); trackmouseevent.dwHoverTime = HOVER_DEFAULT; ::BCGPTrackMouse (&trackmouseevent); } if (m_pToolTip->GetSafeHwnd () != NULL) { CString strToolTip; CString strDescr; OnGetToolTip(pt, strToolTip, strDescr); if (strToolTip != m_strLastDisplayedToolTip || strDescr != m_strLastDisplayedToolTipDescr) { if (m_bTooltipTrackingMode) { m_pToolTip->Update(); } else { m_pToolTip->Pop (); } if (!strToolTip.IsEmpty() && !strDescr.IsEmpty()) { m_bToolTipCleared = TRUE; } } } } break; case WM_CANCELMODE: if (m_bIsCaptured) { ReleaseCapture(); m_bIsCaptured = FALSE; OnCancelMode(); } StopClickAndHold(); break; case WM_KEYDOWN: if (pMsg->wParam == VK_ESCAPE) { if (OnKeyboardDown((UINT)pMsg->wParam, (pMsg->lParam & 0xFFFF), 0)) { return TRUE; } } break; case WM_TIMER: if (pMsg->hwnd == GetSafeHwnd() && pMsg->wParam == GetClickAndHoldID()) { CPoint point; ::GetCursorPos (&point); ScreenToClient (&point); if (GetClickAndHoldRect().PtInRect(point)) { OnClickAndHoldEvent(GetClickAndHoldID(), point); return TRUE; } } break; } return CStatic::PreTranslateMessage(pMsg); }