Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / February 2006

Tip: Looking for answers? Try searching our database.

Drawing on View control of DesignSurface

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Fitim Skenderi - 20 Feb 2006 10:35 GMT
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
jokiz - 21 Feb 2006 03:52 GMT
Have you tried overriding OnPaintAdornments method of your
ControlDesigner?
Fitim Skenderi - 21 Feb 2006 09:39 GMT
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

> Have you tried overriding OnPaintAdornments method of your
> ControlDesigner?
"Jeffrey Tan[MSFT]" - 22 Feb 2006 06:18 GMT
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
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Fitim Skenderi - 22 Feb 2006 09:51 GMT
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

> Hi Fitim,
>
[quoted text clipped - 30 lines]
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
"Jeffrey Tan[MSFT]" - 23 Feb 2006 01:18 GMT
You are welcome :-). If you need any further help, please feel free to
post. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.