Click here to Skip to main content
15,915,059 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Convert ... Pin
Hadi Rezaee9-Jun-01 21:05
Hadi Rezaee9-Jun-01 21:05 
GeneralRe: Convert ... Pin
Anders Molin9-Jun-01 22:56
professionalAnders Molin9-Jun-01 22:56 
GeneralRe: Convert ... Pin
Hadi Rezaee9-Jun-01 23:46
Hadi Rezaee9-Jun-01 23:46 
GeneralDatabase question ... Pin
Hadi Rezaee8-Jun-01 20:46
Hadi Rezaee8-Jun-01 20:46 
GeneralRe: Database question ... Pin
Steve Driessens8-Jun-01 20:52
Steve Driessens8-Jun-01 20:52 
GeneralRe: Database question ... Pin
Hadi Rezaee8-Jun-01 22:53
Hadi Rezaee8-Jun-01 22:53 
Generalsave diolog when cloding the application Pin
mr20038-Jun-01 20:15
mr20038-Jun-01 20:15 
GeneralRe: save diolog when cloding the application Pin
Christian Graus8-Jun-01 20:27
protectorChristian Graus8-Jun-01 20:27 
I do it in an MDI App in my MainFrame OnClose handler like this:

CWinApp* pApp = AfxGetApp();
POSITION posTemplate = pApp->GetFirstDocTemplatePosition();

while (posTemplate)
{
CDocTemplate* pTemplate = pApp->GetNextDocTemplate(posTemplate);

POSITION posDocument = pTemplate->GetFirstDocPosition();

while(posDocument)
{
CDocument* pDoc = pTemplate->GetNextDoc(posDocument);
if (pDoc)
{
CGrausPaintDoc* pGPDoc = (CGrausPaintDoc*) pDoc;
if (!pGPDoc->m_bSaveSinceLastChange)
{
CString s;
if (pGPDoc->m_Filename.GetLength()>0)
s.Format("%s - save before close ?",pGPDoc->m_Filename);
else
s = "Untitled - save before close ?";
DWORD response = AfxMessageBox(s,MB_YESNOCANCEL | MB_ICONQUESTION);
switch (response)
{
case IDYES:
pGPDoc->OnSaveDocument(pGPDoc->m_Filename);
case IDNO:
pGPDoc->m_bSaveSinceLastChange = true;
pGPDoc->OnCloseDocument();
break;
case IDCANCEL:
return;
}
}
}
}
}

Most of this code is just to step through all the open documents - if you have an SDI app, you just need to get the Doc *, check a flag you set for changes (users will hate being asked to save if they have not done anything to the document ) and call OnSaveDocument. You'll note I also allow the user to press cancel - if they are being prompted they should get a chance to decide not to close the program.


Christian

#include "std_disclaimer.h"

People who love sausage and respect the law should never watch either one being made.

The things that come to those who wait are usually the things left by those who got there first.

GeneralRe: save diolog when cloding the application Pin
Tomasz Sowinski9-Jun-01 2:59
Tomasz Sowinski9-Jun-01 2:59 
GeneralRe: save diolog when cloding the application Pin
Christian Graus9-Jun-01 3:08
protectorChristian Graus9-Jun-01 3:08 
GeneralRe: save diolog when cloding the application Pin
Tomasz Sowinski9-Jun-01 3:14
Tomasz Sowinski9-Jun-01 3:14 
GeneralPlease help with Screen Capture Wallpaper with PaintDesktop(HDC hdc) API Pin
JavaTony8-Jun-01 20:06
JavaTony8-Jun-01 20:06 
GeneralRe: Please help with Screen Capture Wallpaper with PaintDesktop(HDC hdc) API Pin
Christian Graus8-Jun-01 20:32
protectorChristian Graus8-Jun-01 20:32 
GeneralRe: Please help with Screen Capture Wallpaper with PaintDesktop(HDC hdc) API Pin
Tomasz Sowinski9-Jun-01 2:48
Tomasz Sowinski9-Jun-01 2:48 
GeneralCDialogBar Pin
8-Jun-01 12:01
suss8-Jun-01 12:01 
QuestionHow do you create a "Hidden" view in MDI apps? Pin
Paul Steven McLeish8-Jun-01 10:13
Paul Steven McLeish8-Jun-01 10:13 
AnswerRe: How do you create a Pin
#realJSOP9-Jun-01 2:24
professional#realJSOP9-Jun-01 2:24 
Generalpop up menu Pin
mr20038-Jun-01 8:43
mr20038-Jun-01 8:43 
GeneralRe: pop up menu Pin
Oliver Daniel8-Jun-01 14:24
Oliver Daniel8-Jun-01 14:24 
GeneralRe: pop up menu Pin
mr20039-Jun-01 13:52
mr20039-Jun-01 13:52 
GeneralDynamic control over treelist view Pin
hearties8-Jun-01 8:37
hearties8-Jun-01 8:37 
Generalautomation server register error Pin
ernst.maurer8-Jun-01 8:34
ernst.maurer8-Jun-01 8:34 
GeneralApplication and file name Pin
mr20038-Jun-01 7:42
mr20038-Jun-01 7:42 
GeneralRe: Application and file name Pin
Paul Steven McLeish8-Jun-01 10:23
Paul Steven McLeish8-Jun-01 10:23 
GeneralRe: Application and file name Pin
mr20039-Jun-01 13:53
mr20039-Jun-01 13:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.