Link to home
Start Free TrialLog in
Avatar of SGyves
SGyves

asked on

Cascade Closing Views

I am building an IRC client and I have a slight difficulty. I need on view to represent the key view so that when it is closed...all other views associated with that document close as well. The main view is a view to the server the client is connected to. All other views in that doc will be just open channels. Now when a channel view closes...no problem....just part that channel. But when the main server view closes...I want all the channels to close with it. How can I make that happen. I have tried DisconnectViews() in the document and tried to call that in the destructor for the CView. I would check the ID of the view..and if it was a server view...I would then trigger the closing of all other views there. I get a debug error telling me there is a failure in the IsKindOf function with asserting a pointer. Anyway....any ideas as to the right apporach.
Avatar of AlexFM
AlexFM

Enumerate all views using CDocument::GetFirstViewPosition and CDocument::GetNextView. Having View pointer, you can close it, for example, posting WM_CLOSE message to view's parent.
ASKER CERTIFIED SOLUTION
Avatar of Roshan Davis
Roshan Davis
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SGyves

ASKER

Nice code. Compact!! Thank you for your experience.