Click here to Skip to main content
15,893,381 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralThousands Sepearator Pin
BRIMID28-Nov-04 10:07
BRIMID28-Nov-04 10:07 
GeneralRe: Thousands Sepearator Pin
PJ Arends28-Nov-04 13:28
professionalPJ Arends28-Nov-04 13:28 
QuestionHELP!!! String manipulation ""Calculating Atomic no of elements"" ???? Pin
VikramDelhi28-Nov-04 9:36
VikramDelhi28-Nov-04 9:36 
AnswerRe: HELP!!! String manipulation ""Calculating Atomic no of elements"" ???? Pin
ThatsAlok28-Nov-04 20:21
ThatsAlok28-Nov-04 20:21 
GeneralRe: HELP!!! String manipulation ""Calculating Atomic no of elements"" ???? Pin
Alex Korchemniy28-Nov-04 20:30
Alex Korchemniy28-Nov-04 20:30 
GeneralRe: HELP!!! String manipulation ""Calculating Atomic no of elements"" ???? Pin
ThatsAlok28-Nov-04 20:31
ThatsAlok28-Nov-04 20:31 
General1 Document, 3 Concurrent Views Pin
bitpusher28-Nov-04 7:38
bitpusher28-Nov-04 7:38 
GeneralRe: 1 Document, 3 Concurrent Views Pin
PJ Arends28-Nov-04 8:40
professionalPJ Arends28-Nov-04 8:40 
It's been awhile since I did this, but this can be accomplished using an MDI interface. The first step is to match all your documents, child frame, and view classes together. This is done in your apps InitInstance function
CMultiDocTemplate* pDocTemplate = new CMultiDocTemplate(
    IDR_MY_TYPE_ONE,
    RUNTIME_CLASS(CMyDoc),
    RUNTIME_CLASS(CChildFrame),
    RUNTIME_CLASS(CMyView1));
AddDocTemplate(pDocTemplate);

pDocTemplate = new CMultiDocTemplate (
    IDR_MY_TYPE_TWO,
    RUNTIME_CLASS(CMyDoc),
    RUNTIME_CLASS(CChildFrame),
    RUNTIME_CLASS(CMyView2));
AddDocTemplate(pDocTemplate);

    // Add more here...

// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
The IDR_MY_TYPE_ONE and IDR_MY_TYPE_TWO are the resource defines for the string table strings that that name your templates.
IDR_MY_TYPE_ONE   "\nTypeOne\n"
IDR_MY_TYPE_TWO   "\nTypeTwo\n"
The string after the first newline (\n) is used to name the document template.

You then have to override CMainFrame::OnFileNew() so that it uses the proper template
void CMainFrame::OnFileNew()
{
   CDocTemplate *pTemplate = GetTemplate(_T("TypeTwo")); // The name from above
   if (pTemplate)
      pTemplate->OpenDocumentFile(NULL);  // calls CDocument::OnNewDocument
}
In CMainFrame::OnFileOpen you would pass the file name to OpenDocumentFile().

To open a new view of an already open document, you have to add the menu message handlers to your document class
void CMyDoc::OnNewViewTypeOne()
{
   CDocTemplate *pDocTemplate = GetTemplate(_T("TypeOne"));
   if (pDocTemplate)
   {
      CFrameWnd *pFrame = pDocTemplate->CreateNewFrame(this, NULL);
      if (pFrame)
         pFrame->InitialUpdateFrame(this, TRUE);
   }
}


Here is the code for GetTemplate
CDocTemplate *GetTemplate (CString str)
{
    CString strDoc;
    CDocTemplate *pTemplate = NULL;
    bool templatefound = false;
    POSITION pos = AfxGetApp()->m_pDocManager->GetFirstDocTemplatePosition();
    while (pos)
    {
        pTemplate = (CDocTemplate *)AfxGetApp()->m_pDocManager->GetNextDocTemplate(pos);
        pTemplate->GetDocString(strDoc, CDocTemplate::docName);
        if (strDoc == str)
        {
            templatefound = true;
            break;
        }
    }
 
    if (!templatefound)
    {
        TRACE (_T("GetTemplate() failed, Template not found"));
        return NULL;
    }
    return pTemplate;
}
There may be bits I am missing, but this should get you started.




"You're obviously a superstar." - Christian Graus about me - 12 Feb '03

"Obviously ???  You're definitely a superstar!!!" mYkel - 21 Jun '04

Within you lies the power for good - Use it!
GeneralRe: 1 Document, 3 Concurrent Views Pin
bitpusher28-Nov-04 15:20
bitpusher28-Nov-04 15:20 
GeneralRe: 1 Document, 3 Concurrent Views Pin
PJ Arends28-Nov-04 17:08
professionalPJ Arends28-Nov-04 17:08 
GeneralRe: 1 Document, 3 Concurrent Views Pin
bitpusher29-Nov-04 5:59
bitpusher29-Nov-04 5:59 
GeneralRe: 1 Document, 3 Concurrent Views Pin
PJ Arends29-Nov-04 7:51
professionalPJ Arends29-Nov-04 7:51 
GeneralRe: 1 Document, 3 Concurrent Views Pin
Ryan Binns28-Nov-04 17:16
Ryan Binns28-Nov-04 17:16 
QuestionMSFlexgrid distribute? Pin
José Luis Sogorb28-Nov-04 7:24
José Luis Sogorb28-Nov-04 7:24 
GeneralGraph error result returned from 'AxImp.exe'. Pin
h00ps28-Nov-04 6:55
h00ps28-Nov-04 6:55 
QuestionSDK for MP3 ? Pin
lasterix28-Nov-04 6:27
lasterix28-Nov-04 6:27 
AnswerRe: SDK for MP3 ? Pin
Anonymous28-Nov-04 12:21
Anonymous28-Nov-04 12:21 
AnswerRe: SDK for MP3 ? Pin
Michael Dunn28-Nov-04 20:37
sitebuilderMichael Dunn28-Nov-04 20:37 
Generalcreating Menubar in dialog based prj. Pin
ashsri28-Nov-04 6:00
ashsri28-Nov-04 6:00 
GeneralRe: creating Menubar in dialog based prj. Pin
Nick Nougat29-Nov-04 5:30
Nick Nougat29-Nov-04 5:30 
GeneralHeader Pin
BRIMID28-Nov-04 4:35
BRIMID28-Nov-04 4:35 
GeneralRe: Header Pin
Member 153369528-Nov-04 5:53
Member 153369528-Nov-04 5:53 
GeneralRe: Header Pin
BRIMID28-Nov-04 6:05
BRIMID28-Nov-04 6:05 
GeneralRe: Header Pin
PJ Arends28-Nov-04 7:19
professionalPJ Arends28-Nov-04 7:19 
Generalglobal variables Pin
Tomate6628-Nov-04 4:21
Tomate6628-Nov-04 4:21 

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.