Click here to Skip to main content
15,881,380 members
Home / Discussions / C#
   

C#

 
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 
QuestionThe viewable portion of items in a ListBox Pin
GavinSV14-Jul-09 12:59
GavinSV14-Jul-09 12:59 
AnswerRe: The viewable portion of items in a ListBox [modified] Pin
Henry Minute14-Jul-09 13:08
Henry Minute14-Jul-09 13:08 
GeneralRe: The viewable portion of items in a ListBox Pin
GavinSV14-Jul-09 16:24
GavinSV14-Jul-09 16:24 
QuestionWhy is my bitmap file smaller than it should be ? Pin
Paul Carr14-Jul-09 11:47
Paul Carr14-Jul-09 11:47 
AnswerRe: Why is my bitmap file smaller than it should be ? Pin
Christian Graus14-Jul-09 11:58
protectorChristian Graus14-Jul-09 11:58 
GeneralRe: Why is my bitmap file smaller than it should be ? Pin
Paul Carr14-Jul-09 12:11
Paul Carr14-Jul-09 12:11 
GeneralRe: Why is my bitmap file smaller than it should be ? Pin
Paul Carr14-Jul-09 12:13
Paul Carr14-Jul-09 12:13 
GeneralRe: Why is my bitmap file smaller than it should be ? Pin
Paul Carr14-Jul-09 12:17
Paul Carr14-Jul-09 12:17 
GeneralRe: Why is my bitmap file smaller than it should be ? Pin
harold aptroot14-Jul-09 12:20
harold aptroot14-Jul-09 12:20 
GeneralRe: Why is my bitmap file smaller than it should be ? Pin
harold aptroot14-Jul-09 12:19
harold aptroot14-Jul-09 12:19 
GeneralRe: Why is my bitmap file smaller than it should be ? Pin
Christian Graus14-Jul-09 15:17
protectorChristian Graus14-Jul-09 15:17 
Questionusing statements and IDisposable Pin
saxisa14-Jul-09 11:38
saxisa14-Jul-09 11:38 
AnswerRe: using statements and IDisposable Pin
Christian Graus14-Jul-09 11:59
protectorChristian Graus14-Jul-09 11:59 
AnswerRe: using statements and IDisposable Pin
PIEBALDconsult14-Jul-09 17:09
mvePIEBALDconsult14-Jul-09 17:09 
Questionwork with webBrowser properties? Pin
mr.mohsen14-Jul-09 10:16
mr.mohsen14-Jul-09 10:16 
AnswerRe: work with webBrowser properties? Pin
Adam R Harris14-Jul-09 10:26
Adam R Harris14-Jul-09 10:26 

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.