CWnd* CTxMsgListView::pomGetParentWindow() const { CWnd* pWnd = nullptr; // Get Splitter window pointer pWnd = GetParent(); // Get Tx Msg Child Window pointer from Splitter window pointer // At fourth Level // Splitter 3 -> Splitter 2 -> Splitter 1 -> Child Frame if( pWnd != nullptr ) { pWnd = pWnd->GetParent(); } if( pWnd != nullptr ) { pWnd = pWnd->GetParent(); } if( pWnd != nullptr ) { pWnd = pWnd->GetParent(); } // Return Tx Msg Child window pointer or nullptr incase of failure return pWnd; }
BOOL CMyDrawPictureClass::PreTranslateMessage(MSG* pMsg) { // TODO: 在此添加专用代码和/或调用基类 if(pMsg->message==WM_LBUTTONDOWN&&m_IsPicLoaded) { CWnd * hwnd; POINT pointGetCtl; GetCursorPos(&pointGetCtl); hwnd= (CWnd *)WindowFromPoint(pointGetCtl); while (hwnd && hwnd->GetParent()!=this) hwnd = hwnd->GetParent(); if(GetDlgItem(IDC_STATIC_BASECOLOR1)==hwnd) { if(!m_IsMakePic) { m_OldSursor = ::GetCursor(); m_IsMakePic= true; } } else { if(m_IsMakePic) { ::SetCursor(m_OldSursor); m_IsMakePic = false; COLORREF color; color = ::GetPixel(::GetDC(NULL),pMsg->pt.x,pMsg->pt.y); CString wndColor=_T("0"); wndColor.Format(_T("%x"),color); m_BaseColor1.SetBkColor(color); wndColor.MakeUpper(); this->GetDlgItem(IDC_EDIT_COLOR1)->SetWindowTextW(wndColor); ////////设置前台色/////////////////// m_ForegroundColor = color; m_IsPicLoaded = true; drawPicture(); } } } return CMFCPropertyPage::PreTranslateMessage(pMsg); }
void CColumnResizer::MoveWnd(int WndIdx, int x, int Width) { static const LMARGIN = -2; static const RMARGIN = 4; ASSERT(WndIdx >= 0 && WndIdx <= m_Parent.WndIdx); if (WndIdx == m_Parent.WndIdx) x -= GetHScroll(); else { x += LMARGIN; Width = Width - (LMARGIN + RMARGIN); } int Rows = m_WndList == NULL ? GetRowCount() : 1; for (int i = 0; i < Rows; i++) { CRect r; CWnd *wp = m_WndList == NULL ? GetWndList(i)[WndIdx] : m_WndList[WndIdx]; wp->GetWindowRect(r); wp->GetParent()->ScreenToClient(r); int PrevWidth = r.Width(); r.left = x; r.right = x + Width; wp->MoveWindow(r); // if control width changed, must invalidate, otherwise certain control // types paint incorrectly, e.g. static control with horiz. centered text if (r.Width() != PrevWidth && WndIdx != m_Parent.WndIdx) wp->Invalidate(FALSE); } }
BOOL COutputView::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) { //let the trl to route command CWnd* pFocus = GetFocus(); if (pFocus) { CWnd* pParent = pFocus->GetParent(); if (pFocus == &m_progressWnd || pParent == &m_progressWnd ) { if (m_progressWnd.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) return TRUE; } if (pFocus == &m_messageWnd || pParent == &m_messageWnd) { if (m_messageWnd.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) return TRUE; } } return CView::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo); }
void CLryEDBQryView::OnContextMenu(CWnd* pWnd, CPoint point) { // TODO: Add your message handler code here CMenu Menu; CMenu *pMenu; Menu.LoadMenu(IDR_POPUP_E_DATABASE); pMenu = Menu.GetSubMenu(0); if(pReportdlg.m_hWnd==NULL) { pMenu->EnableMenuItem(ID_FILE_PRINT_PREVIEW,MF_DISABLED|MF_GRAYED|MF_BYCOMMAND); pMenu->EnableMenuItem(ID_PRINT_REPORT_SETTING,MF_DISABLED|MF_GRAYED|MF_BYCOMMAND); pMenu->EnableMenuItem(ID_FILE_PRINT_PREVIEW,MF_DISABLED|MF_GRAYED|MF_BYCOMMAND); } CRect rect; CPoint pt; GetClientRect(&rect); pt = point; ScreenToClient(&pt); CWnd *pOwner = this; while(pOwner->GetStyle()&WS_CHILD) { pOwner = pOwner->GetParent(); } if(PtInRect(rect,pt)) pMenu->TrackPopupMenu(TPM_LEFTALIGN,point.x,point.y,pOwner); //弹出自己的右键菜单 else CXTListView::OnContextMenu(pWnd,point); //弹出默认的滚动条菜单 }
BOOL CProgressWnd::GoModal(LPCTSTR pszTitle /*=_T("Progress")"*/, BOOL bSmooth /*=FALSE*/) { CWnd *pMainWnd = AfxGetMainWnd(); if (!::IsWindow(m_hWnd) && !Create(pMainWnd, pszTitle, bSmooth)) return FALSE; // Walk up the window chain to find the main parent wnd and disable it. CWnd * wnd = this; do { CWnd * parent = wnd->GetParent(); // if we have no parent (ie. the main window) // or if our parent is disabled, // then this is the window that we will want to remember for reenabling if (!parent || !parent->IsWindowEnabled()) { m_wRenenableWnd = wnd; m_wRenenableWnd->EnableWindow(false); break; } wnd = parent; } while (1); // Re-enable this window EnableWindow(TRUE); m_bModal = TRUE; return TRUE; }
void COleControl::DestroyTracker() { ASSERT(!m_bOpen); ASSERT(m_bUIActive); if (m_pRectTracker == NULL) return; UINT nHandleSize = m_pRectTracker->m_nHandleSize - 1; // Destroy the tracker. delete m_pRectTracker; m_pRectTracker = NULL; // Restore window to its original (pre-UIActive) size. CWnd* pWndOuter = GetOuterWindow(); CWnd* pWndParent = pWndOuter->GetParent(); CRect rectWindow; CRect rectParent; pWndOuter->GetWindowRect(rectWindow); pWndParent->GetClientRect(rectParent); pWndParent->ClientToScreen(rectParent); rectWindow.OffsetRect(-rectParent.left, -rectParent.top); rectWindow.InflateRect(-(int)nHandleSize, -(int)nHandleSize); ::MoveWindow(pWndOuter->m_hWnd, rectWindow.left, rectWindow.top, rectWindow.Width(), rectWindow.Height(), TRUE); }
BOOL CChildWnd::TestPoint(const CPoint& ptScreen) { CWnd* pHit = WindowFromPoint( ptScreen ); if ( pHit == NULL ) return FALSE; if ( pHit == this ) return TRUE; if ( ! IsWindow( pHit->m_hWnd ) || ! IsWindow( GetSafeHwnd() ) ) return FALSE; if ( ::GetAncestor( pHit->m_hWnd, GA_ROOT ) != ::GetAncestor( GetSafeHwnd(), GA_ROOT ) ) return FALSE; CPoint ptChild( ptScreen ); pHit->ScreenToClient( &ptChild ); CWnd* pChild = pHit->ChildWindowFromPoint( ptChild, CWP_SKIPINVISIBLE ); if ( pChild == NULL ) pChild = pHit; while ( pChild != NULL ) { if ( pChild == this ) return TRUE; pChild = pChild->GetParent(); } return FALSE; }
BOOL CPageLangDisplay::OnInitDialog() { // if we're not in a wizard, we want the abrev box uneditable // However, I can't get it to display correctly, even with this // code; it always looks editable. I've also tried doing this // at ddx time, no difference, and tried with WS_DISABLED. // // Also tried putting this in OnCreate, but I couldn't get a // handle to the CEDit at that time CPropertyPage::OnInitDialog(); if(m_bAbrevIsReadOnly) { CWnd *pWnd = GetDlgItem(IDC_EDITAbrev); ::SendMessage(pWnd->m_hWnd, EM_SETREADONLY, (WPARAM)TRUE, 0); // pWnd->ModifyStyle(NULL , ES_READONLY); pWnd->Invalidate(); pWnd->GetParent()->Invalidate(); Invalidate(); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void CTimeAxis::OnRButtonUp(UINT nFlags, CPoint point) { m_bRBtnDown = FALSE; ReleaseCapture(); CSize sz = point - m_ptTimeR; if ((sz.cx < 3 && sz.cx > -3) && (sz.cy < 3 && sz.cy > -3)) // 单击 { CMenu menu; VERIFY(menu.LoadMenu(IDR_MENU_TIMEAXIS)); CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); CWnd* pWndPopupOwner = this; while (pWndPopupOwner->GetStyle() & WS_CHILD) pWndPopupOwner = pWndPopupOwner->GetParent(); ClientToScreen(&point); pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner); } // CStatic::OnRButtonUp(nFlags, point); }
void CCJControlBar::OnContextMenu(CWnd* /*pWnd*/, CPoint point) { // if no menu, just return. if (m_menuID == 0 ) { TRACE0("No control bar menu defined.\n"); return; } if (point.x == -1 && point.y == -1) { //keystroke invocation CRect rect; GetClientRect(rect); ClientToScreen(rect); point = rect.TopLeft(); point.Offset(5, 5); } CMenu menu; VERIFY(menu.LoadMenu(m_menuID)); CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); CWnd* pWndPopupOwner = this; while (pWndPopupOwner->GetStyle() & WS_CHILD) pWndPopupOwner = pWndPopupOwner->GetParent(); pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner); }
void CADDigitView::OnContextMenu(CWnd* pWnd, CPoint point) { // TODO: Add your message handler code here if (point.x == -1 && point.y == -1) { //keystroke invocation CRect rect; GetClientRect(rect); ClientToScreen(rect); point = rect.TopLeft(); point.Offset(5, 5); } CMenu menu; VERIFY(menu.LoadMenu(IDR_ShowMode)); CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); CWnd* pWndPopupOwner = this; while (pWndPopupOwner->GetStyle() & WS_CHILD) pWndPopupOwner = pWndPopupOwner->GetParent(); pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner); }
void MFCChannelView::ArrangeChildren() { cout << "cv: arrange children()\n"; long atY = 12; for (short i=0; i<NInR(); i++) { MFCInputView *iv = (MFCInputView *)InR(i); iv->SetWindowPos(&wndTop, 1, atY, 0, 0, SWP_NOSIZE); atY += iv->bounds.bottom+1; } atY += 3; for (short i=0; i<NOutR(); i++) { MFCOutputView *ov = (MFCOutputView *)OutR(i); ov->SetWindowPos(&wndTop, 1, atY, 0, 0, SWP_NOSIZE); atY += ov->bounds.bottom+1; } bool adjustMounty = false; if (atY != bounds.bottom) { adjustMounty = true; } SetWindowPos(&wndTop, 0, 0, bounds.right, atY, SWP_NOMOVE); if (adjustMounty) { CWnd *w = GetParent(), *ww=NULL; if (w && w->IsWindowVisible() && (ww=w->GetParent())) { long ret = ww->PostMessage(QM_ARRANGE_VIEW, 0, 0); CFrameWnd *pfw = GetParentFrame(); if (pfw) { QuaChildFrame *qcfw = (QuaChildFrame *)pfw; qcfw->arranger->Invalidate(); } } } }
BOOL CResultDataWnd::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) { //let the view to route command CWnd* pFocus = GetFocus(); if (pFocus) { CWnd* pParent = pFocus->GetParent(); if (pFocus == &m_grid || pParent == &m_grid || pParent == &m_wndToolBar) { if (m_grid.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) return TRUE; } //if (pFocus == &m_wndToolBar || pParent == &m_wndToolBar) //{ //} } if (m_wndToolBar.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) return TRUE; return CDockablePane::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo); }
void CMyView::OnContextMenu(CWnd*, CPoint point) { // CG: This block was added by the Pop-up Menu component { if (point.x == -1 && point.y == -1) { //keystroke invocation CRect rect; GetClientRect(rect); ClientToScreen(rect); point = rect.TopLeft(); point.Offset(5, 5); } CMenu menu; VERIFY(menu.LoadMenu(CG_IDR_POPUP_MY_VIEW)); CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); CWnd* pWndPopupOwner = this; while (pWndPopupOwner->GetStyle() & WS_CHILD) pWndPopupOwner = pWndPopupOwner->GetParent(); pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner); } }
BOOL CALLBACK EnumWindowsProc(HWND hwnd/*当前找到的窗口句柄*/, LPARAM lParam/*自定义参数*/) //枚举当前窗口 { TCHAR tcClass[256]; LPWSTR pStr = (LPWSTR)lParam; HWND htmpWnd = NULL; ::GetClassName(hwnd, tcClass, 255); DWORD dwProcessID; TCHAR szProcessName[260] = { 0 }; GetWindowThreadProcessId(hwnd, &dwProcessID); HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, dwProcessID); GetModuleFileNameEx(hProcess, NULL, szProcessName, MAX_PATH); if (strstr(szProcessName, _T("\\PaperEditor.exe")) != NULL) { CWnd * pWndPrev = CWnd::FromHandle(hwnd); pWndPrev = pWndPrev->GetParent(); if (pWndPrev != NULL) { CWnd * pWndChild = pWndPrev->GetLastActivePopup(); if (pWndPrev->IsIconic()) pWndPrev->ShowWindow(SW_RESTORE); pWndChild->SetForegroundWindow(); } } return TRUE; }
void CSynBCGPEditView::OnHtmltoblog() { CWnd *pParentWnd = GetParent(); if (pParentWnd == NULL) { return; } pParentWnd = pParentWnd->GetParent(); if (pParentWnd == NULL) { return; } CWaitCursor wait; BOOL bAlreadyShow = TRUE; CBCGPTabView *pTabView = (CBCGPTabView *)pParentWnd; if (pTabView->GetTabControl().GetTabsNum() == 1) { CString strTemp; BOOL bNameVaild = strTemp.LoadString(ID_TAB_HTML); ASSERT(bNameVaild); pTabView->AddView(RUNTIME_CLASS(CSynHtmlView), strTemp, ID_TAB_HTML); bAlreadyShow = FALSE; } pTabView->SetActiveView(1); CSynHtmlView *pHtmlView = (CSynHtmlView *)pTabView->GetActiveView(); CString strCode; m_pEdit->ExportToMyHTML(strCode); pHtmlView->ShowCodeToHtml(strCode, m_pEdit->GetText(), m_pEdit->GetSelectLangString(), m_pEdit->GetLineCount(), bAlreadyShow); }
bool CMouse::CursorOnRootWindow(const CPoint& screenPoint, const CFrameWnd& frameWnd) { bool ret = false; CWnd* pWnd = CWnd::WindowFromPoint(screenPoint); CWnd* pRoot = pWnd ? pWnd->GetAncestor(GA_ROOT) : nullptr; // tooltips are special case if (pRoot && pRoot == pWnd) { CString strClass; VERIFY(GetClassName(pRoot->m_hWnd, strClass.GetBuffer(256), 256)); strClass.ReleaseBuffer(); if (strClass == _T("tooltips_class32")) { CWnd* pTooltipOwner = pWnd->GetParent(); pRoot = pTooltipOwner ? pTooltipOwner->GetAncestor(GA_ROOT) : nullptr; } } if (pRoot) { ret = (pRoot->m_hWnd == frameWnd.m_hWnd); } else { ASSERT(FALSE); } return ret; }
BOOL CMyPropertySheet::OnHelpInfo(HELPINFO* pHelpInfo) { BOOL ret = FALSE; bool handled = false; if (GetStyle() & WS_CHILD) { // were an embedded property sheet, need to pass up // the chain to get this message processed correctly CWnd * pWnd = GetParent(); while (pWnd != NULL && pWnd->GetStyle() & WS_CHILD) { // move up the window heirarchy while // finding child windows pWnd = pWnd->GetParent(); } if (pWnd != NULL) { ret = GetParent()->GetParent()->SendMessage(WM_HELP, 0, (LPARAM)(pHelpInfo)); handled = true; } // the sheet does not have a non child parent, // some kind of problem! ASSERT(handled); } if (!handled) { ret = CPropertySheet::OnHelpInfo(pHelpInfo); } return ret; }
void CVarView::OnContextMenu(CWnd* pWnd, CPoint point) { // TODO: この位置にメッセージ ハンドラ用のコードを追加してください CPoint client_point; client_point = point; ScreenToClient(&client_point); // スクリーン座標からクライアント座標へ変換する // CG: このブロックはポップアップ メニュー コンポーネントによって追加されました { if (point.x == -1 && point.y == -1){ //キーストロークの発動 CRect rect; GetClientRect(rect); ClientToScreen(rect); point = rect.TopLeft(); point.Offset(5, 5); } CMenu menu; VERIFY(menu.LoadMenu(CG_IDR_POPUP_VARVIEW)); CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); CWnd* pWndPopupOwner = this; while (pWndPopupOwner->GetStyle() & WS_CHILD) pWndPopupOwner = pWndPopupOwner->GetParent(); pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner); } }
void AFX_CDECL COccManager::UIActivateControl(CWnd* pWndNewFocus) { if (pWndNewFocus == NULL) return; // Find the nearest control in the window parent chain. CWnd* pWndCtrl = pWndNewFocus; COleControlContainer* pCtrlCont = NULL; COleControlSite* pCtrlSite = NULL; while ((pWndCtrl != NULL) && ((pCtrlCont = pWndCtrl->m_pCtrlCont) == NULL) && ((pCtrlSite = pWndCtrl->m_pCtrlSite) == NULL)) { pWndCtrl = pWndCtrl->GetParent(); } if ((pWndCtrl == NULL) || (pCtrlCont != NULL)) return; // This will UI Activate the control. pCtrlSite->SetFocus(); // Make sure focus gets set to correct child of control, if any. if (CWnd::GetFocus() != pWndNewFocus) pWndNewFocus->SetFocus(); }
void CPopupEdit::OnKillFocus(CWnd* pNewWnd) { CEdit::OnKillFocus(pNewWnd); CString Text; GetWindowText(Text); if (Text != "INFINITY") { if (!atoi(Text)) { SetWindowText(m_sInitText); GetWindowText(Text); } Text.Format("%d", atoi(Text)); CString Temp; GetWindowText(Temp); Temp = Temp.Right(1); if (!Temp.SpanIncluding("kKmMgG").IsEmpty()) Text.Format("%s%s", LPCTSTR(Text), LPCTSTR(Temp)); CString OldText; GetWindowText(OldText) ; if (GetModify() || OldText != Text) SetWindowText(Text); } if (m_bIsEmbeddedIntoListCtrl) { CWnd *Parent = GetParent(); ASSERT_VALID(Parent); CString str; GetWindowText(str); LV_DISPINFO dispinfo; dispinfo.hdr.hwndFrom = Parent->m_hWnd; dispinfo.hdr.idFrom = GetDlgCtrlID(); dispinfo.hdr.code = LVN_ENDLABELEDIT; dispinfo.item.mask = LVIF_TEXT; dispinfo.item.iItem = m_iItem; dispinfo.item.iSubItem = m_iSubItem; if (m_bESC) { dispinfo.item.pszText = NULL; dispinfo.item.cchTextMax = 0; } else { dispinfo.item.pszText = const_cast<LPTSTR>((LPCTSTR) str); dispinfo.item.cchTextMax = str.GetLength(); } CWnd *ParentParent = Parent->GetParent(); ASSERT_VALID(ParentParent); ParentParent->SendMessage(WM_NOTIFY, Parent->GetDlgCtrlID(), LPARAM(&dispinfo)); DestroyWindow(); } }
void CuDlgDBEventPane01::UpdateControl() { CView* pView = (CView*)GetParent(); ASSERT (pView); CDbeventDoc* pDoc = (CDbeventDoc*)pView->GetDocument(); ASSERT (pDoc); CWnd* pSplitter = pView->GetParent(); ASSERT (pSplitter); CDbeventFrame* pFrame = (CDbeventFrame*)pSplitter->GetParent(); ASSERT (pFrame); // // Remark: // InitializeDBEvent() is called on the CBN_SELCHANGE of Database ComboBox. CString strNone; if (strNone.LoadString (IDS_DATABASE_NONE) == 0) strNone = "<None>"; if (pDoc->m_strDBName == "" || pDoc->m_strDBName == strNone) return; // Load ... // Initialize the new Database. if (DBETraceInit (pDoc->m_hNode, (LPUCHAR)(LPCTSTR)pDoc->m_strDBName , pFrame->m_hWnd, &(pDoc->m_nHandle)) == RES_SUCCESS) { pDoc->m_bDBInit = TRUE; m_strCurrentDB = pDoc->m_strDBName; } else { pDoc->m_bDBInit = FALSE; pDoc->m_nHandle = -1; BfxMessageBox (VDBA_MfcResourceString(IDS_E_INITIALIZE_DB_EVENT));//"Error while initializing the Database for DB Event Registration" } if (pDoc->m_bDBInit) { int index; CTypedPtrList<CObList, CuDataRegisteredDBevent*>& listDBEvent = pDoc->m_listRegisteredDBEvent; POSITION pos = listDBEvent.GetHeadPosition(); while (pos != NULL) { CuDataRegisteredDBevent* dbe = listDBEvent.GetNext (pos); index = m_cListDBEvent.AddString (dbe->m_strDBEvent); if (index != LB_ERR) { LPTSTR lpszOwner = new TCHAR [dbe->m_strOwner.GetLength() +1]; lstrcpy (lpszOwner, (LPTSTR)(LPCTSTR)dbe->m_strOwner); m_cListDBEvent.SetItemData (index, (DWORD)lpszOwner); if (dbe->m_bRegistered) { if (DBETraceRegister (pDoc->m_nHandle, (LPUCHAR)(LPCTSTR)dbe->m_strDBEvent, (LPUCHAR)(LPCTSTR)dbe->m_strOwner) != RES_SUCCESS) BfxMessageBox (VDBA_MfcResourceString(IDS_E_REGISTERING_DB_EVENT));//"Error while Registering DB Event" else m_cListDBEvent.SetCheck (index, 1); } } } } }
/******************************************************************************* Function Name : pomGetParentWindow Input(s) : - Output : CWnd * - Pointer to CGraphChildFrame Functionality : This Function will return parent window pointer. That is pointer to CGraphChildFrame. This will return NULL incase of failure Member of : CGraphBottomView Author(s) : ArunKumar K Date Created : 04.11.2010 Modifications : *******************************************************************************/ CWnd* CGraphBottomView::pomGetParentWindow() const { CWnd* pWnd = NULL; // Get Splitter window pointer pWnd = GetParent(); // Get CGraphChildFrame pointer from Splitter window pointer if( pWnd != NULL ) { pWnd = pWnd->GetParent(); } if( pWnd != NULL ) { pWnd = pWnd->GetParent(); } // Return CGraphChildFrame pointer or NULL incase of failure return pWnd; }
/******************************************************************************* Function Name : pomGetParentWindow Input(s) : - Output : CWnd * - Pointer to CGraphChildFrame Functionality : This Function will return parent window pointer. That is pointer to CGraphChildFrame. This will return nullptr incase of failure Member of : CGraphRightView Author(s) : ArunKumar K Date Created : 08.11.2010 Modifications : *******************************************************************************/ CWnd* CGraphRightView::pomGetParentWindow() const { CWnd* pWnd = nullptr; // Get Splitter window pointer pWnd = GetParent(); // Get CGraphChildFrame pointer from Splitter window pointer if( pWnd != nullptr ) { pWnd = pWnd->GetParent(); } if( pWnd != nullptr ) { pWnd = pWnd->GetParent(); } // Return CGraphChildFrame pointer or nullptr incase of failure return pWnd; }
void CActivityView::OnContextMenu(CWnd*, CPoint point) { // CG: This block was added by the Pop-up Menu component { if (point.x == -1 && point.y == -1){ //keystroke invocation CRect rect; GetClientRect(rect); ClientToScreen(rect); point = rect.TopLeft(); point.Offset(5, 5); } CMenu menu; VERIFY(menu.LoadMenu(CG_IDR_POPUP_ACTIVITY_VIEW)); CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); CWnd* pWndPopupOwner = this; CMenu mainmenu; // in full-screen mode, give access to all menu items if (Frame.IsFullScreen ()) { VERIFY(mainmenu.LoadMenu(IDR_MUSHCLTYPE)); pPopup->AppendMenu (MF_SEPARATOR, 0, ""); pPopup->AppendMenu (MF_POPUP | MF_ENABLED, (UINT ) mainmenu.m_hMenu, "Main Menus"); } while (pWndPopupOwner->GetStyle() & WS_CHILD && pWndPopupOwner != pWndPopupOwner->GetParent()) pWndPopupOwner = pWndPopupOwner->GetParent(); pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner); } } // end of CActivityView::OnContextMenu
// unfortunately there is a bug in MFC that can cause an infinite loop // when the property page is hosting an OLE control so we fix // it by providing a replacement to the buggy code BOOL COccManager::IsDialogMessage(CWnd* pWndDlg, LPMSG lpMsg) { CWnd* pWndFocus = CWnd::GetFocus(); // HWND hWndFocus = pWndFocus->GetSafeHwnd(); // HWND hWndDlg = pWndDlg->GetSafeHwnd(); UINT uMsg = lpMsg->message; if (((uMsg >= WM_KEYFIRST) && (uMsg <= WM_KEYLAST)) || ((uMsg >= WM_MOUSEFIRST) && (uMsg <= WM_MOUSELAST))) { CWnd* pWndCtrl = pWndFocus; // Walk up the parent chain, until we find an OLE control. while ((pWndCtrl != NULL) && (pWndCtrl->m_pCtrlSite == NULL) && (pWndCtrl->GetParent() != pWndDlg)) { pWndCtrl = pWndCtrl->GetParent(); } // let the control attempt to translate the message if (pWndCtrl != NULL && pWndCtrl->m_pCtrlSite != NULL && pWndCtrl->m_pCtrlSite->m_pActiveObject != NULL && pWndCtrl->m_pCtrlSite->m_pActiveObject->TranslateAccelerator(lpMsg) == S_OK) { return TRUE; } // handle CTRLINFO_EATS_RETURN and CTRLINFO_EATS_ESCAPE flags if ((uMsg == WM_KEYUP || uMsg == WM_KEYDOWN || uMsg == WM_CHAR) && pWndCtrl != NULL && pWndCtrl->m_pCtrlSite != NULL && ((LOWORD(lpMsg->wParam) == VK_RETURN && (pWndCtrl->m_pCtrlSite->m_ctlInfo.dwFlags & CTRLINFO_EATS_RETURN)) || (LOWORD(lpMsg->wParam) == VK_ESCAPE && (pWndCtrl->m_pCtrlSite->m_ctlInfo.dwFlags & CTRLINFO_EATS_ESCAPE)))) { return FALSE; } } // else simple default // because this is where the MFC bug existed return ::IsDialogMessage(pWndDlg->GetSafeHwnd(), lpMsg); }
// // Generic handler for press on any BResultType button. // Records which button was pressed, then pops up the result type menu. // void CPageDisplay::OnBResultType( int which_button ) { CMenu menu; CRect button_rect; RECT screen_rect; int menu_height, menu_x, menu_y; // Record which button was pressed, for later use by OnMDisplay(). selected_button = which_button; // This prevents the menu from popping up if the user is "unchecking" the button. if ( ( (CButton*)GetDlgItem( BResultType1 + selected_button ) )->GetCheck() ) { ( (CButton*)GetDlgItem( BResultType1 + selected_button ) )-> SetCheck( FALSE ); return; } // Create the popup menu from the resource. VERIFY(menu.LoadMenu(IDR_POPUP_DISPLAY_LIST)); CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); // Find the first non-child window to be the popup's parent. CWnd* pWndPopupOwner = this; while (pWndPopupOwner->GetStyle() & WS_CHILD) pWndPopupOwner = pWndPopupOwner->GetParent(); // Get the screen coordinates of the button that was pressed. GetDlgItem( BResultType1 + selected_button )->GetWindowRect( &button_rect ); // Position the menu with its upper left corner at the lower left corner of the button. menu_x = button_rect.TopLeft().x; menu_y = button_rect.BottomRight().y; // If the menu would go off the bottom of the screen, make it go *up* from the button instead. menu_height = GetSystemMetrics(SM_CYMENUSIZE) * MDisplayNumSubmenus; if ( SystemParametersInfo( SPI_GETWORKAREA, 0, &screen_rect, 0) && (menu_y + menu_height > screen_rect.bottom) ) { menu_y = button_rect.TopLeft().y - menu_height + 1; } // Set the button's visual state to "pressed" as long as the menu is popped up. ( (CButton*)GetDlgItem( BResultType1 + selected_button ) )->SetCheck( TRUE ); // Pop up the menu. pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, menu_x, menu_y, pWndPopupOwner); // The user's selection (if any) from the pop-up menu will result in a call to one of the // CGalileoView::OnMDisplay...() functions, which will in turn call CPageDisplay::OnMDisplay(). // Set the button's visual state to "not pressed" after the menu is dismissed. ( (CButton*)GetDlgItem( BResultType1 + selected_button ) )->SetState( FALSE ); }
//------------------------------------------------------------------------ //! Send LV_DISPINFO structure as LVN_ENDLABELEDIT from CListCtrl to parent window //! //! @param wndListCtrl The list control starting edit //! @param nRow The index of the row //! @param nCol The index of the column //! @param lvDispInfo Specifies the properties of the new cell value //! @return Result of the SendMessage to parent window //------------------------------------------------------------------------ LRESULT CGridColumnTraitImage::SendEndLabelEdit(CWnd& wndListCtrl, int nRow, int nCol, LV_DISPINFO& lvDispInfo) { lvDispInfo.hdr.hwndFrom = wndListCtrl.m_hWnd; lvDispInfo.hdr.idFrom = static_cast<UINT_PTR>(wndListCtrl.GetDlgCtrlID()); lvDispInfo.hdr.code = LVN_ENDLABELEDIT; lvDispInfo.item.iItem = nRow; lvDispInfo.item.iSubItem = nCol; return wndListCtrl.GetParent()->SendMessage(WM_NOTIFY, static_cast<WPARAM>(wndListCtrl.GetDlgCtrlID()), reinterpret_cast<LPARAM>(&lvDispInfo)); }
bool CWnd::IsVisible() { CWnd* pWnd = this; while ( pWnd->m_dwFlags & WsVisible ) { pWnd = pWnd->GetParent(); if ( !pWnd ) return true; } return false; }