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

Moving window

Hi.
I wanna move window, by clicking its body ( not the strip ).
Which event should i catch.
I tried with mousedown, but then i only can update position of window,
once.
My task is to change it in real mode ( until mousebutton is up).
Can anyone help?
PK

Dec 5 '05 #1
2 1313
Piotreek,

Are you moving the window in relation to the mouse moving? If that is
the case, then you want to check the MouseMove event, and then set the
position of your window there.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Piotrekk" <Pi*************@gmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
Hi.
I wanna move window, by clicking its body ( not the strip ).
Which event should i catch.
I tried with mousedown, but then i only can update position of window,
once.
My task is to change it in real mode ( until mousebutton is up).
Can anyone help?
PK

Dec 5 '05 #2
Well I wrote this class once, it may help you:

--------------------------------------------
internal class FormDrag
{
Form _form=null ;
int _y = 0, _x = 0;
private bool _mousedown = false;

public FormDrag(Form form)
{

if (form == null)
throw new ArgumentNullException("Must pass a form instance.");
_form = form;
_form.MouseMove += new MouseEventHandler(_form_MouseMove);
_form.MouseDown += new MouseEventHandler(_form_MouseDown);
_form.MouseUp += new MouseEventHandler(_form_MouseUp);

}

void _form_MouseUp(object sender, MouseEventArgs e)
{
_mousedown = false;
}

void _form_MouseDown(object sender, MouseEventArgs e)
{
_mousedown = true;
_y = e.Y;
_x = e.X;

}

void _form_MouseMove(object sender, MouseEventArgs e)
{

if (_mousedown)
{
int a = _y - e.Y;
_form.Top -= a;
a = _x - e.X;
_form.Left -= a;
}
}
}
--------------------------------------------
To use this class, what you do is; on the load event of your form you write:

_formdrag = new FormDrag(this);

where _formdrag is a variable, of type FormDrag class, at class scope.

I hope this helps you.

Ab.
http://joehacker.blogspot.com

"Piotrekk" <Pi*************@gmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
Hi.
I wanna move window, by clicking its body ( not the strip ).
Which event should i catch.
I tried with mousedown, but then i only can update position of window,
once.
My task is to change it in real mode ( until mousebutton is up).
Can anyone help?
PK

Dec 6 '05 #3

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

Similar topics

1
by: Andi B | last post by:
Hi everyone. I have a quick question - if I have a form which refers to a javascript when its submitted using: <form name = "fred" onsubmit = "test()"> and this function creates a popup...
2
by: willem | last post by:
Hi, I want move my form with mouse when I press button over a different position from normal bar of title. I set MouseUp, MouseDown and, MouseMove events and all works good. is it...
5
by: Jon Masterson | last post by:
Hi All I have a requirement to create a window in which I can place a moving map. I also probably need to create the data points that go onto the map - airports, navigation aids etc. The whole...
7
by: =?Utf-8?B?TW9iaWxlTWFu?= | last post by:
Hello everyone: I am looking for everyone's thoughts on moving large amounts (actually, not very large, but large enough that I'm throwing exceptions using the default configurations). We're...
1
pavlov
by: pavlov | last post by:
Hello everybody. I've this problem: I'm making a jpg moving horizontally from left to right in my page. I'd like to make it start moving from the left off-screen side. I tried using position...
3
by: cjparis | last post by:
Hello All I built a simple script to move a div tag with a MouseOver event handler. This worked fine in Safari but would not work in Netscape and Firefox Can anyone help? You can see it...
1
by: rsteph | last post by:
I bought a book to help me learn to use DirectX with windows programming. It's first trying to walk me through some basic windows programming and graphics before getting into DirectX. I'm trying to...
4
by: sethupnr | last post by:
i need to make a new window in a explorer and also floating in main window. do not show it as a new explorer file. check this link www.manashosting.com. u can find there is a moving window(question)....
1
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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...

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.