473,320 Members | 1,976 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,320 software developers and data experts.

Rectangle Marker

I'm trying to make a rectangle follow my mouse along the X axis.

For some reason, the rectangle toggle between two places on my form, both
somewhat proportional from where I first click, but neither in line with the
mouse pointer. It's as if at:
* one pixel X=how far the mouse has moved from the point it clicked, the
* next pixel X=current X position minus how far the mouse has moved.

Here's my code.

Private Sub rctMarker_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
If (Button And acLeftButton) 0 Then
rctMarker.Left = X
End If
End Sub

Am I doing this correctly, or am I supposed to reference to the forms X
reference?
Thanks in advance.
Dom
Mar 17 '08 #1
2 1575
DFS
Dominic Vella wrote:
I'm trying to make a rectangle follow my mouse along the X axis.

For some reason, the rectangle toggle between two places on my form,
both somewhat proportional from where I first click, but neither in
line with the mouse pointer. It's as if at:
* one pixel X=how far the mouse has moved from the point it clicked,
the * next pixel X=current X position minus how far the mouse has moved.

Here's my code.

Private Sub rctMarker_MouseMove(Button As Integer, Shift As Integer,
X As Single, Y As Single)
If (Button And acLeftButton) 0 Then
rctMarker.Left = X
End If
End Sub

Am I doing this correctly, or am I supposed to reference to the forms
X reference?

This should center the rectangle on your mouse, and move it as you want:

rctMarker.Left = rctMarker.Left + X - (0.5 * rctMarker.Width)
Mar 17 '08 #2
Ohhh, I'm supposed to re-reference to my rctMarker.Left. How interesting.

Thanks.
Dom

"DFS" <nospam@dfs_.comwrote in message
news:g9******************@bignews2.bellsouth.net.. .
Dominic Vella wrote:
>I'm trying to make a rectangle follow my mouse along the X axis.

For some reason, the rectangle toggle between two places on my form,
both somewhat proportional from where I first click, but neither in
line with the mouse pointer. It's as if at:
* one pixel X=how far the mouse has moved from the point it clicked,
the * next pixel X=current X position minus how far the mouse has moved.

Here's my code.

Private Sub rctMarker_MouseMove(Button As Integer, Shift As Integer,
X As Single, Y As Single)
If (Button And acLeftButton) 0 Then
rctMarker.Left = X
End If
End Sub

Am I doing this correctly, or am I supposed to reference to the forms
X reference?


This should center the rectangle on your mouse, and move it as you want:

rctMarker.Left = rctMarker.Left + X - (0.5 * rctMarker.Width)


Mar 17 '08 #3

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

Similar topics

25
by: Haines Brown | last post by:
I have a table with three columns, and I want the data in the first column to align left, while that in the remaining columns to align right: #testTable { text-align: right; } #leftcol {...
15
by: Steven T. Hatton | last post by:
The following may strike many of you as just plain silly, but it represents the kind of delelima I find myself in when trying to make a design decision. This really is a toy project written for...
6
by: kimos | last post by:
hi all, how to calculate the intersection of 2 rectangle a rectangle is the following: Rectangle makeRectangle (Point lowerLeft, Point upperRight) { Rectangle r;
3
by: | last post by:
I am having a hard time understanding the logic behind the Rectangle object. My problem has to do with the way the rectangle treats the "Width" property. For example, take the following rectangle...
1
by: Wannabe_Geek | last post by:
Do we have something in ASP.net like freemarker for java.(freemarker.sourceforge.net) The idea is to use simple HTML file as template for the site and replace the Marker tags with appropriate...
5
by: DazedAndConfused | last post by:
I have a rectangle around text that I want to fill in with color. I do not know the height of the rectangle until I actually go through and draw out the text. Is there a way of filling in the...
4
by: RobinS | last post by:
I am drawing a rectangle on a picture that has already been drawn on the graphics area (a user control). It works something like this: //in the MouseDown event m_isDragging = true; m_oldX =...
2
by: flymo | last post by:
Hello All, Hopefully this is the correct forum... I have some code that creates a text (dat) for a billing process created in Access2000, I add an Eof of Line marker to each line item and then...
1
by: kummu4help | last post by:
hi, i want to draw rectangle based on mousedrag event. if user dragging the mouse, then the rectangle on the applet should increase or decrease basing on current mouse coordinates. i have the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.