开发者

Auto scrolling control (WinAPI)?

开发者 https://www.devze.com 2023-01-01 13:43 出处:网络
In C# (.Net) you can create a panel and set autoscroll to true. you can then add controls into it, including beyond it\'s size, then it will scroll.

In C# (.Net) you can create a panel and set autoscroll to true. you can then add controls into it, including beyond it's size, then it will scroll.

I was wondering if when using the real WinAPI in c++ (not .net) how one could acheive the same result.

Must I keep track of the controls inside 开发者_Go百科and move them all when I scroll or is there an easier way like in C#.

Thanks


For an edit control (textbox), you can supply ES_AUTOVSCROLL when creating it via CreateWindow or CreateWindowEx. For adding a scrollbar for multiple controls in a window, I believe you have to do it manually. Write a function to sum the vertical height of all the child controls + spacing between them and if it's smaller than the window, add a vertical scroll bar, if it's larger, remove the vertical scroll bar (if it exists). Be sure to call this after adding/removing child controls and on window resize.

0

精彩评论

暂无评论...
验证码 换一张
取 消