473,406 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How can i know the mouse positioin on the form???

3
I wanna move mouse postioin(100, 100) on the form. So, I use SetCursorPos(100, 100). but, the position is not of the form. It's the position of My screen. I want to set mouse position 100, 100 of the form T_T.

Can I get the mouse position of the form?
May 6 '10 #1

✓ answered by tlhintoq

Just add your desired mouse-in-form position to the form's location.
The upper left corner is the form's location.

So if the form location is point { 840, 200 } add those to your target to get {940, 300}

5 1288
tlhintoq
3,525 Expert 2GB
Just add your desired mouse-in-form position to the form's location.
The upper left corner is the form's location.

So if the form location is point { 840, 200 } add those to your target to get {940, 300}
May 6 '10 #2
Phiru
3
That's pretty simple than I thought. ahah.
Thanks tlhintoq.
May 6 '10 #3
tlhintoq
3,525 Expert 2GB
I like simple. What was Scotty's line: The more than overhaul the plumbing the easier it is to stop up the drain.

I know there are some fancier methods using built-in .NET functions for converting screen position to form location etc. But I have seen too many such things fail on multi-monitor systems.

So I K*I*S*S
May 6 '10 #4
A best answer is given already. But if you want to get the cursor on (100, 100) on the screen, and next time you want it somewhere else.. You dont really need to add the form's location value. Do it like this. Use 2 textboxes(or nothing.) to write the position you want to get on the form.

dim ax as integer = val(100) + val(me.location.x)
dim ay as integer = val(100) + val(me.location.y)
setcursorpos(ax, az)

Now you can also change the 100's to textbox1.text and textbox2.text
May 8 '10 #5
tlhintoq
3,525 Expert 2GB
Shekoasinger: You just tried to say you don't need to get the form's location, then in your formula you use the form's location. (me.location ... hello)

Wake up a bit and have a cuppa before blurting things out like that.

The only difference here is that I didn't spell out the code, so that the O.P. had to work that out on his own - which is the goal with *help* versus doing it for someone, which does not help them in the long run.
May 8 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: VbUser25 | last post by:
hi, whats happening is i do a form post from a form "A", to a form "B" where it does some processing and then does a form.redirect to form "C"..where there is a link to the form "A". I only want...
5
by: MLH | last post by:
You know, mouse movements - that sort of thing. I would just like an easy way for a hidden form NOT having the focus to know if the app is just sitting there running by itself, all alone with no...
4
by: harrylmh | last post by:
Hi, I've really been struggling with this. How do I make a form resizable with FormBorderStyle = None? I've had problems trying to get the form to start resizing by following the mouse...
3
by: AinO | last post by:
Hi, (VS2003/c# - System.Windows.Forms) Is there a way to know (have an event triggered) if the mouse leaves a form, if this form's client area is completly covered with child controls ? I...
2
by: yxq | last post by:
Hi When a sub-Form are loading, how to know the sub-Form has been loaded to finish(all work end)? I wrote the code ********************************************* Me.Cursor =...
0
by: hmm | last post by:
Hi all I have two problems: Problem #1: I'm using a .NET Form with the property 'FormBorderStyle' set to 'None'. The idea is to completely cover the area of that Form with a UserControl. In...
1
by: gazelle04 | last post by:
I want to import a group of forms from another database and I want to know how to check if a form already existed in the current database.
6
by: =?Utf-8?B?bGpsZXZlbmQy?= | last post by:
I want to implement the following: If the user clicks on the border of a form, then I want to show a box around the form that represents the form's bounds. As the user moves the mouse only the...
2
by: LB | last post by:
How may i do to know if a form is already open ?? In vb6, i use Forms but i don't know how to do this in vbnet. Thank you!!!
3
VBWheaties
by: VBWheaties | last post by:
In vb.net, I want to allow a user to click and drag a form like what is supported when you click and drag a moveable forms title bar: you click and hold titlebar, then move the mouse, the form moves...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.