From b4f7cf35238812e7c118742ba9624ceaea33e9f7 Mon Sep 17 00:00:00 2001 From: Ged Murphy Date: Mon, 19 Feb 2007 23:56:16 +0000 Subject: [PATCH] add chars to the edit box when either double clicked or the select button is hit svn path=/trunk/; revision=25848 --- reactos/base/applications/charmap/about.c | 75 ++++++++-------- reactos/base/applications/charmap/charmap.c | 97 +++++++++++++++++++-- reactos/base/applications/charmap/lrgcell.c | 9 +- reactos/base/applications/charmap/map.c | 47 +++++++++- reactos/base/applications/charmap/precomp.h | 13 ++- 5 files changed, 194 insertions(+), 47 deletions(-) diff --git a/reactos/base/applications/charmap/about.c b/reactos/base/applications/charmap/about.c index 661138b2fc2..61112e47251 100644 --- a/reactos/base/applications/charmap/about.c +++ b/reactos/base/applications/charmap/about.c @@ -7,53 +7,58 @@ AboutDialogProc(HWND hDlg, WPARAM wParam, LPARAM lParam) { - HWND hLicenseEditWnd; - HICON hIcon = NULL; - TCHAR strLicense[700]; + static HICON hIcon = NULL; switch (message) { - case WM_INITDIALOG: - - hIcon = LoadImage(hInstance, - MAKEINTRESOURCE(IDI_ICON), - IMAGE_ICON, - 16, - 16, - 0); - - SendMessage(hDlg, - WM_SETICON, - ICON_SMALL, - (LPARAM)hIcon); - - hLicenseEditWnd = GetDlgItem(hDlg, - IDC_LICENSE_EDIT); - - LoadString(hInstance, - IDS_LICENSE, - strLicense, - sizeof(strLicense) / sizeof(TCHAR)); - - SetWindowText(hLicenseEditWnd, - strLicense); - return TRUE; - - case WM_COMMAND: - if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL)) + case WM_INITDIALOG: { - DestroyIcon(hIcon); - EndDialog(hDlg, - LOWORD(wParam)); + HWND hLicenseEditWnd; + TCHAR strLicense[700]; + + hIcon = LoadImage(hInstance, + MAKEINTRESOURCE(IDI_ICON), + IMAGE_ICON, + 16, + 16, + 0); + + SendMessage(hDlg, + WM_SETICON, + ICON_SMALL, + (LPARAM)hIcon); + + hLicenseEditWnd = GetDlgItem(hDlg, + IDC_LICENSE_EDIT); + + LoadString(hInstance, + IDS_LICENSE, + strLicense, + sizeof(strLicense) / sizeof(TCHAR)); + + SetWindowText(hLicenseEditWnd, + strLicense); return TRUE; } - break; + case WM_COMMAND: + { + if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL)) + { + DestroyIcon(hIcon); + EndDialog(hDlg, + LOWORD(wParam)); + return TRUE; + } + + break; + } } return FALSE; } + VOID ShowAboutDlg(HWND hWndParent) { diff --git a/reactos/base/applications/charmap/charmap.c b/reactos/base/applications/charmap/charmap.c index abb707fdb3d..68ac14e7337 100644 --- a/reactos/base/applications/charmap/charmap.c +++ b/reactos/base/applications/charmap/charmap.c @@ -75,11 +75,10 @@ FillFontStyleComboList(HWND hwndCombo) ReleaseDC(hwndCombo, hdc); - /* set default to Arial */ SendMessage(hwndCombo, - CB_SELECTSTRING, - -1, - (LPARAM)_T("Arial")); + CB_SETCURSEL, + 0, + 0); } @@ -105,7 +104,7 @@ ChangeMapFont(HWND hDlg) { SendMessage(hCombo, WM_GETTEXT, - 31, + Len + 1, (LPARAM)lpFontName); hMap = GetDlgItem(hDlg, IDC_FONTMAP); @@ -119,6 +118,58 @@ ChangeMapFont(HWND hDlg) } +static VOID +AddCharToSelection(HWND hText, + TCHAR ch) +{ + LPTSTR lpText; + INT Len = GetWindowTextLength(hText); + + if (Len != 0) + { + lpText = HeapAlloc(GetProcessHeap(), + 0, + (Len + 2) * sizeof(TCHAR)); + + if (lpText) + { + LPTSTR lpStr = lpText; + + SendMessage(hText, + WM_GETTEXT, + Len + 1, + (LPARAM)lpStr); + + lpStr += Len; + *lpStr = ch; + lpStr++; + *lpStr = _T('\0'); + + SendMessage(hText, + WM_SETTEXT, + 0, + (LPARAM)lpText); + + HeapFree(GetProcessHeap(), + 0, + lpText); + } + } + else + { + TCHAR szText[2]; + + szText[0] = ch; + szText[1] = _T('\0'); + + SendMessage(hText, + WM_SETTEXT, + 0, + (LPARAM)szText); + } +} + + static BOOL CALLBACK DlgProc(HWND hDlg, UINT Message, @@ -204,6 +255,19 @@ DlgProc(HWND hDlg, } break; + case IDC_SELECT: + { + TCHAR ch; + HWND hMap = GetDlgItem(hDlg, IDC_FONTMAP); + + ch = SendMessage(hMap, FM_GETCHAR, 0, 0); + + AddCharToSelection(GetDlgItem(hDlg, IDC_TEXTBOX), + ch); + + break; + } + case IDOK: EndDialog(hDlg, 0); break; @@ -222,6 +286,29 @@ DlgProc(HWND hDlg, } break; + case WM_NOTIFY: + { + LPMAPNOTIFY lpnm = (LPMAPNOTIFY)lParam; + + switch (lpnm->hdr.idFrom) + { + case IDC_FONTMAP: + { + switch (lpnm->hdr.code) + { + case FM_SETCHAR: + { + AddCharToSelection(GetDlgItem(hDlg, IDC_TEXTBOX), + lpnm->ch); + } + break; + } + } + break; + } + } + break; + default: return FALSE; } diff --git a/reactos/base/applications/charmap/lrgcell.c b/reactos/base/applications/charmap/lrgcell.c index 7ff12bd77fe..66b2319bc7b 100644 --- a/reactos/base/applications/charmap/lrgcell.c +++ b/reactos/base/applications/charmap/lrgcell.c @@ -11,7 +11,8 @@ SetLrgFont(PMAP infoPtr) LPTSTR lpFontName; INT Len; - hCombo = GetDlgItem(infoPtr->hParent, IDC_FONTCOMBO); + hCombo = GetDlgItem(infoPtr->hParent, + IDC_FONTCOMBO); Len = GetWindowTextLength(hCombo); @@ -28,12 +29,14 @@ SetLrgFont(PMAP infoPtr) 31, (LPARAM)lpFontName); - ZeroMemory(&lf, sizeof(lf)); + ZeroMemory(&lf, + sizeof(lf)); hdc = GetDC(infoPtr->hLrgWnd); lf.lfHeight = GetDeviceCaps(hdc, LOGPIXELSY) / 2; - ReleaseDC(infoPtr->hLrgWnd, hdc); + ReleaseDC(infoPtr->hLrgWnd, + hdc); lf.lfCharSet = DEFAULT_CHARSET; lstrcpy(lf.lfFaceName, diff --git a/reactos/base/applications/charmap/map.c b/reactos/base/applications/charmap/map.c index 3830f1f4e30..3f485776ba9 100644 --- a/reactos/base/applications/charmap/map.c +++ b/reactos/base/applications/charmap/map.c @@ -72,7 +72,6 @@ static VOID FillGrid(PMAP infoPtr, HDC hdc) { - //GLYPHSET gs; HFONT hOldFont; TCHAR ch; INT x, y; @@ -194,6 +193,34 @@ SetFont(PMAP infoPtr, } +static LRESULT +NotifyParentOfSelection(PMAP infoPtr, + UINT code, + TCHAR ch) +{ + LRESULT Ret = 0; + + if (infoPtr->hParent != NULL) + { + MAPNOTIFY mnmh; + + mnmh.hdr.hwndFrom = infoPtr->hMapWnd; + mnmh.hdr.idFrom = GetWindowLongPtr(infoPtr->hMapWnd, + GWLP_ID); + mnmh.hdr.code = code; + + mnmh.ch = ch; + + Ret = SendMessage(infoPtr->hParent, + WM_NOTIFY, + (WPARAM)mnmh.hdr.idFrom, + (LPARAM)&mnmh); + } + + return Ret; +} + + static VOID OnClick(PMAP infoPtr, WORD ptx, @@ -430,6 +457,16 @@ MapWndProc(HWND hwnd, break; } + case WM_LBUTTONDBLCLK: + { + NotifyParentOfSelection(infoPtr, + FM_SETCHAR, + infoPtr->pActiveCell->ch); + + + break; + } + case WM_VSCROLL: { OnVScroll(infoPtr, @@ -453,6 +490,11 @@ MapWndProc(HWND hwnd, break; } + case FM_GETCHAR: + { + return infoPtr->pActiveCell->ch; + } + case WM_PAINT: { OnPaint(infoPtr, @@ -485,12 +527,13 @@ MapWndProc(HWND hwnd, return Ret; } + BOOL RegisterMapClasses(HINSTANCE hInstance) { WNDCLASS wc = {0}; - //wc.style = CS_DBLCLKS; + wc.style = CS_DBLCLKS; wc.lpfnWndProc = MapWndProc; wc.cbWndExtra = sizeof(PMAP); wc.hInstance = hInstance; diff --git a/reactos/base/applications/charmap/precomp.h b/reactos/base/applications/charmap/precomp.h index d9e8737e231..49e3128c046 100644 --- a/reactos/base/applications/charmap/precomp.h +++ b/reactos/base/applications/charmap/precomp.h @@ -12,10 +12,11 @@ #define YLARGE 25 #define FM_SETFONT (WM_USER + 1) +#define FM_GETCHAR (WM_USER + 2) +#define FM_SETCHAR (WM_USER + 3) extern HINSTANCE hInstance; - typedef struct _CELL { RECT CellExt; @@ -39,9 +40,17 @@ typedef struct _MAP INT iPage; } MAP, *PMAP; +typedef struct { + NMHDR hdr; + TCHAR ch; +} MAPNOTIFY, *LPMAPNOTIFY; + + +LRESULT CALLBACK LrgCellWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); + VOID ShowAboutDlg(HWND hWndParent); BOOL RegisterMapClasses(HINSTANCE hInstance); VOID UnregisterMapClasses(HINSTANCE hInstance); -#endif /* __DEVMGMT_PRECOMP_H */ +#endif /* __CHARMAP_PRECOMP_H */