Click here to Skip to main content
15,888,579 members
Home / Discussions / C#
   

C#

 
GeneralRe: Saving JPEG image Pin
Abdul Rahman Hamidy15-Jul-09 0:58
Abdul Rahman Hamidy15-Jul-09 0:58 
GeneralRe: Saving JPEG image Pin
Abdul Rahman Hamidy15-Jul-09 1:07
Abdul Rahman Hamidy15-Jul-09 1:07 
QuestionClosing COM-Interop Application Pin
Jürgen Jung14-Jul-09 20:11
Jürgen Jung14-Jul-09 20:11 
AnswerRe: Closing COM-Interop Application Pin
SeMartens14-Jul-09 21:03
SeMartens14-Jul-09 21:03 
GeneralRe: Closing COM-Interop Application Pin
Jürgen Jung14-Jul-09 21:08
Jürgen Jung14-Jul-09 21:08 
GeneralRe: Closing COM-Interop Application Pin
SeMartens14-Jul-09 21:20
SeMartens14-Jul-09 21:20 
GeneralRe: Closing COM-Interop Application Pin
Jürgen Jung14-Jul-09 21:23
Jürgen Jung14-Jul-09 21:23 
GeneralRe: Closing COM-Interop Application Pin
SeMartens14-Jul-09 21:29
SeMartens14-Jul-09 21:29 
GeneralRe: Closing COM-Interop Application Pin
Jürgen Jung14-Jul-09 21:56
Jürgen Jung14-Jul-09 21:56 
GeneralRe: Closing COM-Interop Application Pin
SeMartens14-Jul-09 22:03
SeMartens14-Jul-09 22:03 
Questionopenfiledilaog Pin
Satish Pai14-Jul-09 18:47
Satish Pai14-Jul-09 18:47 
AnswerRe: openfiledilaog Pin
BillWoodruff14-Jul-09 19:46
professionalBillWoodruff14-Jul-09 19:46 
GeneralRe: openfiledilaog Pin
Satish Pai14-Jul-09 20:07
Satish Pai14-Jul-09 20:07 
GeneralRe: openfiledilaog Pin
BillWoodruff14-Jul-09 22:09
professionalBillWoodruff14-Jul-09 22:09 
QuestionThe name 'SequentialSearch' does not exist in the current context. Pin
ReynaW122314-Jul-09 15:35
ReynaW122314-Jul-09 15:35 
AnswerRe: The name 'SequentialSearch' does not exist in the current context. Pin
Adam Maras14-Jul-09 15:46
Adam Maras14-Jul-09 15:46 
AnswerRe: The name 'SequentialSearch' does not exist in the current context. Pin
Adam R Harris14-Jul-09 15:49
Adam R Harris14-Jul-09 15:49 
GeneralRe: The name 'SequentialSearch' does not exist in the current context. Pin
Adam R Harris14-Jul-09 15:56
Adam R Harris14-Jul-09 15:56 
GeneralRe: The name 'SequentialSearch' does not exist in the current context. Pin
ReynaW122314-Jul-09 16:20
ReynaW122314-Jul-09 16:20 
QuestionImage coordinates within a picturebox Pin
Quake2Player14-Jul-09 15:19
Quake2Player14-Jul-09 15:19 
AnswerRe: Image coordinates within a picturebox Pin
Quake2Player14-Jul-09 15:37
Quake2Player14-Jul-09 15:37 
AnswerRe: Image coordinates within a picturebox Pin
krishy1928-Jul-09 5:53
krishy1928-Jul-09 5:53 
GeneralRe: Image coordinates within a picturebox Pin
Quake2Player28-Jul-09 7:28
Quake2Player28-Jul-09 7:28 
GeneralRe: Image coordinates within a picturebox Pin
Quake2Player28-Jul-09 7:44
Quake2Player28-Jul-09 7:44 
The thing is that the PictureBoxExtended brings only one event (MouseMoveOverImage), and I needed to create another (MouseClickedImage), but its really easy:

This is what it brings:
/// Handler for when the mouse moves over the image part of the picture box
public delegate void MouseMoveOverImageHandler(object sender, MouseEventArgs e);

/// Occurs when the mouse have moved over the image part of a picture box
public event MouseMoveOverImageHandler MouseMoveOverImage;


And I added the following
/// Handler for when the mouse clicks over the image part of the picture box
public delegate void MouseClickedImageHandler(object sender, MouseEventArgs e);

/// Occurs when the mouse have clicked over the image part of a picture box
public event MouseMoveOverImageHandler MouseClickedImage;


And then go down to the protected methods part and create a method that overrides the OnMouseClick method of the base class PictureBox,

so:
protected override void OnMouseClick(MouseEventArgs e)
{
    base.OnMouseClick(e);
    if (Image != null)
    {
        if (MouseClickedImage != null)
        {
            Point p = TranslatePointToImageCoordinates(e.Location);
            if (p.X >= 0 && p.X < Image.Width && p.Y >= 0 && p.Y < Image.Height)
            {
                MouseEventArgs ne = new MouseEventArgs(e.Button, e.Clicks, p.X, p.Y, e.Delta);
                MouseClickedImage(this, ne);
            }
        }
    }
}


And what I wrote here is just like the code within the OnMouseMove method... so I didn't had to think anything... Look that i'm calling to the base method also, so you can still use the MouseClick event normally

Cya!
GeneralRe: Image coordinates within a picturebox Pin
krishy1928-Jul-09 19:37
krishy1928-Jul-09 19:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.