Re: sizing handles control
- From: David Thielen <thielen@xxxxxxxxxxxxx>
- Date: Mon, 30 Apr 2007 22:35:00 -0700
ok - thanks
--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com
Cubicle Wars - http://www.windwardreports.com/film.htm
"Bob Powell [MVP]" wrote:
PictureBox controls draw pictures that are placed in their Image property..
If you want to create an image editor then just derive a control from the
Control or ScrollableControl base class and build in the desired behaviours.
This way you have full control over the appearance of the object and don't
have to compromise to work around the intended behaviour of the original.
As a starting point you can use the source of my ZoomPicBox and build in
some mouse interaction from my "Backtrack the mouse" article. This will give
you a basic drawing canvas.
I have a commercial control that does the sizing squares thingy...
http://www.xraytools.net/productdetail.aspx?id=4
Otherwise, drawing the adornments and handling the mouse-clicks etc is
pretty much a manual job.
--
--
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.
"David Thielen" <thielen@xxxxxxxxxxxxx> wrote in message
news:086BF0B8-14B6-4D33-93B9-1F77B1CA728F@xxxxxxxxxxxxxxxx
Hi;
This is sort-of it and what you posted helped a lot. I am not sizing the
PictureBox control - I am sizing the image inside it.
At present I have the picture box set to fill a panel in my form and size
the image inside it. Would it be better to not set the picture box to fill
the panel and instead to be the size of the image and size the picture
box?
Also, I thought that there was a control that would draw a dashed
rectangle
with sizing squares at the corners and middle of each line. I think that
works better for what I am doing. Is there such a control?
--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com
Cubicle Wars - http://www.windwardreports.com/film.htm
"Linda Liu [MSFT]" wrote:
Hi Dave,
Based on my understanding, you'd like to display a bitmap on a PictureBox
and show a size grip on the right bottom corner of the PictureBox. When
the
user drags the size grip on the PictureBox, the PictureBox is resized. If
I'm off base, please feel free to let me know.
My solution is to draw the image and a size grid using the
ControlPaint.DrawSizeGrip method in the Paint event handler of the
PictureBox. To resize the PictureBox when the user drags the size grip on
the PictureBox, handle the MouseDown, MouseMove and MouseUp events of the
PictureBox.
The following is a sample. It requires that you add an image in the
project's resources and add a PictureBox on the form.
public partial class Form1 : Form
{
bool ismousedown = false;
public Form1()
{
InitializeComponent();
this.pictureBox1.Paint += new
PaintEventHandler(pictureBox1_Paint);
this.pictureBox1.MouseDown += new
MouseEventHandler(pictureBox1_MouseDown);
this.pictureBox1.MouseUp += new
MouseEventHandler(pictureBox1_MouseUp);
this.pictureBox1.MouseMove += new
MouseEventHandler(pictureBox1_MouseMove);
}
void pictureBox1_Paint(object sender, PaintEventArgs e)
{
Rectangle rect = new Rectangle(0,0,
this.pictureBox1.Width,this.pictureBox1.Height);
e.Graphics.DrawImage(Properties.Resources.Image1, rect);
ControlPaint.DrawSizeGrip(e.Graphics, SystemColors.Control,
rect.Width - 15,rect.Height -15,15,15);
}
void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (ismousedown)
{
this.pictureBox1.Width = e.X;
this.pictureBox1.Height = e.Y;
this.pictureBox1.Invalidate();
}
}
void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
ismousedown = false;
}
void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
if (Math.Abs(this.pictureBox1.Width - e.X) <= 15 &&
Math.Abs(this.pictureBox1.Height - e.Y) <= 15)
{
ismousedown = true;
}
}
}
Hope this helps.
If you have anything unclear, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent
issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each
follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
- References:
- RE: sizing handles control
- From: David Thielen
- Re: sizing handles control
- From: Bob Powell [MVP]
- RE: sizing handles control
- Prev by Date: Re: sizing handles control
- Next by Date: Re: Using CreateDesktop User32.dll method
- Previous by thread: Re: sizing handles control
- Next by thread: RE: sizing handles control
- Index(es):
Relevant Pages
|