all groups > dotnet windows forms designtime > february 2006 >
You're in the

dotnet windows forms designtime

group:

Drawing on View control of DesignSurface


Drawing on View control of DesignSurface Fitim Skenderi
2/20/2006 12:00:00 AM
dotnet windows forms designtime: Hi,

I am trying to draw a custom image to the View Control of DesignSurface but
without any success. I have tried by capturing Graphics from window handle
of View control (Graphics.FromHwnd) but without any success. I have also
tried to set BackgroundImage but again without success.

Can anyone please help

Fitim Skenderi

Re: Drawing on View control of DesignSurface jokiz
2/20/2006 7:52:50 PM
Have you tried overriding OnPaintAdornments method of your
ControlDesigner?
Re: Drawing on View control of DesignSurface Fitim Skenderi
2/21/2006 12:00:00 AM
Hi,

I need to draw on the design surface itself, not on the control. Basically I
am trying to do something similar to Visual Studio when you create a PDA
application, the PDA image appears in the design surface.

Thanks


Fitim Skenderi


[quoted text, click to view]

Re: Drawing on View control of DesignSurface jetan NO[at]SPAM online.microsoft.com (
2/22/2006 12:00:00 AM
Hi Fitim,

Thanks for your feedback.

Based on my understanding, you want to draw on the design surface.

Regarding this, we can first get the DesignSurface.View control, then draw
on its child control. Sample code like this:

private void Form1_Load(object sender, EventArgs e)
{
DesignSurface surface = new DesignSurface();
surface.BeginLoad(typeof(Form));
Control view = (Control)surface.View;
view.Controls[0].Paint += new PaintEventHandler(view_Paint);
view.Dock = DockStyle.Fill;
view.Controls[0].BackgroundImage = Image.FromFile("c:\\test.jpg");
this.Controls.Add(view);
}

void view_Paint(object sender, PaintEventArgs e)
{
//throw new Exception("The method or operation is not implemented.");
e.Graphics.DrawLine(new Pen(new SolidBrush(Color.Red)), 0, 0,
this.Width, this.Height);
}

Hope this helps!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Re: Drawing on View control of DesignSurface Fitim Skenderi
2/22/2006 12:00:00 AM
Hi Jeffrey,

THANK YOU VERYYYY MUCH !!!!

It is working as a treat.

THANKS, THANKS, THANKS :)

I have spent at least a week to try and make it work.

Fitim


[quoted text, click to view]

Re: Drawing on View control of DesignSurface jetan NO[at]SPAM online.microsoft.com (
2/23/2006 1:18:21 AM
You are welcome :-). If you need any further help, please feel free to
post. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
AddThis Social Bookmark Button