Click here to Skip to main content
15,885,366 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
JokeRe: Off Topic Pin
toxcct4-Dec-07 21:48
toxcct4-Dec-07 21:48 
GeneralRe: compile error about member variable initialization Pin
toxcct4-Dec-07 3:23
toxcct4-Dec-07 3:23 
GeneralRe: compile error about member variable initialization Pin
Matthew Faithfull4-Dec-07 3:33
Matthew Faithfull4-Dec-07 3:33 
Generalenable tool bar button Pin
CJ9420024-Dec-07 2:43
CJ9420024-Dec-07 2:43 
GeneralRe: enable tool bar button Pin
CPallini4-Dec-07 2:56
mveCPallini4-Dec-07 2:56 
GeneralRe: enable tool bar button Pin
Maximilien4-Dec-07 3:03
Maximilien4-Dec-07 3:03 
AnswerRe: enable tool bar button Pin
Paresh Chitte4-Dec-07 18:00
Paresh Chitte4-Dec-07 18:00 
GeneralIn CFormView SDI, change CFormView dynamically, got a problem [modified] Pin
followait4-Dec-07 2:15
followait4-Dec-07 2:15 
When I call SetNewView, it's ok ,and the new formview (A) can receive message. But then I press a button in the view, and it called SetNewView to change to another formview (B), it looks ok, but B can't receive its messages, instead A receives, also, A's buttons will appear when I click on that area.
Here is how to do with CViews instead of CFormViews
http://msdn2.microsoft.com/en-us/library/s199bks0(VS.80).aspx#vcconswitchingfunctiona4[^]

BOOL CMyAlbumEditorApp::InitInstance()
{
	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	// Change the registry key under which our settings are stored.
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization.
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));

	LoadStdProfileSettings();  // Load standard INI file options (including MRU)

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views.

	CSingleDocTemplate* pDocTemplate;
	pDocTemplate = new CSingleDocTemplate(
		IDR_MAINFRAME,
		RUNTIME_CLASS(CMyAlbumEditorDoc),
		RUNTIME_CLASS(CMainFrame),       // main SDI frame window
		RUNTIME_CLASS(CMyAlbumEditorView));
	AddDocTemplate(pDocTemplate);

	// Enable DDE Execute open
	EnableShellOpen();
	RegisterShellFileTypes(TRUE);

	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	// Dispatch commands specified on the command line
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;
	
	InitViews();
	SetNewView(m_pStartView);
	

	// The one and only window has been initialized, so show and update it.
	m_pMainWnd->ShowWindow(SW_SHOW);
	m_pMainWnd->UpdateWindow();

	// Enable drag/drop open
	//m_pMainWnd->DragAcceptFiles();

	return TRUE;
}

void CMyAlbumEditorApp::InitViews()
{
	m_pNativeView = ((CFrameWnd*)m_pMainWnd)->GetActiveView();
	CDocument* pCurrentDoc = ((CFrameWnd*)m_pMainWnd)->GetActiveDocument();

	CCreateContext newContext;
	UINT viewID;
	CRect rect(0, 0, 0, 0); // Gets resized later.
	
	//////////////////////////////////////////////////////////////////////////
	//the start formview
	m_pStartView = (CView*) new CStartForm;
	newContext.m_pNewDocTemplate = NULL;
	newContext.m_pLastView = NULL;
	newContext.m_pCurrentFrame = NULL;
	newContext.m_pCurrentDoc = pCurrentDoc;
	viewID = AFX_IDW_PANE_FIRST;
	m_pStartView->Create(NULL, "StartFormViewName", WS_CHILD, rect, m_pMainWnd, viewID, &newContext);
	m_pStartView->SendMessage(WM_INITIALUPDATE, 0, 0);

	//////////////////////////////////////////////////////////////////////////
	//the album property formview
	m_pAlbumPropertyView = (CView*) new CAlbumPropertyForm;
	newContext.m_pNewViewClass = NULL;
	newContext.m_pNewDocTemplate = NULL;
	newContext.m_pLastView = NULL;
	newContext.m_pCurrentFrame = NULL;
	newContext.m_pCurrentDoc = pCurrentDoc;
	viewID = AFX_IDW_PANE_FIRST;
	m_pAlbumPropertyView->Create(NULL, "AlbumPropertyFormViewName", WS_CHILD, rect, m_pMainWnd, viewID, &newContext);
	m_pAlbumPropertyView->SendMessage(WM_INITIALUPDATE, 0, 0);

//	//////////////////////////////////////////////////////////////////////////
//	//the editor formview
//	m_pEditorView = (CView*) new ;
//	newContext.m_pNewViewClass = NULL;
//	newContext.m_pNewDocTemplate = NULL;
//	newContext.m_pLastView = NULL;
//	newContext.m_pCurrentFrame = NULL;
//	newContext.m_pCurrentDoc = pCurrentDoc;
//	viewID = AFX_IDW_PANE_FIRST;
//	m_pEditorView->Create(NULL, "EditorFormViewName", WS_CHILD, rect, m_pMainWnd, viewID, &newContext);
//	m_pEditorView->SendMessage(WM_INITIALUPDATE, 0, 0);
}

void CMyAlbumEditorApp::SetNewView(CView *pNV)
{
//	CView* pAV=((CFrameWnd*) m_pMainWnd)->GetActiveView();
	// Exchange view window IDs so RecalcLayout() works.
#ifndef _WIN32
	::SetWindowWord(m_pNativeView->m_hWnd, GWW_ID, ::GetWindowWord(pNV->m_hWnd, GWW_ID));
#else
	::SetWindowLong(m_pNativeView->m_hWnd, GWL_ID, ::GetWindowLong(pNV->m_hWnd, GWL_ID));
#endif
	((CFrameWnd*) m_pMainWnd)->SetActiveView(pNV);
	((CFrameWnd*) m_pMainWnd)->RecalcLayout();
	pNV->ShowWindow(SW_SHOW);
//	pNV->Invalidate();
}


modified on Tuesday, December 04, 2007 9:25:01 AM

GeneralMore accurate Pin
followait4-Dec-07 2:25
followait4-Dec-07 2:25 
GeneralRe: In CFormView SDI, change CFormView dynamically, got a problem Pin
followait4-Dec-07 2:36
followait4-Dec-07 2:36 
GeneralHey YOU !!! :( Pin
toxcct4-Dec-07 2:43
toxcct4-Dec-07 2:43 
GeneralRe: Hey YOU !!! :( Pin
followait4-Dec-07 3:19
followait4-Dec-07 3:19 
GeneralRe: Hey YOU !!! :( Pin
Nelek4-Dec-07 21:50
protectorNelek4-Dec-07 21:50 
Generalintellisense in VC++/C# Pin
sree4-Dec-07 1:47
sree4-Dec-07 1:47 
GeneralRe: intellisense in VC++/C# Pin
Maximilien4-Dec-07 2:53
Maximilien4-Dec-07 2:53 
GeneralUsing RAPI Copy Files From Pocket PC to Desktop PC Pin
ni_yuansheng4-Dec-07 1:42
ni_yuansheng4-Dec-07 1:42 
GeneralI Want to work with word 2003,2007 in my mfc app Pin
javad_20054-Dec-07 1:24
javad_20054-Dec-07 1:24 
GeneralRe: I Want to work with word 2003,2007 in my mfc app Pin
toxcct4-Dec-07 1:33
toxcct4-Dec-07 1:33 
GeneralRe: I Want to work with word 2003,2007 in my mfc app Pin
javad_20054-Dec-07 3:21
javad_20054-Dec-07 3:21 
GeneralRe: I Want to work with word 2003,2007 in my mfc app Pin
toxcct4-Dec-07 3:33
toxcct4-Dec-07 3:33 
GeneralRe: I Want to work with word 2003,2007 in my mfc app Pin
javad_20054-Dec-07 3:53
javad_20054-Dec-07 3:53 
GeneralRe: I Want to work with word 2003,2007 in my mfc app Pin
Mark Salsbery4-Dec-07 7:07
Mark Salsbery4-Dec-07 7:07 
GeneralRe: I Want to work with word 2003,2007 in my mfc app Pin
javad_20055-Dec-07 2:40
javad_20055-Dec-07 2:40 
GeneralRe: I Want to work with word 2003,2007 in my mfc app Pin
javad_20055-Dec-07 3:51
javad_20055-Dec-07 3:51 
GeneralRe: I Want to work with word 2003,2007 in my mfc app Pin
David Crow4-Dec-07 7:11
David Crow4-Dec-07 7:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.