15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


How to destroy/close a formview?

arhan Arhan Demirali
Sunday, January 28, 1996

Hi all,

I have a simple question:
We have an MDI application, and we create/display a formview from the
mainframe menu bar option. I need to close/destroy the view before it
goes to ondraw() function. Is it possible to do this in the view constructor,
or oninitialupdate, or precreatewindow. I find out whether I should close
the view before going any further by getting a pointer to the document
variable, so I wasn't able to destroy in the constructor since the link
to the document wasn't established yet. Is there any easy way of doing this?
Thanks.

Arhan



beriksen@cda.com
Tuesday, January 30, 1996

[Mini-digest: 2 responses]

     Shouldn't this be done in OnCreate?  Here's the MFC documentation:
     
     afx_msg int OnCreate( LPCREATESTRUCT lpCreateStruct );
       
     Return Value
     OnCreate must return 0 to continue the creation of the CWnd object. If 
     the application returns -1, the window will be destroyed.
     Parameters
     lpCreateStruct   Points to a CREATESTRUCT structure that contains 
     information about the CWnd object being created.
     Remarks
     The framework calls this member function when an application requests 
     that the Windows window be created by calling the Create or CreateEx 
     member function. The CWnd object receives this call after the window 
     is created but before it becomes visible. OnCreate is called before 
     the Create or CreateEx member function returns. 
     Override this member function to perform any needed initialization of 
     a derived class. 
     The CREATESTRUCT structure contains copies of the parameters used to 
     create the window.
       
     Note   This member function is called by the framework to allow your 
     application to handle a Windows message. The parameters passed to your 
     function reflect the parameters received by the framework when the 
     message was received. If you call the base-class implementation of 
     this function, that implementation will use the parameters originally 
     passed with the message and not the parameters you supply to the 
     function.
     

-----From: darius@world.std.com (Darius Thabit)

   Hm, you can return fail status in PreCreateWindow, but that's too early; 
and you can't in OnIntialUpdate.  Maybe what you want to do is define your 
own document class, derived from CDocument.  Then override OnOpenDocument, 
let the base class do its thing, and return fail status after examining the 
opened document.  I don't know offhand whether the framework is going to put 
up a dialog after that, but I don't think so, I think it's up to the open 
code to throw an exception.





| Вернуться в корень Архива |