void OnDragging( CPoint& point ){ if( m_bDragging ) { CPoint pt(point); ClientToScreen( &pt ); m_pDragImage->DragMove( pt ); m_pDragImage->DragShowNolock( FALSE ); CWnd* pDropWnd = CWnd::WindowFromPoint( pt ); ASSERT(pDropWnd); if( pDropWnd != m_pDropWnd ) { if( m_hDropItem ) { ((CTreeCtrl*)m_pDropWnd)->SelectDropTarget( NULL ); m_hDropItem = NULL; } if( m_nDropIndex != -1 ) { CListCtrl* pList = (CListCtrl*)m_pDropWnd; pList->SetItemState( m_nDropIndex, 0, LVIS_DROPHILITED ); pList->RedrawItems( m_nDropIndex, m_nDropIndex ); pList->UpdateWindow(); m_nDropIndex = -1; } } m_pDropWnd = pDropWnd; pDropWnd->ScreenToClient( &pt ); if( pDropWnd->IsKindOf(RUNTIME_CLASS(CTreeCtrl)) ) { UINT uFlags; m_hDropItem = ((CTreeCtrl*)pDropWnd)->HitTest( pt, &uFlags ); ((CTreeCtrl*)pDropWnd)->SelectDropTarget( m_hDropItem ); } else if( pDropWnd->IsKindOf(RUNTIME_CLASS(CListCtrl)) ) { UINT uFlags; CListCtrl* pList = (CListCtrl*)pDropWnd; pList->SetItemState( m_nDropIndex, 0, LVIS_DROPHILITED ); pList->RedrawItems( m_nDropIndex, m_nDropIndex ); m_nDropIndex = ((CListCtrl*)pDropWnd)->HitTest( pt, &uFlags ); pList->SetItemState( m_nDropIndex, LVIS_DROPHILITED, LVIS_DROPHILITED ); pList->RedrawItems( m_nDropIndex, m_nDropIndex ); pList->UpdateWindow(); } m_pDragImage->DragShowNolock( TRUE ); } }
/** * Performs a rename operation on the selected material or stage. */ void MEMainFrame::OnEditRename() { CWnd* focus = GetFocus(); if(focus) { if (focus->IsKindOf(RUNTIME_CLASS(StageView))) { m_stageView->OnRenameStage(); } else if (focus->IsKindOf(RUNTIME_CLASS(MaterialTreeView))) { m_materialTreeView->OnRenameMaterial(); } } }
void CuDlgPageFixedWidth::OnCheckConfirmChoice() { // // You have already checked one.\nThe previous check will be cancelled. CString strMsg; strMsg.LoadString(IDS_CONFIRM_CHOICE_WITH_CHECKBOX); CWnd* pParent = GetParent(); ASSERT(pParent && pParent->IsKindOf(RUNTIME_CLASS(CTabCtrl))); if (pParent && pParent->IsKindOf(RUNTIME_CLASS(CTabCtrl))) { BOOL nAsked = FALSE; TCITEM item; memset (&item, 0, sizeof (item)); item.mask = TCIF_PARAM; CTabCtrl* pTab = (CTabCtrl*)pParent; int nCheck, i, nCount = pTab->GetItemCount(); for (i=0; i<nCount; i++) { if (pTab->GetItem (i, &item)) { CWnd* pPage = (CWnd*)item.lParam; ASSERT (pPage); if (!pPage) continue; if (pPage == this) continue; nCheck = pPage->SendMessage(WMUSRMSG_GETITEMDATA, (WPARAM)CHECK_CONFIRM_CHOICE, 0); if (nCheck == 1) { if (!nAsked) { nAsked = TRUE; int nAnswer = AfxMessageBox (strMsg, MB_OKCANCEL|MB_ICONEXCLAMATION); if (nAnswer != IDOK) { m_cCheckConfirmChoice.SetCheck (0); return; } // // Uncheck the checkbox m_cCheckConfirmChoice: pPage->SendMessage(WMUSRMSG_UPDATEDATA, (WPARAM)CHECK_CONFIRM_CHOICE, 0); } else { // // Uncheck the checkbox m_cCheckConfirmChoice: pPage->SendMessage(WMUSRMSG_UPDATEDATA, (WPARAM)CHECK_CONFIRM_CHOICE, 0); } } } } } }
void CWTabBar::retrieveData() { // send this on to the form view CWnd *pWnd = getContentView(); // could also be a heading view or a list view if(pWnd->IsKindOf(RUNTIME_CLASS(CWFormView))) ((CWFormView*)pWnd)->retrieveData(); else if (pWnd->IsKindOf(RUNTIME_CLASS(CWListView))) ((CWListView*)pWnd)->retrieveHeaderParams(); }
LONG CWTabBar::doFindReplace(FINDREPLACE * pFRStruct) { // send this on to the form view CWnd *pWnd = getContentView(); gsFindWhat = pFRStruct->lpstrFindWhat; // save for next time gdwFindFlags = pFRStruct->Flags; // save for next time or F3 // could also be a heading view or a list view if(pWnd->IsKindOf(RUNTIME_CLASS(CWFormView))) return ((CWFormView*)pWnd)->doFindReplace(pFRStruct); else if (pWnd->IsKindOf(RUNTIME_CLASS(CWListView))) return ((CWListView*)pWnd)->doFindReplace(pFRStruct); return 0; }
CPropertySheet* CWizPage::getOwner() { CWnd* pW = GetParent(); ASSERTX(pW); ASSERTX(pW->IsKindOf(RUNTIME_CLASS(CPropertySheet))); return (CPropertySheet*)pW; }
BOOL CMediaWnd::OnDropFiles(CStringList& pFiles, const CPoint& ptScreen, BOOL bDrop) { if ( bDrop == FALSE ) return TRUE; CPoint pt( ptScreen ); m_wndFrame.ScreenToClient( &pt ); CWnd* pDropped = m_wndFrame.ChildWindowFromPoint( pt ); BOOL bEnqueue; if ( pDropped != NULL ) bEnqueue = ( pDropped->IsKindOf( RUNTIME_CLASS(CMediaListCtrl) ) ); else bEnqueue = FALSE; for ( POSITION pos = pFiles.GetHeadPosition() ; pos ; ) { CString strFile = pFiles.GetNext( pos ); if ( bEnqueue ) EnqueueFile( strFile ); else PlayFile( strFile ); } return TRUE; }
void CPreviewView::CalcWindowRect(LPRECT lpClientRect) { CView::CalcWindowRect(lpClientRect); // The preview view is created with the WS_BORDER style, and when // the view is repositioned, these borders will by default be placed // outside the main monitor. If there are other monitors adjacent to // the main monitor, the border shows up on those monitors, which looks // sloppy. To prevent this we resize the window rect as necessary to // keep the borders inside the MDI parent frame window's client area. // Also note that we can't just get rid of the borders entirely because // this looks bad on a PowerBook where the edges of the screen are // white instead of black - if there aren't any borders, there's no // dividing line between the edge of the preview view's scrollbars // and the non-drawing areas of the screen. CWnd* pParent = GetParent(); if (pParent->IsKindOf(RUNTIME_CLASS(CMDIFrameWnd))) { RECT rect; pParent->GetClientRect(&rect); if (lpClientRect->left < rect.left) lpClientRect->left = rect.left; if (lpClientRect->right > rect.right) lpClientRect->right = rect.right; if (lpClientRect->bottom > rect.bottom) lpClientRect->bottom = rect.bottom; // top not needed because it will be adjacent to the print // preview toolbar } }
/////////////////////////////////////////////////////////////////////////////// // Check if the specified window is child of a docked toolbar bool ChildOfDockedToolbar (CWnd* pWnd) { CWnd* pParent = pWnd->GetParent(); return pParent->IsKindOf (RUNTIME_CLASS(CControlBar)) && ((CControlBar*)pParent)->m_pDockBar != NULL; }
//------------------------------------------------------------------------// BOOL CBCGPGlobalUtils::IsWndCanFloatMulti (CWnd* pWnd) const { CBCGPControlBar* pBar = NULL; CBCGPMiniFrameWnd* pMiniFrame = DYNAMIC_DOWNCAST (CBCGPMiniFrameWnd, pWnd); if (pMiniFrame != NULL) { pBar = DYNAMIC_DOWNCAST (CBCGPControlBar, pMiniFrame->GetControlBar ()); } else { pBar = DYNAMIC_DOWNCAST (CBCGPControlBar, pWnd); } if (pBar == NULL) { return FALSE; } if (pBar->IsTabbed ()) { CWnd* pParentMiniFrame = pBar->GetParentMiniFrame (); // tabbed bar that is floating in multi miniframe if (pParentMiniFrame != NULL && pParentMiniFrame->IsKindOf (RUNTIME_CLASS (CBCGPMultiMiniFrameWnd))) { return TRUE; } } return ((pBar->GetBarStyle () & CBRS_FLOAT_MULTI) != 0); }
/** * * \param nFlags * \param point */ void CUnitListBox::OnMouseMove(UINT nFlags, CPoint point) { if (m_bDragging && m_pDragImage != NULL) { CPoint cPt(point); ClientToScreen(&cPt); m_pDragImage->DragMove(cPt); m_pDragImage->DragShowNolock(false); CWnd* pDropWnd = WindowFromPoint (cPt); if (pDropWnd) { pDropWnd->ScreenToClient(&cPt); if(pDropWnd->IsKindOf(RUNTIME_CLASS (CView))) { SetCursor(LoadCursor(NULL, IDC_ARROW)); } else { SetCursor(LoadCursor(NULL, IDC_NO)); } m_pDragImage->DragShowNolock(true); } } }
///////////////////////////////////////////////////////////////////////////// // CSettingsDialog::AddPage(...) // // Description: Add a page specified by CRuntimeClass. // If pWndClass = NULL, the corresponding tree item has no page // The page identified by pCaption on the tree control will be inserted // under the parent tree item identified by pParentCaption. // If pParentCaption is empty, them the page becomes a root item on the // tree control // Return value: A CWnd type pointer to the page created if successful, // otherwise return NULL // CWnd* CSettingsDialog::AddPage(CRuntimeClass *pWndClass, const char *pCaption, UINT nID, const char *pParentCaption) { CWnd* pWnd = NULL; if (m_hWnd) { // Can't add once the window has been created ASSERT(0); return pWnd; } // Create the specified page object if (pWndClass) pWnd = (CWnd*) pWndClass->CreateObject(); PAGE_INFO *pInfo = new PAGE_INFO; pInfo->bViewClass = TRUE; // Default to generic CWnd or CView class if (pWnd) // If it is a dialog or dialog-derived class { // Set bViewClass = FALSE if (pWnd->IsKindOf(RUNTIME_CLASS(CDialog))) pInfo->bViewClass = FALSE; } pInfo->nID = nID; // ID of the page pInfo->pWnd = pWnd; // Point to the page pInfo->csCaption = pCaption; // Caption of page in the tree control pInfo->pWndParent = NULL; // Parent page is not specified yet pInfo->csParentCaption = pParentCaption; // Parent caption to be inserted under m_pInfo.Add(pInfo); // Add to to page list return pWnd; }
/** * * \param nFlags * \param point */ void CUnitListBox::OnLButtonUp(UINT nFlags, CPoint point) { if (m_bDragging && m_pDragImage != NULL) { ReleaseCapture (); m_bDragging = FALSE; m_pDragImage->DragLeave (GetDesktopWindow ()); m_pDragImage->EndDrag (); delete m_pDragImage; CPoint pt(point); ClientToScreen(&pt); CWnd* pDropWnd = WindowFromPoint (pt); if (pDropWnd) { if (pDropWnd->IsKindOf (RUNTIME_CLASS (CView))) { CMainFrame* pMainFrame = (CMainFrame*)(AfxGetMainWnd()); if (pMainFrame) { wmCreateUnit c; strcpy(c.Name, m_szFileName.GetBuffer()); // 通知文件窗口 ::SendMessage(pMainFrame->GetActiveView()->m_hWnd, WM_CREATE_UNIT, (WPARAM)&c, NULL); } } } } }
/** @brief @author HumKyung.BAEK */ void CAssignLoadToBusDlg::OnLButtonUp(UINT nFlags, CPoint point) { if (m_bDragging) { // Release mouse capture, so that other controls can get control/messages ReleaseCapture (); // Note that we are NOT in a drag operation m_bDragging = FALSE; // End dragging image m_pDragImage->DragLeave (GetDesktopWindow ()); m_pDragImage->EndDrag (); delete m_pDragImage; //must delete it because it was created at the beginning of the drag CPoint pt (point); //Get current mouse coordinates ClientToScreen (&pt); //Convert to screen coordinates // Get the CWnd pointer of the window that is under the mouse cursor CWnd* pDropWnd = WindowFromPoint (pt); ASSERT (pDropWnd); //make sure we have a window pointer // If window is CListCtrl, we perform the drop if (pDropWnd->IsKindOf (RUNTIME_CLASS (CMFCListCtrl))) { m_pDropList = (CMFCTextColorListCtrl*)pDropWnd; //Set pointer to the list we are dropping on DropItemOnList(m_pDragList, m_pDropList); //Call routine to perform the actual drop } } CDialog::OnLButtonUp(nFlags, point); }
BOOL CDlgStrategyHQ::PreTranslateMessage(MSG* pMsg) { if(pMsg->message == WM_KEYDOWN) { if(pMsg->wParam == VK_RETURN ) { UINT nID = GetFocus()->GetDlgCtrlID(); switch( nID) { case IDC_EDITGAP: { CWnd* pwnd = GetParent(); if (pwnd && pwnd->IsKindOf(RUNTIME_CLASS(CDlgStrategyMain))) { CDlgStrategyMain *pMain = (CDlgStrategyMain*)pwnd; pMain->OnBnClickedOk(); } break; } default: NextDlgCtrl(); } return TRUE; } else if (pMsg->wParam == VK_TAB) { NextDlgCtrl(); return TRUE; } } return FALSE; }
int CWinnerView::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message) { CWnd *pParent = GetParent(); if(pParent != NULL && pParent->IsKindOf(RUNTIME_CLASS(CChildFrame))) return CView::OnMouseActivate(pDesktopWnd, nHitTest, message); else return TRUE; }
//------------------------------------------------------------------------// void CBCGPGlobalUtils::ForceAdjustLayout (CBCGPDockManager* pDockManager, BOOL bForce, BOOL bForceInvisible, BOOL bForceNcArea) { if (pDockManager != NULL && (CBCGPControlBar::m_bHandleMinSize || bForce)) { CWnd* pDockSite = pDockManager->GetDockSite (); if (pDockSite == NULL) { return; } if (!pDockSite->IsWindowVisible () && !bForceInvisible) { return; } if (pDockSite->IsKindOf(RUNTIME_CLASS(CBCGPFrameWnd)) || pDockSite->IsKindOf(RUNTIME_CLASS(CBCGPMDIFrameWnd))) { m_bIsAdjustLayout = (pDockSite->GetStyle() & WS_MAXIMIZE) == WS_MAXIMIZE; } CRect rectWnd; pDockSite->SetRedraw (FALSE); pDockSite->GetWindowRect (rectWnd); pDockSite->SetWindowPos (NULL, -1, -1, rectWnd.Width () + 1, rectWnd.Height () + 1, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); pDockSite->SetWindowPos (NULL, -1, -1, rectWnd.Width (), rectWnd.Height (), SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); pDockSite->SetRedraw (TRUE); if (bForceNcArea) { pDockSite->SetWindowPos(NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); } m_bIsAdjustLayout = FALSE; pDockSite->RedrawWindow (NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE | RDW_ALLCHILDREN); } }
/** * Performs a cut operation on the selected material. */ void MEMainFrame::OnEditCut() { CWnd* focus = GetFocus(); if(focus) { if (focus->IsKindOf(RUNTIME_CLASS(MaterialTreeView))) { m_materialTreeView->OnCut(); } } }
void DrumSequencerMenubar::OnAfterFloat() { CWnd *pWnd = AfxGetMainWnd(); if (pWnd->IsKindOf(RUNTIME_CLASS(CFrameWnd))) { ((CFrameWnd*)pWnd)->RecalcLayout(); } CMFCMenuBar::OnAfterFloat(); }
void DrumSequencerMenubar::OnAfterDock(CBasePane* pBar, LPCRECT lpRect, AFX_DOCK_METHOD dockMethod) { CWnd *pWnd = AfxGetMainWnd(); if (pWnd->IsKindOf(RUNTIME_CLASS(CFrameWnd))) { ((CFrameWnd*)pWnd)->RecalcLayout(); } CMFCMenuBar::OnAfterDock(pBar, lpRect, dockMethod); }
static CMainFrame* GetMainFrame() { CWnd *pWnd = AfxGetMainWnd(); if (!pWnd) return 0; if (!pWnd->IsKindOf(RUNTIME_CLASS(CMainFrame))) return 0; return (CMainFrame*)AfxGetMainWnd(); }
CDockBar* CLogo::GetParentDockBar() { CWnd* pParentWnd =GetParent(); if(!pParentWnd || !pParentWnd->IsKindOf(RUNTIME_CLASS(CDockBar))) return NULL; return static_cast<CDockBar*>(pParentWnd); }
void FullViewWindow( HWND hWindow, int x, int y, int cx, int cy, BOOL fClipToImage ) /************************************************************************/ { RECT NewWindowRect; LPIMAGE lpImage; LPDISPLAY lpDisplay; HWND hMDIWindow = hWindow; CWnd *pWnd = CWnd::FromHandle(hMDIWindow); if (pWnd->IsKindOf(RUNTIME_CLASS(CServerView))) hMDIWindow = pWnd->GetParentFrame()->GetSafeHwnd(); // if window is iconic, do nothing here if (IsIconic(hMDIWindow)) return; lpImage = GetImagePtr(hWindow); lpDisplay = GetDisplayPtr(hWindow); // if window is maximized, do not change the size of the window if ( !IsZoomed(hMDIWindow) ) { // get the difference between the client area and the window area // not including scrollbars (i.e. - pretend scrollbars aren't there) // this is so we know how much extra size is needed for caption, // borders, etc. when we size the window CalcFullViewWindowSize( &NewWindowRect, &lpDisplay->FileRect, lpDisplay->FileRate, lpImage->npix, lpImage->nlin, x, y, lpDisplay->HasRulers, fClipToImage ); // now actually size the window, it's possible nothing will happen here ASSERT(pWnd->IsKindOf(RUNTIME_CLASS(CServerView))); pWnd->GetParentFrame()->MoveWindow(NewWindowRect.left, NewWindowRect.top, RectWidth(&NewWindowRect), RectHeight(&NewWindowRect), TRUE); } // recompute DispRect and FileRect for cx and cy // and also it's possible there was no WM_SIZE ComputeDispRect(hWindow); ComputeFileRect(hWindow, cx, cy, lpDisplay->FileRate ); SetupRulers(hWindow); InvalidateRect(hWindow, NULL, TRUE); }
void DDX_FileEditCtrl(CDataExchange *pDX, int nIDC, CString& rStr, BOOL bFindFolder) { // Subclasses the edit control with Id nIDC. Coordinates the window text // with the CString. bFindFolder determines if the control is used to // browse for files or folders. CWnd *pWnd = pDX->m_pDlgWnd->GetDlgItem(nIDC); if (pDX->m_bSaveAndValidate) // update string with text from control { // ensure the control is a CFileEditCtrl control if (pWnd->IsKindOf(RUNTIME_CLASS(CFileEditCtrl))) { // copy the first file listed in the control to the string rStr.Empty(); CFileEditCtrl *pFEC = (CFileEditCtrl *)pWnd; POSITION pos = pFEC->GetStartPosition(); if (pos) rStr = pFEC->GetNextPathName(pos); } } else // create the control if it is not already created { // set the control text to the text in string CFileEditCtrl *pFEC = NULL; if (!pWnd->IsKindOf(RUNTIME_CLASS(CFileEditCtrl))) // not subclassed yet { // create then subclass the control to the edit control with the ID nIDC HWND hWnd = pDX->PrepareEditCtrl(nIDC); pFEC = new CFileEditCtrl(TRUE); // create the control with autodelete if (!pFEC->SubclassWindow(hWnd)) { // failed to subclass the edit control ASSERT(FALSE); AfxThrowNotSupportedException(); } // Force a call to CFileEditCtrl::OnNcCalcSize() to calculate button size pFEC->SetWindowPos(NULL,0,0,0,0,SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE); // call CFileEditCtrl::FindFolder() to initialize the internal data structures pFEC->SetFindFolder(bFindFolder); } else // control already exists pFEC = (CFileEditCtrl *)pWnd; if (pFEC) pFEC->SetWindowText(rStr); // set the control text } }
BOOL CDlgManualTask::PreTranslateMessage(MSG* pMsg) { // TODO: 在此添加专用代码和/或调用基类 if (pMsg->message == WM_KEYDOWN && (pMsg->wParam == VK_RETURN || pMsg->wParam == VK_F1 || pMsg->wParam == VK_ESCAPE)) { return TRUE; } if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_SPACE ) { CWnd* pWnd = GetFocus(); if ( !(pWnd && (pWnd->IsKindOf(RUNTIME_CLASS(CEdit))||pWnd->IsKindOf(RUNTIME_CLASS(CEdit)))) ) { return TRUE; } } return CDialog::PreTranslateMessage(pMsg); }
// should be overridden to enable/disable next button void CWizPage::checkStatus() { CWnd* pW = GetParent(); if(pW->IsKindOf(RUNTIME_CLASS(CPropertySheet)))//CWizNewFromFiles))) { //ASSERTX(m_pOwner); //m_pOwner-> ((CPropertySheet*)pW)->SetWizardButtons(PSWIZB_BACK | PSWIZB_NEXT ); // first page overrides this so back is ok } }
// message handler. Force the parent of the control bar to update it's style // after floating, otherwise we'll wait till an WM_NCHITTEST. LONG COXSizeControlBar::OnAfterFloatMessage(UINT /* wParam */, LONG /* lParam */) { CWnd* pFrame = GetParentFrame(); if(pFrame != NULL && pFrame->IsKindOf(RUNTIME_CLASS(COXSizableMiniDockFrameWnd))) { ((COXSizableMiniDockFrameWnd*)pFrame)->GetContainedBarType(); } return TRUE; // message handled. }
void CTestQuestionPage::OnShowQuestionaireSettings() { if (ShowQuestionnaireSettings(m_bButtonsChanged, m_bEditNewQuestion) == IDOK ) { CWnd *pParent = GetParent(); if (pParent && pParent->IsKindOf(RUNTIME_CLASS(CTestSettings))) { ((CTestSettings*) pParent)->SetQuestionnaireSettingsShown(); ((CTestSettings*) pParent)->RefreshOptionpageActionsControls(); } } }
void CTestDockBar::OnShowDockBar( bool bShowDockBar ) { CWnd* pWnd = DockBarClientWnd(); if( pWnd && pWnd->IsKindOf(RUNTIME_CLASS(CTestDockBarDialog)) ) { CTestDockBarDialog* pDialog = static_cast<CTestDockBarDialog*>(pWnd); if( pDialog ) pDialog->OnShowDockBar( bShowDockBar ); } }
void CTestDockBar::OnDockBarPositionChanged( DWORD dwNewLocation ) { CWnd* pWnd = DockBarClientWnd(); if( pWnd && pWnd->IsKindOf(RUNTIME_CLASS(CTestDockBarDialog)) ) { CTestDockBarDialog* pDialog = static_cast<CTestDockBarDialog*>(pWnd); if( pDialog ) pDialog->OnDockBarPositionChanged( dwNewLocation ); } }