02-02-2012 04:15 PM
I'm looking to find or make a custom control (or simple subVI) that will appear as a 100x100 unit grid and allow me to draw a line from one point to another on that grid. It will then output the (x,y) of the starting and end point of that line on the grid. Any help or ideas?
Thanks,
Steve
LabVIEW 2009 SP1
Solved! Go to Solution.
02-02-2012 04:27 PM
Check out XControls
02-03-2012 03:40 AM
What you basically want is a loop with an event structure where you process Mouse Down, Move and Up events for your controls. There are any number of ways of implementing something like this, but this one will probably be the simplest:
If you want to simplify things somewhat, you can also use the timeout event instead of the Mouse Move event to draw the line, but then you'll need to keep the timeout value in a shift register and reset it to -1 (no timeout) when the Mouse Up event happens.
I would also suggest processing Mouse Enter and Leave events to change the cursor and cancel if the user leaves in the middle of dragging.
02-03-2012 03:42 PM
Thank you for the guidance, as I think this has taken me down a path that will be successful for my needs. One obstacle that I'm having a tough time working around however, is the pixel coordinates for the Point to Row Column feature. When I set the Multicolumn Listbox position to 240,240 let's say, it will position it that far from the origin of the VI window, but when I use the mouse and Point to Row Column, it is translating the pixel position relative to the upper left corner of the computer monitor, not the Listbox. One solution I have in mind is if I could just add the position of the origin relative to the upper corner of the monitor to the Point to Row Column position, it would correct it. I can't find this property though, if it exists. Any help on this solution or any other ideas?
02-04-2012 10:57 AM
The mouse events should give you the coords relative to the origin of the pane, not the screen, so that should work the same no matter where the window is. Are you using the mouse input VIs instead? If that isn't it, you should post your code.
Even for the events, you might need to do some playing around with the numbers - if the position of your control is not on the origin, you will need to subtract that in order to know where to draw in the picture control and you would usually also need to account for the two or three pixels of the border of the control.
I don't think you can get a single property or method which will give you screen coordinates translation. You can get the info for the window, but translating that into something in your pane is unreliable.