带有嵌入式框架的 Toolbar2000 的大小问题
我有 Jordan Russel 的 Toolbar2000 工具栏,我在运行时使用嵌入式 TFrame 创建并停靠在应用程序主窗体上。该框架有一个嵌入式窗格,依次 包含其他面板和各种控件。所以结构是:
TTBDock
TTBToolbar
TFrame (align=alNone, Autosize=true)
TPanel 1 (align=alNone, Autosize=true)
TPanel 2 (align=alTop ,Autosize = false)
TPanel 3 (align=alTop ,Autosize = false)
TPanel 4 (align=alTop , Autosize = false)
这个想法是面板 2、3、4 的高度被明确调整,然后框架(以及工具栏)自动调整大小以适应新的尺寸。
它工作正常,只是工具栏第一次显示在应用程序主窗体上时,工具栏的大小是错误的。如果我强制调整工具栏的大小 点(例如,通过单击鼠标再次明确调整 TPanel 高度的大小)它是正确的。我尝试调用例程两次设置大小,调用 Update、Application.ProcessMessages、ReAlign - 除了让主窗体绘制然后再次手动执行调整大小之外,似乎没有任何效果。
如果我在调整大小例程结束时中断并检查面板大小和框架大小,它们是正确的,但工具栏大小不是,所以第一次显示时,框架部分显示在错误大小的工具栏中。它紧随另一次调用大小调整例程之后出现,但仅在主窗体自行绘制之后出现。
我可以拼凑出一些令人讨厌的东西,比如在计时器到期后明确调整面板大小,但我宁愿从根源上解决问题。
关于为什么会发生(或不发生)这种情况有什么想法吗?
I have Jordan Russel's Toolbar2000 toolbars that I create at runtime with an embedded TFrame and dock on the application main form. This frame has an embedded pane that in turn
contains other panels and various controls. So the structure is:
TTBDock
TTBToolbar
TFrame (align=alNone, Autosize=true)
TPanel 1 (align=alNone, Autosize=true)
TPanel 2 (align=alTop ,Autosize = false)
TPanel 3 (align=alTop ,Autosize = false)
TPanel 4 (align=alTop , Autosize = false)
The idea is that panels 2, 3, 4 have their heights sized explicitly and the frame (and hence the toolbar) then resizes automatically to accommodate the new size.
It works fine except that the size of the toolbar is wrong the first time the toolbar is shown docked on the application main form. If I force a resize of the toolbar at that
point (e.g. by explicitly resizing the TPanel heights again from a mouse click) it comes right. I've tried calling the routine to set the size twice, calling Update, Application.ProcessMessages, ReAlign - nothing seems to work except letting the main form paint and then performing the resize manually again.
If I break at the end of the resize routine and inspect the panel size and frame size, they are correct, but the toolbar size is not, so the first time it shows, the frame is partially shown in a wrong-sized toolbar. It comes right after another call to the sizing routine, but only after the main form has painted itself.
I could kludge up something nasty like explicitly resizing the panels after a timer expires but I'd rather solve the problem at it's source.
Any ideas as to why this might be happening (or not happening)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
嗯,这并不能从根本上解决问题,但可以是一个快速解决方案。在显示表单之前浮动栏一次将强制它计算所有控件对齐方式,而停靠它会强制停靠执行相同的操作。像这样:
Well, this is not solving the problem at its source but could be a quick fix. Floating the bar once before your form is shown would force it to calculate all control alignment and docking it would force the dock to do the same. Like this:
经过一番咬牙切齿,我解决了这个问题。该问题是由于当分配给 Control.Font.Height 时,控件的 Font 属性和控件的 Canvas 的 Font 属性不会立即对齐。计算框架内面板高度的部分代码在我分配给它之后使用了字体高度。我需要补充一点:
无论如何,感谢您的兴趣和帮助。
(答案和评论被投票因为……好吧,因为我是一个好人。)
After much gnashing of teeth, I solved this. The problem resulted from the fact that the Font properties of a control and of a Control's Canvas do not become aligned straight away when one assigns to Control.Font.Height. Part of the code that calculated the height of the panels within the frame used the font height after I had assigned to it. I needed to add:
Thanks for your interest and help anyway.
(answers and comments voted up because.. well, because I'm a nice guy.)