[MFC] OnVScroll 의 nPos 파라미터의 사용제한
afx_msg void OnVScroll( UINT nSBCode, UINT nPos, CScrollBar* pScrollBar ); |
nPos
Contains the current scroll-box position if the scroll-bar code is SB_THUMBPOSITION or SB_THUMBTRACK; otherwise not used. Depending on the initial scroll range, nPos may be negative and should be cast to an int if necessary.
여기서 nPos 값이 32,767을 넘어버리면 음수로 들어오게 되어 난감할 때가 있습니다.
(int)로 type casing을 해도 음수이니..
왜 그런가 하고 찾아보니 아래와 같이 나와있더군요.
The difference between the values specified by nMinPos and nMaxPos must not be greater than 32,767. The default range for a scroll-bar control is empty (both nMinPos and nMaxPos are 0).
이럴 때는
SCROLLINFO scInfo;
scInfo.cbSize = sizeof(SCROLLINFO);
scInfo.fMask = SIF_RANGE;
GetScrollInfo(&scInfo);
이런식으로 스크롤바의 정보를 얻어와서
scInfo.nTrackPos를nPos 파라미터 대신 사용하시면 됩니다.
"프로그래밍 / TIP& Study" 분류의 다른 글
| [퀴즈] SQLite collate 문제 (0) | 2010/07/16 |
| [TIP] XP, Vista에서 CD/DVD롬이 보이지 않을 경우 (2) | 2009/08/05 |
| [C#] WinForm 에서 Docking 순서 변경하기 (0) | 2009/07/29 |
| [WPF] InkCanvas 사용하기 (2) | 2009/06/29 |
| [C#] Control Library 만들 때 TIP (0) | 2009/06/26 |
| [C#] 자연스럽게 Pen으로 그리기 (0) | 2009/06/23 |
| [WPF] Canvas의 Width, Height Binding (0) | 2009/06/23 |
| [C#] DateTime으로 7일 후는 어떻게? (0) | 2009/06/23 |
프로그래밍/TIP& Study
2007/01/15 22:14

댓글을 달아 주세요