如何旋转“面板"类型的用户控件 [英] How to rotate a user control with type of 'Panel'

查看:62
本文介绍了如何旋转“面板"类型的用户控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows应用程序,有一个MainForm,这个主窗体
当然会包含多个用户控件("Panel"类型),
这些用户控件将包含图像或某些图形.

现在,我想旋转用户控件(例如,rotage 45度
从用户控制中心可以帮助您显示完整且
最有效的方法达到了吗?非常感谢.

注意:我的目的不是要旋转用户控件中的图像",我的

I have a windows application, there is a MainForm, this main form
will include several user controls (with ''Panel'' type), of course,
these user controls will include image or some graphic.

Now, I would like to rotate the user control (eg. rotage 45 degree
from center of user control, can you help to show a complete and
the most efficient way to reach it ? Thanks so much.

Note : My purpose is not to ''rotate image in user control'', my
purpose is to directly rotate the user control.

推荐答案

据我所知,您不能旋转通用用户控件;它只能旋转用户控件.此控件不是以这种方式设计的.

如果您想考虑其他想法,我可以告诉您,您可以轻松设计一个可以旋转的自定义控件.但是,这样的控件几乎不能成为标准控件的父级,并相应地旋转它们.但是,如果所有子控件均由您设计,则可以.如果要这样做,则可以通过处理事件Paint或覆盖虚拟方法OnPaint来定义整个控件的图形呈现.渲染方法应取决于您可以更改的角度.更改角度时,可以通过调用Control.Invalidate引起WM_PAINT处理.

我在上面提到过,如果要与孩子一起旋转,则所有子控件都应该是您的.这就是为什么:您应该能够将每个子代旋转相同的角度并移动它们的位置,以使所有子代像单个实体一样旋转.

—SA
To best of my knowledge, you cannot rotate the general purpose user control; this control is not designed this way.

If you want to consider alternative ideas, I can tell you that you can easily design a custom control which you can rotate that way. However, such control hardly can be a parent of standard control and rotate them accordingly. But if all child controls are designed by you, you can. If you want to do it this way, you can define graphical rendering of the whole control by handling the event Paint or overriding the virtual method OnPaint. The rendering method should depend on angle which you can change. When you change the angle, you can cause WM_PAINT processing by the call to Control.Invalidate.

I mentioned above, that if you want to rotate it with children, all child controls should be yours. Here is why: you should be able to rotate each of children by the same angle and move their location to make all together rotating like a single solid body.

—SA


这篇关于如何旋转“面板"类型的用户控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆