Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How do I create a View and assing it his document class

How do I create a View and assing it his document class

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jose Cruz
    wrote on last edited by
    #1

    When you add a derived CView class to your MFC project how do I relate My View derived Class to my CDocument derived class. I´m trying to add another view to my MFC project.:confused:

    P 2 Replies Last reply
    0
    • J Jose Cruz

      When you add a derived CView class to your MFC project how do I relate My View derived Class to my CDocument derived class. I´m trying to add another view to my MFC project.:confused:

      P Offline
      P Offline
      Pavel Klocek
      wrote on last edited by
      #2

      You do it in the InitInstance method of your CWinApp derived application class. You will find there something like this: CMultiDocTemplate* pDocTemplate; pDocTemplate = new CMultiDocTemplate( IDR_TESTDFTYPE, RUNTIME_CLASS(CTestdfsdDoc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CTestdfsdView)); AddDocTemplate(pDocTemplate); You register your new document/view pair by copy-paste-edit: pDocTemplate = new CMultiDocTemplate( IDR_MYTYPE, RUNTIME_CLASS(CMyDoc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CMyView)); AddDocTemplate(pDocTemplate); Don't forget to create document string in resources - see the string of existing document in string table resources for example (IDR_TESTDFTYPE in this case). Sonork 100.15206;PavelK

      1 Reply Last reply
      0
      • J Jose Cruz

        When you add a derived CView class to your MFC project how do I relate My View derived Class to my CDocument derived class. I´m trying to add another view to my MFC project.:confused:

        P Offline
        P Offline
        Pavel Klocek
        wrote on last edited by
        #3

        Jose Cruz wrote: Don't forget to create document string in resources - see the string of existing document in string table resources for example (IDR_TESTDFTYPE in this case). First of all thank you for your help. Now do you have some explanation for the above phrase. Every MFC document class has a corresponding definition string in string table resource - ID of the string is ID of the document (IDR_xxx), it defines parameters like name of the document for OLE, filename extension and so on. You need one for every CDocument derived class in Your project. CDocTemplate class uses it. It looks like: NTGen\nNTGen\nNTGen\nNTGen Files (*.mdb)\n.mdb\nNTGen.Document\nNTGen Document Sonork 100.15206;PavelK

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups