0

i have made a list control and when i cliked on list then it goes to OnLvnItemchangedList1 twice.Can anyone tell me the reason and how to avoid this.

Suri
  • 3,287
  • 9
  • 45
  • 75

2 Answers2

1

It is called on deselect as well as on select, so when you click the item it deselects the previous item and selects the current item, thus calling it twice.

To check if it is selecting or deselecting check my answer to this question.

Community
  • 1
  • 1
djeidot
  • 4,542
  • 4
  • 42
  • 45
0

I am not sure why is happening, though there are some issues in some MFC controls. A workaround could be to define a global bool, initially false, and if the function is called you set it to true. Before you set the global to true you can check its value and if its true you set it false and return the function. Usually it happens to change functions linked with controls.

Sunscreen
  • 3,452
  • 8
  • 34
  • 40