There are more or less complex mathematical ways to do it but the quick and
All new articles provide code in C# and VB.NET.
"Mirek Endys" <Mirek Endys@discussions.microsoft.com> wrote in message
news:B196F7C1-3A17-45EC-AC65-234C9BDC9B09@microsoft.com...
> Hello Bob,
>
> I have read all the news about this problem...
>
> maybe.. I should to describe more my problem.
>
> I need to have UserControl, that is able to variable rotate...
> User control, that overrides OnPaint method.. like this..
>
> protected override void OnPaint(PaintEventArgs e)
> {
>
>
> base.OnPaint(e);
>
> Graphics g = e.Graphics;
> g.TranslateTransform(base.ClientSize.Width / 2.0F,
> base.ClientSize.Height / 2.0F);
> g.RotateTransform(5);
> g.DrawRectangle(new Pen(new SolidBrush(Color.Black)), new
> Rectangle(0, 0, base.Width - 1, base.Height - 1));
> }
>
> After rotation of my drawing, I need more place for this rectangle... can
> I
> get the value for new size of the base control?
> Or should I simple use two time longer size of the longer side of my
> drawing
> for the base control?
>
> My control has some initial Size, well.. but if I will rotate my drawing,
> how do I get the new required size of my control?
>
>
>
> "Bob Powell [MVP]" wrote:
>
>> You cannot rotate the window in which a control is contained. You can
>> rotate
>> the contents of a control but in cases of TextBox or indeed any control
>> that
>> is a wrapper round a win32 control you will be unsuccessful.
>>
>> To rotate the contents of a control you can use the Matrix to transform
>> any
>> completely custom control drawing.
>>
>> --
>> Bob Powell [MVP]
>> Visual C#, System.Drawing
>>
>> Find great Windows Forms articles in Windows Forms Tips and Tricks
>>
http://www.bobpowell.net/tipstricks.htm >>
>> Answer those GDI+ questions with the GDI+ FAQ
>>
http://www.bobpowell.net/faqmain.htm >>
>> All new articles provide code in C# and VB.NET.
>> Subscribe to the RSS feeds provided and never miss a new article.
>>
>>
>>
>>
>>
>> <news@endys.cz> wrote in message
>> news:eCbOwN2OFHA.2132@TK2MSFTNGP14.phx.gbl...
>> > Hello,
>> >
>> > i want to create my own control, but this control must be able to
>> > rotate.
>> > I know, how to overide OnPaint method.
>> > But..., for example I want to paint this control as rectangle with
>> > width
>> > 40,
>> > height 60 with variable rotation.
>> > How do I get new size of my control afer rotation?
>> >
>> > Is there way to get size of the affected rectangle by transformated
>> > drawing?
>> > (My controls will not be only rectangle... I want to create several
>> > types
>> > but i need to rotate them too)
>> >
>> > Thanks
>> >
>> > ME
>> >
>> >
>> >
>> >
>>
>>
>>