Reputation: 2176
In some environments, like the Office macros environment, or Visual Studio, there are designers which can show a preview, which you can drag and drop items on to it. They are rendered using the same theme as the rest of the OS. I'm not trying to create an MDI, but rather draw a windows form in the same form.
Example:
In C#, how would I go about implementing a similar functionality?
Upvotes: 1
Views: 1061
Reputation: 54453
You can use this nice method to make a form2 draw itself onto a target bitmap:
form2.DrawToBitmap(tagetBmp, new Rectangle(0, 0, form2.Size.Width, form2.Size.Height));
To make it work you would create a form to show and call this method on it. It will include all its controls etc but if you want it empty you would need just an empty form of the right proportions..
Here is a test, which draws a window onto itself:
private void button1_Click(object sender, EventArgs e)
{
Size oldSize = this.Size;
Size newSize = new Size(this.Width / 4, this.Height / 4);
Bitmap targetBmp = new Bitmap(newSize.Width, newSize.Height);
this.Size = newSize;
button1.Hide();
this.DrawToBitmap(targetBmp, new Rectangle(Point.Empty, newSize));
this.Size = oldSize;
using (Graphics G = this.CreateGraphics())
{
G.DrawImage(targetBmp, 0, 0);
}
button1.Show();
}
Upvotes: 1
Reputation: 7210
Maybe you should have a look at this article: http://msdn.microsoft.com/en-us/magazine/cc163871.aspx
The article discusses:
Upvotes: 3