summaryrefslogtreecommitdiff
path: root/apps/win_main.c
diff options
context:
space:
mode:
authorPaul Gardiner <paulg.artifex@glidos.net>2012-08-02 16:04:44 +0100
committerPaul Gardiner <paulg.artifex@glidos.net>2012-08-02 16:04:44 +0100
commit901f3ea1bb6ffc55f297a52b7b4c72138962a986 (patch)
treedca67928ce95e4458a76c4dff0c58b1758db0626 /apps/win_main.c
parent8068b7ba7ac0f103f4770736518fe7e545ceba30 (diff)
downloadmupdf-901f3ea1bb6ffc55f297a52b7b4c72138962a986.tar.xz
Forms: add support for save on exit to the windows app
Diffstat (limited to 'apps/win_main.c')
-rw-r--r--apps/win_main.c49
1 files changed, 47 insertions, 2 deletions
diff --git a/apps/win_main.c b/apps/win_main.c
index 71cf9203..a76fe053 100644
--- a/apps/win_main.c
+++ b/apps/win_main.c
@@ -99,6 +99,16 @@ void winerror(pdfapp_t *app, char *msg)
exit(1);
}
+int winsavequery(pdfapp_t *app)
+{
+ switch(MessageBoxA(hwndframe, "File has unsaved changes. Do you want to save", "MuPDF", MB_YESNOCANCEL))
+ {
+ case IDYES: return SAVE;
+ case IDNO: return DISCARD;
+ default: return CANCEL;
+ }
+}
+
int winfilename(wchar_t *buf, int len)
{
OPENFILENAME ofn;
@@ -115,6 +125,34 @@ int winfilename(wchar_t *buf, int len)
return GetOpenFileNameW(&ofn);
}
+int wingetsavepath(pdfapp_t *app, char *buf, int len)
+{
+ OPENFILENAMEA ofn;
+ buf[0] = 0;
+ if (strlen(filename) < (unsigned int)len)
+ strcpy(buf, filename);
+ memset(&ofn, 0, sizeof(OPENFILENAME));
+ ofn.lStructSize = sizeof(OPENFILENAME);
+ ofn.hwndOwner = hwndframe;
+ ofn.lpstrFile = buf;
+ ofn.nMaxFile = len;
+ ofn.lpstrInitialDir = NULL;
+ ofn.lpstrTitle = "MuPDF: Save PDF file";
+ ofn.lpstrFilter = "Documents (*.pdf;*.xps;*.cbz;*.zip)\0*.zip;*.cbz;*.xps;*.pdf\0PDF Files (*.pdf)\0*.pdf\0XPS Files (*.xps)\0*.xps\0CBZ Files (*.cbz;*.zip)\0*.zip;*.cbz\0All Files\0*\0\0";
+ ofn.Flags = OFN_HIDEREADONLY;
+ if (GetSaveFileNameA(&ofn))
+ {
+ if (strlen(buf) < sizeof(filename))
+ strcpy(filename, buf);
+
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
+}
+
static char pd_filename[256] = "The file is encrypted.";
static char pd_password[256] = "";
static char td_textinput[1024] = "";
@@ -411,8 +449,11 @@ void winopen()
void winclose(pdfapp_t *app)
{
- pdfapp_close(app);
- exit(0);
+ if (pdfapp_preclose(app))
+ {
+ pdfapp_close(app);
+ exit(0);
+ }
}
void wincursor(pdfapp_t *app, int curs)
@@ -740,6 +781,10 @@ frameproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_NOTIFY:
case WM_COMMAND:
return SendMessage(hwndview, message, wParam, lParam);
+
+ case WM_CLOSE:
+ if (!pdfapp_preclose(&gapp))
+ return 0;
}
return DefWindowProc(hwnd, message, wParam, lParam);