CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2006
    Posts
    63

    [RESOLVED] How to inhibit OnDraw on startup?

    I have a standard wizard - generated SDI, which imports data via OnOpenDocument. I want to view this processed data, and can do so quite happily in the View. Trouble is, when the SDI App first starts, the Doc data is not valid. What would be a reliable way to inform the View that drawing should be done only after the document data has been loaded?
    (I can use a crude flag, such as an int, and inhibit the actions controlled by OnDraw unless the int has a value set after the data has been read, but I can't believe there is not a proper method).

  2. #2
    Join Date
    Feb 2007
    Posts
    59

    Re: How to inhibit OnDraw on startup?

    Will,

    CDocument::UpdateAllViews
    CDocument::IsModified

    helpful ?

    Regards,
    Paresh.

  3. #3
    Join Date
    Mar 2006
    Posts
    63

    Re: How to inhibit OnDraw on startup?

    Thanks, but IsModified doesn't help, because at startup, i.e. when the View is first displayed, no document has been loaded, but the App Window is created and drawn. "IsModified" doesn't seem to be effective then. At this point, all Document variables are indeterminate, therefore any drawing code which uses Document data in the View will generate a spurious display or crash the App.
    It is this first draw that I want to control. Presently in the OnDraw dependent code I simply interrogate an integer variable from the Document, which is set to a value of 1 as soon as the Document data is loaded and all the variables are valid. The possibility of this highly inelegant check going wrong is remote, but it could.
    I had hoped that CView::GetDocument would return NULL if no document is opened, but this is not the case.
    Some global flag set when the App first starts would help.
    Otherwise, I will continue with happy reluctance to use a hack.

  4. #4
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: How to inhibit OnDraw on startup?

    Check out CDocument::GetPathName() :
    Return Value
    The document's fully qualified path. This string is empty if the document has not been saved or does not have a disk file associated with it.

    However, if you would properly initialize your document data, there should be no problem drawing it.
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  5. #5
    Join Date
    Mar 2006
    Posts
    63

    [CLOSED] Re: How to inhibit OnDraw on startup?

    Thanks for the reply, VladimirF.
    No, GetPathName returns NULL until OnOpenDocument finishes.
    Thanks for your trouble. I'll use my solution. It's only some code to control temperature in a nuclear reactor on a satellite.

  6. #6
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: [CLOSED] Re: How to inhibit OnDraw on startup?

    Quote Originally Posted by crasher
    No, GetPathName returns NULL until OnOpenDocument finishes.
    Isn't that what you wanted? Some indication that the document is loaded?
    Also, I think it returns an empty string, NOT NULL.
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: [RESOLVED] How to inhibit OnDraw on startup?

    Hi, crasher!
    FYI: After the new document has been opened the View OnInitalUpdate method is called.
    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured