The reason is that
OnLvnItemchangedList
is not called when changing the selection. It is called when changing the content by calling
SetItemText
in
onupbuutonclicked
. But when that is processed the selection is still on the old position and the button is not disabled.
So you might disable the button at the end of
onupbuutonclicked
when
item2 == 1
(but it looks like your posted code is for button down instead of button up because you are exchanging
item2
and
item2+1
).
You may also use a single call to enable / disable the button in
OnLvnItemchangedList
:
GetDlgItem(IDC_BUTTON_UP)->EnableWindow(row > 0);