开发者

What's the overhead of TPanel over TBevel

开发者 https://www.devze.com 2023-04-06 15:32 出处:网络
I\'m working on a project where they essentially used TPanel for the only purpose of displaying a bevel (And maybe the design time convenience Panel have over Bevels).

I'm working on a project where they essentially used TPanel for the only purpose of displaying a bevel (And maybe the design time convenience Panel have over Bevels).

Ok, I know TPanel is heavier than TBevel. Amongs other things, each TPanel create a user objects, which is a limited resource.

What I would like to know, beyond user objects, what's the overhead of TPanel? Is it next to non-existent (Especially on modern day machines).

If you were working on such a system, would you suggest :

  • Going back and changing all TPanel to TBevel.
  • Say "Ok it was bad. Lets not do it again in the future" or
  • it's too smal开发者_如何转开发l a concern and the design time convenience is well worth it.


I wouldn't know if this design is intentional but, there's a slight navigational behavior difference when controls are grouped together in a window. If the focus is changed by arrow keys, after the one having the last tab order the first control will be focused (down/right), or vice-versa (up/left). IOW the focus will be wrapped in the parent. That's of course if any of the controls do not need the arrow keys.

Regarding the question, as it is already stated in the comments, apart from using up a count in an object pool, there're other resources associated with a window. It will also waste a few CPU cycles. There'll be one more level in the clipping chain or the messaging or keeping one more z-order list etc.. MSDN puts it as (I guess navigational aspect is being referred rather than visual partitioning):

For best performance, an application that needs to logically divide its main window should do so in the window procedure of the main window rather than by using child windows.


Nevertheless, as again already stated in the comments, most probably, no one will be able to tell the performance or resource difference caused by a few panels..


The correct answer is choice #3, so if that's the project's design approach, don't change it.

0

精彩评论

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

关注公众号