Re: sizing handles control



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.



.



Relevant Pages

  • Re: Help for hDC and textcontrol.coms ActiveX Control
    ... Microsoft Picture Clip Control v6 and the new error in both ... You're picturebox control would ... >> hDC Property to Text Control's PrintDevice Property. ... >> a device context for the Printer object and for each form and PictureBox ...
    (microsoft.public.fox.programmer.exchange)
  • Re: Help for hDC and textcontrol.coms ActiveX Control
    ... Windows handle or anything like that. ... You're picturebox control would need ... > hDC Property to Text Control's PrintDevice Property. ...
    (microsoft.public.fox.programmer.exchange)
  • Re: PictureBoxes and Charting
    ... It appears that the best way to add indicators to the bottom of my price ... charts is to actually add another PictureBox below the chart PictureBox ... I've always just dragged the control onto the ... array at run time using the Load and Unload ...
    (microsoft.public.vb.general.discussion)
  • Re: Appending one image to other
    ... I was using my own double-buffering, but so was the control too!! ... I have written a screensaver program and I noticed your FAQ ... >> image in its correct aspect ratio. ... >>> I have an image object which is to be shown in a picturebox. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: sizing handles control
    ... 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. ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.framework.windowsforms.controls)