Click here to Skip to main content
16,006,535 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: HELP!! About memory access Pin
Christian Graus3-Dec-06 11:57
protectorChristian Graus3-Dec-06 11:57 
GeneralRe: HELP!! About memory access Pin
kcynic3-Dec-06 12:21
kcynic3-Dec-06 12:21 
GeneralRe: HELP!! About memory access Pin
Christian Graus3-Dec-06 12:32
protectorChristian Graus3-Dec-06 12:32 
AnswerRe: HELP!! About memory access Pin
Jörgen Sigvardsson3-Dec-06 12:29
Jörgen Sigvardsson3-Dec-06 12:29 
QuestionAdding Multiple views to one document Pin
barrem3-Dec-06 7:04
barrem3-Dec-06 7:04 
AnswerRe: Adding Multiple views to one document Pin
Mark Salsbery3-Dec-06 8:14
Mark Salsbery3-Dec-06 8:14 
GeneralRe: Adding Multiple views to one document Pin
barrem3-Dec-06 8:21
barrem3-Dec-06 8:21 
GeneralRe: Adding Multiple views to one document Pin
Mark Salsbery3-Dec-06 12:11
Mark Salsbery3-Dec-06 12:11 
I had to look up how I do it since I've been moving away from doc/view for quite a few years but
I still have windows that open as views. The framework does it using the CDocTemplate class to
associate the document, view, and frame window class - useless for creating a child view Smile | :)
Anyway, I found a better generic example of what has to be done (from MFC docs)...
CView* pActiveView = ((CFrameWnd*) m_pMainWnd)->GetActiveView();
m_pOldView = pActiveView;
m_pNewView = (CView*) new CNewView;
 
CDocument* pCurrentDoc = ((CFrameWnd*)m_pMainWnd)->GetActiveDocument();
 
// Initialize a CCreateContext to point to the active document.
// With this context, the new view is added to the document
// when the view is created in CView::OnCreate().
CCreateContext newContext;
newContext.m_pNewViewClass = NULL;
newContext.m_pNewDocTemplate = NULL;
newContext.m_pLastView = NULL;
newContext.m_pCurrentFrame = NULL;
newContext.m_pCurrentDoc = pCurrentDoc;
 
// The ID of the initial active view is AFX_IDW_PANE_FIRST.
// Incrementing this value by one for additional views works
// in the standard document/view case but the technique cannot
// be extended for the CSplitterWnd case.
UINT viewID = AFX_IDW_PANE_FIRST + 1;
CRect rect(0, 0, 0, 0); // Gets resized later.
 
// Create the new view. In this example, the view persists for
// the life of the application. The application automatically
// deletes the view when the application is closed.
m_pNewView->Create(NULL, "AnyWindowName", WS_CHILD, rect, m_pMainWnd, viewID, &newContext);
 
// When a document template creates a view, the WM_INITIALUPDATE
// message is sent automatically. However, this code must
// explicitly send the message, as follows.
m_pNewView->SendMessage(WM_INITIALUPDATE, 0, 0);
...

The key is the CCreateContext stuff. You may not need some of the code - for example you
probably already have a document pointer so you don't need to obtain it. AddView will be called
in CView::OnCreate() automagically.

I Hope this helps!
Mark

*EDIT* Here's a link Adding Multiple Views to a Single Document[^]
QuestionOpen a binary file and dispaly the content Pin
epuwi3-Dec-06 6:00
epuwi3-Dec-06 6:00 
AnswerRe: Open a binary file and dispaly the content Pin
CPallini3-Dec-06 6:47
mveCPallini3-Dec-06 6:47 
GeneralRe: Open a binary file and dispaly the content Pin
epuwi3-Dec-06 7:09
epuwi3-Dec-06 7:09 
GeneralRe: Open a binary file and dispaly the content Pin
CPallini3-Dec-06 8:28
mveCPallini3-Dec-06 8:28 
GeneralRe: Open a binary file and dispaly the content Pin
epuwi3-Dec-06 8:34
epuwi3-Dec-06 8:34 
QuestionHow to code an overlay inside a game like how FRAPS works? Pin
RDarrylR3-Dec-06 4:59
RDarrylR3-Dec-06 4:59 
QuestionEnumerating control handle in a dialog Pin
Super Hornet3-Dec-06 4:08
Super Hornet3-Dec-06 4:08 
AnswerRe: Enumerating control handle in a dialog Pin
CPallini3-Dec-06 6:46
mveCPallini3-Dec-06 6:46 
AnswerRe: Enumerating control handle in a dialog Pin
Mark Salsbery3-Dec-06 6:48
Mark Salsbery3-Dec-06 6:48 
QuestionRe: Enumerating control handle in a dialog Pin
Super Hornet3-Dec-06 7:26
Super Hornet3-Dec-06 7:26 
AnswerRe: Enumerating control handle in a dialog Pin
Mark Salsbery3-Dec-06 8:01
Mark Salsbery3-Dec-06 8:01 
AnswerRe: Enumerating control handle in a dialog Pin
CPallini3-Dec-06 8:22
mveCPallini3-Dec-06 8:22 
AnswerRe: Enumerating control handle in a dialog Pin
ThatsAlok3-Dec-06 18:35
ThatsAlok3-Dec-06 18:35 
AnswerRe: Enumerating control handle in a dialog Pin
Hamid_RT15-Dec-06 7:08
Hamid_RT15-Dec-06 7:08 
Questionhow can i rotate a radio [modified] Pin
selectgood3-Dec-06 3:41
selectgood3-Dec-06 3:41 
AnswerRe: how can i rotate a radio Pin
Hamid_RT15-Dec-06 7:08
Hamid_RT15-Dec-06 7:08 
QuestionHow to get the object or resource id of dialog controls? Pin
Super Hornet3-Dec-06 3:00
Super Hornet3-Dec-06 3:00 

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.