From 8212d55c39b6dc9c1f7b96e1d989567dcaa81780 Mon Sep 17 00:00:00 2001 From: Kohki Akikaze <67105596+kazasaku@users.noreply.github.com> Date: Sun, 2 Jan 2022 10:22:54 +0900 Subject: [PATCH 1/4] =?UTF-8?q?=E3=83=80=E3=82=A4=E3=82=A2=E3=83=AD?= =?UTF-8?q?=E3=82=B0=E3=81=AE=E4=BD=8D=E7=BD=AE=E3=81=A8=E3=82=B5=E3=82=A4?= =?UTF-8?q?=E3=82=BA=E3=82=92=E8=A8=98=E6=86=B6=E3=81=99=E3=82=8B=E5=87=A6?= =?UTF-8?q?=E7=90=86=E3=82=92=E8=A3=9C=E5=AE=8C=E5=80=99=E8=A3=9C=E3=83=80?= =?UTF-8?q?=E3=82=A4=E3=82=A2=E3=83=AD=E3=82=B0=E3=81=AB=E9=99=90=E3=81=A3?= =?UTF-8?q?=E3=81=A6=E5=BE=A9=E5=85=83=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sakura_core/CHokanMgr.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sakura_core/CHokanMgr.cpp b/sakura_core/CHokanMgr.cpp index ac271a81e1..e361aa997d 100644 --- a/sakura_core/CHokanMgr.cpp +++ b/sakura_core/CHokanMgr.cpp @@ -483,6 +483,12 @@ BOOL CHokanMgr::OnSize( WPARAM wParam, LPARAM lParam ) POINT po; RECT rcDlg; + ::GetWindowRect(GetHwnd(), &rcDlg); + m_xPos = rcDlg.left; + m_xPos = rcDlg.top; + m_nWidth = rcDlg.right - rcDlg.left; + m_nHeight = rcDlg.bottom - rcDlg.top; + ::GetClientRect( GetHwnd(), &rcDlg ); nWidth = rcDlg.right - rcDlg.left; // width of client area nHeight = rcDlg.bottom - rcDlg.top; // height of client area From 62d06add280849ed77b4636a024fac8083d8d8ab Mon Sep 17 00:00:00 2001 From: Kohki Akikaze <67105596+kazasaku@users.noreply.github.com> Date: Sun, 2 Jan 2022 10:25:37 +0900 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BC=BC=E9=80=9A=E3=81=A3=E3=81=9F?= =?UTF-8?q?=E5=A4=89=E6=95=B0=E5=90=8D=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sakura_core/CHokanMgr.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sakura_core/CHokanMgr.cpp b/sakura_core/CHokanMgr.cpp index e361aa997d..5056137f0f 100644 --- a/sakura_core/CHokanMgr.cpp +++ b/sakura_core/CHokanMgr.cpp @@ -475,8 +475,6 @@ BOOL CHokanMgr::OnSize( WPARAM wParam, LPARAM lParam ) IDC_LIST_WORDS }; int nControls = _countof( Controls ); - int nWidth; - int nHeight; int i; RECT rc; HWND hwndCtrl; @@ -490,8 +488,8 @@ BOOL CHokanMgr::OnSize( WPARAM wParam, LPARAM lParam ) m_nHeight = rcDlg.bottom - rcDlg.top; ::GetClientRect( GetHwnd(), &rcDlg ); - nWidth = rcDlg.right - rcDlg.left; // width of client area - nHeight = rcDlg.bottom - rcDlg.top; // height of client area + int nClientWidth = rcDlg.right - rcDlg.left; // width of client area + int nClientHeight = rcDlg.bottom - rcDlg.top; // height of client area // 2001/06/18 Start by asa-o: サイズ変更後の位置を保存 m_poWin.x = rcDlg.left - 4; @@ -518,8 +516,8 @@ BOOL CHokanMgr::OnSize( WPARAM wParam, LPARAM lParam ) NULL, rc.left, rc.top, - nWidth - rc.left * 2, - nHeight - rc.top * 2/* - 20*/, + nClientWidth - rc.left * 2, + nClientHeight - rc.top * 2/* - 20*/, SWP_NOOWNERZORDER | SWP_NOZORDER ); } From c8996484bb9d77455951610116e7c722f28eeb40 Mon Sep 17 00:00:00 2001 From: Kohki Akikaze <67105596+kazasaku@users.noreply.github.com> Date: Sun, 2 Jan 2022 10:27:05 +0900 Subject: [PATCH 3/4] =?UTF-8?q?=E3=83=AA=E3=82=B9=E3=83=88=E3=83=9C?= =?UTF-8?q?=E3=83=83=E3=82=AF=E3=82=B9=E3=81=8B=E3=82=89=E3=81=AE=E3=83=86?= =?UTF-8?q?=E3=82=AD=E3=82=B9=E3=83=88=E5=8F=96=E5=BE=97=E5=87=A6=E7=90=86?= =?UTF-8?q?=E3=81=A7=E5=8F=96=E3=82=8A=E3=81=93=E3=81=BC=E3=81=97=E3=81=8C?= =?UTF-8?q?=E7=94=9F=E3=81=98=E3=81=A6=E3=81=84=E3=82=8B=E3=81=AE=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sakura_core/apiwrap/StdControl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sakura_core/apiwrap/StdControl.cpp b/sakura_core/apiwrap/StdControl.cpp index 9fd2546770..e9a824351c 100644 --- a/sakura_core/apiwrap/StdControl.cpp +++ b/sakura_core/apiwrap/StdControl.cpp @@ -108,7 +108,7 @@ namespace ApiWrap{ } // アイテムテキストを設定するのに必要なバッファを確保する - strText.resize( cchRequired ); + strText.resize(cchRequired + 1); // ListBox_GetText() はコピーした文字数を返す。 const int actualCopied = ListBox_GetText( hList, nIndex, strText.data() ); From 978a9a5e26d92b1cf17cb521a4ec57adb8419f34 Mon Sep 17 00:00:00 2001 From: Kohki Akikaze <67105596+kazasaku@users.noreply.github.com> Date: Sun, 2 Jan 2022 10:28:04 +0900 Subject: [PATCH 4/4] =?UTF-8?q?ApiWrap::List=5FGetText()=E3=81=AE=E3=83=86?= =?UTF-8?q?=E3=82=B9=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/unittests/test-StdControl.cpp | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/unittests/test-StdControl.cpp b/tests/unittests/test-StdControl.cpp index 16045afae0..b2ec2eafb4 100644 --- a/tests/unittests/test-StdControl.cpp +++ b/tests/unittests/test-StdControl.cpp @@ -48,3 +48,35 @@ TEST(StdControl, Wnd_GetText2) DestroyWindow(hwnd); ASSERT_STREQ(s.c_str(), text); } + +TEST(StdControl, List_GetText) { + std::wstring text = L"0123456789abcdef"; + HWND list = ::CreateWindow(L"LISTBOX", nullptr, 0, 1, 1, 1, 1, nullptr, nullptr, nullptr, nullptr); + ApiWrap::List_AddString(list, text.c_str()); + ApiWrap::List_AddString(list, L""); + + std::wstring result1; + ASSERT_TRUE(ApiWrap::List_GetText(list, 0, result1)); + ASSERT_EQ(result1, text); + + result1.clear(); + ASSERT_TRUE(ApiWrap::List_GetText(list, 1, result1)); + ASSERT_TRUE(result1.empty()); + + ASSERT_FALSE(ApiWrap::List_GetText(list, 2, result1)); + + wchar_t result2[15]{}; + ASSERT_EQ(ApiWrap::List_GetText(list, 0, result2), LB_ERRSPACE); + + wchar_t result3[16]{}; + ASSERT_EQ(ApiWrap::List_GetText(list, 0, result3), LB_ERRSPACE); + + wchar_t result4[17]{}; + ASSERT_EQ(ApiWrap::List_GetText(list, 0, result4), text.length()); + ASSERT_STREQ(result4, text.c_str()); + + result4[0] = L'\0'; + ASSERT_EQ(ApiWrap::List_GetText(list, 2, result4), LB_ERR); + + ::DestroyWindow(list); +}