コード例 #1
0
ファイル: viewcore.cpp プロジェクト: rickerliang/OpenNT
int CView::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
{
	int nResult = CWnd::OnMouseActivate(pDesktopWnd, nHitTest, message);
	if (nResult == MA_NOACTIVATE || nResult == MA_NOACTIVATEANDEAT)
		return nResult;   // frame does not want to activate

	CFrameWnd* pParentFrame = GetParentFrame();
	if (pParentFrame != NULL)
	{
		// eat it if this will cause activation
		ASSERT(pParentFrame == pDesktopWnd || pDesktopWnd->IsChild(pParentFrame));

		// either re-activate the current view, or set this view to be active
		CView* pView = pParentFrame->GetActiveView();
		HWND hWndFocus = ::GetFocus();
		if (pView == this && 
			m_hWnd != hWndFocus && !::IsChild(m_hWnd, hWndFocus))
		{
			// re-activate this view
			OnActivateView(TRUE, this, this);
		}
		else
		{
			// activate this view
			pParentFrame->SetActiveView(this); 
		}
	}
	return nResult;
}
コード例 #2
0
ファイル: viewcore.cpp プロジェクト: rickerliang/OpenNT
// OnEndPrintPreview is here for swap tuning reasons
//  (see viewprev.cpp for complete preview mode implementation)
void CView::OnEndPrintPreview(CDC* pDC, CPrintInfo* pInfo,
			POINT, CPreviewView* pView)
{
	ASSERT_VALID(pDC);
	ASSERT_VALID(pView);

	if (pView->m_pPrintView != NULL)
		pView->m_pPrintView->OnEndPrinting(pDC, pInfo);

	CFrameWnd* pParent = (CFrameWnd*)AfxGetThread()->m_pMainWnd;
	ASSERT_VALID(pParent);
	ASSERT(pParent->IsKindOf(RUNTIME_CLASS(CFrameWnd)));

	// restore the old main window
	pParent->OnSetPreviewMode(FALSE, pView->m_pPreviewState);

	// Force active view back to old one
	pParent->SetActiveView(pView->m_pPreviewState->pViewActiveOld);
	if (pParent != GetParentFrame())
		OnActivateView(TRUE, this, this);   // re-activate view in real frame
	pView->DestroyWindow();     // destroy preview view
			// C++ object will be deleted in PostNcDestroy

	// restore main frame layout and idle message
	pParent->RecalcLayout();
	pParent->SendMessage(WM_SETMESSAGESTRING, (WPARAM)AFX_IDS_IDLEMESSAGE, 0L);
	pParent->UpdateWindow();
}
コード例 #3
0
ファイル: MainFrm.cpp プロジェクト: victimofleisure/WaveShop
bool CMainFrame::MakeWave(const WAVEGEN_PARMS& Parms)
{
	POSITION	pos = theApp.GetFirstDocTemplatePosition();
	CDocTemplate	*pTpl = theApp.GetNextDocTemplate(pos);
	CWaveShopDoc	*pDoc = DYNAMIC_DOWNCAST(CWaveShopDoc, pTpl->CreateNewDocument());
	if (pDoc == NULL)
		return(FALSE);
	bool	retc, canceled;
	{
		CProgressDlg	ProgDlg;
		if (!ProgDlg.Create())	// create progress dialog
			AfxThrowResourceException();
		ProgDlg.SetWindowText(LDS(IDS_MAIN_GENERATING_AUDIO));
		retc = CWaveGenDlg::MakeWave(Parms, pDoc->m_Wave, &ProgDlg);
		canceled = ProgDlg.Canceled();
	}	// destroy progress dialog
	if (!retc) {	// if generation failed
		if (!canceled)	// if user canceled
			AfxMessageBox(IDS_MAIN_CANT_MAKE_WAVE);
		return(FALSE);
	}
	CDocument	*pEmptyDoc = pTpl->OpenDocumentFile(NULL);	// create new view
	if (pEmptyDoc == NULL || m_View == NULL)
		return(FALSE);
	CString	title = pEmptyDoc->GetTitle();
	pEmptyDoc->RemoveView(m_View);	// remove empty document from view
	pDoc->SetTitle(title);	// copy empty document's title to generated document
	pDoc->AddView(m_View);	// add generated document to view
	m_View->OnInitialUpdate();
	OnActivateView(m_View);
	// view is still linked to empty document's undo manager; must relink
	m_View->SetUndoManager(&pDoc->m_UndoMgr);	// link view to undo manager
	pDoc->m_UndoMgr.SetRoot(m_View);	// link undo manager to view
	return(TRUE);
}
コード例 #4
0
ファイル: ViewManager.cpp プロジェクト: githubjim/frame
void CViewManager::AddView(const char * csName, CView * pView)
{
	if (bClosing) return;

	CString cs(csName);

	arViews.Add(pView);
	arViewTitles.Add(cs);
	if ( ((CMainFrame*)AfxGetMainWnd())->m_HBTab.GetSafeHwnd())
	{
		TC_ITEM ti;
		ti.mask = TCIF_TEXT|TCIF_PARAM;
		ti.pszText = cs.LockBuffer();
		ti.lParam = (long) pView;
		   ((CMainFrame*)AfxGetMainWnd())->m_HBTab.InsertItem(   ((CMainFrame*)AfxGetMainWnd())->m_HBTab.GetItemCount(), &ti);
		cs.UnlockBuffer();
		((CMainFrame*)AfxGetMainWnd())->m_HBTab.SetMinTabWidth(110);

		OnActivateView(TRUE, pView);
	}
}