Thread: Map editor asserts in line 175 of doctempl.cpp

  1. #1
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001

    Map editor asserts in line 175 of doctempl.cpp

    My new map editor works on my system but it asserts on 2 other systems that it has been tried on. The assertion is coming from AddDocTemplate() within the actual MFC source. Obviously doc template is null but it shouldn't be.

    I've also tested the view class out after creation and it too is NULL. Very strange that it does not assert on my system. It's also very strange because most of the code that is the problem was not written by me, it was put there by the project wizard.

    Any ideas?

    Also am having lots of troubles creating a new CScrollView document in an SDI app. If the constructor is protected then how can I create a new instance of the class? Or is it already instantiated when the document, view, and app classes are created? It seems to me from the design that the philosophy is each is instantiated when the application starts. So File->New should only clear the existing SDI document and view and start a new one (of course it should prompt to save), not actually instantiate an entirely new class/object as in the case of a MDI app.

    If this is the case, then why is my CScrollView evaluating to NULL in OnFilenew() in my CMainFrame class?

    So are the document and view valid immediately after the program starts or is there something I need to do to create them? I'm quite lost.

  2. #2
    Registered User
    Join Date
    Aug 2003
    Bubba, if your using some version of direct3d for your map, then you probably don't want to use CScrollView, because it scrolls using the gdi function. Instead, you could use CViow, and intercept the scroll events. You might then somehow move the observer to the left or the right inside your world. But I don't know how you'd do that exactly.

    Also, the creation of CScrollView is managed by mfc. Inside of InitInstance of your application class, you want to add a document template, like this:
    CSingleDocTemplate* pDocTemplate;
        pDocTemplate = new CSingleDocTemplate(
            RUNTIME_CLASS(CMainFrame),       // main SDI frame window
        if (!pDocTemplate)
            return FALSE;
    Then, MFC is able to create an object of the view class, somehow from the RUNTIME_CLASS(CMyView). If your changing all your view types, from CView to CScrollView, you have to be careful to update all the mfc dynamic creation macros inside the clas and inside the implementation file. This is quite tedious; so if you know your using a CScrollView it's better to use the AppWizard and change the view class to CScrollView.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. adding line numbers and concatenating a filename
    By durrty in forum C Programming
    Replies: 25
    Last Post: 06-28-2008, 03:36 AM
  2. Reading a buffer line by line, while using system read
    By Hammad Saleem in forum C Programming
    Replies: 9
    Last Post: 05-27-2008, 05:41 AM
  3. Greenhand want help!
    By leereg in forum C Programming
    Replies: 6
    Last Post: 01-29-2002, 06:04 AM
  4. SSCANF help
    By mattz in forum C Programming
    Replies: 7
    Last Post: 12-10-2001, 04:53 PM
  5. Validating the contents of a char buffer
    By mattz in forum C Programming
    Replies: 3
    Last Post: 12-09-2001, 06:21 PM