Skip to content

Commit

Permalink
Merge 978a9a5 into 0dd4391
Browse files Browse the repository at this point in the history
  • Loading branch information
Kohki Akikaze committed Jan 3, 2022
2 parents 0dd4391 + 978a9a5 commit b45144f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
16 changes: 10 additions & 6 deletions sakura_core/CHokanMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,17 +475,21 @@ BOOL CHokanMgr::OnSize( WPARAM wParam, LPARAM lParam )
IDC_LIST_WORDS
};
int nControls = _countof( Controls );
int nWidth;
int nHeight;
int i;
RECT rc;
HWND hwndCtrl;
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
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;
Expand All @@ -512,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
);
}
Expand Down
2 changes: 1 addition & 1 deletion sakura_core/apiwrap/StdControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ namespace ApiWrap{
}

// アイテムテキストを設定するのに必要なバッファを確保する
strText.resize( cchRequired );
strText.resize(cchRequired + 1);

// ListBox_GetText() はコピーした文字数を返す。
const int actualCopied = ListBox_GetText( hList, nIndex, strText.data() );
Expand Down
32 changes: 32 additions & 0 deletions tests/unittests/test-StdControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit b45144f

Please sign in to comment.