https://git.reactos.org/?p=reactos.git;a=commitdiff;h=bf34d6bf8b0e1d243020b6...
commit bf34d6bf8b0e1d243020b67a0fb3ca6206e77b6b Author: Baruch Rutman peterooch@gmail.com AuthorDate: Thu May 17 18:18:57 2018 +0300 Commit: Ged Murphy gedmurphy@reactos.org CommitDate: Thu May 17 16:18:57 2018 +0100
[CHARMAP]Code improvements (#436)
* [CHARMAP][GETUNAME] Code improvements
Based on the code from nls2txt, switches the linking from dynamic to static, also simplifies the code. --- base/applications/charmap/CMakeLists.txt | 2 +- base/applications/charmap/charmap.c | 31 ++++--------------------------- base/applications/charmap/precomp.h | 2 ++ 3 files changed, 7 insertions(+), 28 deletions(-)
diff --git a/base/applications/charmap/CMakeLists.txt b/base/applications/charmap/CMakeLists.txt index e576b741e1..d2e497554e 100644 --- a/base/applications/charmap/CMakeLists.txt +++ b/base/applications/charmap/CMakeLists.txt @@ -10,6 +10,6 @@ list(APPEND SOURCE add_rc_deps(charmap.rc ${CMAKE_CURRENT_SOURCE_DIR}/res/charmap.ico) add_executable(charmap ${SOURCE} charmap.rc) set_module_type(charmap win32gui UNICODE) -add_importlibs(charmap advapi32 user32 gdi32 comctl32 msvcrt kernel32) +add_importlibs(charmap getuname advapi32 user32 gdi32 comctl32 msvcrt kernel32) add_pch(charmap precomp.h SOURCE) add_cd_file(TARGET charmap DESTINATION reactos/system32 FOR all) diff --git a/base/applications/charmap/charmap.c b/base/applications/charmap/charmap.c index 35cc8e6f9f..218f8512c5 100644 --- a/base/applications/charmap/charmap.c +++ b/base/applications/charmap/charmap.c @@ -25,10 +25,6 @@ HICON hSmIcon; HICON hBgIcon; SETTINGS Settings;
-/* GetUName prototype */ -typedef int (WINAPI * GETUNAME)(WORD wCharCode, LPWSTR lpbuf); -GETUNAME GetUName; - /* Font-enumeration callback */ static int @@ -165,7 +161,7 @@ CopyCharacters(HWND hDlg)
// Test if the whose text is unselected if(dwStart == dwEnd) { - + // Select the whole text SendMessageW(hText, EM_SETSEL, 0, -1);
@@ -268,12 +264,9 @@ UpdateStatusBar(WCHAR wch) WCHAR buff[MAX_PATH]; WCHAR szDesc[MAX_PATH];
- if (GetUName) - { - GetUName(wch, szDesc); - wsprintfW(buff, L"U+%04X: %s", wch, szDesc); - SendMessageW(hStatusWnd, SB_SETTEXT, 0, (LPARAM)buff); - } + GetUName(wch, szDesc); + wsprintfW(buff, L"U+%04X: %s", wch, szDesc); + SendMessageW(hStatusWnd, SB_SETTEXT, 0, (LPARAM)buff); }
static @@ -593,7 +586,6 @@ wWinMain(HINSTANCE hInst, INT Ret = 1; HMODULE hRichEd20; MSG Msg; - HINSTANCE hGetUName = NULL;
hInstance = hInst;
@@ -612,18 +604,6 @@ wWinMain(HINSTANCE hInst, iccx.dwICC = ICC_TAB_CLASSES; InitCommonControlsEx(&iccx);
- /* Loading the GetUName function */ - hGetUName = LoadLibraryW(L"getuname.dll"); - if (hGetUName != NULL) - { - GetUName = (GETUNAME) GetProcAddress(hGetUName, "GetUName"); - if (GetUName == NULL) - { - FreeLibrary(hGetUName); - hGetUName = NULL; - } - } - if (RegisterMapClasses(hInstance)) { hRichEd20 = LoadLibraryW(L"RICHED20.DLL"); @@ -649,8 +629,5 @@ wWinMain(HINSTANCE hInst, UnregisterMapClasses(hInstance); }
- if (hGetUName != NULL) - FreeLibrary(hGetUName); - return Ret; } diff --git a/base/applications/charmap/precomp.h b/base/applications/charmap/precomp.h index 0ade7aa1e7..132f275d4e 100644 --- a/base/applications/charmap/precomp.h +++ b/base/applications/charmap/precomp.h @@ -73,6 +73,8 @@ VOID ShowAboutDlg(HWND hWndParent); BOOL RegisterMapClasses(HINSTANCE hInstance); VOID UnregisterMapClasses(HINSTANCE hInstance);
+int WINAPI GetUName(IN WORD wCharCode, OUT LPWSTR lpBuf); + /* charmap.c */ VOID UpdateStatusBar(WCHAR wch); extern VOID ChangeMapFont(HWND hDlg);