diff --git a/programs/notepad/ChangeLog b/programs/notepad/ChangeLog index 2d2b569feeb..b2db9b0f7a8 100644 --- a/programs/notepad/ChangeLog +++ b/programs/notepad/ChangeLog @@ -1,66 +1,75 @@ +Sat Feb 6 20:25:25 1999 Marcel Baur + - Added new IDS_NOTSAVED ressource (needs translation in *.rc) + - Improved printing support (not yet complete) + - Improved file drag and drop (should now work) + - General code cleanup + Thu Jan 28 18:17:08 1999 Jukka Iivonen * [Fi.rc] [main.c] [Makefile.in] Added Finnish language support. + +Sun Oct 18 14:11:42 1998 Marcel Baur + + * [??.rc], [TODO], [dialog.c], [dialog.h], [language.c], + [language.h], [license.c], [license.h], [main.c], [main.h], + [notepad.rc]: + + - Fixed GetOpenFileName and GetSaveFileName dialogs. + - Fixed Print dialog and introduced PrinterSetup dialog. + - Fixed PageSetup dialog: values are now correctly initialized + (had to change all *.rc files) + - Preliminary file drag and drop support. + +Fri Jun 12 23:29:44 1998 Marcel Baur + - Fixed GetDateFormat()->GetTimeFormat() for locale time. + +Mon May 25 14:30:00 1998 Henrik Olsen + * [Da.rc] + - Added Danish language support. + +Fri May 15 23:59:22 1998 Marcel Baur + - Date/Time now uses locale-specific formats + - Language-specific window caption, displays file being edited. + - Started with parsing of command line settings + - Started with DoOpenFile, DoCloseFile, DoSaveFile logics + - Prompt user to save settings when closing a file + -> Introduced a new message box (not yet finished) + - Fixed minor features (missing IDS in main.h, ...) + +Sun Mar 29 20:29:41 1998 Laurent Buffler + * [Fr.rc] + - Added French language support. + +Fri Feb 27 21:03:37 1998 Karl Backström + - Fixed some minor features. + +Sat Feb 14 17:42:29 1998 Karl Backström + * NEW [language.c] [language.h] + - Takes care of all language related stuff. + - A new [programs] in .winerc is in use. + +Tue Feb 10 23:34:08 1998 Marcel Baur + - Fixed broken language menus + +Fri Feb 06 23.54.35 1998 Karl Backström + * [main.c] [main.h] [notepad.rc] + - Fixed language support for menus. + * NEW [dialog.c] [dialog.h] + - Moved all menu and dialog related stuff here. + +Sun Jan 18 23:05:04 1998 Karl Backström + * [Sw.rc] + - Added/updated Swedish language support. + +Tue Dec 23 23:35:04 1997 Marcel Baur + - Fixed lots of bugs w/ resources in *.rc + - moved [notepad.c] into [main.c] + - moved [notepad.h] into [main.h] + +Fri Dec 05 20:51:55 1997 Marcel Baur + * [notepad.c] [notepad.h] [notepad.rc] [En.rc] [De.rc] + [license.c] [license.h] [License_En.c] + [README] [TODO] [ChangeLog] + - Originals by Marcel Baur -Sun Oct 18 14:11:42 1998 Alexandre Julliard - - * Da.rc, De.rc, En.rc, Fr.rc, Sw.rc, TODO, dialog.c, dialog.h, language.c, language.h, license.c, license.h, main.c, main.h, notepad.rc: - Marcel Baur - Fixed GetOpenFileName and GetSaveFileName dialogs. - Fixed Print dialog and introduced PrinterSetup dialog. - Fixed PageSetup dialog: values are now correctly initialized (had to - change all *.rc files) - Preliminary file drag and drop support. - -Fri Jun 12 23:29:44 1998 Marcel Baur - * Fixed GetDateFormat()->GetTimeFormat() for locale time. - -Mon May 25 14:30:00 1998 Henrik Olsen - * [Da.rc] - Added Danish language support. - -Fri May 15 23:59:22 1998 Marcel Baur - * Date/Time now uses locale-specific formats - * Language-specific window caption, displays file being edited. - * Started with parsing of command line settings - * Started with DoOpenFile, DoCloseFile, DoSaveFile logics - * Prompt user to save settings when closing a file - -> Introduced a new message box (not yet finished) - * Fixed minor features (missing IDS in main.h, ...) - -Sun Mar 29 20:29:41 1998 Laurent Buffler - * [Fr.rc] - Added French language support. - -Fri Feb 27 21:03:37 1998 Karl Backström - * Fixed some minor features. - -Sat Feb 14 17:42:29 1998 Karl Backström - * NEW [language.c] [language.h] - Takes care of all language related stuff. - A new [programs] in .winerc is in use. - -Tue Feb 10 23:34:08 1998 Marcel Baur - * Fixed broken language menus - -Fri Feb 06 23.54.35 1998 Karl Backström - * [main.c] [main.h] [notepad.rc] - Fixed language support for menus. - * NEW [dialog.c] [dialog.h] - Moved all menu and dialog related stuff here. - -Sun Jan 18 23:05:04 1998 Karl Backström - * [Sw.rc] - Added/updated Swedish language support. - -Tue Dec 23 23:35:04 1997 Marcel Baur - * Fixed lots of bugs w/ resources in *.rc - * moved [notepad.c] into [main.c] - * moved [notepad.h] into [main.h] - -Fri Dec 05 20:51:55 1997 Marcel Baur - * [notepad.c] [notepad.h] [notepad.rc] [En.rc] [De.rc] - [license.c] [license.h] [License_En.c] - [README] [TODO] [ChangeLog] - Originals by Marcel Baur diff --git a/programs/notepad/Da.rc b/programs/notepad/Da.rc index 1308b531951..dc13c0d19cc 100644 --- a/programs/notepad/Da.rc +++ b/programs/notepad/Da.rc @@ -89,6 +89,11 @@ #define STRING_NOTEXT "Du har ikke skrevet noget tekst. \ \nSkriv noget tekst, og prøv så igen" +/* FIXME: */ + +#define STRING_NOTSAVED "Filen '%s'\n has been modified.\n\n \ +Would you like to save the changes ?" + #define STRING_NOTFOUND "Kan ikke finde '%s'." #define STRING_OUT_OF_MEMORY "Der er ikke nok hukommelse til at udføre \ diff --git a/programs/notepad/De.rc b/programs/notepad/De.rc index 6e201d2b98c..c222246b680 100644 --- a/programs/notepad/De.rc +++ b/programs/notepad/De.rc @@ -92,6 +92,9 @@ Benutzen Sie bitte einen anderen Editor, um diese Datei zu bearbeiten." gespeichert\n werden könnte. Geben Sie Text ein, und versuchen Sie es \ \nerneut." +#define STRING_NOTSAVED "Datei %s\n wurde geaendert.\n\n \ +Moechten Sie die Aenderungen speichern ?" + #define STRING_NOTFOUND "'%s' kann nicht gefunden werden." #define STRING_OUT_OF_MEMORY "Nicht genügend Arbeitsspeicher, \ diff --git a/programs/notepad/En.rc b/programs/notepad/En.rc index 54942f3cc12..1be4cb57fa9 100644 --- a/programs/notepad/En.rc +++ b/programs/notepad/En.rc @@ -91,6 +91,9 @@ Please use a different editor." #define STRING_NOTEXT "You didn't enter any text. \ \nPlease type something and try again" +#define STRING_NOTSAVED "File '%s'\nhas been modified\n\n \ +Would you like to save the changes ?" + #define STRING_NOTFOUND "'%s' can not be found." #define STRING_OUT_OF_MEMORY "Not enough memory to complete this \ diff --git a/programs/notepad/Es.rc b/programs/notepad/Es.rc index b3d21752a64..499612cac7a 100644 --- a/programs/notepad/Es.rc +++ b/programs/notepad/Es.rc @@ -91,6 +91,11 @@ Use otro editor." #define STRING_NOTEXT "Vd. no escribió nada. \ \nPor favor escriba algo y pruebe de vuelta" +/* FIXME */ + +#define STRING_NOTSAVED "El archivo '%s'\n has been changed\n\n \ +Would you like to save your changes ?" + #define STRING_NOTFOUND "no se encontró '%s'." #define STRING_OUT_OF_MEMORY "No hay suficiente memoria para terminar \ diff --git a/programs/notepad/Fi.rc b/programs/notepad/Fi.rc index 16c4e74cc31..877d16078b6 100644 --- a/programs/notepad/Fi.rc +++ b/programs/notepad/Fi.rc @@ -90,6 +90,11 @@ Please use a different editor." #define STRING_NOTEXT "Et syöttänyt lainkaan tekstiä. \ \nKirjoita jotain ja yritä uudelleen" +/* FIXME */ + +#define STRING_NOTSAVED "File '%s'\nhas been modified\n\n \ +Would you like to save your changes ?" + #define STRING_NOTFOUND "'%s' ei löydy." #define STRING_OUT_OF_MEMORY "Muistia ei ole riittävästi tämän \ diff --git a/programs/notepad/Fr.rc b/programs/notepad/Fr.rc index 5a42b4f8158..71dd9eabb4d 100644 --- a/programs/notepad/Fr.rc +++ b/programs/notepad/Fr.rc @@ -91,6 +91,11 @@ Veuillez utiliser un autre #define STRING_NOTEXT "Vous n'avez pas entré de texte. \ \nVeuillez taper quelque chose et recommencer" +/* FIXME */ + +#define STRING_NOTSAVED "Le fichier '%s'\n\n a change\n +Would you like to save your changes ?" + #define STRING_NOTFOUND "'%s' introuvable." #define STRING_OUT_OF_MEMORY "Pas assez de mémoire pour finir cette tâche. \ diff --git a/programs/notepad/License_En.c b/programs/notepad/License_En.c index bec66d995eb..511bce40a7a 100644 --- a/programs/notepad/License_En.c +++ b/programs/notepad/License_En.c @@ -44,5 +44,5 @@ EXCEPT AS OTHERWISE RESTRICTED BY LAW, THIS WORK IS PROVIDED\ ADVISED OF THE POSSIBILITY OF SUCH DAMAGES."; LICENSE WineLicense_En = {License_En, LicenseCaption_En, - NoWarranty_En, NoWarrantyCaption_En}; + NoWarranty_En, NoWarrantyCaption_En}; diff --git a/programs/notepad/README b/programs/notepad/README index 2e03ea9c1a1..010725ec8ef 100644 --- a/programs/notepad/README +++ b/programs/notepad/README @@ -2,6 +2,10 @@ NOTEPAD for WINE ================ +There is now a web page dedicated to Notepad for Wine I am maintaing. +Please see http://www.vis.inf.ethz.ch/students/mbaur/notepad for +latest info about Notepad. This page also includes screenshots. + This is an early release of notepad and most of the code is still broken. It will probably compile but the application will not make much sense yet. @@ -9,11 +13,5 @@ much sense yet. Please see file TODO for things to do and keep the file ChangeLog up to date. -Code is currently under heavy construction. Nearly all files will -change until next release. You can speed up development of notepad -if you send patches and additions directly to my personal email -address . - -I also try to read news:comp.emulators.ms-windows.wine frequently, -so I can also integrate patches posted via usenet. - +I also try to read wine-devel@winehq.com frequently. + \ No newline at end of file diff --git a/programs/notepad/Sw.rc b/programs/notepad/Sw.rc index 84dfde48665..38c6c8d01f2 100644 --- a/programs/notepad/Sw.rc +++ b/programs/notepad/Sw.rc @@ -91,6 +91,11 @@ Anv #define STRING_NOTEXT "Du skrev inte in någon text. \ \nSkriv något och försök sedan igen" +/* FIXME */ + +#define STRING_NOTSAVED "Filen '%s'\nhas been modified\n\n \ +Would you like to save your changes ?" + #define STRING_NOTFOUND "'%s' hittades inte." #define STRING_OUT_OF_MEMORY "Inte tillräkligt med minne för att slutföra \ diff --git a/programs/notepad/TODO b/programs/notepad/TODO index 8d0f335a417..81979037380 100644 --- a/programs/notepad/TODO +++ b/programs/notepad/TODO @@ -2,9 +2,8 @@ - Logfile feature if Notepad opens a file with ".LOG" (really?) in the first line, the current date/time should automatically be inserted into the last line - of the file at startup. This feature is not well documented. + of the file at startup. - Notepad segfaults when selecting "Find" button in "Search" dialog. - This is probably a problem related to Winelib. - create new *.rc files for all languages you know. diff --git a/programs/notepad/dialog.c b/programs/notepad/dialog.c index 11e168f23e4..71980db384b 100644 --- a/programs/notepad/dialog.c +++ b/programs/notepad/dialog.c @@ -1,7 +1,7 @@ /* * Notepad (dialog.c) * - * Copyright 1998 Marcel Baur + * Copyright 1998,99 Marcel Baur * To be distributed under the Wine License */ @@ -20,19 +20,24 @@ #include "language.h" #include "dialog.h" -#include "version.h" -#include "winnls.h" -#include "debug.h" - +#ifdef LCC + #define LCC_HASASSERT + #include "lcc.h" +#else + #include "version.h" + #include "winnls.h" + #include "debug.h" +#endif static LRESULT DIALOG_PAGESETUP_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); + int AlertIDS(UINT ids_message, UINT ids_caption, WORD type) { -/* - * Given some ids strings, this acts as a language-aware wrapper for - * "MessageBox" - */ + /* + * Given some ids strings, this acts as a language-aware wrapper for + * "MessageBox" + */ CHAR szMessage[MAX_STRING_LEN]; CHAR szCaption[MAX_STRING_LEN]; @@ -42,16 +47,46 @@ int AlertIDS(UINT ids_message, UINT ids_caption, WORD type) { return (MessageBox(Globals.hMainWnd, szMessage, szCaption, type)); } -void AlertFileNotFound(LPCSTR szFilename) { +void AlertFileNotFound(LPCSTR szFileName) { int nResult; + CHAR szMessage[MAX_STRING_LEN]; + CHAR szRessource[MAX_STRING_LEN]; + + /* Load and format szMessage */ + LoadString(Globals.hInstance, IDS_NOTFOUND, szRessource, sizeof(szRessource)); + wvsprintf(szMessage, szRessource, szFileName); - nResult = AlertIDS(IDS_NOTFOUND, IDS_ERROR, MB_ICONEXCLAMATION); + /* Load szCaption */ + LoadString(Globals.hInstance, IDS_ERROR, szRessource, sizeof(szRessource)); + + /* Display Modal Dialog */ + nResult = MessageBox(Globals.hMainWnd, szMessage, szRessource, MB_ICONEXCLAMATION); + +} + +int AlertFileNotSaved(LPCSTR szFileName) { + + int nResult; + CHAR szMessage[MAX_STRING_LEN]; + CHAR szRessource[MAX_STRING_LEN]; + + /* Load and format Message */ + + LoadString(Globals.hInstance, IDS_NOTSAVED, szRessource, sizeof(szRessource)); + wvsprintf(szMessage, szRessource, szFileName); + + /* Load Caption */ + + LoadString(Globals.hInstance, IDS_ERROR, szRessource, sizeof(szRessource)); + + /* Display modal */ + nResult = MessageBox(Globals.hMainWnd, szMessage, szRessource, MB_ICONEXCLAMATION + MB_YESNOCANCEL); + return(nResult); } VOID AlertOutOfMemory(void) { - int nResult; nResult = AlertIDS(IDS_OUT_OF_MEMORY, IDS_ERROR, MB_ICONEXCLAMATION); @@ -65,17 +100,17 @@ BOOL ExistFile(LPCSTR szFilename) { * FALSE - if it does not */ WIN32_FIND_DATA entry; - HANDLE32 handle; + HANDLE32 hFile; - handle = FindFirstFile(szFilename, &entry); + hFile = FindFirstFile(szFilename, &entry); - return (handle!=INVALID_HANDLE_VALUE32); + return (hFile!=INVALID_HANDLE_VALUE32); } VOID DoSaveFile(VOID) { - /* Really Save the file */ - - /* ... (Globals.szFileName); */ + + /* FIXME: Really Save the file */ + /* ... (Globals.szFileName); */ } @@ -83,60 +118,47 @@ BOOL DoCloseFile(void) { /* Return value: TRUE - User agreed to close (both save/don't save) */ /* FALSE - User cancelled close by selecting "Cancel" */ - CHAR szMessage[MAX_STRING_LEN]; - CHAR szCaption[MAX_STRING_LEN]; - - INT nResult; + int nResult; - if (strlen(Globals.szFileName)>0) { + if (strlen(Globals.szFileName)>0) { + /* prompt user to save changes */ + nResult = AlertFileNotSaved(Globals.szFileName); + switch (nResult) { + case IDYES: DoSaveFile(); + break; - /* prompt user to save changes */ - - /* FIXME: The following resources are not yet in the .rc files */ - /* szMessage, szCaption show up random values. Please keep these lines! */ + case IDNO: break; - strcpy(szMessage, "Save changes ?"); - strcpy(szCaption, "Save changes"); - -/* LoadString(Globals.hInstance, ids_savechanges, szMessage, sizeof(szMessage)); */ -/* LoadString(Globals.hInstance, ids_savetitle, szCaption, sizeof(szCaption)); */ - - nResult = MessageBox(Globals.hMainWnd, szMessage, szCaption, MB_YESNOCANCEL); - - switch (nResult) { - case IDYES: DoSaveFile(); - break; - - case IDNO: break; - - case IDCANCEL: return(FALSE); - break; + case IDCANCEL: return(FALSE); + break; - default: return(FALSE); - break; - } - - - } - - /* Forget file name */ - lstrcpy(Globals.szFileName, ""); - LANGUAGE_UpdateWindowCaption(); - - return(TRUE); + default: return(FALSE); + break; + } /* switch */ + } /* if */ + /* Forget file name */ + lstrcpy(Globals.szFileName, ""); + LANGUAGE_UpdateWindowCaption(); + return(TRUE); } void DoOpenFile(LPCSTR szFileName) { + int hFile; + WORD nResult; + /* Close any files and prompt to save changes */ if (DoCloseFile) { - - /* Open file */ - lstrcpy(Globals.szFileName, szFileName); + GetFileTitle(szFileName, Globals.szFileName, sizeof(Globals.szFileName)); LANGUAGE_UpdateWindowCaption(); - + hFile = _lopen(szFileName, OF_READ); + nResult = _lread(hFile, Globals.Buffer, sizeof(Globals.Buffer)); + _lclose(hFile); + + /* FIXME: Append time/date if first line contains LOGPREFIX */ + /* (Globals.Buffer, ) */ } } @@ -145,16 +167,12 @@ VOID DIALOG_FileNew(VOID) { /* Close any files and promt to save changes */ if (DoCloseFile()) { - /* do nothing yet */ - } } - VOID DIALOG_FileOpen(VOID) { - OPENFILENAME openfilename; CHAR szPath[MAX_PATHNAME_LEN]; CHAR szDir[MAX_PATHNAME_LEN]; @@ -210,7 +228,9 @@ VOID DIALOG_FileOpen(VOID) VOID DIALOG_FileSave(VOID) { - fprintf(stderr, "FileSave()\n"); + /* FIXME: Save File */ + + DIALOG_FileSaveAs(); } VOID DIALOG_FileSaveAs(VOID) @@ -269,19 +289,40 @@ VOID DIALOG_FileSaveAs(VOID) VOID DIALOG_FilePrint(VOID) { + LONG bFlags, nBase; + WORD nOffset; + DOCINFO di; + int nResult; + HDC hContext; PRINTDLG printer; + + CHAR szDocumentName[MAX_STRING_LEN]; /* Name of document */ + CHAR szPrinterName[MAX_STRING_LEN]; /* Name of the printer */ + CHAR szDeviceName[MAX_STRING_LEN]; /* Name of the printer device */ + CHAR szOutput[MAX_STRING_LEN]; /* in which file/device to print */ + +/* LPDEVMODE hDevMode; */ +/* LPDEVNAMES hDevNames; */ + +/* hDevMode = GlobalAlloc(GMEM_MOVEABLE + GMEM_ZEROINIT, sizeof(DEVMODE)); */ +/* hDevNames = GlobalAlloc(GMEM_MOVEABLE + GMEM_ZEROINIT, sizeof(DEVNAMES)); */ + + /* Get Current Settings */ + printer.lStructSize = sizeof(PRINTDLG); printer.hwndOwner = Globals.hMainWnd; printer.hInstance = Globals.hInstance; + + /* Let PrintDlg create a DEVMODE structure */ printer.hDevMode = 0; printer.hDevNames = 0; printer.hDC = 0; - printer.Flags = 0; + printer.Flags = PD_RETURNDEFAULT; printer.nFromPage = 0; printer.nToPage = 0; printer.nMinPage = 0; printer.nMaxPage = 0; - printer.nCopies = 1; + printer.nCopies = 0; printer.lCustData = 0; printer.lpfnPrintHook = 0; printer.lpfnSetupHook = 0; @@ -289,10 +330,106 @@ VOID DIALOG_FilePrint(VOID) printer.lpSetupTemplateName = 0; printer.hPrintTemplate = 0; printer.hSetupTemplate = 0; - + + nResult = PrintDlg(&printer); + +/* hContext = CreateDC(, szDeviceName, "TEST.TXT", 0); */ + + /* Congratulations to those Microsoft Engineers responsable */ + /* for the following pointer acrobatics */ + + assert(printer.hDevNames!=0); + + nBase = (LONG)(printer.hDevNames); + + nOffset = (WORD)((LPDEVNAMES) printer.hDevNames)->wDriverOffset; + lstrcpy(szPrinterName, (LPCSTR) (nBase + nOffset)); + + nOffset = (WORD)((LPDEVNAMES) printer.hDevNames)->wDeviceOffset; + lstrcpy(szDeviceName, (LPCSTR) (nBase + nOffset)); + + nOffset = (WORD)((LPDEVNAMES) printer.hDevNames)->wOutputOffset; + lstrcpy(szOutput, (LPCSTR) (nBase + nOffset)); + + MessageBox(Globals.hMainWnd, szPrinterName, "Printer Name", MB_ICONEXCLAMATION); + MessageBox(Globals.hMainWnd, szDeviceName, "Device Name", MB_ICONEXCLAMATION); + MessageBox(Globals.hMainWnd, szOutput, "Output", MB_ICONEXCLAMATION); + + /* Set some default flags */ + + bFlags = PD_RETURNDC + PD_SHOWHELP; + + if (TRUE) { + /* Remove "Print Selection" if there is no selection */ + bFlags = bFlags + PD_NOSELECTION; + } + + printer.Flags = bFlags; +/* + printer.nFromPage = 0; + printer.nToPage = 0; + printer.nMinPage = 0; + printer.nMaxPage = 0; +*/ + + /* Let commdlg manage copy settings */ + printer.nCopies = PD_USEDEVMODECOPIES; + if (PrintDlg(&printer)) { - /* do nothing */ - }; + + /* initialize DOCINFO */ + di.cbSize = sizeof(DOCINFO); + lstrcpy(di.lpszDocName, szDocumentName); + lstrcpy(di.lpszOutput, szOutput); + + hContext = printer.hDC; + assert(hContext!=0); + assert( (int) hContext!=PD_RETURNDC); + + SetMapMode(hContext, MM_LOMETRIC); +/* SetViewPortExExt(hContext, 10, 10, 0); */ + SetBkMode(hContext, OPAQUE); + + nResult = TextOut(hContext, 0, 0, " ", 1); + assert(nResult != 0); + + nResult = StartDoc(hContext, &di); + assert(nResult != SP_ERROR); + + nResult = StartPage(hContext); + assert(nResult >0); + + /* FIXME: actually print */ + + nResult = EndPage(hContext); + + switch (nResult) { + case SP_ERROR: + MessageBox(Globals.hMainWnd, "Generic Error", "Print Engine Error", MB_ICONEXCLAMATION); + break; + case SP_APPABORT: + MessageBox(Globals.hMainWnd, "The print job was aborted.", "Print Engine Error", MB_ICONEXCLAMATION); + break; + case SP_USERABORT: + MessageBox(Globals.hMainWnd, "The print job was aborted using the Print Manager ", "Print Engine Error", MB_ICONEXCLAMATION); + break; + case SP_OUTOFDISK: + MessageBox(Globals.hMainWnd, "Out of disk space", "Print Engine Error", MB_ICONEXCLAMATION); + break; + case SP_OUTOFMEMORY: + AlertOutOfMemory(); + break; + default: + MessageBox(Globals.hMainWnd, "Default", "Print", MB_ICONEXCLAMATION); + } /* switch */ + nResult = EndDoc(hContext); + assert(nResult>=0); + nResult = DeleteDC(hContext); + assert(nResult!=0); + } /* if */ + +/* GlobalFree(hDevNames); */ +/* GlobalFree(hDevMode); */ } VOID DIALOG_FilePageSetup(VOID) @@ -303,25 +440,26 @@ VOID DIALOG_FilePageSetup(VOID) VOID DIALOG_FilePrinterSetup(VOID) { PRINTDLG printer; - printer.lStructSize = sizeof(PRINTDLG); - printer.hwndOwner = Globals.hMainWnd; - printer.hInstance = Globals.hInstance; - printer.hDevMode = 0; - printer.hDevNames = 0; - printer.hDC = 0; - printer.Flags = PD_PRINTSETUP; - printer.nFromPage = 0; - printer.nToPage = 0; - printer.nMinPage = 0; - printer.nMaxPage = 0; - printer.nCopies = 1; - printer.lCustData = 0; - printer.lpfnPrintHook = 0; - printer.lpfnSetupHook = 0; - printer.lpPrintTemplateName = 0; - printer.lpSetupTemplateName = 0; - printer.hPrintTemplate = 0; - printer.hSetupTemplate = 0; + + printer.lStructSize = sizeof(PRINTDLG); + printer.hwndOwner = Globals.hMainWnd; + printer.hInstance = Globals.hInstance; + printer.hDevMode = 0; + printer.hDevNames = 0; + printer.hDC = 0; + printer.Flags = PD_PRINTSETUP; + printer.nFromPage = 0; + printer.nToPage = 0; + printer.nMinPage = 0; + printer.nMaxPage = 0; + printer.nCopies = 1; + printer.lCustData = 0; + printer.lpfnPrintHook = 0; + printer.lpfnSetupHook = 0; + printer.lpPrintTemplateName = 0; + printer.lpSetupTemplateName = 0; + printer.hPrintTemplate = 0; + printer.hSetupTemplate = 0; if (PrintDlg(&printer)) { /* do nothing */ @@ -338,37 +476,79 @@ VOID DIALOG_FileExit(VOID) VOID DIALOG_EditUndo(VOID) { - fprintf(stderr, "EditUndo()\n"); + MessageBox(Globals.hMainWnd, "Undo", "Debug", MB_ICONEXCLAMATION); + /* undo */ } VOID DIALOG_EditCut(VOID) { - fprintf(stderr, "EditCut()\n"); + HANDLE hMem; + + hMem = GlobalAlloc(GMEM_ZEROINIT, 99); + + OpenClipboard(Globals.hMainWnd); + EmptyClipboard(); + + /* FIXME: Get text */ + lstrcpy((CHAR *)hMem, "Hello World"); + + SetClipboardData(CF_TEXT, hMem); + CloseClipboard(); + + GlobalFree(hMem); } VOID DIALOG_EditCopy(VOID) { - fprintf(stderr, "EditCopy()\n"); + HANDLE hMem; + + hMem = GlobalAlloc(GMEM_ZEROINIT, 99); + + OpenClipboard(Globals.hMainWnd); + EmptyClipboard(); + + /* FIXME: Get text */ + lstrcpy((CHAR *)hMem, "Hello World"); + + SetClipboardData(CF_TEXT, hMem); + CloseClipboard(); + + GlobalFree(hMem); } VOID DIALOG_EditPaste(VOID) { - fprintf(stderr, "EditPaste()\n"); + HANDLE hClipText; + + if (IsClipboardFormatAvailable(CF_TEXT)) { + OpenClipboard(Globals.hMainWnd); + hClipText = GetClipboardData(CF_TEXT); + CloseClipboard(); + MessageBox(Globals.hMainWnd, (CHAR *)hClipText, "PASTE", MB_ICONEXCLAMATION); + } } VOID DIALOG_EditDelete(VOID) { - fprintf(stderr, "EditDelete()\n"); + /* Delete */ } VOID DIALOG_EditSelectAll(VOID) { - fprintf(stderr, "EditSelectAll()\n"); + /* Select all */ } VOID DIALOG_EditTimeDate(VOID) { - DIALOG_TimeDate(); + SYSTEMTIME st; + LPSYSTEMTIME lpst = &st; + CHAR szDate[MAX_STRING_LEN]; + LPSTR date = szDate; + + GetLocalTime(&st); + GetDateFormat(LOCALE_USER_DEFAULT, LOCALE_SLONGDATE, lpst, NULL, date, MAX_STRING_LEN); + GetTimeFormat(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, lpst, NULL, date, MAX_STRING_LEN); + } VOID DIALOG_EditWrap(VOID) @@ -380,42 +560,28 @@ VOID DIALOG_EditWrap(VOID) VOID DIALOG_Search(VOID) { - FINDREPLACE find; - CHAR szFind[MAX_PATHNAME_LEN+10]; - CHAR szReplace[MAX_PATHNAME_LEN+10]; - - HWND hResult; + Globals.find.lStructSize = sizeof(Globals.find); + Globals.find.hwndOwner = Globals.hMainWnd; + Globals.find.hInstance = Globals.hInstance; + Globals.find.lpstrFindWhat = (CHAR *) &Globals.szFindText; + Globals.find.wFindWhatLen = sizeof(Globals.szFindText); + Globals.find.lpstrReplaceWith = 0; + Globals.find.wReplaceWithLen = 0; + Globals.find.Flags = FR_DOWN; + Globals.find.lCustData = 0; + Globals.find.lpfnHook = 0; + Globals.find.lpTemplateName = 0; - lstrcpy(szReplace, ""); - lstrcpy(szFind, Globals.szFindText); - - find.lStructSize = sizeof(FINDREPLACE); - find.hwndOwner = Globals.hMainWnd; - find.hInstance = 0; - find.lpstrFindWhat = szFind; - find.wFindWhatLen = MAX_PATHNAME_LEN; - find.lpstrReplaceWith = szReplace; - find.wReplaceWithLen = MAX_PATHNAME_LEN; - find.Flags = FR_DOWN; - find.lCustData = 0; - find.lpfnHook = 0; - find.lpTemplateName = 0; - - hResult = FindText(&find); - - if (hResult) { - lstrcpy(Globals.szFindText, szFind); - } - else - { - /* do nothing yet */ - }; + /* We only need to create the modal FindReplace dialog which will */ + /* notify us of incoming events using hMainWnd Window Messages */ + Globals.hFindReplaceDlg = FindText(&Globals.find); + assert(Globals.hFindReplaceDlg !=0); } VOID DIALOG_SearchNext(VOID) { - fprintf(stderr, "SearchNext()\n"); + /* Search Next */ } VOID DIALOG_HelpContents(VOID) @@ -425,7 +591,7 @@ VOID DIALOG_HelpContents(VOID) VOID DIALOG_HelpSearch(VOID) { - fprintf(stderr, "HelpSearch()\n"); + /* Search Help */ } VOID DIALOG_HelpHelp(VOID) @@ -445,7 +611,10 @@ VOID DIALOG_HelpNoWarranty(VOID) VOID DIALOG_HelpAboutWine(VOID) { - ShellAbout(Globals.hMainWnd, "Notepad", "Notepad\n" WINE_RELEASE_INFO, 0); + CHAR szNotepad[MAX_STRING_LEN]; + + LoadString(Globals.hInstance, IDS_NOTEPAD, szNotepad, sizeof(szNotepad)); + ShellAbout(Globals.hMainWnd, szNotepad, "Notepad\n" WINE_RELEASE_INFO, 0); } /*********************************************************************** @@ -462,30 +631,6 @@ VOID DIALOG_PageSetup(VOID) FreeProcInstance(lpfnDlg); } -/*********************************************************************** - * - * DIALOG_TimeDate - */ - -VOID DIALOG_TimeDate(VOID) -{ - /* uses [KERNEL32.310] (ole2nls.c) */ - - SYSTEMTIME st; - LPSYSTEMTIME lpst = &st; - CHAR szDate[MAX_STRING_LEN]; - LPSTR date = szDate; - - GetLocalTime(&st); - GetDateFormat(LOCALE_USER_DEFAULT, LOCALE_SLONGDATE, lpst, NULL, date, MAX_STRING_LEN); - - printf("Date: %s\n", date); - - GetTimeFormat(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, lpst, NULL, date, MAX_STRING_LEN); - - printf("Time: %s\n", date); - -} /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @@ -494,22 +639,37 @@ VOID DIALOG_TimeDate(VOID) static LRESULT DIALOG_PAGESETUP_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - switch (msg) + + switch (msg) { case WM_COMMAND: switch (wParam) { case IDOK: + /* save user input and close dialog */ + GetDlgItemText(hDlg, NP_PAGESETUP_HEAD, Globals.szHeader, sizeof(Globals.szHeader)); + GetDlgItemText(hDlg, NP_PAGESETUP_TAIL, Globals.szFooter, sizeof(Globals.szFooter)); + GetDlgItemText(hDlg, NP_PAGESETUP_TOP, Globals.szMarginTop, sizeof(Globals.szMarginTop)); + GetDlgItemText(hDlg, NP_PAGESETUP_BOTTOM, Globals.szMarginBottom, sizeof(Globals.szMarginBottom)); + GetDlgItemText(hDlg, NP_PAGESETUP_LEFT, Globals.szMarginLeft, sizeof(Globals.szMarginLeft)); + GetDlgItemText(hDlg, NP_PAGESETUP_RIGHT, Globals.szMarginRight, sizeof(Globals.szMarginRight)); EndDialog(hDlg, IDOK); return TRUE; case IDCANCEL: + /* discard user input and close dialog */ EndDialog(hDlg, IDCANCEL); return TRUE; + + case IDHELP: + /* FIXME: Bring this to work */ + MessageBox(Globals.hMainWnd, "Sorry, no help available", "Help", MB_ICONEXCLAMATION); + return TRUE; } break; case WM_INITDIALOG: + /* fetch last user input prior to display dialog */ SetDlgItemText(hDlg, NP_PAGESETUP_HEAD, Globals.szHeader); SetDlgItemText(hDlg, NP_PAGESETUP_TAIL, Globals.szFooter); SetDlgItemText(hDlg, NP_PAGESETUP_TOP, Globals.szMarginTop); @@ -517,13 +677,7 @@ static LRESULT DIALOG_PAGESETUP_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPAR SetDlgItemText(hDlg, NP_PAGESETUP_LEFT, Globals.szMarginLeft); SetDlgItemText(hDlg, NP_PAGESETUP_RIGHT, Globals.szMarginRight); break; - - case WM_CLOSE: - break; } + return FALSE; } - -/* Local Variables: */ -/* c-file-style: "GNU" */ -/* End: */ diff --git a/programs/notepad/dialog.h b/programs/notepad/dialog.h index a14d4df9b47..3c1cb6cf771 100644 --- a/programs/notepad/dialog.h +++ b/programs/notepad/dialog.h @@ -37,6 +37,3 @@ VOID DIALOG_HelpAboutWine(VOID); VOID DIALOG_PageSetup(VOID); VOID DIALOG_TimeDate(VOID); -/* Local Variables: */ -/* c-file-style: "GNU" */ -/* End: */ diff --git a/programs/notepad/language.c b/programs/notepad/language.c index 68372d61620..8593986c22b 100644 --- a/programs/notepad/language.c +++ b/programs/notepad/language.c @@ -2,7 +2,7 @@ * Notepad * * Copyright 1997,98 Marcel Baur - * Copyright 1998 Karl Backstr÷m + * Copyright 1998 Karl Backstr”m */ #include @@ -48,10 +48,15 @@ void LANGUAGE_UpdateWindowCaption(void) { static BOOL LANGUAGE_LoadStringOther(UINT num, UINT ids, LPSTR str, UINT len) { + BOOL bOk; + ids -= Globals.wStringTableOffset; ids += num * 0x100; - return(LoadString(Globals.hInstance, ids, str, len)); -}; + + bOk = LoadString(Globals.hInstance, ids, str, len); + + return(bOk); +} @@ -145,15 +150,13 @@ VOID LANGUAGE_Init(VOID) #else CHAR buffer[MAX_PATHNAME_LEN], *p; +#ifndef LCC PROFILE_GetWineIniString("programs", "language", "language", buffer, sizeof(buffer)); +#endif Globals.lpszLanguage = p = LocalLock(LocalAlloc(LMEM_FIXED, lstrlen(buffer)+1)); strcpy(p, buffer); /* hmemcpy(p, buffer, 1 + lstrlen(buffer)); */ #endif } -/* Local Variables: */ -/* c-file-style: "GNU" */ -/* End: */ - diff --git a/programs/notepad/language.h b/programs/notepad/language.h index 35fa6921e81..1e6b3db208d 100644 --- a/programs/notepad/language.h +++ b/programs/notepad/language.h @@ -2,7 +2,7 @@ * Notepad * * Copyright 1997,98 Marcel Baur - * Copyright 1998 Karl Backstr÷m + * Copyright 1998 Karl Backstr”m */ VOID LANGUAGE_UpdateWindowCaption(VOID); @@ -11,6 +11,3 @@ VOID LANGUAGE_SelectByName(LPCSTR lang); VOID LANGUAGE_DefaultHandle(WPARAM wParam); VOID LANGUAGE_Init(VOID); -/* Local Variables: */ -/* c-file-style: "GNU" */ -/* End: */ diff --git a/programs/notepad/lcc.h b/programs/notepad/lcc.h new file mode 100644 index 00000000000..8b14a9f0e93 --- /dev/null +++ b/programs/notepad/lcc.h @@ -0,0 +1,39 @@ +/* + * lcc.h + * + * Copyright 1999 by Marcel Baur + * To be distributed under the Wine license + * + * This file is only required when compiling Notepad using LCC-WIN32 + */ + +#ifdef LCC + + #include "assert.h" + #include "shellapi.h" + + #define HANDLE32 HANDLE + #define INVALID_HANDLE_VALUE32 INVALID_HANDLE_VALUE + + #define WINE_RELEASE_INFO "Compiled using LCC" + #define OIC_WINEICON 0 + + #ifndef LCC_HASASSERT + /* prevent multiple inclusion of assert methods */ + + int _assertfail(char *__msg, char *__cond, char *__file, int __line) { + + CHAR szMessage[255]; + + strcat(szMessage, "Assert failure "); + strcat(szMessage, __msg); + strcat(szMessage, "\n"); + strcat(szMessage, "in line "); + strcat(szMessage, "of file "); + strcat(szMessage, __line); + + MessageBox(0, szMessage, "ERROR: ASSERT FAILURE", MB_ICONEXCLAMATION); + } + #endif + +#endif diff --git a/programs/notepad/lccmake b/programs/notepad/lccmake new file mode 100644 index 00000000000..e3b684c2d36 --- /dev/null +++ b/programs/notepad/lccmake @@ -0,0 +1,89 @@ +# +# Makefile for LCC-WIN32 +# +# Copyright 1999 Marcel Baur (mbaur@g26.ethz.ch) +# To be distributed under the Wine License +# +# Use lccmake -f lccmake to use this makefile +# +# See http://www.cs.virgina.edu/~lcc-win32 for +# information about LCC-WIN32 +# + +# +# LCC home directory +# +LCCHOME=C:\LCC + +# +# individual flags for LCC, LCCLNK, LRC +# +CFLAGS=-O -DLCC -g2 +LNKFLAGS=-O winepad.exe -subsystem windows +LRCFLAGS=/r /v /m + +# +# available languages +# +LANGUAGES=Da De En Es Fi Fr Sw + +# +# default language +# +LANGUAGE=En + +# +# required include libraries +# +LIBS=SHELL32.LIB + +# +# object files +# +OBJS=main.obj dialog.obj license.obj license_En.obj language.obj + +# +# ---[ it is save not to change anything behind this line ]--- # +# + +winepad.exe: $(OBJS) resources + $(LCCHOME)\bin\lcclnk $(LNKFLAGS) $(OBJS) notepad.res $(LIBS) + @echo *** "winepad.exe" successfully created + +resources: $(RESOURCES) + FOR %%i IN ($(LANGUAGES)) DO $(LCCHOME)\bin\lrc $(LRCFLAGS) %%i.rc + copy /b $(LANGUAGE).res notepad.res + +clean: + if exist winepad.exe erase winepad.exe + if exist main.obj erase main.obj + if exist dialog.obj erase dialog.obj + if exist license.obj erase license.obj + if exist license_En.obj erase license_En.obj + if exist language.obj erase language.obj + if exist notepad.res erase notepad.res + FOR %%i IN ($(LANGUAGES)) DO IF EXIST %%i.res erase %%i.res + FOR %%i IN ($(LANGUAGES)) DO IF EXIST %%i.map erase %%i.map + +help: + @echo lccmake help - display this help + @echo lccmake - to compile winepad.exe + @echo lccmake resources - to compile .res files + @echo lccmake clean - to clean up + + +# +# some more targets (for novice users and compatibility reasons only) +# + +distclean: clean + @echo *** next time please use "lccmake clean" + +all: winepad.exe + @echo *** next time please use "lccmake" (without parameters) + + +# +# please make sure that at least one empty line follows this statement +# + diff --git a/programs/notepad/license.c b/programs/notepad/license.c index 4f0ab76ca61..0b2423b0801 100644 --- a/programs/notepad/license.c +++ b/programs/notepad/license.c @@ -38,7 +38,7 @@ VOID WineLicense(HWND Wnd, LPCSTR Language) LICENSE *License = SelectLanguage(Language); MessageBox(Wnd, License->License, License->LicenseCaption, - MB_ICONINFORMATION | MB_OK); + MB_ICONINFORMATION | MB_OK); } @@ -47,6 +47,6 @@ VOID WineWarranty(HWND Wnd, LPCSTR Language) LICENSE *License = SelectLanguage(Language); MessageBox(Wnd, License->Warranty, License->WarrantyCaption, - MB_ICONEXCLAMATION | MB_OK); + MB_ICONEXCLAMATION | MB_OK); } diff --git a/programs/notepad/main.c b/programs/notepad/main.c index 2bbee907cc7..26e14f5d067 100644 --- a/programs/notepad/main.c +++ b/programs/notepad/main.c @@ -7,7 +7,13 @@ #include #include "windows.h" + +#ifdef LCC +#include "lcc.h" +#else #include "shell.h" +#endif + #include "main.h" #include "license.h" #include "dialog.h" @@ -20,8 +26,10 @@ void LIBWINE_Register_Da(); void LIBWINE_Register_De(); void LIBWINE_Register_En(); -void LIBWINE_Register_Sw(); +void LIBWINE_Register_Es(); void LIBWINE_Register_Fi(); +void LIBWINE_Register_Fr(); +void LIBWINE_Register_Sw(); #endif NOTEPAD_GLOBALS Globals; @@ -81,7 +89,10 @@ int NOTEPAD_MenuCommand (WPARAM wParam) LRESULT NOTEPAD_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; + HDC hContext; + HANDLE hDrop; /* drag & drop */ CHAR szFileName[MAX_STRING_LEN]; + RECT Windowsize; lstrcpy(szFileName, ""); @@ -91,7 +102,8 @@ LRESULT NOTEPAD_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) break; case WM_PAINT: - BeginPaint(hWnd, &ps); + hContext = BeginPaint(hWnd, &ps); + TextOut(hContext, 1, 1, Globals.Buffer, strlen(Globals.Buffer)); EndPaint(hWnd, &ps); break; @@ -99,16 +111,31 @@ LRESULT NOTEPAD_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) NOTEPAD_MenuCommand(wParam); break; + case WM_DESTROYCLIPBOARD: + MessageBox(Globals.hMainWnd, "Empty clipboard", "Debug", MB_ICONEXCLAMATION); + break; + + case WM_CLOSE: + if (DoCloseFile()) { + PostQuitMessage(0); + } + break; + case WM_DESTROY: - PostQuitMessage (0); + PostQuitMessage (0); + break; + + case WM_SIZE: + GetClientRect(Globals.hMainWnd, &Windowsize); break; case WM_DROPFILES: - DragQueryFile(wParam, 0, szFileName, sizeof(szFileName)); - printf("file %s to be opened by drag and drop !\n", szFileName); - DragFinish(wParam); - break; - + /* User has dropped a file into main window */ + hDrop = (HANDLE) wParam; + DragQueryFile(hDrop, 0, (CHAR *) &szFileName, sizeof(szFileName)); + DragFinish(hDrop); + DoOpenFile(szFileName); + break; default: return DefWindowProc (hWnd, msg, wParam, lParam); @@ -135,8 +162,10 @@ int PASCAL WinMain (HANDLE hInstance, HANDLE prev, LPSTR cmdline, int show) LIBWINE_Register_Da(); LIBWINE_Register_De(); LIBWINE_Register_En(); - LIBWINE_Register_Sw(); + LIBWINE_Register_Es(); LIBWINE_Register_Fi(); + LIBWINE_Register_Fr(); + LIBWINE_Register_Sw(); #endif /* Select Language */ @@ -145,14 +174,18 @@ int PASCAL WinMain (HANDLE hInstance, HANDLE prev, LPSTR cmdline, int show) /* Setup Globals */ - Globals.lpszIniFile = "notepad.ini"; - Globals.lpszIcoFile = "notepad.ico"; + lstrcpy(Globals.lpszIniFile, "notepad.ini"); + lstrcpy(Globals.lpszIcoFile, "notepad.ico"); Globals.hInstance = hInstance; + +#ifndef LCC Globals.hMainIcon = ExtractIcon(Globals.hInstance, Globals.lpszIcoFile, 0); - if (!Globals.hMainIcon) Globals.hMainIcon = - LoadIcon(0, MAKEINTRESOURCE(DEFAULTICON)); +#endif + if (!Globals.hMainIcon) { + Globals.hMainIcon = LoadIcon(0, MAKEINTRESOURCE(DEFAULTICON)); + } lstrcpy(Globals.szFindText, ""); lstrcpy(Globals.szFileName, ""); @@ -162,6 +195,7 @@ int PASCAL WinMain (HANDLE hInstance, HANDLE prev, LPSTR cmdline, int show) lstrcpy(Globals.szMarginRight, "20 mm"); lstrcpy(Globals.szHeader, "&n"); lstrcpy(Globals.szFooter, "Page &s"); + lstrcpy(Globals.Buffer, "Hello World"); if (!prev){ class.style = CS_HREDRAW | CS_VREDRAW; @@ -176,13 +210,18 @@ int PASCAL WinMain (HANDLE hInstance, HANDLE prev, LPSTR cmdline, int show) class.lpszClassName = className; } - if (!RegisterClass (&class)) - return FALSE; + if (!RegisterClass (&class)) return FALSE; - Globals.hMainWnd = CreateWindow (className, winName, WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0, - LoadMenu(Globals.hInstance, STRING_MENU_Xx), - Globals.hInstance, 0); + /* Setup windows */ + + + Globals.hMainWnd = CreateWindow (className, winName, + WS_OVERLAPPEDWINDOW + WS_HSCROLL + WS_VSCROLL, + CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0, + LoadMenu(Globals.hInstance, STRING_MENU_Xx), + Globals.hInstance, 0); + + Globals.hFindReplaceDlg = 0; LANGUAGE_SelectByName(Globals.lpszLanguage); @@ -191,6 +230,16 @@ int PASCAL WinMain (HANDLE hInstance, HANDLE prev, LPSTR cmdline, int show) ShowWindow (Globals.hMainWnd, show); UpdateWindow (Globals.hMainWnd); + /* Set up dialogs */ + + /* Identify Messages originating from FindReplace */ + + Globals.nCommdlgFindReplaceMsg = RegisterWindowMessage("commdlg_FindReplace"); + if (Globals.nCommdlgFindReplaceMsg==0) { + MessageBox(Globals.hMainWnd, "Could not register commdlg_FindReplace window message", + "Error", MB_ICONEXCLAMATION); + } + /* now handle command line */ while (*cmdline && (*cmdline == ' ' || *cmdline == '-')) @@ -214,17 +263,26 @@ int PASCAL WinMain (HANDLE hInstance, HANDLE prev, LPSTR cmdline, int show) } } + /* Set up Drag&Drop */ + DragAcceptFiles(Globals.hMainWnd, TRUE); + MessageBox(Globals.hMainWnd, "BEWARE!\nThis is ALPHA software that may destroy your file system.\nPlease take care.", + "A note from the developer...", MB_ICONEXCLAMATION); + /* now enter mesage loop */ while (GetMessage (&msg, 0, 0, 0)) { - TranslateMessage (&msg); - DispatchMessage (&msg); + if (IsDialogMessage(Globals.hFindReplaceDlg, &msg)!=0) { + /* Message belongs to FindReplace dialog */ + /* We just let IsDialogMessage handle it */ + } + else + { + /* Message belongs to the Notepad Main Window */ + TranslateMessage (&msg); + DispatchMessage (&msg); + } } return 0; } - -/* Local Variables: */ -/* c-file-style: "GNU" */ -/* End: */ diff --git a/programs/notepad/main.h b/programs/notepad/main.h index 2a0dded8616..47c441779ee 100644 --- a/programs/notepad/main.h +++ b/programs/notepad/main.h @@ -9,16 +9,20 @@ #define MAX_PATHNAME_LEN 1024 #define MAX_LANGUAGE_NUMBER (NP_LAST_LANGUAGE - NP_FIRST_LANGUAGE) -#define HELPFILE "notepad.hlp" +#define HELPFILE "notepad.hlp" +#define LOGPREFIX ".LOG" #define DEFAULTICON OIC_WINEICON /* hide the following from winerc */ #ifndef RC_INVOKED +#include "commdlg.h" + typedef struct { HANDLE hInstance; HWND hMainWnd; + HWND hFindReplaceDlg; HICON hMainIcon; HICON hDefaultIcon; HMENU hMainMenu; @@ -33,6 +37,7 @@ typedef struct UINT wStringTableOffset; BOOL bWrapLongLines; CHAR szFindText[MAX_PATHNAME_LEN]; + CHAR szReplaceText[MAX_PATHNAME_LEN]; CHAR szFileName[MAX_PATHNAME_LEN]; CHAR szMarginTop[MAX_PATHNAME_LEN]; CHAR szMarginBottom[MAX_PATHNAME_LEN]; @@ -40,6 +45,10 @@ typedef struct CHAR szMarginRight[MAX_PATHNAME_LEN]; CHAR szHeader[MAX_PATHNAME_LEN]; CHAR szFooter[MAX_PATHNAME_LEN]; + + FINDREPLACE find; + WORD nCommdlgFindReplaceMsg; + CHAR Buffer[12000]; } NOTEPAD_GLOBALS; extern NOTEPAD_GLOBALS Globals; @@ -71,9 +80,10 @@ extern CHAR STRING_PAGESETUP_Xx[]; #define IDS_INFO STRINGID(07) #define IDS_TOOLARGE STRINGID(08) #define IDS_NOTEXT STRINGID(09) -#define IDS_NOTFOUND STRINGID(0A) -#define IDS_OUT_OF_MEMORY STRINGID(0B) -#define IDS_UNTITLED STRINGID(0C) +#define IDS_NOTSAVED STRINGID(0A) +#define IDS_NOTFOUND STRINGID(0B) +#define IDS_OUT_OF_MEMORY STRINGID(0C) +#define IDS_UNTITLED STRINGID(0D) #define IDS_PAGESETUP_HEADERVALUE STRINGID(0D) #define IDS_PAGESETUP_FOOTERVALUE STRINGID(0E) diff --git a/programs/notepad/notepad.rc b/programs/notepad/notepad.rc index 38ff1fec8e8..9d19d248c33 100644 --- a/programs/notepad/notepad.rc +++ b/programs/notepad/notepad.rc @@ -29,10 +29,10 @@ CONCAT(MENU_, LANGUAGE_ID) MENU POPUP MENU_EDIT { MENUITEM MENU_EDIT_UNDO, NP_EDIT_UNDO MENUITEM SEPARATOR - MENUITEM MENU_EDIT_CUT, NP_EDIT_CUT, GRAYED - MENUITEM MENU_EDIT_COPY, NP_EDIT_COPY, GRAYED - MENUITEM MENU_EDIT_PASTE, NP_EDIT_PASTE, GRAYED - MENUITEM MENU_EDIT_DELETE, NP_EDIT_DELETE, GRAYED + MENUITEM MENU_EDIT_CUT, NP_EDIT_CUT + MENUITEM MENU_EDIT_COPY, NP_EDIT_COPY + MENUITEM MENU_EDIT_PASTE, NP_EDIT_PASTE + MENUITEM MENU_EDIT_DELETE, NP_EDIT_DELETE MENUITEM SEPARATOR MENUITEM MENU_EDIT_SELECTALL, NP_EDIT_SELECTALL MENUITEM MENU_EDIT_TIMEDATE, NP_EDIT_TIMEDATE @@ -74,15 +74,16 @@ EDITTEXT NP_PAGESETUP_HEAD, 60, 05,110, 12, WS_BOR LTEXT DIALOG_PAGESETUP_TAIL, NP_PAGESETUP_TAIL_TXT, 10, 24, 40, 15 EDITTEXT NP_PAGESETUP_TAIL, 60, 22,110, 12, WS_BORDER | WS_TABSTOP -GROUPBOX DIALOG_PAGESETUP_MARGIN,NP_PAGESETUP_MARGIN, 10, 43,160, 45 -LTEXT DIALOG_PAGESETUP_LEFT, NP_PAGESETUP_LEFT_TXT, 20, 55, 30, 10, WS_CHILD -EDITTEXT NP_PAGESETUP_LEFT, 50, 55, 35, 11, WS_CHILD | WS_BORDER | WS_TABSTOP -LTEXT DIALOG_PAGESETUP_TOP, NP_PAGESETUP_TOP_TXT, 20, 73, 30, 10, WS_CHILD -EDITTEXT NP_PAGESETUP_TOP, 50, 73, 35, 11, WS_CHILD | WS_BORDER | WS_TABSTOP -LTEXT DIALOG_PAGESETUP_RIGHT, NP_PAGESETUP_RIGHT_TXT, 100, 55, 30, 10, WS_CHILD -EDITTEXT NP_PAGESETUP_RIGHT, 130, 55, 35, 11, WS_CHILD | WS_BORDER | WS_TABSTOP -LTEXT DIALOG_PAGESETUP_BOTTOM,NP_PAGESETUP_BOTTOM_TXT,100, 73, 30, 10, WS_CHILD -EDITTEXT NP_PAGESETUP_BOTTOM, 130, 73, 35, 11, WS_CHILD | WS_BORDER | WS_TABSTOP +GROUPBOX DIALOG_PAGESETUP_MARGIN, NP_PAGESETUP_MARGIN, 10, 43,160, 45 +LTEXT DIALOG_PAGESETUP_LEFT, NP_PAGESETUP_LEFT_TXT, 20, 55, 30, 10, WS_CHILD +EDITTEXT STRING_PAGESETUP_LEFTVALUE, NP_PAGESETUP_LEFT, 50, 55, 35, 11, WS_CHILD | WS_BORDER | WS_TABSTOP +LTEXT DIALOG_PAGESETUP_TOP, NP_PAGESETUP_TOP_TXT, 20, 73, 30, 10, WS_CHILD +EDITTEXT STRING_PAGESETUP_TOPVALUE, NP_PAGESETUP_TOP, 50, 73, 35, 11, WS_CHILD | WS_BORDER | WS_TABSTOP +LTEXT DIALOG_PAGESETUP_RIGHT, NP_PAGESETUP_RIGHT_TXT, 100, 55, 30, 10, WS_CHILD +EDITTEXT STRING_PAGESETUP_RIGHTVALUE, NP_PAGESETUP_RIGHT, 130, 55, 35, 11, WS_CHILD | WS_BORDER | WS_TABSTOP +LTEXT DIALOG_PAGESETUP_BOTTOM, NP_PAGESETUP_BOTTOM_TXT,100, 73, 30, 10, WS_CHILD +EDITTEXT STRING_PAGESETUP_BOTTOMVALUE, NP_PAGESETUP_BOTTOM, 130, 73, 35, 11, WS_CHILD | WS_BORDER | WS_TABSTOP + DEFPUSHBUTTON DIALOG_OK, IDOK, 180, 3, 40, 15, WS_TABSTOP PUSHBUTTON DIALOG_CANCEL, IDCANCEL, 180, 21, 40, 15, WS_TABSTOP @@ -114,6 +115,7 @@ ADDSTRING(WARNING) ADDSTRING(INFO) ADDSTRING(TOOLARGE) ADDSTRING(NOTEXT) +ADDSTRING(NOTSAVED) ADDSTRING(NOTFOUND) ADDSTRING(OUT_OF_MEMORY) ADDSTRING(UNTITLED)