리스트 박스 안에 필요시 수평 스크롤이 생성되게 하는 방법을 알아보자~!

우선 VS2005 기준, 리스트박스의 속성에서 Horizontal Scroll 을 "true"로 설정한다.

사용자 삽입 이미지


그리고 아래 코드를 자신의 원하는 곳에 넣고 수정한다 ^^

// m_fdlist는 ListBox Control 변수.
CString str;
CSize sz;
CDC* pDc = m_fdlist.GetDC();
int dx = 0;

for ( int i=0; i < m_fdlist.GetCount(); i++)
{
m_fdlist.GetText(i, str);
sz = pDc->GetTextExtent(str);

if (sz.cx > dx)
dx = sz.cx;
}

m_fdlist.ReleaseDC(pDc);

// Set the horizontal extent so every character of all strings
// can be scrolled to.
m_fdlist.SetHorizontalExtent(dx);

크리에이티브 커먼즈 라이센스
Creative Commons License
2008/08/11 14:01 2008/08/11 14:01

이 글에는 트랙백을 보낼 수 없습니다

Leave a Comment
[로그인][오픈아이디란?]
1 ... 56 57 58 59 60 61 62 63 64 ... 78