Implemented font selection.
Added accelerators resources.
This commit is contained in:
parent
cfda84ef53
commit
fc0d07f8cf
|
@ -24,14 +24,15 @@ MAIN_MENU MENU LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
|
|||
{
|
||||
POPUP "&File" {
|
||||
MENUITEM "&New...", CMD_NEW
|
||||
MENUITEM "&Open", CMD_OPEN
|
||||
MENUITEM "&Save", CMD_SAVE
|
||||
MENUITEM "&Open\tCtrl+O", CMD_OPEN
|
||||
MENUITEM "&Save\tCtrl+S", CMD_SAVE
|
||||
MENUITEM "Save &as...", CMD_SAVE_AS
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Print", CMD_PRINT
|
||||
MENUITEM "Page Se&tup...", CMD_PAGE_SETUP
|
||||
MENUITEM "P&rinter Setup...", CMD_PRINTER_SETUP
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Exit", CMD_EXIT
|
||||
MENUITEM "E&xit", CMD_EXIT
|
||||
}
|
||||
POPUP "&Edit" {
|
||||
MENUITEM "&Undo\tCtrl+Z", CMD_UNDO
|
||||
|
@ -41,15 +42,17 @@ POPUP "&Edit" {
|
|||
MENUITEM "&Paste\tCtrl+V", CMD_PASTE
|
||||
MENUITEM "&Delete\tDel", CMD_DELETE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Select &all", CMD_SELECT_ALL
|
||||
MENUITEM "Select &all\tCtrl+A", CMD_SELECT_ALL
|
||||
MENUITEM "&Time/Date\tF5", CMD_TIME_DATE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Wrap long lines", CMD_WRAP
|
||||
}
|
||||
POPUP "&Search" {
|
||||
MENUITEM "&Search", CMD_SEARCH
|
||||
MENUITEM "&Search\tCtrl+F", CMD_SEARCH
|
||||
MENUITEM "&Search next\tF3", CMD_SEARCH_NEXT
|
||||
}
|
||||
POPUP "F&ormat" {
|
||||
MENUITEM "&Wrap long lines", CMD_WRAP
|
||||
MENUITEM "&Font...", CMD_FONT
|
||||
}
|
||||
POPUP "&Help" {
|
||||
MENUITEM "&Contents", CMD_HELP_CONTENTS
|
||||
MENUITEM "&Search...", CMD_HELP_SEARCH
|
||||
|
@ -91,6 +94,16 @@ PUSHBUTTON "Cancel", 0x152, 180, 21, 40, 15, WS_TABSTOP
|
|||
PUSHBUTTON "&Help", 0x153, 180, 39, 40, 15, WS_TABSTOP
|
||||
}
|
||||
|
||||
ID_ACCEL ACCELERATORS LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
|
||||
{
|
||||
"^A", CMD_SELECT_ALL
|
||||
"^F", CMD_SEARCH
|
||||
"^O", CMD_OPEN
|
||||
"^S", CMD_SAVE
|
||||
VK_F3, CMD_SEARCH_NEXT, VIRTKEY
|
||||
VK_F5, CMD_TIME_DATE, VIRTKEY
|
||||
}
|
||||
|
||||
STRINGTABLE DISCARDABLE LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
|
||||
{
|
||||
STRING_PAGESETUP_HEADERVALUE, "&n" /* FIXME */
|
||||
|
|
|
@ -504,7 +504,7 @@ VOID DIALOG_FilePrint(VOID)
|
|||
/* I don't know what's up with this TextOut command. This comes out
|
||||
kind of mangled.
|
||||
*/
|
||||
TextOut(hContext, border*2, border+szMetric.cy*0.5, szDocumentName, count);
|
||||
TextOut(hContext, border*2, border+szMetric.cy/2, szDocumentName, count);
|
||||
}
|
||||
|
||||
/* The starting point for the main text */
|
||||
|
@ -669,6 +669,29 @@ VOID DIALOG_EditWrap(VOID)
|
|||
MF_BYCOMMAND | (Globals.bWrapLongLines ? MF_CHECKED : MF_UNCHECKED));
|
||||
}
|
||||
|
||||
VOID DIALOG_SelectFont(VOID)
|
||||
{
|
||||
CHOOSEFONT cf;
|
||||
LOGFONT lf=Globals.lfFont;
|
||||
|
||||
ZeroMemory( &cf, sizeof(cf) );
|
||||
cf.lStructSize=sizeof(cf);
|
||||
cf.hwndOwner=Globals.hMainWnd;
|
||||
cf.lpLogFont=&lf;
|
||||
cf.Flags=CF_SCREENFONTS;
|
||||
|
||||
if( ChooseFont(&cf) )
|
||||
{
|
||||
HFONT currfont=Globals.hFont;
|
||||
|
||||
Globals.hFont=CreateFontIndirect( &lf );
|
||||
Globals.lfFont=lf;
|
||||
SendMessage( Globals.hEdit, WM_SETFONT, (WPARAM)Globals.hFont, (LPARAM)TRUE );
|
||||
if( currfont!=NULL )
|
||||
DeleteObject( currfont );
|
||||
}
|
||||
}
|
||||
|
||||
VOID DIALOG_Search(VOID)
|
||||
{
|
||||
ZeroMemory(&Globals.find, sizeof(Globals.find));
|
||||
|
|
|
@ -34,11 +34,13 @@ VOID DIALOG_EditPaste(VOID);
|
|||
VOID DIALOG_EditDelete(VOID);
|
||||
VOID DIALOG_EditSelectAll(VOID);
|
||||
VOID DIALOG_EditTimeDate(VOID);
|
||||
VOID DIALOG_EditWrap(VOID);
|
||||
|
||||
VOID DIALOG_Search(VOID);
|
||||
VOID DIALOG_SearchNext(VOID);
|
||||
|
||||
VOID DIALOG_EditWrap(VOID);
|
||||
VOID DIALOG_SelectFont(VOID);
|
||||
|
||||
VOID DIALOG_HelpContents(VOID);
|
||||
VOID DIALOG_HelpSearch(VOID);
|
||||
VOID DIALOG_HelpHelp(VOID);
|
||||
|
|
|
@ -72,11 +72,13 @@ int NOTEPAD_MenuCommand(WPARAM wParam)
|
|||
case CMD_DELETE: DIALOG_EditDelete(); break;
|
||||
case CMD_SELECT_ALL: DIALOG_EditSelectAll(); break;
|
||||
case CMD_TIME_DATE: DIALOG_EditTimeDate();break;
|
||||
case CMD_WRAP: DIALOG_EditWrap(); break;
|
||||
|
||||
case CMD_SEARCH: DIALOG_Search(); break;
|
||||
case CMD_SEARCH_NEXT: DIALOG_SearchNext(); break;
|
||||
|
||||
case CMD_WRAP: DIALOG_EditWrap(); break;
|
||||
case CMD_FONT: DIALOG_SelectFont(); break;
|
||||
|
||||
case CMD_HELP_CONTENTS: DIALOG_HelpContents(); break;
|
||||
case CMD_HELP_SEARCH: DIALOG_HelpSearch(); break;
|
||||
case CMD_HELP_ON_HELP: DIALOG_HelpHelp(); break;
|
||||
|
@ -118,23 +120,16 @@ LRESULT WINAPI NOTEPAD_WndProc(HWND hWnd, UINT msg, WPARAM wParam,
|
|||
{
|
||||
RECT rc;
|
||||
GetClientRect(hWnd, &rc);
|
||||
if (LoadLibrary("RichEd32.dll"))
|
||||
{
|
||||
Globals.hEdit =
|
||||
CreateWindow("RICHEDIT", "",
|
||||
Globals.hEdit = CreateWindow("EDIT", "",
|
||||
WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL |
|
||||
ES_AUTOVSCROLL | ES_MULTILINE,
|
||||
0, 0, rc.right, rc.bottom, hWnd,
|
||||
NULL, Globals.hInstance, NULL);
|
||||
} else {
|
||||
ShowLastError();
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_COMMAND:
|
||||
NOTEPAD_MenuCommand(wParam);
|
||||
NOTEPAD_MenuCommand(LOWORD(wParam));
|
||||
break;
|
||||
|
||||
case WM_DESTROYCLIPBOARD:
|
||||
|
@ -273,6 +268,7 @@ void HandleCommandLine(LPSTR cmdline)
|
|||
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show)
|
||||
{
|
||||
MSG msg;
|
||||
HACCEL hAccel;
|
||||
WNDCLASSEX class;
|
||||
char className[] = "NPClass";
|
||||
char winName[] = "Notepad";
|
||||
|
@ -313,9 +309,22 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show)
|
|||
|
||||
HandleCommandLine(cmdline);
|
||||
|
||||
while (GetMessage(&msg, 0, 0, 0)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
hAccel=LoadAccelerators( hInstance, MAKEINTRESOURCE(ID_ACCEL) );
|
||||
|
||||
if( hAccel!=NULL )
|
||||
{
|
||||
while( GetMessage(&msg, 0, 0, 0)) {
|
||||
if( !TranslateAccelerator( Globals.hMainWnd, hAccel, &msg ) ) {
|
||||
TranslateMessage( &msg );
|
||||
DispatchMessage( &msg );
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
while (GetMessage(&msg, 0, 0, 0)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
return msg.wParam;
|
||||
}
|
||||
|
|
|
@ -46,6 +46,8 @@ typedef struct
|
|||
HWND hMainWnd;
|
||||
HWND hFindReplaceDlg;
|
||||
HWND hEdit;
|
||||
HFONT hFont; /* Font used by the edit control */
|
||||
LOGFONT lfFont;
|
||||
HICON hMainIcon;
|
||||
HICON hDefaultIcon;
|
||||
LPCSTR lpszIcoFile;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#define MAIN_MENU 0x201
|
||||
#define DIALOG_PAGESETUP 0x202
|
||||
#define ID_ACCEL 0x203
|
||||
|
||||
/* Commands */
|
||||
#define CMD_NEW 0x100
|
||||
|
@ -39,11 +40,13 @@
|
|||
#define CMD_DELETE 0x114
|
||||
#define CMD_SELECT_ALL 0x116
|
||||
#define CMD_TIME_DATE 0x117
|
||||
#define CMD_WRAP 0x119
|
||||
|
||||
#define CMD_SEARCH 0x120
|
||||
#define CMD_SEARCH_NEXT 0x121
|
||||
|
||||
#define CMD_WRAP 0x119
|
||||
#define CMD_FONT 0x140
|
||||
|
||||
#define CMD_HELP_CONTENTS 0x130
|
||||
#define CMD_HELP_SEARCH 0x131
|
||||
#define CMD_HELP_ON_HELP 0x132
|
||||
|
|
Loading…
Reference in New Issue