473,689 Members | 3,048 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Snap to grid functionality?? ?

I have a picture that I allow the user to move around and would like to
offer grid support like VB and other apps so that it will snap to the
nearest point.

How can I offer grid support so that the image will snap in place on
grid points like a commerical app? I am not sure how to implement that.

Anyone have any code?

Thanks,

Shane
Nov 21 '05 #1
2 4983
"SStory" <Th*******@TAKE OUTTHISSPAMBUST ERsofthome.net> wrote in message
news:%2******** *******@TK2MSFT NGP12.phx.gbl.. .
I have a picture that I allow the user to move around and would like to
offer grid support like VB and other apps so that it will snap to the
nearest point.

How can I offer grid support so that the image will snap in place on
grid points like a commerical app? I am not sure how to implement that.
This is a very expansive question. Can you fully describe what you want?
For example, do you want it to snap to the grid when the mouse moves, when
they click, drag, drop, etc...

In VS.NET, the basic concept is this (drag and snap):

- When the user drags an object, the new object location is snapped to the
nearest grid point as the object moves.
- The grid spacing and snap distance are defined in the user settings
- Visual cues are rendered so the user knows what the grid looks like (and
thus, how the objects will snap to it).

- How does an object go into motion (Not using drag-n-drop)?
- Set flag when mouse goes down over object
- When mouse moves, check to see if the flag is set, if so, then we are
draging
- Set flag off when mouse goes up over object

- How does the snap work?
- starting from the origin, points are determined based on the grid size
- when an object moves, the closest point must be determined
- (y2 - y1) / (x2 - x1) = Distance (if I remember my Algebra
correctly)
- where XY1 is the current point, and XY2 are the 8 possible
neighbors
- the objects location is then set to the nearest point

- Use ControlPaint.Dr awGrid( ) to draw the grid easily

Anyone have any code?


Nope, sorry.
HTH,
Jeremy
Nov 21 '05 #2
hmm..... interesting ideas...
yes I just have any number of pictures on a form in a picture box and the
user will click on one and drag it, although it won't be "drag and drop
there", just keeping track of the last mouse coord and making the adjustment
and redrawing.

When the user lets off the mousebutton I want it to snap.

Thanks for the input.... I will need to try the distance formula I guess and
make this work.
At least I have some idea now..

Shane
"Jeremy" <th***********@ hotmail.com> wrote in message
news:8j******** **********@twis ter.tampabay.rr .com...
"SStory" <Th*******@TAKE OUTTHISSPAMBUST ERsofthome.net> wrote in message
news:%2******** *******@TK2MSFT NGP12.phx.gbl.. .
I have a picture that I allow the user to move around and would like to
offer grid support like VB and other apps so that it will snap to the
nearest point.

How can I offer grid support so that the image will snap in place on
grid points like a commerical app? I am not sure how to implement that.
This is a very expansive question. Can you fully describe what you want?
For example, do you want it to snap to the grid when the mouse moves, when
they click, drag, drop, etc...

In VS.NET, the basic concept is this (drag and snap):

- When the user drags an object, the new object location is snapped to the
nearest grid point as the object moves.
- The grid spacing and snap distance are defined in the user settings
- Visual cues are rendered so the user knows what the grid looks like (and
thus, how the objects will snap to it).

- How does an object go into motion (Not using drag-n-drop)?
- Set flag when mouse goes down over object
- When mouse moves, check to see if the flag is set, if so, then we

are draging
- Set flag off when mouse goes up over object

- How does the snap work?
- starting from the origin, points are determined based on the grid size - when an object moves, the closest point must be determined
- (y2 - y1) / (x2 - x1) = Distance (if I remember my Algebra
correctly)
- where XY1 is the current point, and XY2 are the 8 possible
neighbors
- the objects location is then set to the nearest point

- Use ControlPaint.Dr awGrid( ) to draw the grid easily

Anyone have any code?


Nope, sorry.
HTH,
Jeremy

Nov 21 '05 #3

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

Similar topics

0
2830
by: Norm | last post by:
Does anyone know a fix to this problem? In the Windows Form Designer, I have set my snap-to grid setting to false. However, the controls on the form still snap to the grid. I have tried setting this and restarting VB.NET, but to no avail.
2
6827
by: Rhonda | last post by:
Using AccessXP I have lost snap to grid on my system. New or existing databases do not snap to grid for forms and reports in design view. Anyone have an idea on how to get it back?? Thanks. Rhonda
6
1741
by: MLH | last post by:
You know, snap to grid when dragging a new command button or other object? If you used autocad (command line DOS) YOU know exactly what I mean. I want to size my objects - not be forced to snap to the grid.
1
5496
by: Michel Racicot | last post by:
I know that this post don't really belong to this newsgroup, but I can't find any better... I'm currently using Microsoft Visual C# 2005 Express Edition Beta and I can't find the "snap to grid" feature in the form designer. Is this available yet? Will it be? Thank you
1
1573
by: Rob Richardson | last post by:
Greetings! I see from the group archives that a lot of people don't like how Snap to Grid works when placing controls on forms. I am now among that number. When I had the Windows Forms Designer option for snap to grid set to False and the form's SnapToGrid and DrawGrid properties left at their default settings, I could hold down Ctrl and use the arrow keys and my control would move one pixel in the desired direction. But when I used...
1
1716
by: Sam | last post by:
Hi guys I'm writing a small drawing program which has "snap to grid" mode and I want to display something (some kind of shapes for example a small square or circle which indicate the current snap point of my mouse) but I have no success so far. I tried controlpain.drawreversibleframe method to draw a tiny square to indicate my current snap point of my mouse as it moves on my grid points; and this somwhat gives me what I want. The...
1
2327
by: Marc | last post by:
Hi, Anyone know how I can have my drag and drop form controls 'snap' to a grid like in windows desktop?
4
2199
by: MangroveRoot | last post by:
A few years ago, I worked on a project in which I designed some tables, queries, forms, and reports. I'm reasonably certain that when I was designing the forms for that project, I set the snap-to grid to something like 1/16", or 1/10", or 1/8" -- enough so that it was obvious that the form elements were nicely lined up (and nicely spaced), but nothing so widely spaced as 1 whole inch apart (origin to origin). Now, however, I'm trying...
0
8594
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9076
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7621
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6454
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5810
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4547
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2965
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 we have to send another system
2
2219
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1952
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.