Revision: 9386 https://osdn.net/projects/ttssh2/scm/svn/commits/9386 Author: zmatsuo Date: 2021-08-29 00:33:25 +0900 (Sun, 29 Aug 2021) Log Message: ----------- Windows 95 で表示が崩れたり動作がおかしいのを修正 - Layer for Unicode にAPIを追加 - DefWindowProcW() - ModifyMenuW() - GetMenuStringW() - DefWindowProcA() ではなく DefWindowProcW() を使用するよう修正 - common/tipwin - tmfc で ANSI版ウィンドウ生成(TTCFrameWnd::CreateA())を削除 Modified Paths: -------------- trunk/teraterm/common/tipwin.cpp trunk/teraterm/common/tmfc.cpp trunk/teraterm/common/tmfc.h trunk/teraterm/common/tmfc_frame.cpp trunk/teraterm/common/tmfc_property.cpp trunk/teraterm/layer_for_unicode/README.md trunk/teraterm/layer_for_unicode/init_ptr.cpp trunk/teraterm/layer_for_unicode/layer_for_unicode.cpp trunk/teraterm/layer_for_unicode/layer_for_unicode.h trunk/teraterm/layer_for_unicode/layer_for_unicode.v8.vcproj trunk/teraterm/layer_for_unicode/symbol_list.txt -------------- next part -------------- Modified: trunk/teraterm/common/tipwin.cpp =================================================================== --- trunk/teraterm/common/tipwin.cpp 2021-08-28 15:33:11 UTC (rev 9385) +++ trunk/teraterm/common/tipwin.cpp 2021-08-28 15:33:25 UTC (rev 9386) @@ -164,7 +164,7 @@ break; } - return DefWindowProc(hWnd, nMsg, wParam, lParam); + return DefWindowProcW(hWnd, nMsg, wParam, lParam); } CTipWin::CTipWin(HINSTANCE hInstance): hInstance(hInstance) Modified: trunk/teraterm/common/tmfc.cpp =================================================================== --- trunk/teraterm/common/tmfc.cpp 2021-08-28 15:33:11 UTC (rev 9385) +++ trunk/teraterm/common/tmfc.cpp 2021-08-28 15:33:25 UTC (rev 9386) @@ -259,10 +259,10 @@ LRESULT TTCWnd::DefWindowProc(UINT msg, WPARAM wParam, LPARAM lParam) { - return DefWindowProcW(m_hWnd, msg, wParam, lParam); + return ::DefWindowProcW(m_hWnd, msg, wParam, lParam); } -//////////////////////////////////////// +//////////////////////////////////////// TTCDialog *TTCDialog::pseudoPtr; Modified: trunk/teraterm/common/tmfc.h =================================================================== --- trunk/teraterm/common/tmfc.h 2021-08-28 15:33:11 UTC (rev 9385) +++ trunk/teraterm/common/tmfc.h 2021-08-28 15:33:25 UTC (rev 9386) @@ -90,14 +90,6 @@ virtual ~TTCFrameWnd(); static TTCFrameWnd *pseudoPtr; static LRESULT CALLBACK ProcStub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp); - BOOL CreateA(HINSTANCE hInstance, - LPCSTR lpszClassName, - LPCSTR lpszWindowName, - DWORD dwStyle = WS_OVERLAPPEDWINDOW, - const RECT& rect = rectDefault, - HWND pParentWnd = NULL, - LPCTSTR lpszMenuName = NULL, - DWORD dwExStyle = 0); BOOL CreateW(HINSTANCE hInstance, LPCWSTR lpszClassName, LPCWSTR lpszWindowName, Modified: trunk/teraterm/common/tmfc_frame.cpp =================================================================== --- trunk/teraterm/common/tmfc_frame.cpp 2021-08-28 15:33:11 UTC (rev 9385) +++ trunk/teraterm/common/tmfc_frame.cpp 2021-08-28 15:33:25 UTC (rev 9386) @@ -53,41 +53,6 @@ { } -BOOL TTCFrameWnd::CreateA( - HINSTANCE hInstance, - LPCSTR lpszClassName, - LPCSTR lpszWindowName, - DWORD dwStyle, - const RECT& rect, - HWND hParentWnd, - LPCTSTR lpszMenuName, - DWORD dwExStyle) -{ - m_hInst = hInstance; - m_hParentWnd = hParentWnd; - pseudoPtr = this; - HWND hWnd = ::CreateWindowEx( - WS_EX_OVERLAPPEDWINDOW, - lpszClassName, - lpszWindowName, - dwStyle, - rect.left, rect.top, - rect.right - rect.left, rect.bottom - rect.top, - hParentWnd, - nullptr, - hInstance, - nullptr); - pseudoPtr = nullptr; - if (hWnd == nullptr) { - OutputDebugPrintf("CreateWindow %d\n", GetLastError()); - return FALSE; - } else { - m_hWnd = hWnd; - SetWindowLongPtr(GWLP_USERDATA, (LONG_PTR)this); - return TRUE; - } -} - BOOL TTCFrameWnd::CreateW( HINSTANCE hInstance, LPCWSTR lpszClassName, Modified: trunk/teraterm/common/tmfc_property.cpp =================================================================== --- trunk/teraterm/common/tmfc_property.cpp 2021-08-28 15:33:11 UTC (rev 9385) +++ trunk/teraterm/common/tmfc_property.cpp 2021-08-28 15:33:25 UTC (rev 9386) @@ -86,7 +86,7 @@ HBRUSH TTCPropertyPage::OnCtlColor(HDC hDC, HWND hWnd) { - return (HBRUSH)::DefWindowProc(m_hWnd, WM_CTLCOLORSTATIC, (WPARAM)hDC, (LPARAM)hWnd); + return (HBRUSH)::DefWindowProcW(m_hWnd, WM_CTLCOLORSTATIC, (WPARAM)hDC, (LPARAM)hWnd); } void TTCPropertyPage::OnHelp() Modified: trunk/teraterm/layer_for_unicode/README.md =================================================================== --- trunk/teraterm/layer_for_unicode/README.md 2021-08-28 15:33:11 UTC (rev 9385) +++ trunk/teraterm/layer_for_unicode/README.md 2021-08-28 15:33:25 UTC (rev 9386) @@ -2,10 +2,4 @@ ================= - Unicode API を持たない9x系用 -- Unicode API を ANSI API でエミュレーションする - -## 準備 - -- linuxでは nasm パッケージが必要 - `apt-get install nasm` - +- [layer_for_unicode.md](layer_for_unicode.md)参照 Modified: trunk/teraterm/layer_for_unicode/init_ptr.cpp =================================================================== --- trunk/teraterm/layer_for_unicode/init_ptr.cpp 2021-08-28 15:33:11 UTC (rev 9385) +++ trunk/teraterm/layer_for_unicode/init_ptr.cpp 2021-08-28 15:33:25 UTC (rev 9386) @@ -30,9 +30,13 @@ #include "codeconv.h" +// #define ALWAYS_ANSI 1 + static bool IsWindowsNTKernel(void) { -#if defined(_MSC_VER) && _MSC_VER > 1400 +#if ALWAYS_ANSI + return false; +#elif defined(_MSC_VER) && _MSC_VER > 1400 // VS2005\x82\xE6\x82肠\x82\xBD\x82炵\x82\xA2\x8Fꍇ\x82́ANT\x82݂̂\xF0\x83^\x81[\x83Q\x83b\x83g\x82Ƃ\xB7\x82\xE9 return true; #else Modified: trunk/teraterm/layer_for_unicode/layer_for_unicode.cpp =================================================================== --- trunk/teraterm/layer_for_unicode/layer_for_unicode.cpp 2021-08-28 15:33:11 UTC (rev 9385) +++ trunk/teraterm/layer_for_unicode/layer_for_unicode.cpp 2021-08-28 15:33:25 UTC (rev 9386) @@ -781,3 +781,37 @@ free(lpPrefixStringA); return r; } + +LRESULT WINAPI _DefWindowProcW(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) +{ + return DefWindowProcA(hWnd, Msg, wParam, lParam); +} + +BOOL WINAPI _ModifyMenuW(HMENU hMnu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem) +{ + char *lpNewItemA = ToCharW(lpNewItem); + BOOL r = ModifyMenuA(hMnu, uPosition, uFlags, uIDNewItem, lpNewItemA); + free(lpNewItemA); + return r; +} + +int WINAPI _GetMenuStringW(HMENU hMenu, UINT uIDItem, LPWSTR lpString, int cchMax, UINT flags) +{ + int len = GetMenuStringA(hMenu, uIDItem, NULL, 0, flags); + if (len == 0) { + return 0; + } + len++; // for '\0' + char *strA = (char* )malloc(len); + int r = GetMenuStringA(hMenu, uIDItem, strA, len, flags); + if (r == 0) { + free(strA); + return 0; + } + wchar_t *strW = ToWcharA(strA); + wcsncpy_s(lpString, cchMax, strW, _TRUNCATE); + len = wcslen(lpString); + free(strW); + free(strA); + return len; +} Modified: trunk/teraterm/layer_for_unicode/layer_for_unicode.h =================================================================== --- trunk/teraterm/layer_for_unicode/layer_for_unicode.h 2021-08-28 15:33:11 UTC (rev 9385) +++ trunk/teraterm/layer_for_unicode/layer_for_unicode.h 2021-08-28 15:33:25 UTC (rev 9386) @@ -42,6 +42,7 @@ extern "C" { #endif +// user32.dll BOOL WINAPI _SetWindowTextW(HWND hWnd, LPCWSTR lpString); BOOL WINAPI _SetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPCWSTR lpString); UINT WINAPI _GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int cchMax); @@ -62,6 +63,9 @@ LONG_PTR WINAPI _GetWindowLongPtrW(HWND hWnd, int nIndex); LRESULT WINAPI _CallWindowProcW(WNDPROC lpPrevWndFunc, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); int WINAPI _DrawTextW(HDC hdc, LPCWSTR lpchText, int cchText, LPRECT lprc, UINT format); +LRESULT WINAPI _DefWindowProcW(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); +BOOL WINAPI _ModifyMenuW(HMENU hMnu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem); +int WINAPI _GetMenuStringW(HMENU hMenu, UINT uIDItem, LPWSTR lpString, int cchMax, UINT flags); // kernel32.dll DWORD WINAPI _GetFileAttributesW(LPCWSTR lpFileName); Modified: trunk/teraterm/layer_for_unicode/layer_for_unicode.v8.vcproj =================================================================== --- trunk/teraterm/layer_for_unicode/layer_for_unicode.v8.vcproj 2021-08-28 15:33:11 UTC (rev 9385) +++ trunk/teraterm/layer_for_unicode/layer_for_unicode.v8.vcproj 2021-08-28 15:33:25 UTC (rev 9386) @@ -179,6 +179,10 @@ > </File> <File + RelativePath=".\DefWindowProcW.obj" + > + </File> + <File RelativePath=".\DeleteFileW.obj" > </File> @@ -219,6 +223,10 @@ > </File> <File + RelativePath=".\GetMenuStringW.obj" + > + </File> + <File RelativePath=".\GetModuleFileNameW.obj" > </File> @@ -279,6 +287,10 @@ > </File> <File + RelativePath=".\ModifyMenuW.obj" + > + </File> + <File RelativePath=".\MoveFileW.obj" > </File> Modified: trunk/teraterm/layer_for_unicode/symbol_list.txt =================================================================== --- trunk/teraterm/layer_for_unicode/symbol_list.txt 2021-08-28 15:33:11 UTC (rev 9385) +++ trunk/teraterm/layer_for_unicode/symbol_list.txt 2021-08-28 15:33:25 UTC (rev 9386) @@ -16,6 +16,9 @@ user32 SetWindowLongW @ 12 user32 GetWindowLongW @ 8 user32 DrawTextW @ 20 +user32 DefWindowProcW @ 16 +user32 ModifyMenuW @ 20 +user32 GetMenuStringW @ 20 kernel32 GetFileAttributesW @ 4 kernel32 GetModuleFileNameW @ 12