From 68ce6023817c9ab5f5c11da213a9e4b7378e7614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Nicolaysen=20S=C3=B8rnes?= Date: Thu, 31 May 2007 15:38:51 +0200 Subject: [PATCH] wordpad: Add file saving dialog. --- programs/wordpad/De.rc | 1 + programs/wordpad/En.rc | 1 + programs/wordpad/Fr.rc | 3 ++- programs/wordpad/Hu.rc | 1 + programs/wordpad/Ko.rc | 1 + programs/wordpad/Nl.rc | 1 + programs/wordpad/No.rc | 1 + programs/wordpad/Pl.rc | 1 + programs/wordpad/Ru.rc | 1 + programs/wordpad/Tr.rc | 1 + programs/wordpad/resource.h | 7 ++++--- programs/wordpad/wordpad.c | 32 ++++++++++++++++++++++++++++++-- 12 files changed, 45 insertions(+), 6 deletions(-) diff --git a/programs/wordpad/De.rc b/programs/wordpad/De.rc index 6d973ab87cc..054e234b490 100644 --- a/programs/wordpad/De.rc +++ b/programs/wordpad/De.rc @@ -25,6 +25,7 @@ BEGIN MENUITEM "&Neu\tCtrl+N", ID_FILE_NEW MENUITEM "&Öffnen\tCtrl+O", ID_FILE_OPEN MENUITEM "&Speichern\tCtrl+S", ID_FILE_SAVE + MENUITEM "Speichern &unter...", ID_FILE_SAVEAS MENUITEM SEPARATOR MENUITEM "&Beenden", ID_FILE_EXIT END diff --git a/programs/wordpad/En.rc b/programs/wordpad/En.rc index bab41781053..4fa734d8e1d 100644 --- a/programs/wordpad/En.rc +++ b/programs/wordpad/En.rc @@ -25,6 +25,7 @@ BEGIN MENUITEM "&New\tCtrl+N", ID_FILE_NEW MENUITEM "&Open\tCtrl+O", ID_FILE_OPEN MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE + MENUITEM "Save &as . . .", ID_FILE_SAVEAS MENUITEM SEPARATOR MENUITEM "E&xit", ID_FILE_EXIT END diff --git a/programs/wordpad/Fr.rc b/programs/wordpad/Fr.rc index 901749e6322..e0d83702797 100644 --- a/programs/wordpad/Fr.rc +++ b/programs/wordpad/Fr.rc @@ -24,7 +24,8 @@ BEGIN BEGIN MENUITEM "&Nouveau\tCtrl+N", ID_FILE_NEW MENUITEM "&Ouvrir\tCtrl+O", ID_FILE_OPEN - MENUITEM "&Sauver\tCtrl+S", ID_FILE_SAVE + MENUITEM "&Enregistrer\tCtrl+S", ID_FILE_SAVE + MENUITEM "Enregistrer &sous...", ID_FILE_SAVEAS MENUITEM SEPARATOR MENUITEM "&Quitter", ID_FILE_EXIT END diff --git a/programs/wordpad/Hu.rc b/programs/wordpad/Hu.rc index 8c1e0586922..2cab4f5a9b7 100644 --- a/programs/wordpad/Hu.rc +++ b/programs/wordpad/Hu.rc @@ -25,6 +25,7 @@ BEGIN MENUITEM "&Új\tCtrl+N", ID_FILE_NEW MENUITEM "&Megnyitás\tCtrl+O", ID_FILE_OPEN MENUITEM "M&entés\tCtrl+S", ID_FILE_SAVE + MENUITEM "Mentés má&sként...", ID_FILE_SAVEAS MENUITEM SEPARATOR MENUITEM "&Kilépés", ID_FILE_EXIT END diff --git a/programs/wordpad/Ko.rc b/programs/wordpad/Ko.rc index 33c76783180..6694006c71f 100644 --- a/programs/wordpad/Ko.rc +++ b/programs/wordpad/Ko.rc @@ -26,6 +26,7 @@ BEGIN MENUITEM "»õ ÆÄÀÏ(&N)\tCtrl+N", ID_FILE_NEW MENUITEM "¿­±â(&O)\tCtrl+O", ID_FILE_OPEN MENUITEM "ÀúÀå(&S)\tCtrl+S", ID_FILE_SAVE + MENUITEM "´Ù¸¥ À̸§À¸·Î ÀúÀå(&A)...", ID_FILE_SAVEAS MENUITEM SEPARATOR MENUITEM "³ª°¡±â(&X)", ID_FILE_EXIT END diff --git a/programs/wordpad/Nl.rc b/programs/wordpad/Nl.rc index 3a18519e9e8..e009d5fb4bf 100644 --- a/programs/wordpad/Nl.rc +++ b/programs/wordpad/Nl.rc @@ -25,6 +25,7 @@ BEGIN MENUITEM "&Nieuw\tCtrl+N" ID_FILE_NEW MENUITEM "&Openen\tCtrl+O", ID_FILE_OPEN MENUITEM "O&pslaan\tCtrl+S", ID_FILE_SAVE + MENUITEM "Ops&laan als...", ID_FILE_SAVEAS MENUITEM SEPARATOR MENUITEM "&Afsluiten", ID_FILE_EXIT END diff --git a/programs/wordpad/No.rc b/programs/wordpad/No.rc index b13fb678beb..3efb4084f5a 100644 --- a/programs/wordpad/No.rc +++ b/programs/wordpad/No.rc @@ -25,6 +25,7 @@ BEGIN MENUITEM "&Ny\tCtrl+N", ID_FILE_NEW MENUITEM "&Åpne\tCtrl+O", ID_FILE_OPEN MENUITEM "&Lagre\tCtrl+S", ID_FILE_SAVE + MENUITEM "Lagre &som . . .", ID_FILE_SAVEAS MENUITEM SEPARATOR MENUITEM "&Avslutt", ID_FILE_EXIT END diff --git a/programs/wordpad/Pl.rc b/programs/wordpad/Pl.rc index 2c277e4b9cf..9498484a514 100644 --- a/programs/wordpad/Pl.rc +++ b/programs/wordpad/Pl.rc @@ -26,6 +26,7 @@ BEGIN MENUITEM "&Nowy\tCtrl+N", ID_FILE_NEW MENUITEM "&Otwórz\tCtrl+O", ID_FILE_OPEN MENUITEM "&Zapisz\tCtrl+S", ID_FILE_SAVE + MENUITEM "Z&apisz jako...", ID_FILE_SAVEAS MENUITEM SEPARATOR MENUITEM "Za&koñcz", ID_FILE_EXIT END diff --git a/programs/wordpad/Ru.rc b/programs/wordpad/Ru.rc index fd24593f717..ff471e2b7d8 100644 --- a/programs/wordpad/Ru.rc +++ b/programs/wordpad/Ru.rc @@ -25,6 +25,7 @@ BEGIN MENUITEM "Ñîçä&àòü\tCtrl+N", ID_FILE_NEW MENUITEM "&Îòêðûòü\tCtrl+O", ID_FILE_OPEN MENUITEM "&Ñîõðàíèòü\tCtrl+S", ID_FILE_SAVE + MENUITEM "Ñîõðàíèòü &êàê...", ID_FILE_SAVEAS MENUITEM SEPARATOR MENUITEM "Â&ûõîä", ID_FILE_EXIT END diff --git a/programs/wordpad/Tr.rc b/programs/wordpad/Tr.rc index f43f8fd6965..0d6598e0c56 100644 --- a/programs/wordpad/Tr.rc +++ b/programs/wordpad/Tr.rc @@ -27,6 +27,7 @@ BEGIN MENUITEM "&Yeni\tCtrl+N", ID_FILE_NEW MENUITEM "&Aç\tCtrl+O", ID_FILE_OPEN MENUITEM "&Kaydet\tCtrl+S", ID_FILE_SAVE + MENUITEM "&Farklý Kaydet...", ID_FILE_SAVEAS MENUITEM SEPARATOR MENUITEM "&Çýk", ID_FILE_EXIT END diff --git a/programs/wordpad/resource.h b/programs/wordpad/resource.h index e818e400328..bc7647d0e3e 100644 --- a/programs/wordpad/resource.h +++ b/programs/wordpad/resource.h @@ -20,11 +20,12 @@ #define ID_FILE_OPEN 1001 #define ID_FILE_SAVE 1002 #define ID_FILE_NEW 1003 +#define ID_FILE_SAVEAS 1004 -#define ID_PRINT 1004 -#define ID_PREVIEW 1005 +#define ID_PRINT 1005 +#define ID_PREVIEW 1006 -#define ID_FIND 1006 +#define ID_FIND 1007 #define ID_ALIGN_LEFT 1100 #define ID_ALIGN_CENTER 1101 diff --git a/programs/wordpad/wordpad.c b/programs/wordpad/wordpad.c index 360f2a3bffd..5a9f7fdc700 100644 --- a/programs/wordpad/wordpad.c +++ b/programs/wordpad/wordpad.c @@ -223,6 +223,29 @@ static void DoSaveFile(LPCWSTR wszSaveFileName) set_caption(wszFileName); } +static void DialogSaveFile(void) +{ + OPENFILENAMEW sfn; + + WCHAR wszFile[MAX_PATH] = {'\0'}; + static const WCHAR wszDefExt[] = {'r','t','f','\0'}; + + ZeroMemory(&sfn, sizeof(sfn)); + + sfn.lStructSize = sizeof(sfn); + sfn.Flags = OFN_HIDEREADONLY | OFN_PATHMUSTEXIST; + sfn.hwndOwner = hMainWnd; + sfn.lpstrFilter = wszFilter; + sfn.lpstrFile = wszFile; + sfn.nMaxFile = MAX_PATH; + sfn.lpstrDefExt = wszDefExt; + + if(!GetSaveFileNameW(&sfn)) + return; + + DoSaveFile(sfn.lpstrFile); +} + static void HandleCommandLine(LPWSTR cmdline) { WCHAR delimiter; @@ -466,9 +489,14 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam) case ID_FILE_SAVE: if(wszFileName[0]) + { DoSaveFile(wszFileName); - else - MessageBox(hWnd, "Can only save existing for now", "WordPad", MB_OK); + break; + } + /* Fall through */ + + case ID_FILE_SAVEAS: + DialogSaveFile(); break; case ID_PRINT: