|
Actually just a few hours if you look at the time stamps
|
|
|
|
|
Not sure he took the opportunity though.
|
|
|
|
|
private int x;
private int y;
private int aX;
private int aY;
public Form1()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
Point pt = PointToClient(Control.MousePosition));
if (aX != pt.X || aY != pt.Y)
{
aX = (pt.X - x);
aY = (pt.Y - y);
this.Location = new Point(pt.X - aX, pt.Y - aY);
}
x = pt.X;
y = pt.Y;
}
If you do something like this you get a nasty oscillating effect. I'm not sure why?
|
|
|
|
|
you have a twisted mind.
Check the documentation: both Control.MousePosition and Form.Location use screen coordinates (unless your Form isn't a TopMost one).
Now check again what Griff showed you.
|
|
|
|
|
Only a little twisted! I've only been at this for a couple of months so there is still time! However, I tried the one line approach and this certainly is not correct:
private void timer1_Tick(object sender, EventArgs e)
{
this.Location = PointToClient(Control.MousePosition);
}
You get an oscillating set of windows. I would appreciate knowing how you would do it?
|
|
|
|
|
For a window on the desktop it would be
window.Location=Control.MousePosition;
and for a moving Control held in some container Control it is
movingControl.Location=containingControl.PointToClient(Control.MousePosition);
as Control.PointToClient[^] translates screen coordinates to coordinates relative to the Control.
BTW: if you apply your (or my) logic to just one object, there is no way it could oscillate. And generally it is wise to test new techniques on one object only, until it works satisfactorily; this helps observation and understanding of what is going on.
|
|
|
|
|
Thank's that very informative.
|
|
|
|
|
really? all PointToClient does is subtract the screen location of the containing Control. I admit MSDN could have made that clearer (as usual), but if you think about it, it can't be doing anything else. So pick the right sucker before calling PointToClient.
Homework: how does a container figure out its screen location?
|
|
|
|
|
|
Yes, that is the method that does it if you feed it (0,0), but the question really is how does it do so? what is inside?
|
|
|
|
|
To expand slightly on what I said above (inserting some of the bits I glossed over with "yada yada":
bool catchme = false;
private void frmMain_MouseDown(object sender, MouseEventArgs e)
{
catchme = true;
}
private void frmMain_MouseUp(object sender, MouseEventArgs e)
{
catchme = false;
}
private void frmMain_MouseMove(object sender, MouseEventArgs e)
{
if (catchme)
{
Location = System.Windows.Forms.Control.MousePosition;
}
}
Top left corner of the form follows the mouse. If you want some other part to follow it, you need to offset the Location by the start co-ords of the mouse when first pressed down - not too difficult!
I really wouldn't use a timer for this, unless you want the form to move around on a pre-set (or random if you must) path.You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
You would need to move the form relative to your cursor position.
Catch the mouse move event and then move the form relative to your co-ordinates.Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
I've got a bit closer, I modified the code a little. Now I have a form that jumps when the cursor moves over it. I've now realized that the mouseover event may not work since I want the form to follow the cursor anywhere about the screen.
void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (posx != e.X || posy != e.Y) {this.DesktopLocation = new Point(e.X - posx, e.Y - posy); }
posx = e.X;
posy = e.Y;
}
|
|
|
|
|
Hello guys,
I want to make a multi finance application and i need some example for my basic ground about multi finance. I had tried to search it on google but i didn't find it.
Maybe you guys know multi finance application whether it's a shareware or freeware?
Or maybe some good books for starting? the calculation related to multi finance etc?
Thank you guys for the attention.
|
|
|
|
|
|
Thank you for the answer Saksida Bojan.
And sorry for wrong posting place.
|
|
|
|
|
Hi..,
Can anyone pls tell e how to convert the lat/long values to mils and also to georef?
|
|
|
|
|
|
Pls help me.. I am not able to find any apllication that converts lat/long to mils.. I am sure there is such example codes available
|
|
|
|
|
Look at the links in my reply. The last link is article on this site. Or are you looking APLICATION instead code?
|
|
|
|
|
Thank u but that just show the distance between two lat/long vlaues. I actually want the conversions. I'll go through it again and try to find if ther's any conversion used in it.
|
|
|
|
|
From what into what do you want to convert?
How to convert lat/long values to mils??? (From Title)
this kind of conversion is not possible. From lat/long you get only a fixed cordinates. while miles is a distance. They are not related. If you have 2 cordinates of lan/long, you can easly get distance and miles
|
|
|
|
|
I have no idea what you're talking about -- what's a mil?
|
|
|
|
|
A mil is 0.001 inch..45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Actually he is talking about an angular mil. See [^] CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|