Created
February 8, 2016 16:39
-
-
Save nibasya/0206de16f789e7372e1b to your computer and use it in GitHub Desktop.
Example of CListBox function which holds scroll bar position during insertion/ removal of item
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void CDragDropListBox::SwapItem(int newIndex) | |
{ | |
DWORD data; | |
CString str; | |
int top; | |
SetRedraw(FALSE); | |
top = GetTopIndex(); | |
GetText(newIndex, str); | |
data = GetItemData(newIndex); | |
ASSERT(data != LB_ERR); | |
VERIFY(DeleteString(newIndex) != LB_ERR); | |
VERIFY(InsertString(m_TargetIndex, str) >= 0); | |
VERIFY(SetItemData(m_TargetIndex, data) != LB_ERR); | |
m_TargetIndex = newIndex; | |
SetTopIndex(top); | |
SetRedraw(TRUE); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment