Effect of MoveWindow in EnumChildWindows over listview inside the Dialog Box: Why ListView Header is not correctly scrolling

安稳与你 提交于 2019-12-01 13:36:55

From the remarks section of EnumChildWindows() reference:

If a child window has created child windows of its own, EnumChildWindows enumerates those windows as well.

So what you are doing here is scrolling the listview control and then also scroll the header control separately. The result is that the header control moves relative to the listview control as seen in your 2nd screenshot.

Instead you should only move immediate children of the dialog box, because grand children will move automatically with their parents.

Possible solutions:

  • Check parent/child relationship in the EnumChildWindows() callback (e. g. by calling GetParent() on the child and compare it with your dialog handle).
  • Instead of calling EnumChildWindows() and MoveWindow(), call ScrollWindowEx() with SW_SCROLLCHILDREN. This is the easiest way of implementing scrolling, so I would prefer this solution.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!