|
Hi,
Is there a way to close a document without closing the application?
What I mean by this using a menu option, e.g. File -> Close, to invoke a file save if need be, and then clearing the view, but not closing the application?
Obviously I can write a function that will do this for me, but is there a standard CDocument member that will do this for me?
TIA
Tony
|
|
|
|
|
I think you should override the OnCloseDocument method,...Well,...Good luck!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
Thanks for that.
I have managed to achieve what I wanted, except for 1 remaining item.
Having succssfully closed the document, and my View has reverted to the original empty View, I find that I can open new files, except for the one that was just closed. I cannot open the file that was previously open until I have viewed a different file.
Is there a flag I need to reset, or function call I need to make so it is possible to open the fiel immediately after it has been closed?
I've managed to overcome that problem now by using the DocTemplate and Removing the document, but I now find that if I use this method, wi have to close my application multiple times dependent on how many times I have closed a document, e.g. close 2 documents and I have to close the application twice (press the application 'X' button twice). Any suggestions?
TIA
Tony
modified on Wednesday, January 27, 2010 10:24 AM
|
|
|
|
|
You didn't indicate if this is an MDI or SDI application, but either way there is a DeleteContents() method that's called automatically just before a document closes.
Perhaps that function may do what you need.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Hi Karl,
It's a SDI.
I am using DeleteContents() as part of my closure code, see below.........
if(TRUE == IsModified())
{
OnFileSave();
}
CDocTemplate* pDocTemplate = GetDocTemplate();
if(NULL != pDocTemplate)
{
pDocTemplate->RemoveDocument(this);
}
DeleteContents();
CString csUntitled;
csUntitled.LoadString(AFX_IDS_UNTITLED);
SetTitle(csUntitled);
UpdateAllViews(NULL);
AS I say, the only issue now is that I have to close mutliple times, once for each file opened.
Tony
|
|
|
|
|
I'm not sure if it could be part of your problem, however it probably is not a good idea to call RemoveDocument. In an SDI, there is only one document, and it lasts for the life of the program - it's never destroyed.
Of course, your DeleteContents is also responsible for resetting any document member data to it's original state.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Hi Karl,
If I remove the call to RemoveDocument, I'm left with not being able to reopen the last closed file - this is caused by the CDocTemplate::yesAlreadyOpen flag being set.
Is there a way to force this flag, or my DocTemplate, to be something that reflects that I have closed (hopefully!!) the last open file?
TIA
Tony
|
|
|
|
|
Haven't tried it, but perhaps
CloseAllDocuments(FALSE) will reset that flag. Check it out on MSDN[^]
In fact, calling CloseAllDocuments causes the call to DeleteContents.
Hope it helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
I tried that, and my application closed whether I set the flag TRUE or FALSE.
I guess I am missing something else.
Thanks for your help.
Tony
|
|
|
|
|
I have C++ Simple MAPI routines for sending emails. This works well for straight text emails. I have prepared a HMTL body for emailing but do not know how to flag the fact that the body is HTML to the client when using Simple MAPI.
Can this be done with Simple MAPI ?
If it can't be done using Simple MAPI how is it done using an alternative.
Let's start with Extended MAPI before moving on to something super sophisticated.
Try to keep it simple. I'm only looking at sending a single email body with simple HTML.
|
|
|
|
|
Some little help (?)
An email contains a header (from, to, ...) and a body and 0 or more attachments. Attachments have different mimetypes. A HTML-body is of type multipart/mixed. So your email contans a header, an empty body and 2 attachments both of type multipart/mixed, 1 attachment contains the text in plain ascii, the other one contains the HTML version of this text. multipart/mixed means for the email client: take the variant that suits best resulting in HTML in most email clients and in plain ascii if the client doesn't support HTML.
Hopefully weaponed with this knowledge you can find yor way in MAPI. If not: forget what i wrote.
|
|
|
|
|
Hi All,
I am using CFileDialog class in my application to browse a file. when i click on browse always by default application is opening desktop folder. I have one default path how to open that path instead of desktop.
Thanks in advance.
Regards,
anil
|
|
|
|
|
Set the lpstrInitialDir of the CFileDialog member m_ofn .
Read more here[^] and here[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Wow Roger! There's documentation for these things? Who'd have thought.
OT: How are things going for you? It's been a long time.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
|
Yeah, there are a few interesting things that I'm trying out (involved in a research). Nothing new or profoundly exciting though.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Rajesh R Subramanian wrote: involved in a research
Rajesh R Subramanian wrote: Nothing new or profoundly exciting though.
I see a contraddiction, Watson!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Problem is, it isn't anywhere in my area of interests that I'm "researching" on.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
You should set the lpstrInitialDir member of the CFileDialog 's m_ofn struct (see [^] and [^]).
Please read carefully the documentation: file dialog behaviour is OS-dependant (for instance, Windows 7 behaves distinctively with respect the initial directory).
[added]
Wow! Damned *fast* Roger!
[/added]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks Pallini
I have problem with filter, i am adding filter like this
dlgFile.m_ofn.lpstrFilter = _T("*.pdm");
it has to display all .pdm files, but its not displaying .pdm files in the dialog. please help me in this regard.
Thanks in advance.
Regards,
Anil
|
|
|
|
|
Member 4399771 wrote: dlgFile.m_ofn.lpstrFilter = _T("*.pdm");
Should be
dlgFile.m_ofn.lpstrFilter = _T("*.pdm\0");
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Dear Pallini thanks for your reply!
I tried with \0 still dialog not filtering. please check the code below.
CFileDialog dlgFile(TRUE);
CString fileName;
const int c_cMaxFiles = 100;
const int c_cbBuffSize = (c_cMaxFiles * (MAX_PATH + 1)) + 1;
dlgFile.GetOFN().lpstrFile = fileName.GetBuffer(c_cbBuffSize);
dlgFile.GetOFN().nMaxFile = c_cMaxFiles;
dlgFile.m_ofn.lpstrInitialDir = m_sWorkpathPdm;
dlgFile.m_ofn.lpstrFilter = _T("*.sct\0");
dlgFile.DoModal();
fileName.ReleaseBuffer();
if (!fileName.IsEmpty())
m_sMapFileName = fileName;
UpdateData(FALSE);
Regards,
Anil
hi
|
|
|
|
|
Member 4399771 wrote: dlgFile.m_ofn.lpstrFilter = _T("*.sct\0");
Change to
dlgFile.m_ofn.lpstrFilter = _T("sct files\0*.sct\0");
dlgFile.m_ofn.nFilterIndex = 1;
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thank you very much Pallini
The problem is fixed! Is there any documentation available on this topic.
Regards,
Anil
|
|
|
|
|
Member 4399771 wrote: Thank you very much Pallini
You are welcome.
Member 4399771 wrote: Is there any documentation available on this topic.
There is, of course:
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|