当前位置: 首页>>代码示例>>C++>>正文


C++ ASSERT_VALID函数代码示例

本文整理汇总了C++中ASSERT_VALID函数的典型用法代码示例。如果您正苦于以下问题:C++ ASSERT_VALID函数的具体用法?C++ ASSERT_VALID怎么用?C++ ASSERT_VALID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ASSERT_VALID函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: UpdateData

//*****************************************************************************************
void CBCGMenuPage::OnBcgbarresResetFrameMenu() 
{
	UpdateData ();

	if (m_pMenuBar == NULL)
	{
		ASSERT (FALSE);
		return;
	}

	int iIndex = m_wndMenuesList.GetCurSel ();
	if (iIndex == CB_ERR)
	{
		ASSERT (FALSE);
		return;
	}

	{
		CBCGLocalResource locaRes;

		CString strPrompt;
		strPrompt.Format (IDS_BCGBARRES_RESET_MENU_FMT, m_strMenuName);

		if (AfxMessageBox (strPrompt, MB_YESNO | MB_ICONQUESTION) != IDYES)
		{
			return;
		}
	}

	HMENU hOldMenu = NULL;

	CBCGMultiDocTemplate* pTemplate = 
			(CBCGMultiDocTemplate*) m_wndMenuesList.GetItemData (iIndex);
	if (pTemplate != NULL)	// Document's menu
	{
		ASSERT_VALID (pTemplate);

		HINSTANCE hInst = AfxFindResourceHandle (
			MAKEINTRESOURCE (pTemplate->GetResId ()), RT_MENU);

		BOOL bIsCurrent = (pTemplate->m_hMenuShared == m_hmenuCurr);

		hOldMenu = pTemplate->m_hMenuShared;

		pTemplate->m_hMenuShared = ::LoadMenu (hInst, MAKEINTRESOURCE (pTemplate->GetResId ()));
		m_pMenuBar->CreateFromMenu (pTemplate->m_hMenuShared, FALSE);
		
		CBCGMenuBar::UpdateMDIChildrenMenus (pTemplate);

		if (m_pParentFrame != NULL)
		{
			if (m_pParentFrame->SendMessage (BCGM_RESETMENU, pTemplate->GetResId ()))
            {
                m_pMenuBar->AdjustLayout();
            };
		}

		g_menuHash.SaveMenuBar (pTemplate->m_hMenuShared, m_pMenuBar);

		if (bIsCurrent)
		{
			ASSERT (!m_bIsDefaultMDIMenu);
			m_hmenuCurr = pTemplate->m_hMenuShared;
		}
	}
	else	// Frame's default menu
	{
		UINT uiDefMenuResId = m_pMenuBar->GetDefaultMenuResId ();
		if (uiDefMenuResId != 0)
		{
			HINSTANCE hInst = AfxFindResourceHandle (
				MAKEINTRESOURCE (uiDefMenuResId), RT_MENU);

			hOldMenu = m_pMenuBar->m_hDefaultMenu;

			HMENU hDefaultMenu = ::LoadMenu (hInst, MAKEINTRESOURCE (uiDefMenuResId));
			m_pMenuBar->OnDefaultMenuLoaded (hDefaultMenu);

			m_pMenuBar->CreateFromMenu (hDefaultMenu, TRUE);

			if (m_pParentFrame != NULL)
			{
				if (m_pParentFrame->SendMessage (BCGM_RESETMENU, uiDefMenuResId))
                {
                    m_pMenuBar->AdjustLayout();
                };

				m_pParentFrame->m_hMenuDefault = hDefaultMenu;
			}

			g_menuHash.SaveMenuBar (hDefaultMenu, m_pMenuBar);

			if (m_bIsDefaultMDIMenu)
			{
				m_hmenuCurr = hDefaultMenu;
			}
		}
	}

//.........这里部分代码省略.........
开发者ID:SnipeDragon,项目名称:gamecq,代码行数:101,代码来源:MenuPage.cpp

示例2: ASSERT_VALID

//********************************************************************************
BOOL CBCGPRibbonSlider::OnProcessKey (UINT nChar)
{
	ASSERT_VALID (this);

	const int nPrevPos = m_nPos;
	int nPos = m_nPos;

	switch (nChar)
	{
	case VK_LEFT:
		if (!IsVert ())
		{
			nPos--;
		}
		else
		{
			return FALSE;
		}
		break;

	case VK_UP:
		if (IsVert ())
		{
			nPos++;
		}
		else
		{
			return FALSE;
		}
		break;

	case VK_SUBTRACT:
		if (!m_bZoomButtons)
		{
			return FALSE;
		}

	case VK_PRIOR:
		if (IsVert ())
		{
			nPos += m_nPageSize;
		}
		else
		{
			nPos -= m_nPageSize;
		}
		break;

	case VK_ADD:
		if (!m_bZoomButtons)
		{
			return FALSE;
		}

	case VK_NEXT:
		if (IsVert ())
		{
			nPos -= m_nPageSize;
		}
		else
		{
			nPos += m_nPageSize;
		}
		break;

	case VK_RIGHT:
		if (!IsVert ())
		{
			nPos++;
		}
		else
		{
			return FALSE;
		}
		break;

	case VK_DOWN:
		if (IsVert ())
		{
			nPos--;
		}
		else
		{
			return FALSE;
		}
		break;

	case VK_HOME:
		nPos = IsVert () ? m_nMax : m_nMin;
		break;

	case VK_END:
		nPos = IsVert () ? m_nMin : m_nMax;
		break;

	default:
		return FALSE;
	}

//.........这里部分代码省略.........
开发者ID:cugxiangzhenwei,项目名称:WorkPlatForm,代码行数:101,代码来源:BCGPRibbonSlider.cpp

示例3: ASSERT_VALID

HFONT CToolBoxCtrl::SetCurrFont(CDC* pDC)
{
	ASSERT_VALID(pDC);

	return(HFONT) ::SelectObject(pDC->GetSafeHdc(), m_hFont != NULL ? m_hFont : ::GetStockObject(DEFAULT_GUI_FONT));
}
开发者ID:ECNU-ZR,项目名称:physwf-c-lab,代码行数:6,代码来源:ToolBoxCtrl.cpp

示例4: ASSERT_VALID

void MyGraph::DrawLegend(CDC& dc)
{
	VALIDATE;
	ASSERT_VALID(&dc);

	// Create the legend font.
	CFont fontLegend;
	int pointFontHeight = max(m_rcGraph.Height() / LEGEND_DIVISOR, MIN_FONT_SIZE);
	VERIFY(fontLegend.CreatePointFont(pointFontHeight, _T("Arial"), &dc));

	// Get the height of each label.
	LOGFONT lf;
	::SecureZeroMemory(&lf, sizeof(lf));
	VERIFY(fontLegend.GetLogFont(&lf));
	int nLabelHeight(abs(lf.lfHeight));

	// Get number of legend entries
	int nLegendEntries = max(1, GetMaxSeriesSize());

	// Calculate optimal label height = AvailableLegendHeight/AllAuthors
	// Use a buffer of (GAP_PIXELS / 2) on each side inside the legend, and in addition the same
	// gab above and below the legend frame, so in total 2*GAP_PIXELS
	double optimalLabelHeight = double(m_rcGraph.Height() - 2*GAP_PIXELS)/nLegendEntries;

	// Now relate the LabelHeight to the PointFontHeight
	int optimalPointFontHeight = int(pointFontHeight*optimalLabelHeight/nLabelHeight);

	// Limit the optimal PointFontHeight to the available range
	optimalPointFontHeight = min( max(optimalPointFontHeight, MIN_FONT_SIZE), pointFontHeight);

	// If the optimalPointFontHeight is different from the initial one, create a new legend font
	if (optimalPointFontHeight != pointFontHeight) {
		fontLegend.DeleteObject();
		VERIFY(fontLegend.CreatePointFont(optimalPointFontHeight, _T("Arial"), &dc));
		VERIFY(fontLegend.GetLogFont(&lf));
		nLabelHeight = abs(lf.lfHeight);
	}

	// Calculate maximum number of authors that can be shown with the current label height
	int nShownAuthors = (m_rcGraph.Height() - 2*GAP_PIXELS)/nLabelHeight - 1;
	// Fix rounding errors.
	if (nShownAuthors+1 == GetMaxSeriesSize())
		++nShownAuthors;

	// Get number of authors to be shown.
	nShownAuthors = min(nShownAuthors, GetMaxSeriesSize());
	// nShownAuthors contains now the number of authors

	CFont* pFontOld = dc.SelectObject(&fontLegend);
	ASSERT_VALID(pFontOld);

	// Determine actual size of legend.  A buffer of (GAP_PIXELS / 2) on each side,
	// plus the height of each label based on the pint size of the font.
	int nLegendHeight = (GAP_PIXELS / 2) + (nShownAuthors * nLabelHeight) + (GAP_PIXELS / 2);
	// Draw the legend border.  Allow LEGEND_COLOR_BAR_PIXELS pixels for
	// display of label bars.
	m_rcLegend.top = (m_rcGraph.Height() - nLegendHeight) / 2;
	m_rcLegend.bottom = m_rcLegend.top + nLegendHeight;
	m_rcLegend.right = m_rcGraph.Width() - GAP_PIXELS;
	m_rcLegend.left = m_rcLegend.right - GetMaxLegendLabelLength(dc) -
		LEGEND_COLOR_BAR_WIDTH_PIXELS;
	VERIFY(dc.Rectangle(m_rcLegend));

	int skipped_row = -1; // if != -1, this is the row that we show the ... in
	if (nShownAuthors < GetMaxSeriesSize())
		skipped_row = nShownAuthors-2;
	// Draw each group's label and bar.
	for (int nGroup = 0; nGroup < nShownAuthors; ++nGroup) {

		int nLabelTop(m_rcLegend.top + (nGroup * nLabelHeight) +
			(GAP_PIXELS / 2));

		int nShownGroup = nGroup; // introduce helper variable to avoid code duplication

		// Do we have a skipped row?
		if (skipped_row != -1)
		{
			if (nGroup == skipped_row) {
				// draw the dots
				VERIFY(dc.TextOut(m_rcLegend.left + GAP_PIXELS, nLabelTop, _T("...") ));
				continue;
			}
			if (nGroup == nShownAuthors-1) {
				// we show the last group instead of the scheduled group
				nShownGroup = GetMaxSeriesSize()-1;
			}
		}
		// Draw the label.
		VERIFY(dc.TextOut(m_rcLegend.left + GAP_PIXELS, nLabelTop,
			m_saLegendLabels.GetAt(nShownGroup)));

		// Determine the bar.
		CRect rcBar;
		rcBar.left = m_rcLegend.left + GAP_PIXELS + GetMaxLegendLabelLength(dc) + GAP_PIXELS;
		rcBar.top = nLabelTop + LEGEND_COLOR_BAR_GAP_PIXELS;
		rcBar.right = m_rcLegend.right - GAP_PIXELS;
		rcBar.bottom = rcBar.top + nLabelHeight - LEGEND_COLOR_BAR_GAP_PIXELS;
		VERIFY(dc.Rectangle(rcBar));

		// Draw bar for group.
//.........这里部分代码省略.........
开发者ID:ghostenter,项目名称:TortoiseGit,代码行数:101,代码来源:MyGraph.cpp

示例5: GetDocument

void CDijshowView::OnDraw(CDC* pDC)
{
	CDijshowDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	CRect client,rect;  
    CPoint point;  
    CDC dc,*pDrawDC;
    CBitmap bitmap, *pOldBitmap;
    pDC->GetClipBox(client);
    point=client.TopLeft();
 
  // draw to offscreen bitmap for fast looking repaints
	if (dc.CreateCompatibleDC(pDC))
	{
		if (bitmap.CreateCompatibleBitmap(pDC, client.Width(),client.Height()))
		{
			OnPrepareDC(&dc, NULL);//用途?
			
			pDrawDC = &dc;
			// offset origin more because bitmap is just piece of the whole drawing
			pOldBitmap = dc.SelectObject(&bitmap);
			
			dc.OffsetViewportOrg(-client.left, -client.top);
		//	dc.OffsetViewportOrg(client.left, client.top);		
			dc.SetBrushOrg(client.left % 8, client.top % 8);
			// might as well clip to the same rectangle
			dc.IntersectClipRect(client);
			//用途 
		}
		
	}  
	
	CBrush br;
//	CBrush * old_br;

	br.CreateSolidBrush(RGB(255,255,255));
	pDrawDC->SelectObject(br);
	CRect rect1(client.left-5,client.top-5,client.right+5,client.bottom+5);
	pDrawDC->Rectangle(rect1);

	POSITION pos = NodeList.GetHeadPosition();
	for (int i=0;i < NodeList.GetCount();i++)
	{	
	    CNodeObject * node=NodeList.GetNext(pos);
		node->Draw(pDrawDC);
	}
	pos = PathList.GetHeadPosition();
	for ( i=0;i < PathList.GetCount();i++)
	{	
	    CPathObject * path=PathList.GetNext(pos);
		path->Draw(pDrawDC);
	}

    if (pDrawDC != pDC)
	{
		pDC->SetViewportOrg(0, 0);
		pDC->SetWindowOrg(0,0);
		pDC->SetMapMode(MM_TEXT);
		dc.SetViewportOrg(0, 0);
		dc.SetWindowOrg(0,0);
		dc.SetMapMode(MM_TEXT);
		pDC->BitBlt(client.left,client.top, client.Width(),client.Height(),
			&dc, 0,0, SRCCOPY);
		dc.SelectObject(pOldBitmap);
	}


	// TODO: add draw code for native data here
}
开发者ID:jiangzhw,项目名称:DijkstraPathShow,代码行数:69,代码来源:dijshowView.cpp

示例6: GetFirstViewPosition

void CDocument::UpdateFrameCounts()
	 // assumes 1 doc per frame
{
	// walk all frames of views (mark and sweep approach)
	POSITION pos = GetFirstViewPosition();
	while (pos != NULL)
	{
		CView* pView = GetNextView(pos);
		ASSERT_VALID(pView);
		ASSERT(::IsWindow(pView->m_hWnd));
		if (pView->IsWindowVisible())   // Do not count invisible windows.
		{
			CFrameWnd* pFrame = pView->GetParentFrame();
			if (pFrame != NULL)
				pFrame->m_nWindow = -1;     // unknown
		}
	}

	// now do it again counting the unique ones
	int nFrames = 0;
	pos = GetFirstViewPosition();
	while (pos != NULL)
	{
		CView* pView = GetNextView(pos);
		ASSERT_VALID(pView);
		ASSERT(::IsWindow(pView->m_hWnd));
		if (pView->IsWindowVisible())   // Do not count invisible windows.
		{
			CFrameWnd* pFrame = pView->GetParentFrame();
			if (pFrame != NULL && pFrame->m_nWindow == -1)
			{
				ASSERT_VALID(pFrame);
				// not yet counted (give it a 1 based number)
				pFrame->m_nWindow = ++nFrames;
			}
		}
	}

	// lastly walk the frames and update titles (assume same order)
	// go through frames updating the appropriate one
	int iFrame = 1;
	pos = GetFirstViewPosition();
	while (pos != NULL)
	{
		CView* pView = GetNextView(pos);
		ASSERT_VALID(pView);
		ASSERT(::IsWindow(pView->m_hWnd));
		if (pView->IsWindowVisible())   // Do not count invisible windows.
		{
			CFrameWnd* pFrame = pView->GetParentFrame();
			if (pFrame != NULL && pFrame->m_nWindow == iFrame)
			{
				ASSERT_VALID(pFrame);
				if (nFrames == 1)
					pFrame->m_nWindow = 0;      // the only one of its kind
				pFrame->OnUpdateFrameTitle(TRUE);
				iFrame++;
			}
		}
	}
	ASSERT(iFrame == nFrames + 1);
}
开发者ID:pixelspark,项目名称:corespark,代码行数:62,代码来源:doccore.cpp

示例7: ASSERT_VALID

void CDocument::OnFinalRelease()
{
	ASSERT_VALID(this);

	OnCloseDocument();  // may 'delete this'
}
开发者ID:pixelspark,项目名称:corespark,代码行数:6,代码来源:doccore.cpp

示例8: ASSERT_VALID

void COXItemTipWnd::Display(CRect& rect, CString sText, int nOffset, int nAlignment,
							CFont* pFont, COLORREF clrText, COLORREF clrBackground)
{
	ASSERT_VALID(m_pParentWnd);
    ASSERT(::IsWindow(m_pParentWnd->GetSafeHwnd()));
	ASSERT(::IsWindow(m_hWnd));

	CWnd* pWnd=GetActiveWindow();
	if(pWnd==NULL || (!IsDescendant(pWnd,m_pParentWnd) && 
		(m_pParentWnd->GetExStyle()&WS_EX_TOPMOST)!=WS_EX_TOPMOST))
	{
		return;
	}

	CClientDC dc(this); // device context for drawing
	
	CFont* pOldFont=NULL;
	if(pFont)
	{
		pOldFont=dc.SelectObject(pFont);
	}
	COLORREF clrOld=ID_OX_COLOR_NONE;
	if(clrText!=ID_OX_COLOR_NONE)
	{
		clrOld=dc.SetTextColor(clrText);
	}
	int nOldBkMode=dc.SetBkMode(TRANSPARENT);

	CRect rectDraw=rect;
	dc.DrawText(sText,&rectDraw,DT_CALCRECT|DT_LEFT|DT_SINGLELINE|DT_NOPREFIX);
	rectDraw.right+=2*nOffset;
	if(rectDraw.Width()>rect.Width())
	{
		rect.right=rect.left+rectDraw.Width();
	}
	if(rectDraw.Height()>rect.Height())
	{
		rect.bottom=rect.top+rectDraw.Height();
	}

	// it's show time!
	m_pParentWnd->ClientToScreen(&rect);

	// adjust rectangle to fit the screen
	//
	CWnd* pParentWnd=m_pParentWnd;
	BOOL bTopMostParent=FALSE;
	while(pParentWnd!=NULL)
	{
		if(pParentWnd->GetExStyle() & WS_EX_TOPMOST)
		{
			bTopMostParent=TRUE;
			break;
		}
		pParentWnd=pParentWnd->GetParent();
	}

	DWORD dwMessagePos=::GetMessagePos();
	CPoint point(GET_X_LPARAM(dwMessagePos),GET_Y_LPARAM(dwMessagePos));
	CRect rectDisplay=GetMonitorRectFromPoint(point,!bTopMostParent);

	if(rect.right>rectDisplay.right)
	{
		rect.OffsetRect(rectDisplay.right-rect.right,0);
	}
	if(rect.left<rectDisplay.left)
	{
		rect.OffsetRect(rectDisplay.left-rect.left,0);
	}
	//
	/////////////////////////////////////////////////////////////

	if(bTopMostParent)
	{
		SetWindowPos(&wndTopMost,rect.left,rect.top,rect.Width(),
			rect.Height(),SWP_NOACTIVATE);
	}
	else
	{
		SetWindowPos(NULL,rect.left,rect.top,rect.Width(),
			rect.Height(),SWP_NOZORDER|SWP_NOACTIVATE);
	}
	ShowWindow(SW_SHOWNA);

	if(clrBackground!=ID_OX_COLOR_NONE)
	{
		CBrush brush;
		brush.CreateSolidBrush(clrBackground);
		CRect rectClient;
		GetClientRect(rectClient);
		dc.FillRect(&rectClient,&brush);
	}
	else
	{
		SendMessage(WM_ERASEBKGND,(WPARAM)(HDC)dc);
	}

	rectDraw=rect;
	rectDraw.DeflateRect(nOffset,0);
	ScreenToClient(&rectDraw);
//.........这里部分代码省略.........
开发者ID:Spritutu,项目名称:AiPI-1,代码行数:101,代码来源:OXItemTipWnd.cpp

示例9: AfxMessageBox

CDocument* CMyDocManager::OpenDocumentFile(LPCTSTR lpszFileName)
{
	// From MFC: CDocManager::OpenDocumentFile

	CString strFileName = lpszFileName;

	strFileName.TrimLeft();
	strFileName.TrimRight();
	if (strFileName[0] == '\"')
		strFileName.Delete(0);
	int nPos = strFileName.ReverseFind('\"');
	if (nPos != -1)
		strFileName.Delete(nPos);

	CString strQuery, strPage;
	nPos = strFileName.Find('?');
	if (nPos != -1)
	{
		strQuery = strFileName.Mid(nPos + 1);
		strFileName = strFileName.Left(nPos);
	}

	bool bPathTooLong = false;
	TCHAR szPath[_MAX_PATH];
	if (!AfxFullPath(szPath, strFileName))
		bPathTooLong = true;

	if (bPathTooLong || !PathFileExists(szPath))
	{
		// Try extracting page number
		nPos = strFileName.ReverseFind('#');
		if (nPos != -1)
		{
			strPage = strFileName.Mid(nPos + 1);
			strFileName = strFileName.Left(nPos);

			if (!AfxFullPath(szPath, strFileName))
				bPathTooLong = true;
		}
	}

	if (bPathTooLong)
	{
		AfxMessageBox(FormatString(IDS_PATH_TOO_LONG, szPath), MB_ICONEXCLAMATION | MB_OK);
		return NULL;
	}

	TCHAR szLinkName[_MAX_PATH];
	if (AfxResolveShortcut(GetMainWnd(), szPath, szLinkName, _MAX_PATH))
		lstrcpy(szPath, szLinkName);

	// find the highest confidence
	CDocTemplate::Confidence bestMatch = CDocTemplate::noAttempt;
	CDocTemplate* pBestTemplate = NULL;
	CDocument* pOpenDocument = NULL;
	CMainFrame* pOldMainFrm = (CMainFrame*) theApp.m_pMainWnd;

	POSITION pos = m_templateList.GetHeadPosition();
	while (pos != NULL)
	{
		CDocTemplate* pTemplate = (CDocTemplate*)m_templateList.GetNext(pos);
		ASSERT_KINDOF(CDocTemplate, pTemplate);

		CDocTemplate::Confidence match;
		ASSERT(pOpenDocument == NULL);
		match = pTemplate->MatchDocType(szPath, pOpenDocument);
		if (match > bestMatch)
		{
			bestMatch = match;
			pBestTemplate = pTemplate;
		}
		if (match == CDocTemplate::yesAlreadyOpen)
			break;
	}

	if (pOpenDocument != NULL)
	{
		POSITION pos = pOpenDocument->GetFirstViewPosition();
		if (pos != NULL)
		{
			CView* pView = pOpenDocument->GetNextView(pos);
			ASSERT_VALID(pView);

			CMainFrame* pMainFrm = (CMainFrame*) pView->GetTopLevelFrame();
			pMainFrm->ActivateDocument(pOpenDocument);
		}
		else
			TRACE(_T("Error: Can not find a view for document to activate.\n"));
	}

	if (pOpenDocument == NULL)
	{
		if (pBestTemplate == NULL)
		{
			AfxMessageBox(AFX_IDP_FAILED_TO_OPEN_DOC);
			return NULL;
		}

		pOpenDocument = pBestTemplate->OpenDocumentFile(szPath);
	}
//.........这里部分代码省略.........
开发者ID:ijprest,项目名称:WinDjVu,代码行数:101,代码来源:MyDocManager.cpp

示例10: ASSERT

CDocument* CSingleDocTemplate::OpenDocumentFile(LPCTSTR lpszPathName,
	BOOL bMakeVisible)
	// if lpszPathName == NULL => create new file of this type
{
	CDocument* pDocument = NULL;
	CFrameWnd* pFrame = NULL;
	BOOL bCreated = FALSE;      // => doc and frame created
	BOOL bWasModified = FALSE;

	if (m_pOnlyDoc != NULL)
	{
		// already have a document - reinit it
		pDocument = m_pOnlyDoc;
		if (!pDocument->SaveModified())
			return NULL;        // leave the original one

		pFrame = (CFrameWnd*)AfxGetMainWnd();
		ASSERT(pFrame != NULL);
		ASSERT_KINDOF(CFrameWnd, pFrame);
		ASSERT_VALID(pFrame);
	}
	else
	{
		// create a new document
		pDocument = CreateNewDocument();
		ASSERT(pFrame == NULL);     // will be created below
		bCreated = TRUE;
	}

	if (pDocument == NULL)
	{
		AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
		return NULL;
	}
	ASSERT(pDocument == m_pOnlyDoc);

	if (pFrame == NULL)
	{
		ASSERT(bCreated);

		// create frame - set as main document frame
		BOOL bAutoDelete = pDocument->m_bAutoDelete;
		pDocument->m_bAutoDelete = FALSE;
					// don't destroy if something goes wrong
		pFrame = CreateNewFrame(pDocument, NULL);
		pDocument->m_bAutoDelete = bAutoDelete;
		if (pFrame == NULL)
		{
			AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
			delete pDocument;       // explicit delete on error
			return NULL;
		}
	}

	if (lpszPathName == NULL)
	{
		// create a new document
		SetDefaultTitle(pDocument);

		// avoid creating temporary compound file when starting up invisible
		if (!bMakeVisible)
			pDocument->m_bEmbedded = TRUE;

		if (!pDocument->OnNewDocument())
		{
			// user has been alerted to what failed in OnNewDocument
			TRACE(traceAppMsg, 0, "CDocument::OnNewDocument returned FALSE.\n");
			if (bCreated)
				pFrame->DestroyWindow();    // will destroy document
			return NULL;
		}
	}
	else
	{
		CWaitCursor wait;

		// open an existing document
		bWasModified = pDocument->IsModified();
		pDocument->SetModifiedFlag(FALSE);  // not dirty for open

		if (!pDocument->OnOpenDocument(lpszPathName))
		{
			// user has been alerted to what failed in OnOpenDocument
			TRACE(traceAppMsg, 0, "CDocument::OnOpenDocument returned FALSE.\n");
			if (bCreated)
			{
				pFrame->DestroyWindow();    // will destroy document
			}
			else if (!pDocument->IsModified())
			{
				// original document is untouched
				pDocument->SetModifiedFlag(bWasModified);
			}
			else
			{
				// we corrupted the original document
				SetDefaultTitle(pDocument);

				if (!pDocument->OnNewDocument())
				{
//.........这里部分代码省略.........
开发者ID:jbeaurain,项目名称:omaha_vs2010,代码行数:101,代码来源:docsingl.cpp

示例11: ASSERT_VALID

void CSingleDocTemplate::AssertValid() const
{
	CDocTemplate::AssertValid();
	if (m_pOnlyDoc)
		ASSERT_VALID(m_pOnlyDoc);
}
开发者ID:jbeaurain,项目名称:omaha_vs2010,代码行数:6,代码来源:docsingl.cpp

示例12: ASSERT_VALID

void CSettingPropSheetFrame::OnSetFocus(CWnd* /*pOldWnd*/)
{
	// Forward focus to the embedded property sheet
	ASSERT_VALID(m_pModelessSettingPropSheet);
	m_pModelessSettingPropSheet->SetFocus();
}
开发者ID:bblr001,项目名称:MVS,代码行数:6,代码来源:SettingPropSheetFrame.cpp

示例13: ASSERT_VALID

CUniformResourceLocator& CUniformResourceLocator::operator = ( const CUniversalNamingConvention& source )
{
   ASSERT_VALID( this );
   Copy( source );
   return( *this );
}
开发者ID:DimeSPb,项目名称:ecuExplorer,代码行数:6,代码来源:CURL.CPP

示例14: GetDocument

void CNPainterView::OnDraw(CDC* pDC)
{
	CNPainterDoc* pdoc = GetDocument();
	ASSERT_VALID(pdoc);
	if (!pdoc)
		return;

	CRect client, rect;
	
	CDC dc;
	CDC *pdrawdc = pDC;
	CBitmap bitmap;
	CBitmap* poldbmp = nullptr;
	pDC->GetClipBox(client);
	rect = client;
	docToClient(rect);
	CString str;
	str.Format(_T("CNPainterView::OnDraw clipRect:<%d,%d,%d,%d %d,%d>"), rect.left, rect.top, rect.right, rect.bottom, rect.Width(), rect.Height());
	AfxGetMainWnd()->SetWindowText(str);
	if(!pDC->IsPrinting())
	{
		if(dc.CreateCompatibleDC(pDC))
		{
			if(bitmap.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height()))
			{
				OnPrepareDC(&dc, NULL);
				pdrawdc = &dc;
				dc.OffsetViewportOrg(-rect.left, -rect.top);
				poldbmp = dc.SelectObject(&bitmap);
				dc.SetBrushOrg(rect.left % 8, rect.top % 8);

				// might as well clip to the same rectangle
				//dc.SelectClipRgn(NULL);
				dc.IntersectClipRect(client);
			}
		}
	}
	//// 更新背景
	//if(!pdrawdc->IsPrinting())
	//	DoDrawBackground(pdrawdc);
	//// 背景图片
	//pdoc->m_adminObjs.DrawPaperBack(pdrawdc);
	////// 画网格 VSP3.1 网格线已经集成到itobjPage::Draw()
	////if(!pdrawdc->IsPrinting() && pdoc->m_adminObjs.IsVisibleGrid())
	////	DoDrawGrid(pdrawdc);
	//pdoc->m_adminObjs.DrawObjects(pdrawdc);
	//// 绘制选中标识
	//DoDrawSelectItems(pdrawdc);
	// 
	pdoc->getAdminer().drawBackground(pdrawdc, m_szWorker);
	//// 画对象
	pdoc->getAdminer().draw(pdrawdc, this);
	pdoc->draw(pdrawdc);
	// 刷新客户区
	
	//if(pdrawdc != pDC)
	//{	
	//	pDC->BitBlt(client.left, client.top, client.Width(), client.Height(), pdrawdc, client.left, client.top, SRCCOPY);
	//	if(poldbmp)
	//		pdrawdc->SelectObject(poldbmp);
	//}
	if (pdrawdc != pDC)
	{
		pDC->SetViewportOrg(0, 0);
		pDC->SetWindowOrg(0,0);
		pDC->SetMapMode(MM_TEXT);
		dc.SetViewportOrg(0, 0);
		dc.SetWindowOrg(0,0);
		dc.SetMapMode(MM_TEXT);
		pDC->BitBlt(rect.left, rect.top, rect.Width(), rect.Height(),
			&dc, 0, 0, SRCCOPY);
		dc.SelectObject(poldbmp);
	}

	

}
开发者ID:madsen-git,项目名称:NTools,代码行数:77,代码来源:NTool.cpp


注:本文中的ASSERT_VALID函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。