Click here to Skip to main content
15,903,362 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Multiple inheritance in MFC Pin
Mark Salsbery4-Jul-07 9:31
Mark Salsbery4-Jul-07 9:31 
GeneralRe: Multiple inheritance in MFC Pin
tom groezer4-Jul-07 10:19
tom groezer4-Jul-07 10:19 
GeneralRe: Multiple inheritance in MFC Pin
David Crow5-Jul-07 3:13
David Crow5-Jul-07 3:13 
GeneralRe: Multiple inheritance in MFC Pin
Mark Salsbery5-Jul-07 10:54
Mark Salsbery5-Jul-07 10:54 
Questionhow to use "OnNewDocument" from cview or cmainframe class Pin
chaitannya_m4-Jul-07 9:18
chaitannya_m4-Jul-07 9:18 
AnswerRe: how to use "OnNewDocument" from cview or cmainframe class Pin
Mark Salsbery4-Jul-07 9:47
Mark Salsbery4-Jul-07 9:47 
GeneralRe: how to use "OnNewDocument" from cview or cmainframe class Pin
chaitannya_m4-Jul-07 16:21
chaitannya_m4-Jul-07 16:21 
GeneralRe: how to use "OnNewDocument" from cview or cmainframe class Pin
Mark Salsbery5-Jul-07 6:53
Mark Salsbery5-Jul-07 6:53 
Smile | :) I'm glad it worked. That's how MFC does it but it's using an undocumented variable (although
it's worked for as long as I can remember).

You probably could just give your button the id ID_FILE_NEW and it would have worked like magic
too Smile | :) I thought for sure someone here would jump on me for that one LOL.

chaitannya_m wrote:
But how do i get a pointer to each view. I want to pass data to the view


Which view? The one just created?

The view just created should be the active view. To get the active view in MDI;
// this is the MFC example from the docs
 
CMDIFrameWnd *pFrame = 
             (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
 
// Get the active MDI child window.
CMDIChildWnd *pChild = 
             (CMDIChildWnd *) pFrame->GetActiveFrame();
 
// or CMDIChildWnd *pChild = pFrame->MDIGetActive();
 
// Get the active view attached to the active MDI child
// window.
CMyView *pView = (CMyView *) pChild->GetActiveView();

To iterate through all views, one way is to iterate through all documents and their associated
views:
// Iterate through doc templates
 
POSITION DocTemplatePos = AfxGetApp()->GetFirstDocTemplatePosition();
while (DocTemplatePos != NULL)
{
   CDocTemplate *pTmpl = AfxGetApp()->GetNextDocTemplate(DocTemplatePos);
 
   // Iterate through documents for the current template
 
   POSITION DocPos = pTmpl->GetFirstDocPosition();
   while (DocPos != NULL)
   {
      CDocument *pDoc = pTmpl->GetNextDoc(DocPos);
 
      // Iterate through views for the current document
 
      // You could use CDocument::UpdateAllViews() or ...
 
      POSITION ViewPos = pDoc->GetFirstViewPosition();
      while (ViewPos != NULL)
      {
         CView *pView = pDoc->GetNextView(ViewPos);
 
         // Do something with the current view
      }
   }
}



Mark Salsbery
Microsoft MVP - Visual C++


"Go that way, really fast. If something gets in your way, turn."

QuestionC++ data structures Pin
tom groezer4-Jul-07 8:54
tom groezer4-Jul-07 8:54 
AnswerRe: C++ data structures Pin
Maximilien4-Jul-07 9:06
Maximilien4-Jul-07 9:06 
QuestionRe: C++ data structures Pin
David Crow5-Jul-07 3:15
David Crow5-Jul-07 3:15 
QuestionCString::Replace Problem [modified] Pin
lparsonson4-Jul-07 5:58
lparsonson4-Jul-07 5:58 
AnswerRe: CString::Replace Problem Pin
Mark Salsbery4-Jul-07 7:02
Mark Salsbery4-Jul-07 7:02 
GeneralRe: CString::Replace Problem Pin
lparsonson5-Jul-07 4:54
lparsonson5-Jul-07 4:54 
QuestionCStatic drawing interrupted... Worker, UI Threads???? Pin
Greg Ellis4-Jul-07 5:41
Greg Ellis4-Jul-07 5:41 
AnswerRe: CStatic drawing interrupted... Worker, UI Threads???? Pin
Matthew Faithfull4-Jul-07 6:27
Matthew Faithfull4-Jul-07 6:27 
GeneralRe: CStatic drawing interrupted... Worker, UI Threads???? Pin
Greg Ellis4-Jul-07 6:35
Greg Ellis4-Jul-07 6:35 
GeneralRe: CStatic drawing interrupted... Worker, UI Threads???? Pin
Matthew Faithfull4-Jul-07 6:55
Matthew Faithfull4-Jul-07 6:55 
AnswerRe: CStatic drawing interrupted... Worker, UI Threads???? [modified] Pin
Mark Salsbery4-Jul-07 7:08
Mark Salsbery4-Jul-07 7:08 
QuestionOnSize Assertion Error Pin
sdancer754-Jul-07 5:11
sdancer754-Jul-07 5:11 
AnswerRe: OnSize Assertion Error Pin
Arman S.4-Jul-07 5:19
Arman S.4-Jul-07 5:19 
GeneralRe: OnSize Assertion Error Pin
sdancer754-Jul-07 22:56
sdancer754-Jul-07 22:56 
AnswerRe: OnSize Assertion Error Pin
Hamid_RT4-Jul-07 19:28
Hamid_RT4-Jul-07 19:28 
Questionneed your suggestion for data expression Pin
includeh104-Jul-07 4:56
includeh104-Jul-07 4:56 
QuestionRe: need your suggestion for data expression Pin
David Crow5-Jul-07 3:25
David Crow5-Jul-07 3:25 

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.