Author: gedmurphy Date: Tue Feb 20 02:56:16 2007 New Revision: 25848
URL: http://svn.reactos.org/svn/reactos?rev=25848&view=rev Log: add chars to the edit box when either double clicked or the select button is hit
Modified: trunk/reactos/base/applications/charmap/about.c trunk/reactos/base/applications/charmap/charmap.c trunk/reactos/base/applications/charmap/lrgcell.c trunk/reactos/base/applications/charmap/map.c trunk/reactos/base/applications/charmap/precomp.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 Tue Feb 20 02:56:16 2007 @@ -7,52 +7,57 @@ WPARAM wParam, LPARAM lParam) { - HWND hLicenseEditWnd; - HICON hIcon = NULL; - TCHAR strLicense[700]; + static HICON hIcon = NULL;
switch (message) { - case WM_INITDIALOG: + case WM_INITDIALOG: + { + HWND hLicenseEditWnd; + TCHAR strLicense[700];
- hIcon = LoadImage(hInstance, - MAKEINTRESOURCE(IDI_ICON), - IMAGE_ICON, - 16, - 16, - 0); + hIcon = LoadImage(hInstance, + MAKEINTRESOURCE(IDI_ICON), + IMAGE_ICON, + 16, + 16, + 0);
- SendMessage(hDlg, - WM_SETICON, - ICON_SMALL, - (LPARAM)hIcon); + SendMessage(hDlg, + WM_SETICON, + ICON_SMALL, + (LPARAM)hIcon);
- hLicenseEditWnd = GetDlgItem(hDlg, - IDC_LICENSE_EDIT); + hLicenseEditWnd = GetDlgItem(hDlg, + IDC_LICENSE_EDIT);
- LoadString(hInstance, - IDS_LICENSE, - strLicense, - sizeof(strLicense) / sizeof(TCHAR)); + LoadString(hInstance, + IDS_LICENSE, + strLicense, + sizeof(strLicense) / sizeof(TCHAR));
- SetWindowText(hLicenseEditWnd, - strLicense); - return TRUE; - - case WM_COMMAND: - if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL)) - { - DestroyIcon(hIcon); - EndDialog(hDlg, - LOWORD(wParam)); + 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)
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 Tue Feb 20 02:56:16 2007 @@ -75,11 +75,10 @@ ReleaseDC(hwndCombo, hdc);
- /* set default to Arial */ SendMessage(hwndCombo, - CB_SELECTSTRING, - -1, - (LPARAM)_T("Arial")); + CB_SETCURSEL, + 0, + 0); }
@@ -105,7 +104,7 @@ { SendMessage(hCombo, WM_GETTEXT, - 31, + Len + 1, (LPARAM)lpFontName);
hMap = GetDlgItem(hDlg, IDC_FONTMAP); @@ -115,6 +114,58 @@ 0, (LPARAM)lpFontName); } + } +} + + +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); } }
@@ -204,6 +255,19 @@ } 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 @@ } 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; }
Modified: trunk/reactos/base/applications/charmap/lrgcell.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/charmap/l... ============================================================================== --- trunk/reactos/base/applications/charmap/lrgcell.c (original) +++ trunk/reactos/base/applications/charmap/lrgcell.c Tue Feb 20 02:56:16 2007 @@ -11,7 +11,8 @@ LPTSTR lpFontName; INT Len;
- hCombo = GetDlgItem(infoPtr->hParent, IDC_FONTCOMBO); + hCombo = GetDlgItem(infoPtr->hParent, + IDC_FONTCOMBO);
Len = GetWindowTextLength(hCombo);
@@ -28,12 +29,14 @@ 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,
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 Tue Feb 20 02:56:16 2007 @@ -72,7 +72,6 @@ FillGrid(PMAP infoPtr, HDC hdc) { - //GLYPHSET gs; HFONT hOldFont; TCHAR ch; INT x, y; @@ -191,6 +190,34 @@ InvalidateRect(infoPtr->hMapWnd, NULL, TRUE); +} + + +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; }
@@ -430,6 +457,16 @@ break; }
+ case WM_LBUTTONDBLCLK: + { + NotifyParentOfSelection(infoPtr, + FM_SETCHAR, + infoPtr->pActiveCell->ch); + + + break; + } + case WM_VSCROLL: { OnVScroll(infoPtr, @@ -451,6 +488,11 @@ lpFontName);
break; + } + + case FM_GETCHAR: + { + return infoPtr->pActiveCell->ch; }
case WM_PAINT: @@ -485,12 +527,13 @@ 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;
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 Tue Feb 20 02:56:16 2007 @@ -12,9 +12,10 @@ #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 { @@ -39,9 +40,17 @@ 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 */