473,473 Members | 1,994 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

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

Oct 13 '06 #1
5 1727
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:
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
Oct 13 '06 #2
hi seth

sorry for late reply

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

thanks
sagar

Oct 24 '06 #3
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:
hi seth

sorry for late reply

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

thanks
sagar
Oct 24 '06 #4

hi seth
i m not able to figure out what is ProductionName

thanks
sagar

Oct 25 '06 #5
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:
hi seth
i m not able to figure out what is ProductionName

thanks
sagar
Oct 25 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Samantha | last post by:
Looking at the goto(xy) thread. Is there a way to get the X,Y position from a cursor click and then use the position to apply something like a water mark on an image at that position? Thanks,
6
by: lauren quantrell | last post by:
I have a command button on a continuous subform and I want the user to click it to open a small popup form that opens in the position of the mouse (which is the same as the position of the command...
3
by: harvie wang | last post by:
Hi, I create a system mouse hook, to get mouse position and click events. use GetDesktopWiindow and WindowFromPoint(x,y) to get window handle in my hook proc. Click mouse on desktop window and...
2
by: mmdst23 | last post by:
I'm working on a video player app, and I want to implement a trackbar that behaves like the one in Media Player, that is the cursor position moves to where the user clicked instead of moving in...
0
by: kloplop321 | last post by:
I found this code(vb only) and it does about the same thing(in vb, not vb .NET 2005) Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute...
1
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, I've panel in my windows form, and i want to get the exact mouse position when i double click. I used: Point p = this.panel1.PointToClient(Cursor.Position); but now, if i'm pointing on...
1
by: Randy | last post by:
I'm struggling with identifying whether a user has clicked on the left or right arrows within the MonthCalendar controls. I had a good suggestion to trap the mouse coordinates that the user clicks...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.