[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).
Re: How to inhibit OnDraw on startup?
Will,
CDocument::UpdateAllViews
CDocument::IsModified
helpful ?
Regards,
Paresh.
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.
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.
[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.
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.
Re: [RESOLVED] How to inhibit OnDraw on startup?
Hi, crasher!
FYI: After the new document has been opened the View OnInitalUpdate method is called.