Home All Groups Group Topic Archive Search About

is there any way to find the position of mouse click on a form

Author
13 Oct 2006 2:28 PM
sagar
is there any way to find the position of mouse click on a form
actually the problem is i m having more than one controls on a form i
want to find which control is selected using mouse down

any help is fine for me

thanks

Author
13 Oct 2006 2:40 PM
rowe_newsgroups
> is there any way to find the position of mouse click on a form

Check the e.X and e.Y values generated by the form.mouseclick event.

> want to find which control is selected

If you want "global" handler then you could do a recursive search for
controls on the form, and use addhandler to map the control.GotFocus()
event to the method you want to handle the gotfocus events. Let me know
if you need some code.

Thanks,

Seth Rowe


sagar wrote:
Show quoteHide quote
> is there any way to find the position of mouse click on a form
> actually the problem is i m having more than one controls on a form i
> want to find which control is selected using mouse down
>
> any help is fine for me
>
> thanks
Author
24 Oct 2006 2:27 PM
sagar
hi seth

sorry for late reply

i ll be very thankful to u if u provide me the code

thanks
sagar
Author
24 Oct 2006 2:40 PM
rowe_newsgroups
Here you go - I wrote this in a hurry so be careful!

<pseudocode>

    Private Sub MapControls(ByVal container As
Windows.Forms.Control.ControlCollection)
        For Each c As Control In container
            AddHandler c.MouseDown, AddressOf HandleMouseDown
            If c.Controls.Count > 0 Then
                MapControls(c.Controls)
            End If
        Next
    End Sub

    Private Sub HandleMouseDown(ByVal sender As System.Object, ByVal e
As System.Windows.Forms.MouseEventArgs) Handles
ProductionName.MouseDown
        MsgBox("X:" & e.X & " Y:" & e.Y)
    End Sub

</pseudocode>

Thanks,

Seth Rowe


sagar wrote:
Show quoteHide quote
> hi seth
>
> sorry for late reply
>
> i ll be very thankful to u if u provide me the code
>
> thanks
> sagar
Author
25 Oct 2006 2:30 PM
sagar
hi seth
i m not able to figure out what is ProductionName

thanks
sagar
Author
25 Oct 2006 2:46 PM
rowe_newsgroups
> i m not able to figure out what is ProductionName

It's a textbox that lists the name of the Production Contact in the
project I was working on when you posted last! :-)

Anyways, just get rid of that entire handles statement - it shouldn't
be there. (at least I tagged the code as pseudocode). I just chose a
textbox on my form and selected the mouseclick event for in order to
autogenerate the code. Sorry about that!

Thanks,

Seth Rowe


sagar wrote:
Show quoteHide quote
> hi seth
> i m not able to figure out what is ProductionName
>
> thanks
> sagar