From 7c17b26c4e0836f96ed79a174c70b41aa8f918ee Mon Sep 17 00:00:00 2001 From: Robert Dickenson Date: Tue, 19 Nov 2002 12:56:47 +0000 Subject: [PATCH] Created skeleton for notepad application. svn path=/trunk/; revision=3769 --- rosapps/notepad/.cvsignore | 13 + rosapps/notepad/framewnd.c | 503 ++++++++++++++++++++++++++++++++ rosapps/notepad/framewnd.h | 41 +++ rosapps/notepad/main.c | 158 ++++++++++ rosapps/notepad/main.h | 57 ++++ rosapps/notepad/makefile | 56 ++++ rosapps/notepad/notepad.rc | 259 ++++++++++++++++ rosapps/notepad/res/notepad.ico | Bin 0 -> 1078 bytes rosapps/notepad/res/small.ico | Bin 0 -> 318 bytes rosapps/notepad/resource.h | 59 ++++ 10 files changed, 1146 insertions(+) create mode 100644 rosapps/notepad/.cvsignore create mode 100644 rosapps/notepad/framewnd.c create mode 100644 rosapps/notepad/framewnd.h create mode 100644 rosapps/notepad/main.c create mode 100644 rosapps/notepad/main.h create mode 100644 rosapps/notepad/makefile create mode 100644 rosapps/notepad/notepad.rc create mode 100644 rosapps/notepad/res/notepad.ico create mode 100644 rosapps/notepad/res/small.ico create mode 100644 rosapps/notepad/resource.h diff --git a/rosapps/notepad/.cvsignore b/rosapps/notepad/.cvsignore new file mode 100644 index 00000000000..f9ce057f31b --- /dev/null +++ b/rosapps/notepad/.cvsignore @@ -0,0 +1,13 @@ +*.exe +*.a +*.o +*.d +*.coff +*.dsp +*.dsw +*.aps +*.ncb +*.opt +*.sym +*.plg +*.bak diff --git a/rosapps/notepad/framewnd.c b/rosapps/notepad/framewnd.c new file mode 100644 index 00000000000..4268c7e6f50 --- /dev/null +++ b/rosapps/notepad/framewnd.c @@ -0,0 +1,503 @@ +/* + * ReactOS notepad + * + * framewnd.c + * + * Copyright (C) 2002 Robert Dickenson + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include +//#include + +#include "main.h" +#include "framewnd.h" + + +//////////////////////////////////////////////////////////////////////////////// +// Global and Local Variables: +// + +static BOOL bInMenuLoop = FALSE; // Tells us if we are in the menu loop + +static HWND hChildWnd; + +//////////////////////////////////////////////////////////////////////////////// +// Local module support methods +// + +static void resize_frame_rect(HWND hWnd, PRECT prect) +{ + RECT rt; +/* + if (IsWindowVisible(hToolBar)) { + SendMessage(hToolBar, WM_SIZE, 0, 0); + GetClientRect(hToolBar, &rt); + prect->top = rt.bottom+3; + prect->bottom -= rt.bottom+3; + } + */ + if (IsWindowVisible(hStatusBar)) { + SetupStatusBar(hWnd, TRUE); + GetClientRect(hStatusBar, &rt); + prect->bottom -= rt.bottom; + } + MoveWindow(hChildWnd, prect->left, prect->top, prect->right, prect->bottom, TRUE); +} + +void resize_frame_client(HWND hWnd) +{ + RECT rect; + + GetClientRect(hWnd, &rect); + resize_frame_rect(hWnd, &rect); +} + +//////////////////////////////////////////////////////////////////////////////// + +static void OnEnterMenuLoop(HWND hWnd) +{ + int nParts; + + // Update the status bar pane sizes + nParts = -1; + SendMessage(hStatusBar, SB_SETPARTS, 1, (long)&nParts); + bInMenuLoop = TRUE; + SendMessage(hStatusBar, SB_SETTEXT, (WPARAM)0, (LPARAM)_T("")); +} + +static void OnExitMenuLoop(HWND hWnd) +{ + bInMenuLoop = FALSE; + // Update the status bar pane sizes + SetupStatusBar(hWnd, TRUE); + UpdateStatusBar(); +} + +static void OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu) +{ + TCHAR str[100]; + + _tcscpy(str, _T("")); + if (nFlags & MF_POPUP) { + if (hSysMenu != GetMenu(hWnd)) { + if (nItemID == 2) nItemID = 5; + } + } + if (LoadString(hInst, nItemID, str, 100)) { + // load appropriate string + LPTSTR lpsz = str; + // first newline terminates actual string + lpsz = _tcschr(lpsz, '\n'); + if (lpsz != NULL) + *lpsz = '\0'; + } + SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)str); +} + +void SetupStatusBar(HWND hWnd, BOOL bResize) +{ + RECT rc; + int nParts; + GetClientRect(hWnd, &rc); + nParts = rc.right; +// nParts = -1; + if (bResize) + SendMessage(hStatusBar, WM_SIZE, 0, 0); + SendMessage(hStatusBar, SB_SETPARTS, 1, (LPARAM)&nParts); +} + +void UpdateStatusBar(void) +{ + TCHAR text[260]; + DWORD size; + + size = sizeof(text)/sizeof(TCHAR); + GetComputerName(text, &size); + SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)text); +} + +static void toggle_child(HWND hWnd, UINT cmd, HWND hchild) +{ + BOOL vis = IsWindowVisible(hchild); + HMENU hMenuView = GetSubMenu(hMenuFrame, ID_VIEW_MENU); + + CheckMenuItem(hMenuView, cmd, vis?MF_BYCOMMAND:MF_BYCOMMAND|MF_CHECKED); + ShowWindow(hchild, vis?SW_HIDE:SW_SHOW); + resize_frame_client(hWnd); +} + +static BOOL CheckCommDlgError(HWND hWnd) +{ + DWORD dwErrorCode = CommDlgExtendedError(); + switch (dwErrorCode) { + case CDERR_DIALOGFAILURE: + break; + case CDERR_FINDRESFAILURE: + break; + case CDERR_NOHINSTANCE: + break; + case CDERR_INITIALIZATION: + break; + case CDERR_NOHOOK: + break; + case CDERR_LOCKRESFAILURE: + break; + case CDERR_NOTEMPLATE: + break; + case CDERR_LOADRESFAILURE: + break; + case CDERR_STRUCTSIZE: + break; + case CDERR_LOADSTRFAILURE: + break; + case FNERR_BUFFERTOOSMALL: + break; + case CDERR_MEMALLOCFAILURE: + break; + case FNERR_INVALIDFILENAME: + break; + case CDERR_MEMLOCKFAILURE: + break; + case FNERR_SUBCLASSFAILURE: + break; + default: + break; + } + return TRUE; +} + +UINT_PTR CALLBACK File_OFNHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) +{ + OPENFILENAME* pOpenFileName; + OFNOTIFY* pOfNotify; + + switch (uiMsg) { + case WM_INITDIALOG: + pOpenFileName = (OPENFILENAME*)lParam; + break; + case WM_NOTIFY: + pOfNotify = (OFNOTIFY*)lParam; + if (pOfNotify->hdr.code == CDN_INITDONE) { + } + break; + default: + break; + } + return 0L; +} + +#define MAX_CUSTOM_FILTER_SIZE 50 +TCHAR CustomFilterBuffer[MAX_CUSTOM_FILTER_SIZE]; +TCHAR FileNameBuffer[_MAX_PATH]; +TCHAR FileTitleBuffer[_MAX_PATH]; + +static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME* pofn) +{ + memset(pofn, 0, sizeof(OPENFILENAME)); + pofn->lStructSize = sizeof(OPENFILENAME); + pofn->hwndOwner = hWnd; + pofn->hInstance = hInst; + + pofn->lpstrFilter = _T("Registration Files\0*.reg\0Win9x/NT4 Registration Files (notepad4)\0*.reg\0All Files (*.*)\0*.*\0\0"); + pofn->lpstrCustomFilter = CustomFilterBuffer; + pofn->nMaxCustFilter = MAX_CUSTOM_FILTER_SIZE; + pofn->nFilterIndex = 0; + pofn->lpstrFile = FileNameBuffer; + pofn->nMaxFile = _MAX_PATH; + pofn->lpstrFileTitle = FileTitleBuffer; + pofn->nMaxFileTitle = _MAX_PATH; +// pofn->lpstrInitialDir = _T(""); +// pofn->lpstrTitle = _T("Import Registry File"); +// pofn->Flags = OFN_ENABLETEMPLATE + OFN_EXPLORER + OFN_ENABLESIZING; + pofn->Flags = OFN_HIDEREADONLY; +// pofn->nFileOffset = ; +// pofn->nFileExtension = ; +// pofn->lpstrDefExt = _T(""); +// pofn->lCustData = ; +// pofn->lpfnHook = ImportRegistryFile_OFNHookProc; +// pofn->lpTemplateName = _T("ID_DLG_IMPORT_REGFILE"); +// pofn->lpTemplateName = MAKEINTRESOURCE(IDD_DIALOG1); +// pofn->FlagsEx = ; + return TRUE; +} + +BOOL open_file(TCHAR* file_name) +{ + return TRUE; +} + +BOOL save_file(TCHAR* file_name, TCHAR* unused) +{ + return TRUE; +} + +static BOOL OpenFileName(HWND hWnd) +{ + OPENFILENAME ofn; + + InitOpenFileName(hWnd, &ofn); + ofn.lpstrTitle = _T("Import Registry File"); +// ofn.lCustData = ; + if (GetOpenFileName(&ofn)) { + if (!open_file(ofn.lpstrFile)) { + //printf("Can't open file \"%s\"\n", ofn.lpstrFile); + return FALSE; + } + } else { + CheckCommDlgError(hWnd); + } + return TRUE; +} + +static BOOL SaveFileName(HWND hWnd) +{ + OPENFILENAME ofn; + TCHAR ExportKeyPath[_MAX_PATH]; + + ExportKeyPath[0] = _T('\0'); + InitOpenFileName(hWnd, &ofn); + ofn.lpstrTitle = _T("Export Registry File"); +// ofn.lCustData = ; + ofn.Flags = OFN_ENABLETEMPLATE + OFN_EXPLORER; + ofn.lpfnHook = File_OFNHookProc; + ofn.lpTemplateName = MAKEINTRESOURCE(IDD_DIALOG1); + if (GetSaveFileName(&ofn)) { + BOOL result; + result = save_file(ofn.lpstrFile, ExportKeyPath); + //result = export_registry_key(ofn.lpstrFile, NULL); + //if (!export_registry_key(ofn.lpstrFile, NULL)) { + if (!result) { + //printf("Can't open file \"%s\"\n", ofn.lpstrFile); + return FALSE; + } + } else { + CheckCommDlgError(hWnd); + } + return TRUE; +} + +BOOL PrintFile(HWND hWnd, LPTSTR path) +{ +#if 1 + PRINTDLG pd; + + ZeroMemory(&pd, sizeof(PRINTDLG)); + pd.lStructSize = sizeof(PRINTDLG); + pd.hwndOwner = hWnd; + pd.hDevMode = NULL; // Don't forget to free or store hDevMode + pd.hDevNames = NULL; // Don't forget to free or store hDevNames + pd.Flags = PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC; + pd.nCopies = 1; + pd.nFromPage = 0xFFFF; + pd.nToPage = 0xFFFF; + pd.nMinPage = 1; + pd.nMaxPage = 0xFFFF; + if (PrintDlg(&pd) == TRUE) { + // GDI calls to render output. + DeleteDC(pd.hDC); // Delete DC when done. + } +#else + HRESULT hResult; + PRINTDLGEX pd; + + hResult = PrintDlgEx(&pd); + if (hResult == S_OK) { + switch (pd.dwResultAction) { + case PD_RESULT_APPLY: + //The user clicked the Apply button and later clicked the Cancel button. This indicates that the user wants to apply the changes made in the property sheet, but does not yet want to print. The PRINTDLGEX structure contains the information specified by the user at the time the Apply button was clicked. + break; + case PD_RESULT_CANCEL: + //The user clicked the Cancel button. The information in the PRINTDLGEX structure is unchanged. + break; + case PD_RESULT_PRINT: + //The user clicked the Print button. The PRINTDLGEX structure contains the information specified by the user. + break; + default: + break; + } + } else { + switch (hResult) { + case E_OUTOFMEMORY: + //Insufficient memory. + break; + case E_INVALIDARG: + // One or more arguments are invalid. + break; + case E_POINTER: + //Invalid pointer. + break; + case E_HANDLE: + //Invalid handle. + break; + case E_FAIL: + //Unspecified error. + break; + default: + break; + } + return FALSE; + } +#endif + return TRUE; +} + +BOOL CopyToClipboard(HWND hWnd, LPTSTR keyName) +{ + BOOL result; + + result = OpenClipboard(hWnd); + if (result) { + result = EmptyClipboard(); + if (result) { + + //HANDLE hClipData; + //hClipData = SetClipboardData(UINT uFormat, HANDLE hMem); + + } else { + // error emptying clipboard + DWORD dwError = GetLastError(); + } + if (!CloseClipboard()) { + // error closing clipboard + DWORD dwError = GetLastError(); + } + } else { + // error opening clipboard + DWORD dwError = GetLastError(); + } + return result; +} + +BOOL RefreshView(HWND hWnd) +{ + // TODO: + MessageBeep(-1); + MessageBeep(MB_ICONASTERISK); + MessageBeep(MB_ICONEXCLAMATION); + MessageBeep(MB_ICONHAND); + MessageBeep(MB_ICONQUESTION); + MessageBeep(MB_OK); + return TRUE; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION: _CmdWndProc(HWND, unsigned, WORD, LONG) +// +// PURPOSE: Processes WM_COMMAND messages for the main frame window. +// +// +static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (LOWORD(wParam)) { + // Parse the menu selections: + case ID_FILE_OPEN: + OpenFileName(hWnd); + break; + case ID_FILE_SAVE: + case ID_FILE_SAVEAS: + SaveFileName(hWnd); + break; + case ID_FILE_PAGESETUP: + case ID_FILE_PRINT: + PrintFile(hWnd, _T("")); + break; + //case ID_FILE_PRINTERSETUP: + //PRINTDLG pd; + //PrintDlg(&pd); + //PAGESETUPDLG psd; + //PageSetupDlg(&psd); + // break; + case ID_FILE_EXIT: + DestroyWindow(hWnd); + break; + case ID_EDIT_COPY: + CopyToClipboard(hWnd, _T("")); + break; + case ID_VIEW_REFRESH: + RefreshView(hWnd); + break; +// case ID_VIEW_TOOLBAR: +// toggle_child(hWnd, LOWORD(wParam), hToolBar); +// break; +// case ID_VIEW_STATUSBAR: +// toggle_child(hWnd, LOWORD(wParam), hStatusBar); +// break; + case ID_HELP_HELPTOPICS: +// WinHelp(hWnd, _T("notepad"), HELP_CONTENTS, 0); + WinHelp(hWnd, _T("notepad"), HELP_FINDER, 0); + break; + case ID_HELP_ABOUT: +#ifdef WINSHELLAPI +// ShellAbout(hWnd, szTitle, _T(""), LoadIcon(hInst, (LPCTSTR)IDI_notepad)); +#else +// ShowAboutBox(hWnd); +#endif + break; + default: + return FALSE; + } + return TRUE; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION: FrameWndProc(HWND, unsigned, WORD, LONG) +// +// PURPOSE: Processes messages for the main frame window. +// + +LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) { + case WM_CREATE: + hChildWnd = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, _T("notepad edit"), + WS_VISIBLE | WS_CHILD, + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, + hWnd, (HMENU)0, hInst, NULL); + break; + case WM_COMMAND: + if (!_CmdWndProc(hWnd, message, wParam, lParam)) { + return DefWindowProc(hWnd, message, wParam, lParam); + } + break; + case WM_SIZE: + resize_frame_client(hWnd); + break; + case WM_TIMER: + break; + case WM_ENTERMENULOOP: + OnEnterMenuLoop(hWnd); + break; + case WM_EXITMENULOOP: + OnExitMenuLoop(hWnd); + break; + case WM_MENUSELECT: + OnMenuSelect(hWnd, LOWORD(wParam), HIWORD(wParam), (HMENU)lParam); + break; + case WM_DESTROY: + WinHelp(hWnd, _T("notepad"), HELP_QUIT, 0); + PostQuitMessage(0); + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + return 0; +} diff --git a/rosapps/notepad/framewnd.h b/rosapps/notepad/framewnd.h new file mode 100644 index 00000000000..6e6d8bc25a6 --- /dev/null +++ b/rosapps/notepad/framewnd.h @@ -0,0 +1,41 @@ +/* + * ReactOS notepad + * + * framewnd.h + * + * Copyright (C) 2002 Robert Dickenson + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __FRAMEWND_H__ +#define __FRAMEWND_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +LRESULT CALLBACK FrameWndProc(HWND, UINT, WPARAM, LPARAM); + +void SetupStatusBar(HWND hWnd, BOOL bResize); +void UpdateStatusBar(void); + + +#ifdef __cplusplus +}; +#endif + +#endif // __FRAMEWND_H__ diff --git a/rosapps/notepad/main.c b/rosapps/notepad/main.c new file mode 100644 index 00000000000..48b754a3ec8 --- /dev/null +++ b/rosapps/notepad/main.c @@ -0,0 +1,158 @@ +/* + * ReactOS notepad + * + * main.c + * + * Copyright (C) 2002 Robert Dickenson + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include +#include +#include +#include + +#include "main.h" +#include "framewnd.h" + + +//////////////////////////////////////////////////////////////////////////////// +// Global Variables: +// + +HINSTANCE hInst; +HWND hFrameWnd; +HWND hStatusBar; +HMENU hMenuFrame; +UINT nClipboardFormat; +LPCTSTR strClipboardFormat = _T("TODO: SET CORRECT FORMAT"); + + +TCHAR szTitle[MAX_LOADSTRING]; +TCHAR szFrameClass[MAX_LOADSTRING]; +TCHAR szChildClass[MAX_LOADSTRING]; + + +BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) +{ + WNDCLASSEX wcFrame = { + sizeof(WNDCLASSEX), + CS_HREDRAW | CS_VREDRAW/*style*/, + FrameWndProc, + 0/*cbClsExtra*/, + 0/*cbWndExtra*/, + hInstance, + LoadIcon(hInstance, MAKEINTRESOURCE(IDI_NOTEPAD)), + LoadCursor(0, IDC_ARROW), + 0/*hbrBackground*/, + 0/*lpszMenuName*/, + szFrameClass, + (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_NOTEPAD), IMAGE_ICON, + GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED) + }; + ATOM hFrameWndClass = RegisterClassEx(&wcFrame); // register frame window class +#if 0 + WNDCLASSEX wcChild = { + sizeof(WNDCLASSEX), + CS_HREDRAW | CS_VREDRAW/*style*/, + ChildWndProc, + 0/*cbClsExtra*/, + sizeof(HANDLE)/*cbWndExtra*/, + hInstance, + LoadIcon(hInstance, MAKEINTRESOURCE(IDI_NOTEPAD)), + LoadCursor(0, IDC_ARROW), + 0/*hbrBackground*/, + 0/*lpszMenuName*/, + szChildClass, + (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_NOTEPAD), IMAGE_ICON, + GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED) + + }; + ATOM hChildWndClass = RegisterClassEx(&wcChild); // register child windows class + hChildWndClass = hChildWndClass; // warning eater +#endif + hMenuFrame = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_NOTEPAD_MENU)); + + // Initialize the Windows Common Controls DLL + InitCommonControls(); + + nClipboardFormat = RegisterClipboardFormat(strClipboardFormat); + if (nClipboardFormat == 0) { + DWORD dwError = GetLastError(); + } + + hFrameWnd = CreateWindowEx(0, (LPCTSTR)(int)hFrameWndClass, szTitle, + WS_OVERLAPPEDWINDOW | WS_EX_CLIENTEDGE, + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, + NULL, hMenuFrame, hInstance, NULL/*lpParam*/); + + if (!hFrameWnd) { + return FALSE; + } + + // Create the status bar + hStatusBar = CreateStatusWindow(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS, + _T(""), hFrameWnd, STATUS_WINDOW); + if (hStatusBar) { + // Create the status bar panes + SetupStatusBar(hFrameWnd, FALSE); + CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_STATUSBAR, MF_BYCOMMAND|MF_CHECKED); + } + ShowWindow(hFrameWnd, nCmdShow); + UpdateWindow(hFrameWnd); + return TRUE; +} + +//////////////////////////////////////////////////////////////////////////////// + +void ExitInstance(void) +{ + DestroyMenu(hMenuFrame); +} + +int APIENTRY WinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpCmdLine, + int nCmdShow) +{ + MSG msg; + HACCEL hAccel; + + // Initialize global strings + LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); + LoadString(hInstance, IDC_NOTEPAD_FRAME, szFrameClass, MAX_LOADSTRING); + LoadString(hInstance, IDC_NOTEPAD, szChildClass, MAX_LOADSTRING); + + // Store instance handle in our global variable + hInst = hInstance; + + // Perform application initialization: + if (!InitInstance(hInstance, nCmdShow)) { + return FALSE; + } + hAccel = LoadAccelerators(hInstance, (LPCTSTR)IDC_NOTEPAD); + + // Main message loop: + while (GetMessage(&msg, (HWND)NULL, 0, 0)) { + if (!TranslateAccelerator(msg.hwnd, hAccel, &msg)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + ExitInstance(); + return msg.wParam; +} diff --git a/rosapps/notepad/main.h b/rosapps/notepad/main.h new file mode 100644 index 00000000000..41cd8addc12 --- /dev/null +++ b/rosapps/notepad/main.h @@ -0,0 +1,57 @@ +/* + * ReactOS notepad + * + * main.h + * + * Copyright (C) 2002 Robert Dickenson + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __MAIN_H__ +#define __MAIN_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +#include "resource.h" + + +#define STATUS_WINDOW 2001 +#define MAX_LOADSTRING 100 + + +//////////////////////////////////////////////////////////////////////////////// +// Global Variables: +// + +extern HINSTANCE hInst; +extern HWND hFrameWnd; +extern HMENU hMenuFrame; +extern HWND hStatusBar; +extern HFONT hFont; + +extern TCHAR szTitle[]; +extern TCHAR szFrameClass[]; +extern TCHAR szChildClass[]; + + +#ifdef __cplusplus +}; +#endif + +#endif // __MAIN_H__ diff --git a/rosapps/notepad/makefile b/rosapps/notepad/makefile new file mode 100644 index 00000000000..1ccd626d822 --- /dev/null +++ b/rosapps/notepad/makefile @@ -0,0 +1,56 @@ +# +# ReactOS notepad +# +# Makefile +# +# Copyright (C) 2002 Robert Dickenson +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# + +PATH_TO_TOP = .. + +TARGET = notepad + +BASE_CFLAGS = -D_WIN32_IE=0x0400 + +RCFLAGS = -D_WIN32_IE=0x0400 + +OBJS = framewnd.o \ + main.o + +LIBS = -lgdi32 -luser32 -lkernel32 -lcomctl32 -lcomdlg32 + +all: $(TARGET).exe + +$(TARGET).res: $(TARGET).rc + +$(TARGET).exe: $(OBJS) $(TARGET).coff + $(CC) -Wl,--subsystem,windows -o $(TARGET).exe $(OBJS) $(TARGET).coff $(LIBS) + $(NM) --numeric-sort $(TARGET).exe > $(TARGET).sym + + +main.o: main.c main.h framewnd.h resource.h + +framewnd.o: framewnd.c framewnd.h main.h resource.h + + +clean: + - $(RM) $(OBJS) + - $(RM) $(TARGET).exe + - $(RM) $(TARGET).sym + - $(RM) $(TARGET).coff + +include $(PATH_TO_TOP)/rules.mak diff --git a/rosapps/notepad/notepad.rc b/rosapps/notepad/notepad.rc new file mode 100644 index 00000000000..893ba4e7637 --- /dev/null +++ b/rosapps/notepad/notepad.rc @@ -0,0 +1,259 @@ +#include +#include +#include "resource.h" + + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_NOTEPAD ICON DISCARDABLE "res/notepad.ico" +IDI_SMALL ICON DISCARDABLE "res/small.ico" + + +///////////////////////////////////////////////////////////////////////////// +// +// Bitmap +// + + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDC_NOTEPAD MENU DISCARDABLE +BEGIN + POPUP "&File" + BEGIN + MENUITEM "E&xit", ID_FILE_EXIT + END + POPUP "&Help" + BEGIN + MENUITEM "&About ...", ID_HELP_ABOUT + END +END + +IDR_NOTEPAD_MENU MENU DISCARDABLE +BEGIN + POPUP "&File" + 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 "Page Set&up", ID_FILE_PAGESETUP, GRAYED + MENUITEM "&Print\tCtrl+P", ID_FILE_PRINT, GRAYED + MENUITEM SEPARATOR + MENUITEM "E&xit", ID_FILE_EXIT + END + POPUP "&Edit" + BEGIN + MENUITEM "&Undo", ID_EDIT_UNDO, GRAYED + MENUITEM SEPARATOR + MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT + MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY + MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE + MENUITEM "De&lete\tDel", ID_EDIT_DELETE + MENUITEM SEPARATOR + MENUITEM "&Find...\tCtrl+F", ID_EDIT_FIND, GRAYED + MENUITEM "Find Ne&xt\tF3", ID_EDIT_FINDNEXT, GRAYED + MENUITEM "&Replace...\tCtrl+H", ID_EDIT_REPLACE, GRAYED + MENUITEM "&Go To...\tCtrl+G", ID_EDIT_GOTO, GRAYED + MENUITEM SEPARATOR + MENUITEM "Select &All..\tCtrl+A", ID_EDIT_SELECTALL + MENUITEM "Time/&Date...\tF5", ID_EDIT_TIMEDATE + END + POPUP "&View" + BEGIN + MENUITEM "&Status Bar", ID_VIEW_STATUSBAR, GRAYED + MENUITEM "&Tool Bar", ID_VIEW_TOOLBAR, GRAYED + MENUITEM SEPARATOR + MENUITEM "&Refresh\tF5", ID_VIEW_REFRESH, GRAYED + END + POPUP "F&ormat" + BEGIN + MENUITEM "&Word Wrap", ID_FORMAT_WORDWRAP, GRAYED + MENUITEM "&Font...", ID_FORMAT_FONT + END + POPUP "&Help" + BEGIN + MENUITEM "&Help Topics", ID_HELP_HELPTOPICS + MENUITEM SEPARATOR + MENUITEM "&About Notepad", ID_HELP_ABOUT + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ABOUTBOX DIALOG DISCARDABLE 22, 17, 230, 75 +STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU +CAPTION "About" +FONT 8, "System" +BEGIN + ICON IDI_NOTEPAD,IDI_NOTEPAD,14,9,16,16 + LTEXT "ReactOS Notepad Version 1.0",IDC_STATIC,49,10,119,8, + SS_NOPREFIX + LTEXT "Copyright (C) 2002 ReactOS Team",IDC_STATIC,49,20,119,8 + DEFPUSHBUTTON "OK",IDOK,195,6,30,11,WS_GROUP +END + +IDD_DIALOG1 DIALOG DISCARDABLE 50, 50, 268, 98 +STYLE DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | + WS_BORDER +FONT 8, "MS Sans Serif" +BEGIN +END + +IDD_DIALOG2 DIALOG DISCARDABLE 0, 0, 187, 95 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Dialog" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "OK",IDOK,130,7,50,14 + PUSHBUTTON "Cancel",IDCANCEL,130,24,50,14 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +(1) VERSIONINFO + FILEVERSION 0,0,21,3 + PRODUCTVERSION 0,0,21,0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "Absolutely no warranties whatsoever - Use at your own risk\0" + VALUE "CompanyName", "ReactOS Development Team\0" + VALUE "FileDescription", "ReactOS Notepad by Robert Dickenson\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "notepad\0" + VALUE "LegalCopyright", "Copyright © 2002 Robert Dickenson\0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename", "notepad.exe\0" + VALUE "PrivateBuild", "\0" + VALUE "ProductName", "ReactOS Operating System\0" + VALUE "ProductVersion", "0.0.21\0" + VALUE "SpecialBuild", "Non-versioned Development Beta Release\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0xc09, 1200 + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE DISCARDABLE +BEGIN + IDS_APP_TITLE "ReactOS Notepad" + IDC_NOTEPAD "NOTEPAD" + IDC_NOTEPAD_FRAME "NOTEPAD_FRAME" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_FILE_MENU "Contains commands for loading and saving files" + ID_EDIT_MENU "Contains commands for editing the current text" + ID_VIEW_MENU "Contains commands for manipulating notepad's options" + ID_FORMAT_MENU "Contains commands for customising the look of the text" + ID_HELP_MENU "Contains commands for displaying help and information about notepad" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_FILE_NEW "Creates and empty un-named text buffer" + ID_FILE_OPEN "Opens a text file into notepads buffer" + ID_FILE_SAVE "Saves the current text buffer to file" + ID_FILE_SAVEAS "Saves the current text buffer to a new file" + ID_FILE_PAGESETUP "Modify the setup options for printing the text" + ID_FILE_PRINT "Prints all or part of the current text buffer" + ID_HELP_HELPTOPICS "Opens notepad help" + ID_HELP_ABOUT "Displays program information, version number and copyright" + ID_FILE_EXIT "Quits this notepad text editor" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_EDIT_UNDO "Undo the last buffer editing operation performed" + ID_EDIT_CUT "Removes the selected text and places it on the clipboard" + ID_EDIT_COPY "Copies the selected text to the clipboard" + ID_EDIT_PASTE "Pastes the contents of the clipboard at the cursor location" + ID_EDIT_DELETE "Deletes the selected text" + ID_EDIT_FIND "Finds a text string in the buffer" + ID_EDIT_FINDNEXT "Finds next occurrence of text specified in previous search" + ID_EDIT_GOTO "Jump to specified line number in buffer" + ID_EDIT_SELECTALL "Selects the entire text buffer" + ID_EDIT_TIMEDATE "Inserts the current date and time at the cursor location" + ID_VIEW_STATUSBAR "Shows or hides the status bar" + ID_VIEW_TOOLBAR "Shows or hides the tool bar" + ID_VIEW_SPLIT "Change position of split between two panes" + ID_VIEW_REFRESH "Refreshes the text buffer from it's file" + ID_FORMAT_WORDWRAP "Toggles word-wrap display mode" + ID_FORMAT_FONT "Select font for displaying and printing buffer text" +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// English (Australia) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENA) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE DISCARDABLE +BEGIN + ID_HELP_HELPTOPICS "Opens Registry Editor Help." + ID_HELP_ABOUT "Displays program information, version number, and copyright." +END + +#endif // English (Australia) resources +///////////////////////////////////////////////////////////////////////////// + diff --git a/rosapps/notepad/res/notepad.ico b/rosapps/notepad/res/notepad.ico new file mode 100644 index 0000000000000000000000000000000000000000..386883523bcc032db77b69b047cbc5c15ae3b7fe GIT binary patch literal 1078 zcmeH_K@!3s3`IZHwe$$AoF2oYaWszOk{jR)NR>_(PRDWOZgV)&%Zp6VccBVa2?uQ&sh9LW;!?J w2dwKn!S@jnH5GJS10MR3&V{nkc?%F^XS#jrb=7ItXV>BJ*yg?&H~)SR4}%AClK=n! literal 0 HcmV?d00001 diff --git a/rosapps/notepad/res/small.ico b/rosapps/notepad/res/small.ico new file mode 100644 index 0000000000000000000000000000000000000000..8f94d9aa8285725af1920f17fa4ba90a7dad97fc GIT binary patch literal 318 zcmbu1u@S&92m|H2^tei$GGj6tBe4N_?3C#ONWzj2Y0z^{b=^ZcTR}S)7&>4n7JrdT ujNG@ttiTl!1hqz0y#czdCNotgVrj}ml}kwpjQ>