如何将Delphi TPageControl“选项卡索引”转换为“选项卡索引”到“页面索引”?
我正在使用 TPageControl,其中某些页面不可见。
这打破了 TabIndex 和 ActivePageIndex 属性的正常 1:1 映射。
在大多数地方,我可以使用 ActivePageIndex(或 ActivePage 本身)来获取当前页面,但我想要一个动态工具提示提示,它要求我确定哪个页面与特定选项卡索引关联。
如果我调用 pageControl.IndexOfTabAt(X, Y),我会得到一个选项卡索引,但我不能直接将其用作 Pages[] 数组的索引,因为某些页面选项卡不可见。
我可以显式地遍历页面,忽略可见的页面,但感觉 VCL 中应该有一些东西已经为我做到了这一点......?
I'm using a TPageControl, where certain pages are not visible.
This breaks the normal 1:1 mapping of the TabIndex and ActivePageIndex properties.
In most places I can use ActivePageIndex (or ActivePage itself) to get the current page, but I want a dynamic tooltip hint which requires me to determine which page is associated with a specific tab index.
If I call pageControl.IndexOfTabAt(X, Y), I get a Tab Index back, but I can't directly use that as an index into the Pages[] array, as some page tabs aren't visible.
I could explicity iterate through the pages, ignoring the visible ones, but it feels like there should be something in the VCL that does this for me already...?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我在 TPageControl (ComCtrls.pas) 的源代码中查找,有一个私有方法:
可以执行您想要的操作。
但你不能调用它(D2007),所以(不幸的是)你必须复制代码。
I you look in the source for TPageControl (ComCtrls.pas), there is a private method:
that does what you want.
But you can't call it (D2007), so (unfortunately) you have to copy the code.
这个版本似乎有效:
This version seems to work:
这是一篇旧文章,涉及拖动和拖动。掉页。它有一些从(X,Y)位置获取页面索引的逻辑,也许你可以使用它。像这样的东西(未经测试):
Here is an old article that deals with dragging & dropping pages. It has some logic to obtain the index of a page from an (X, Y) position, perhaps you can use it. Something like this (untested):