Author: weiden Date: Sat Feb 17 12:32:33 2007 New Revision: 25828
URL: http://svn.reactos.org/svn/reactos?rev=25828&view=rev Log: - Move around definitions to make the code a bit more modular - Use an about menu instead of an button
Modified: trunk/reactos/base/applications/charmap/about.c trunk/reactos/base/applications/charmap/charmap.c trunk/reactos/base/applications/charmap/lang/en-US.rc trunk/reactos/base/applications/charmap/map.c trunk/reactos/base/applications/charmap/precomp.h trunk/reactos/base/applications/charmap/resource.h
Modified: trunk/reactos/base/applications/charmap/about.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/charmap/a... ============================================================================== --- trunk/reactos/base/applications/charmap/about.c (original) +++ trunk/reactos/base/applications/charmap/about.c Sat Feb 17 12:32:33 2007 @@ -1,7 +1,7 @@ #include <precomp.h>
-INT_PTR CALLBACK +static INT_PTR CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, @@ -53,3 +53,12 @@
return FALSE; } + +VOID +ShowAboutDlg(HWND hWndParent) +{ + DialogBox(hInstance, + MAKEINTRESOURCE(IDD_ABOUTBOX), + hWndParent, + AboutDialogProc); +}
Modified: trunk/reactos/base/applications/charmap/charmap.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/charmap/c... ============================================================================== --- trunk/reactos/base/applications/charmap/charmap.c (original) +++ trunk/reactos/base/applications/charmap/charmap.c Sat Feb 17 12:32:33 2007 @@ -1,12 +1,11 @@ #include <precomp.h>
-const TCHAR szMapWndClass[] = TEXT("FontMapWnd"); -const TCHAR szLrgCellWndClass[] = TEXT("LrgCellWnd"); +#define ID_ABOUT 0x1
HINSTANCE hInstance;
/* Font-enumeration callback */ -int CALLBACK +static int CALLBACK EnumFontNames(ENUMLOGFONTEX *lpelfe, NEWTEXTMETRICEX *lpntme, DWORD FontType, @@ -120,19 +119,20 @@ }
-BOOL CALLBACK +static BOOL CALLBACK DlgProc(HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam) { - static HICON hSmIcon = NULL; - static HICON hBgIcon = NULL; - switch(Message) { case WM_INITDIALOG: { + HICON hSmIcon; + HICON hBgIcon; + HMENU hSysMenu; + hSmIcon = LoadImage(hInstance, MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, @@ -159,6 +159,29 @@ IDC_FONTCOMBO));
ChangeMapFont(hDlg); + + hSysMenu = GetSystemMenu(hDlg, + FALSE); + if (hSysMenu != NULL) + { + LPCTSTR lpAboutText = NULL; + + if (LoadString(hInstance, + IDS_ABOUT, + (LPTSTR)&lpAboutText, + 0)) + { + AppendMenu(hSysMenu, + MF_SEPARATOR, + 0, + NULL); + AppendMenu(hSysMenu, + MF_STRING, + ID_ABOUT, + lpAboutText); + } + } + return TRUE; } break;
@@ -184,8 +207,15 @@ case IDOK: EndDialog(hDlg, 0); break; - - case IDC_ABOUT: + } + } + break; + + case WM_SYSCOMMAND: + { + switch(wParam) + { + case ID_ABOUT: DialogBox(hInstance, MAKEINTRESOURCE(IDD_ABOUTBOX), hDlg, @@ -199,43 +229,7 @@ return FALSE; }
- return TRUE; -} - -BOOL -RegisterControls(HINSTANCE hInstance) -{ - WNDCLASS wc = {0}; - - //wc.style = CS_DBLCLKS; - wc.lpfnWndProc = MapWndProc; - wc.cbWndExtra = sizeof(PMAP); - wc.hInstance = hInstance; - wc.hCursor = LoadCursor(NULL, - (LPTSTR)IDC_ARROW); - wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); - wc.lpszClassName = szMapWndClass; - - if (RegisterClass(&wc)) - { - wc.lpfnWndProc = LrgCellWndProc; - wc.cbWndExtra = 0; - wc.lpszClassName = szLrgCellWndClass; - - return RegisterClass(&wc) != 0; - } - return FALSE; -} - -VOID -UnregisterControls(HINSTANCE hInstance) -{ - UnregisterClass(szMapWndClass, - hInstance); - - UnregisterClass(szLrgCellWndClass, - hInstance); }
@@ -246,7 +240,7 @@ int iCmd) { INITCOMMONCONTROLSEX iccx; - INT Ret; + INT Ret = 1;
hInstance = hInst;
@@ -254,14 +248,15 @@ iccx.dwICC = ICC_TAB_CLASSES; InitCommonControlsEx(&iccx);
- RegisterControls(hInstance); - - Ret = DialogBox(hInstance, - MAKEINTRESOURCE(IDD_CHARMAP), - NULL, - (DLGPROC)DlgProc); - - UnregisterControls(hInstance); + if (RegisterMapClasses(hInstance)) + { + Ret = DialogBox(hInstance, + MAKEINTRESOURCE(IDD_CHARMAP), + NULL, + (DLGPROC)DlgProc) >= 0; + + UnregisterMapClasses(hInstance); + }
return Ret; }
Modified: trunk/reactos/base/applications/charmap/lang/en-US.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/charmap/l... ============================================================================== --- trunk/reactos/base/applications/charmap/lang/en-US.rc (original) +++ trunk/reactos/base/applications/charmap/lang/en-US.rc Sat Feb 17 12:32:33 2007 @@ -3,12 +3,11 @@ IDD_CHARMAP DIALOGEX 6, 6, 293, 205 //233 CAPTION "Character Map" FONT 8,"MS Sans Serif",0,0 -STYLE WS_BORDER | WS_VISIBLE | WS_SYSMENU +STYLE WS_BORDER | WS_VISIBLE | WS_SYSMENU | WS_MINIMIZEBOX BEGIN LTEXT "Font :", IDC_STATIC, 6, 7, 24, 9 - COMBOBOX IDC_FONTCOMBO, 36, 5, 196, 210, WS_CHILD | WS_VISIBLE | WS_VSCROLL | CBS_DROPDOWNLIST | CBS_SORT | CBS_HASSTRINGS - PUSHBUTTON "Help", IDC_CMHELP, 235, 5, 35, 13 - PUSHBUTTON "?", IDC_ABOUT, 272, 5, 14, 13 + COMBOBOX IDC_FONTCOMBO, 36, 5, 210, 210, WS_CHILD | WS_VISIBLE | WS_VSCROLL | CBS_DROPDOWNLIST | CBS_SORT | CBS_HASSTRINGS + PUSHBUTTON "Help", IDC_CMHELP, 249, 5, 35, 13 CONTROL "", IDC_FONTMAP, "FontMapWnd", WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL, 20, 22, 266, 156 LTEXT "Characters to copy :", IDC_STATIC, 6, 188, 66, 9 EDITTEXT IDC_TEXTBOX, 74, 186, 114, 13, WS_CHILD | WS_VISIBLE | WS_TABSTOP @@ -32,4 +31,5 @@ STRINGTABLE DISCARDABLE BEGIN IDS_LICENSE "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.\r\n\r\nThis 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.\r\n\r\nYou 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." + IDS_ABOUT "A&bout..." END
Modified: trunk/reactos/base/applications/charmap/map.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/charmap/m... ============================================================================== --- trunk/reactos/base/applications/charmap/map.c (original) +++ trunk/reactos/base/applications/charmap/map.c Sat Feb 17 12:32:33 2007 @@ -1,5 +1,7 @@ #include <precomp.h>
+static const TCHAR szMapWndClass[] = TEXT("FontMapWnd"); +static const TCHAR szLrgCellWndClass[] = TEXT("LrgCellWnd");
static VOID TagFontToCell(PCELL pCell, @@ -482,3 +484,39 @@
return Ret; } + +BOOL +RegisterMapClasses(HINSTANCE hInstance) +{ + WNDCLASS wc = {0}; + + //wc.style = CS_DBLCLKS; + wc.lpfnWndProc = MapWndProc; + wc.cbWndExtra = sizeof(PMAP); + wc.hInstance = hInstance; + wc.hCursor = LoadCursor(NULL, + (LPTSTR)IDC_ARROW); + wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); + wc.lpszClassName = szMapWndClass; + + if (RegisterClass(&wc)) + { + wc.lpfnWndProc = LrgCellWndProc; + wc.cbWndExtra = 0; + wc.lpszClassName = szLrgCellWndClass; + + return RegisterClass(&wc) != 0; + } + + return FALSE; +} + +VOID +UnregisterMapClasses(HINSTANCE hInstance) +{ + UnregisterClass(szMapWndClass, + hInstance); + + UnregisterClass(szLrgCellWndClass, + hInstance); +}
Modified: trunk/reactos/base/applications/charmap/precomp.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/charmap/p... ============================================================================== --- trunk/reactos/base/applications/charmap/precomp.h (original) +++ trunk/reactos/base/applications/charmap/precomp.h Sat Feb 17 12:32:33 2007 @@ -14,8 +14,6 @@ #define FM_SETFONT (WM_USER + 1)
extern HINSTANCE hInstance; -extern const TCHAR szMapWndClass[]; -extern const TCHAR szLrgCellWndClass[];
typedef struct _CELL @@ -41,11 +39,9 @@ INT iPage; } MAP, *PMAP;
-BOOL RegisterControls(HINSTANCE hInstance); -VOID UnregisterControls(HINSTANCE hInstance); +VOID ShowAboutDlg(HWND hWndParent);
-INT_PTR CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); -LRESULT CALLBACK LrgCellWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); -LRESULT CALLBACK MapWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); +BOOL RegisterMapClasses(HINSTANCE hInstance); +VOID UnregisterMapClasses(HINSTANCE hInstance);
#endif /* __DEVMGMT_PRECOMP_H */
Modified: trunk/reactos/base/applications/charmap/resource.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/charmap/r... ============================================================================== --- trunk/reactos/base/applications/charmap/resource.h (original) +++ trunk/reactos/base/applications/charmap/resource.h Sat Feb 17 12:32:33 2007 @@ -4,15 +4,16 @@
#define IDD_CHARMAP 200 #define IDD_ABOUTBOX 201 + #define IDC_FONTCOMBO 1001 #define IDC_CMHELP 1002 -#define IDC_ABOUT 1003 -#define IDC_FONTMAP 1004 -#define IDC_TEXTBOX 1005 -#define IDC_SELECT 1006 -#define IDC_COPY 1007 -#define IDC_ADVVIEW 1008 -#define IDC_DISPLAY 1009 -#define IDC_SCROLL 1010 -#define IDS_LICENSE 1011 -#define IDC_LICENSE_EDIT 1012 +#define IDC_FONTMAP 1003 +#define IDC_TEXTBOX 1004 +#define IDC_SELECT 1005 +#define IDC_COPY 1006 +#define IDC_ADVVIEW 1007 +#define IDC_DISPLAY 1008 +#define IDC_LICENSE_EDIT 1009 + +#define IDS_LICENSE 1010 +#define IDS_ABOUT 1011