Exemplo n.º 1
0
BOOL COXDateTimeCtrl::Create(DWORD dwStyle, const RECT& rect,
							 CWnd* pParentWnd, UINT nID)
{
	BOOL bRetVal=FALSE;

#if _MFC_VER<=0x0421
	// initialize common controls
	if(!bComCtlInitialized)
	{
		InitializeDTPCtrl();
		bComCtlInitialized = true;
	}

	CWnd* pWnd = this;
	bRetVal=pWnd->Create(DATETIMEPICK_CLASS, NULL, dwStyle, rect, pParentWnd, nID);
#else
	bRetVal=CDateTimeCtrl::Create(dwStyle,rect,pParentWnd,nID);
#endif	//_MFC_VER<=0x0421

	if(bRetVal && !InitDateTimeCtrl())
	{
		TRACE(_T("COXDateTimeCtrl::Create: failed to initialize the date time control"));
		bRetVal=FALSE;
	}

	return bRetVal;
}
Exemplo n.º 2
0
BOOL COXMonthCalCtrl::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID,
							 DWORD dwMonthCalStyle/*=OXMCS_BOLDHOLIDAYS|OXMCS_INFOTIP*/)
{
	m_dwMonthCalStyle=dwMonthCalStyle;

	BOOL bRetVal=FALSE;

#if _MFC_VER<=0x0421
	// initialize common controls
	if(!bComCtlInitialized)
	{
		INITCOMMONCONTROLSEX icex;
		icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
		icex.dwICC = ICC_DATE_CLASSES;
		::InitCommonControlsEx(&icex);
		bComCtlInitialized = true;
	}

	CWnd* pWnd = this;
	bRetVal=pWnd->Create(MONTHCAL_CLASS, NULL, dwStyle, rect, pParentWnd, nID);
#else
	bRetVal=CMonthCalCtrl::Create(dwStyle,rect,pParentWnd,nID);
#endif	//_MFC_VER<=0x0421

	if(bRetVal && !InitMonthCalCtrl())
	{
		TRACE(_T("COXMonthCalCtrl::Create: failed to initialize the calendar control"));
		bRetVal=FALSE;
	}

	return bRetVal;
}
Exemplo n.º 3
0
CWnd* CMyDocTemplate::CreateNewMDIChild(CDocument* pDoc)
{
	CMainFrame* pMainFrame = (CMainFrame*) theApp.m_pMainWnd;
	ASSERT(pMainFrame != NULL);

	CCreateContext context;
	context.m_pCurrentFrame = NULL;
	context.m_pCurrentDoc = pDoc;
	context.m_pNewViewClass = m_pViewClass;
	context.m_pNewDocTemplate = this;

	CWnd* pMDIChild = (CWnd*) m_pMDIChildClass->CreateObject();
	if (pMDIChild == NULL)
	{
		TRACE(_T("Warning: Dynamic create of MDI child %hs failed.\n"),
				m_pMDIChildClass->m_lpszClassName);
		return NULL;
	}

	if (!pMDIChild->Create(NULL, NULL, WS_CHILD, CRect(0, 0, 0, 0), pMainFrame, AFX_IDW_PANE_FIRST, &context))
	{
		TRACE(_T("Warning: could not create MDI child.\n"));
		return NULL;
	}

	return pMDIChild;
}
Exemplo n.º 4
0
BOOL CRichEditCtrl::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID)
{
	if (!AfxInitRichEdit())
		return FALSE;

	CWnd* pWnd = this;
	return pWnd->Create(_T("RICHEDIT"), NULL, dwStyle, rect, pParentWnd, nID);
}
Exemplo n.º 5
0
BOOL CCJToolBarCtrl::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd,
                            UINT nID)
{
  CWnd* pWnd = this;
  BOOL bCreated = pWnd->Create(TOOLBARCLASSNAME, NULL, dwStyle, rect, pParentWnd, nID);

  return bCreated;
}
Exemplo n.º 6
0
BOOL CEGPropertyGrid::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID)
{
	CWnd* pWnd = this;

	LPCTSTR pszCreateClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW, ::LoadCursor(NULL, IDC_ARROW));

	return pWnd->Create(pszCreateClass, _T(""), dwStyle, rect, pParentWnd, nID);
}
Exemplo n.º 7
0
BOOL CReBarCtrl::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd,
	UINT nID)
{
	// initialize common controls
	VERIFY(AfxDeferRegisterClass(AFX_WNDCOMMCTL_COOL_REG));

	CWnd* pWnd = this;
	return pWnd->Create(REBARCLASSNAME, NULL, dwStyle, rect, pParentWnd, nID);
}
Exemplo n.º 8
0
BOOL CMonthCalCtrl::Create(DWORD dwStyle, const RECT& rect,
                           CWnd* pParentWnd, UINT nID)
{
    // initialize common controls
    VERIFY(AfxDeferRegisterClass(AFX_WNDCOMMCTL_DATE_REG));

    CWnd* pWnd = this;
    return pWnd->Create(MONTHCAL_CLASS, NULL, dwStyle, rect, pParentWnd, nID);
}
Exemplo n.º 9
0
BOOL CComboBoxEx::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd,
	UINT nID)
{
	// initialize common controls
	VERIFY(AfxDeferRegisterClass(AFX_WNDCOMMCTL_USEREX_REG));

	CWnd* pWnd = this;
	return pWnd->Create(WC_COMBOBOXEX, NULL, dwStyle, rect, pParentWnd, nID);
}
Exemplo n.º 10
0
BOOL CHTMLayoutCtrl::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd,
  UINT nID)
{
  CWnd* pWnd = this;
  if(pWnd->Create(::HTMLayoutClassNameT(), NULL, dwStyle, rect, pParentWnd, nID))
  {
    SetCallback(); // reroute all HTMLayout notifications directly to this class
    return TRUE;
  }
  return FALSE;
}
Exemplo n.º 11
0
BOOL CIPAddressCtrl::Create(DWORD dwStyle, const RECT& rect,
	CWnd* pParentWnd, UINT nID)
{
	// initialize common controls
	VERIFY(AfxDeferRegisterClass(AFX_WNDCOMMCTL_INTERNET_REG));

	// the IP Address Control must be a child
	ASSERT(dwStyle & WS_CHILD);

	CWnd* pWnd = this;
	return pWnd->Create(WC_IPADDRESS, NULL, dwStyle, rect, pParentWnd, nID);
}
Exemplo n.º 12
0
HRESULT STDMETHODCALLTYPE CTextView::CreateWnd(HWND hWndParent)
{
	CWnd *pWnd = (CWnd*)this;
	CWnd *wndParent = CWnd::FromHandle(hWndParent);
	CRect _Rect(0,0, 100, 100);

	if (pWnd->Create(NULL,
					("MFC CEditView "),
					WS_HSCROLL|WS_VSCROLL|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_VISIBLE|ES_MULTILINE|ES_AUTOHSCROLL,
					_Rect, wndParent, 0))
	{
		m_pEdit = &GetEditCtrl();
		return S_OK;
	}

	return S_FALSE;
}
Exemplo n.º 13
0
BOOL CXTComboBoxEx::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID)
{
	#if (_MSC_VER <= 1100) // Using Visual C++ 5.0

	// initialize common controls
	INITCOMMONCONTROLSEX icex;
	icex.dwSize = sizeof(icex);
	icex.dwICC = ICC_USEREX_CLASSES;
	VERIFY(InitCommonControlsEx(&icex));

	#else

	// initialize common controls
	VERIFY(AfxDeferRegisterClass(AFX_WNDCOMMCTL_USEREX_REG));

	#endif//#if (_MSC_VER <= 1100) // Using Visual C++ 5.0

	CWnd* pWnd = this;
	return pWnd->Create(WC_COMBOBOXEX, NULL, dwStyle, rect, pParentWnd, nID);
}
Exemplo n.º 14
0
BOOL CSTabCtrl::CreateView(INT iTab,CRuntimeClass* pViewClass, SIZE sizeInit, CCreateContext* pContext)
{
	ASSERT_VALID(this);
	ASSERT(pViewClass != NULL);
	ASSERT(pViewClass->IsDerivedFrom(RUNTIME_CLASS(CWnd)));
	ASSERT(AfxIsValidAddress(pViewClass, sizeof(CRuntimeClass), FALSE));

	CWnd* pWnd;
	TRY
	{
		pWnd = (CWnd*)pViewClass->CreateObject();
		if (pWnd == NULL)
			AfxThrowMemoryException();
	}
	CATCH_ALL(e)
	{
		TRACE0("Out of memory creating a splitter pane.\n");
		// Note: DELETE_EXCEPTION(e) not required
		return FALSE;
	}
	END_CATCH_ALL

	ASSERT_KINDOF(CWnd, pWnd);
	ASSERT(pWnd->m_hWnd == NULL);       // not yet created

	DWORD dwStyle = AFX_WS_DEFAULT_VIEW;

	// Create with the right size (wrong position)
	CRect rect(CPoint(0,0), sizeInit);
	if (!pWnd->Create(NULL, NULL, dwStyle,
		rect, this, iTab, pContext))
	{
		TRACE0("Warning: couldn't create client pane for splitter.\n");
			// pWnd will be cleaned up by PostNcDestroy
		return FALSE;
	}

	AttachControlToTab(pWnd,iTab);

	return TRUE;
}
int CStatusView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	USES_CONVERSION;
	if (CView::OnCreate(lpCreateStruct) == -1)
		return -1;

	// Create the style
	DWORD dwStyle = WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_READONLY | WS_VSCROLL | ES_AUTOVSCROLL | ES_NOHIDESEL;
	
	// Custom initialization of the richedit control
#if _MFC_VER > 0x0600
	VERIFY(AfxInitRichEdit() || AfxInitRichEdit2());
#else
	VERIFY(AfxInitRichEdit());
#endif

	CWnd* pWnd = m_pRichEditCtrl;
	BOOL bResult = pWnd->Create(RICHEDIT_CLASS, NULL, dwStyle, CRect(1, 1, 10, 10), this, 0);

	return (bResult ? 0 : -1);
}
Exemplo n.º 16
0
BOOL CRichEditCtrl::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID)
{
	_AFX_RICHEDIT_STATE* pState = _afxRichEditState;
	if (pState->m_hInstRichEdit == NULL)
	{
#ifndef _MAC
		pState->m_hInstRichEdit = LoadLibraryA("RICHED32.DLL");
#else
#ifndef _AFXDLL
		// Ordinarily the __gForceREInit reference would be produced by richedit.h, but
		// MFC builds with _WLM_NOFORCE_LIBS, which prevents richedit.h from generating
		// the reference.
		pState->m_hInstRichEdit = ((HINSTANCE)__gForceREInit), RELoadLibrary();
#else
		pState->m_hInstRichEdit = RELoadLibrary();
#endif
#endif
		if (pState->m_hInstRichEdit == NULL)
			return FALSE;
	}

	CWnd* pWnd = this;
	return pWnd->Create(_T("RICHEDIT"), NULL, dwStyle, rect, pParentWnd, nID);
}
Exemplo n.º 17
0
CWnd *CFrameWnd::CreateView( CCreateContext *pContext, UINT nID )
/***************************************************************/
{
    if( pContext == NULL ) {
        return( NULL );
    }

    CRuntimeClass *pClass = pContext->m_pNewViewClass;
    if( pClass == NULL ) {
        return( NULL );
    }

    CWnd *pView = (CWnd *)pClass->CreateObject();
    if( pView == NULL ) {
        return( NULL );
    }
    ASSERT( pView->IsKindOf( RUNTIME_CLASS( CWnd ) ) );

    if( !pView->Create( NULL, NULL, AFX_WS_DEFAULT_VIEW, CRect( 0, 0, 0, 0 ),
                        this, nID, pContext ) ) {
        return( NULL );
    }
    return( pView );
}
Exemplo n.º 18
0
BOOL CStatic::Create(LPCTSTR lpszText, DWORD dwStyle,
		const RECT& rect, CWnd* pParentWnd, UINT nID)
{
	CWnd* pWnd = this;
	return pWnd->Create(_T("STATIC"), lpszText, dwStyle, rect, pParentWnd, nID);
}
Exemplo n.º 19
0
BOOL CEdit::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID)
{
	CWnd* pWnd = this;
	return pWnd->Create(_T("EDIT"), NULL, dwStyle, rect, pParentWnd, nID);
}
Exemplo n.º 20
0
BOOL CChildFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
	CCreateContext* pContext)
{
	// create a splitter with 1 row, 2 columns
	if (!m_wndSplitter.CreateStatic(this, 1, 2, WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL) )
	{
		TRACE0("Failed to CreateStaticSplitter\n");
		return FALSE;
	}

	if (!m_wndSplitter.CreateView(0, 0,
		RUNTIME_CLASS(CMergeEditView), CSize(-1, 200), pContext))
	{
		TRACE0("Failed to create first pane\n");
		return FALSE;
	}
	
	// add the second splitter pane - an input view in column 1
	if (!m_wndSplitter.CreateView(0, 1,
		RUNTIME_CLASS(CMergeEditView), CSize(-1, 200), pContext))
	{
		TRACE0("Failed to create second pane\n");
		return FALSE;
	}
	m_wndSplitter.ResizablePanes(TRUE);
	m_wndSplitter.AutoResizePanes(GetOptionsMgr()->GetBool(OPT_RESIZE_PANES));

	// Merge frame has also a dockable bar at the very left
	// This is not the client area, but we create it now because we want
	// to use the CCreateContext
	String sCaption = theApp.LoadString(IDS_LOCBAR_CAPTION);
	if (!m_wndLocationBar.Create(this, sCaption.c_str(), WS_CHILD | WS_VISIBLE, ID_VIEW_LOCATION_BAR))
	{
		TRACE0("Failed to create LocationBar\n");
		return FALSE;
	}

	CWnd* pWnd = new CLocationView;
	DWORD dwStyle = AFX_WS_DEFAULT_VIEW ;// & ~WS_BORDER;
	pWnd->Create(NULL, NULL, dwStyle, CRect(0,0,40,100), &m_wndLocationBar, 152, pContext);

	// Merge frame has also a dockable bar at the very bottom
	// This is not the client area, but we create it now because we want
	// to use the CCreateContext
	sCaption = theApp.LoadString(IDS_DIFFBAR_CAPTION);
	if (!m_wndDetailBar.Create(this, sCaption.c_str(), WS_CHILD | WS_VISIBLE, ID_VIEW_DETAIL_BAR))
	{
		TRACE0("Failed to create DiffViewBar\n");
		return FALSE;
	}

	// create a splitter with 2 rows, 1 column
	// this is not a vertical scrollable splitter (see MergeDiffDetailView.h)
	if (!m_wndDetailSplitter.CreateStatic(&m_wndDetailBar, 2, 1, WS_CHILD | WS_VISIBLE | WS_HSCROLL, AFX_IDW_PANE_FIRST+1) )
	{
		TRACE0("Failed to CreateStaticSplitter\n");
		return FALSE;
	}
	// add the first splitter pane - the default view in column 0
	if (!m_wndDetailSplitter.CreateView(0, 0,
		RUNTIME_CLASS(CMergeDiffDetailView), CSize(-1, 200), pContext))
	{
		TRACE0("Failed to create first pane\n");
		return FALSE;
	}
	// add the second splitter pane - an input view in column 1
	if (!m_wndDetailSplitter.CreateView(1, 0,
		RUNTIME_CLASS(CMergeDiffDetailView), CSize(-1, 200), pContext))
	{
		TRACE0("Failed to create second pane\n");
		return FALSE;
	}
	m_wndDetailSplitter.LockBar(TRUE);
	m_wndDetailSplitter.ResizablePanes(TRUE);
	m_wndDetailBar.setSplitter(&m_wndDetailSplitter);

	// stash left & right pointers into the mergedoc
	CMergeEditView * pLeft = (CMergeEditView *)m_wndSplitter.GetPane(0,0);
	CMergeEditView * pRight = (CMergeEditView *)m_wndSplitter.GetPane(0,1);
	// connect merge views up to display of status info
	pLeft->SetStatusInterface(&m_leftStatus);
	pRight->SetStatusInterface(&m_rightStatus);
	// tell merge doc about these views
	m_pMergeDoc = dynamic_cast<CMergeDoc *>(pContext->m_pCurrentDoc);
	m_pMergeDoc->SetMergeViews(pLeft, pRight);
	pLeft->m_nThisPane = 0;
	pRight->m_nThisPane = 1;

	// stash left & right detail pointers into the mergedoc
	CMergeDiffDetailView * pLeftDetail = (CMergeDiffDetailView *)m_wndDetailSplitter.GetPane(0,0);
	CMergeDiffDetailView * pRightDetail = (CMergeDiffDetailView *)m_wndDetailSplitter.GetPane(1,0);
	// tell merge doc about these views
	m_pMergeDoc->SetMergeDetailViews(pLeftDetail, pRightDetail);
	pLeftDetail->m_nThisPane = 0;
	pRightDetail->m_nThisPane = 1;
	
	// Set frame window handles so we can post stage changes back
	((CLocationView *)pWnd)->SetFrameHwnd(GetSafeHwnd());
	pLeftDetail->SetFrameHwnd(GetSafeHwnd());
	pRightDetail->SetFrameHwnd(GetSafeHwnd());
	m_wndLocationBar.SetFrameHwnd(GetSafeHwnd());
	m_wndDetailBar.SetFrameHwnd(GetSafeHwnd());
	return TRUE;
}
Exemplo n.º 21
0
BOOL CScrollBar::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd,
		UINT nID)
{
	CWnd* pWnd = this;
	return pWnd->Create(_T("SCROLLBAR"), NULL, dwStyle, rect, pParentWnd, nID);
}
Exemplo n.º 22
0
CWnd* CCJToolBar::InsertControl(CRuntimeClass * pClass, CString strTitle, CRect & pRect, UINT nID, DWORD dwStyle)
{
	dwStyle |= WS_CHILD | WS_VISIBLE;
	CWnd* pCtrl = 0;
	
	CRect rect = pRect;
	BOOL bCreate = FALSE;
	
	// make sure the id is valid
	ASSERT( CommandToIndex( nID ) >= 0 );
	SetButtonInfo( CommandToIndex( nID ), nID, TBBS_SEPARATOR, pRect.Width());
	
	CString strClass( pClass->m_lpszClassName );
	
	if( strClass == TEXT("CCJComboBox") ) {
		pCtrl = new CCJComboBox();
		bCreate = ((CCJComboBox*)pCtrl)->Create(dwStyle, rect, this, nID);
	}
	
	else if( strClass == TEXT("CComboBox") ) {
		pCtrl = new CComboBox();
		bCreate = ((CComboBox*)pCtrl)->Create(dwStyle, rect, this, nID);
	}
	
	else if( strClass == TEXT("CEdit") ) {
		pCtrl = new CEdit();
		bCreate = ((CEdit*)pCtrl)->Create(dwStyle, rect, this, nID);
	}
	
	else if( strClass == TEXT("CButton") ) {
		pCtrl = new CButton();
		bCreate = ((CButton*)pCtrl)->Create(strTitle,dwStyle, rect, this, nID);
	}
	
	else {
		pCtrl = (CWnd*)pClass->CreateObject();
		bCreate = pCtrl->Create(0, 0, dwStyle, rect, this, nID);
	}
	
	if( !pCtrl ) return 0;
	if( !bCreate ) { delete pCtrl; return 0; }
	
	GetItemRect( CommandToIndex(nID), &pRect );
	
	pCtrl->SetWindowPos(0, pRect.left, pRect.top, 0, 0,
		SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOCOPYBITS );
	
	pCtrl->SetFont( &m_font );
	pCtrl->ShowWindow( SW_SHOW );
	
	// we have to remember this control, so we can delete it later
	if( !m_pControls ) {
		m_pControls = new CObList();
		m_pControls->AddTail( pCtrl );
	}

	// David Cofer
	else
		m_pControls->AddTail( pCtrl);
	
	return pCtrl;
}
Exemplo n.º 23
0
BOOL CSizingTabCtrlBar::AddView(LPCTSTR lpszLabel, CRuntimeClass *pViewClass, CCreateContext *pContext)
{	

#ifdef _DEBUG
	ASSERT_VALID(this);
	ASSERT(pViewClass != NULL);
	ASSERT(pViewClass->IsDerivedFrom(RUNTIME_CLASS(CWnd)));
	ASSERT(AfxIsValidAddress(pViewClass, sizeof(CRuntimeClass), FALSE));
#endif

	CCreateContext context;
	if (pContext == NULL)
	{
		// if no context specified, generate one from the currently selected
		//  client if possible
		CView* pOldView = NULL;
		if (pOldView != NULL && pOldView->IsKindOf(RUNTIME_CLASS(CView)))
		{
			// set info about last pane
			ASSERT(context.m_pCurrentFrame == NULL);
			context.m_pLastView = pOldView;
			context.m_pCurrentDoc = pOldView->GetDocument();
			if (context.m_pCurrentDoc != NULL)
				context.m_pNewDocTemplate =
				context.m_pCurrentDoc->GetDocTemplate();
		}
		pContext = &context;
	}
	
	CWnd* pWnd;
	TRY
	{
		pWnd = (CWnd*)pViewClass->CreateObject();
		if (pWnd == NULL)
			AfxThrowMemoryException();
	}
	CATCH_ALL(e)
	{
		TRACE0("Out of memory creating a view.\n");
		// Note: DELETE_EXCEPTION(e) not required
		return FALSE;
	}
	END_CATCH_ALL
		
    ASSERT_KINDOF(CWnd, pWnd);
	ASSERT(pWnd->m_hWnd == NULL);       // not yet created
	
	DWORD dwStyle = AFX_WS_DEFAULT_VIEW;
	CRect rect;
	// Create with the right size and position
	if (!pWnd->Create(NULL, NULL, dwStyle, rect, this, 0, pContext))
	{
		TRACE0("Warning: couldn't create client pane for view.\n");
		// pWnd will be cleaned up by PostNcDestroy
		return FALSE;
	}
	m_pActiveView = (CView*) pWnd;

	TCB_ITEM *pMember=new TCB_ITEM;
	pMember->pWnd=pWnd;
	_tcscpy(pMember->szLabel, lpszLabel);
	m_views.AddTail(pMember);

	int nViews = m_views.GetCount();
	if (nViews!=1)
	{
		pWnd->EnableWindow(FALSE);
		pWnd->ShowWindow(SW_HIDE);
	}
	else
	{
		((CFrameWnd *)GetParent())->SetActiveView((CView *)m_pActiveView);
	}

	TC_ITEM tci;
	tci.mask = TCIF_TEXT | TCIF_IMAGE;
	tci.pszText = (LPTSTR)(LPCTSTR)lpszLabel;
	tci.iImage = nViews-1;
	m_tabctrl.InsertItem(nViews, &tci);

	return TRUE;
}
Exemplo n.º 24
0
BOOL CButton::Create(LPCTSTR lpszCaption, DWORD dwStyle,
		const RECT& rect, CWnd* pParentWnd, UINT nID)
{
	CWnd* pWnd = this;
	return pWnd->Create(_T("BUTTON"), lpszCaption, dwStyle, rect, pParentWnd, nID);
}
Exemplo n.º 25
0
BOOL CListBox::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd,
		UINT nID)
{
	CWnd* pWnd = this;
	return pWnd->Create(_T("LISTBOX"), NULL, dwStyle, rect, pParentWnd, nID);
}
Exemplo n.º 26
0
BOOL COXTabViewContainer::InsertPage(int nIndex, 
									 CRuntimeClass* pClass, 
									 CCreateContext* pContext,
									 LPCTSTR lpszTitle/*=NULL*/)
{
	ASSERT_VALID(this);
	ASSERT(nIndex>=0 && nIndex<=GetPageCount());
	ASSERT(pClass!=NULL);
	ASSERT(pClass->IsDerivedFrom(RUNTIME_CLASS(CWnd)));
	ASSERT(AfxIsValidAddress(pClass,sizeof(CRuntimeClass),FALSE));

	if(!(nIndex>=0 && nIndex<=GetPageCount()) || pClass==NULL)
		return FALSE;

	CCreateContext context;
	if(pContext==NULL)
	{
		// if no context specified, generate one from the currently active
		// view if possible
		CView* pOldView=(CView*)GetActivePage();
		if(pOldView!=NULL && pOldView->IsKindOf(RUNTIME_CLASS(CView)))
		{
			// set info about last pane
			ASSERT(context.m_pCurrentFrame==NULL);
			context.m_pLastView=pOldView;
			context.m_pCurrentDoc=pOldView->GetDocument();
			if(context.m_pCurrentDoc!=NULL)
			{
				context.m_pNewDocTemplate=context.m_pCurrentDoc->
					GetDocTemplate();
			}
		}
		pContext=&context;
	}

	CWnd* pWnd;
	TRY
	{
		pWnd=(CWnd*)pClass->CreateObject();
		if(pWnd==NULL)
			AfxThrowMemoryException();
	}
	CATCH_ALL(e)
	{
		TRACE(_T("COXTabViewContainer::InsertPage: Out of memory inserting new page\n"));
		// Note: DELETE_EXCEPTION(e) not required
		return FALSE;
	}
	END_CATCH_ALL

	ASSERT_KINDOF(CWnd,pWnd);
	ASSERT(pWnd->m_hWnd==NULL);       // not yet created

	DWORD dwStyle=AFX_WS_DEFAULT_VIEW;
#if _MFC_VER < 0x0700
	if(afxData.bWin4)
#endif
		dwStyle&=~WS_BORDER;

	DWORD dwID=GetUniqueId();

	// Create with the right size
	if(!pWnd->Create(NULL,NULL,dwStyle,m_rectPage,this,dwID,pContext))
	{
		TRACE(_T("COXTabViewContainer::InsertPage: couldn't create new page\n"));
		// pWnd will be cleaned up by PostNcDestroy
		return FALSE;
	}

	if(InsertPage(nIndex,pWnd,lpszTitle))
	{
		CWnd* pWnd=GetPage(nIndex);
		ASSERT(pWnd!=NULL);
		ASSERT(::IsWindow(pWnd->m_hWnd));
		if(pWnd->IsKindOf(RUNTIME_CLASS(CView)))
		{
			// send initial notification message
			pWnd->SendMessage(WM_INITIALUPDATE);
		}
		return TRUE;
	}

	return FALSE;
}
Exemplo n.º 27
0
BOOL CPictureCtrl::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID)
{
	CWnd* pWnd = this;
	return pWnd->Create(WND_CLASSNAME, NULL, dwStyle, rect, pParentWnd, nID);
}