Fog Creek Software
Discussion Board

Welcome! and rules

Joel on Software

Getting click location; superimposing images

I create a Windows Form with a scrollable panel in it, put a PictureBox in the panel, load a JPEG file into the picture box.

What I want to do is be able to double-click on the picture box to add a "blob" which sits above it (the idea is to mark visible features in the beautiful database with their latitude and longitude, so that I can map large amounts of the imagery into a single co-ordinate system).

So: two trivial questions.

1. How do I get the location within the PictureBox on which I've double-clicked? I don't understand what's stored in the EventArgs parameter of the DoubleClick event handler

2. how do I go about superimposing things that I plot myself onto the PictureBox? Do I want to put a transparent panel over the top of it and write the plotting into its Paint routine, or do I want to dispose of the PictureBox entirely and plot the picture myself in the Panel1.Paint event-handler; if so, how would I do that.

Tom Womack
Tuesday, November 19, 2002

Instead of the DoubleClick handler you may want to use MouseUp. You can do the following to get the position:

protected override void OnMouseUp(MouseEventArgs mea)
    if (mea.Button == MouseButtons.Left)
        Point pt = new Point(mea.X, mea.Y);

        // do stuff based on the pt



sean slavin
Tuesday, November 19, 2002

That was a good idea, but the MouseUp event doesn't seem to be behaving on the forms as it is claimed to in the manual. It supposedly has an e.Button.Clicks allowing you to distinguish single and double clicks, but this value never seems to be anything other than 1.

And the MouseWheel event never seems to be called!

Tom Womack
Wednesday, November 20, 2002

*  Recent Topics

*  Fog Creek Home