Transforming Controls?

G

Guest

Hi,
I'm trying to draw a standard windows forms control onto a form with a
transformation. Before drawing the control I'm applying a world
transformation to the graphics object, but the results seem to be
unpredictable. Depending on the control my transformation seems to be
applied incompletely. For example, buttons are translated as I'd expect but
not scaled or rotated.

The easiest way to demonstrate this is to extend Bob Powell's excellent
animation demo from http://www.bobpowell.net/animation.htm

To see what I mean, add this class to Form1.cs in the demo:

public class ButtonShape : Shape
{
private class MyButton : Button
{
public void Draw(Graphics g)
{
PaintEventArgs args = new PaintEventArgs(g, new Rectangle(0,
0, Width, Height));
base.OnPaintBackground(args);
base.OnPaint(args);
}
}

private MyButton mb = new MyButton();
public override void RenderObject(Graphics g)
{
mb.Draw(g);
}
}

And modify the Form1 contstructor to add some ButtonShapes:
switch(r.Next(4))
{
// ... snip ....
case 3:
s = new ButtonShape();
break;
// ...
}

After making these modifications I get some buttons floating around with the
other shapes, but they do not rotate as the others do.

Anyone have any suggestions? Is it just not possible to apply a
transformation to a control because of the way they are drawn?

Thanks,
-Merit Wilkinson
 
B

Bob Powell [MVP]

Controls are generally windows wrapped by a bit of .net wizardry. They are
just Win32 things.

To change the orientation of a whole window is a driver-level thing and not
available to the ordinary developer.


--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top