tamngo
asked on
Activate frame while it's hidden.
I use one document sharing with multiple views. I want to keep the document open when I close all the views, so I have one hidden frame to do the job; because it's hidden, it's not active so then when I close all the other views, all the toolbar buttons cannot function. How can I activate the hidden frame while it's hidden? or if I can't, is there any way I can keep the document open while I close all the views? Thank you very much for your suggestion.
Tam Ngo,
Tam Ngo,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
this is MDI correct? then you can have multiple views to one document.
from MFC code
void CDocument::OnChangedViewLi st()
{
// if no more views on the document, delete ourself
// not called if directly closing the document or terminating the app
if (m_viewList.IsEmpty() && m_bAutoDelete)
{
OnCloseDocument();
return;
}
// update the frame counts as needed
UpdateFrameCounts();
}
Obviously, you want to set m_bAutoDelete to FALSE. This will prevent the doc from being closed when the last view is closed.
Also, on 2: Are these operations document operations or could they just be moved to the application class?
from MFC code
void CDocument::OnChangedViewLi
{
// if no more views on the document, delete ourself
// not called if directly closing the document or terminating the app
if (m_viewList.IsEmpty() && m_bAutoDelete)
{
OnCloseDocument();
return;
}
// update the frame counts as needed
UpdateFrameCounts();
}
Obviously, you want to set m_bAutoDelete to FALSE. This will prevent the doc from being closed when the last view is closed.
Also, on 2: Are these operations document operations or could they just be moved to the application class?
ASKER
Hi danny_pav,
The first part is not clear to me. I also get the pointer to the viewless doc. When the last view is destroyed, what do I have to do with the flag (FALSE) in the doc? it hasn't called OnCloseDocument() until I close the application.
Please give me more information.
The reason why I should keep the doc open when I close all the views is that I need other operation without the views existence.
The first part is not clear to me. I also get the pointer to the viewless doc. When the last view is destroyed, what do I have to do with the flag (FALSE) in the doc? it hasn't called OnCloseDocument() until I close the application.
Please give me more information.
The reason why I should keep the doc open when I close all the views is that I need other operation without the views existence.
1. Is this MDI?
2. What operations are being done to a viewless document?
2. What operations are being done to a viewless document?
ASKER
I think I've got it. Because I still have one viewless frame, it doesn't call OnCloseDocument() when I close all visible views.
If I want to activate buttons just move handlers to mainframe instead of keeping them at CDoc. I just wonder why are the handlers are inactive when the doc still open.
Thank you very much for your time.
If I want to activate buttons just move handlers to mainframe instead of keeping them at CDoc. I just wonder why are the handlers are inactive when the doc still open.
Thank you very much for your time.
ASKER
The first part is not clear to me. I also get the pointer to the viewless doc. When the last view is destroyed, what do I have to do with the flag (FALSE) in the doc? it hasn't called OnCloseDocument() until I close the application.
Please give me more information.
The reason why I should keep the doc open when I close all the views is that I need other operation without the views existence.