473,788 Members | 3,030 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Moving windows forms

Hi all,

I'm having a problem with a form position.
I need to prevent the user to drag the window. I tried to maximize the
window but i still can move the window.

I found something about override the WndProc method, but there are many
messages returned by the OS, and i don't know which messages should i
override. Maybe i'm working in a wrong way. I also tried with the style
borders and anything seems to work

If somebody can help me, i really appreciate that.
Regards.
Nov 16 '05 #1
5 1998
this would prolly be sort of a hack but if you want the window maximized all
the time
just set the minimumsize of the form to the same size of there resolution on
load..

another idea..

the location event on the form might be something of value as well..
"Pablo Cedeno" <do***@thecqgl. com.invalid> wrote in message
news:uG******** ******@TK2MSFTN GP12.phx.gbl...
Hi all,

I'm having a problem with a form position.
I need to prevent the user to drag the window. I tried to maximize the
window but i still can move the window.

I found something about override the WndProc method, but there are many
messages returned by the OS, and i don't know which messages should i
override. Maybe i'm working in a wrong way. I also tried with the style
borders and anything seems to work

If somebody can help me, i really appreciate that.
Regards.

Nov 16 '05 #2
Tnx for your help,

I cannot set the minimun size of the application because it will run on
several machines and i cannot ensure that each machine will have the same
resolution screen.

Now i will work in the location event to see if i can get the desire
behavior.

Regards

"Mike Lundell" <wo*********@ho tmail.com> wrote in message
news:E-*************** *****@comcast.c om...
this would prolly be sort of a hack but if you want the window maximized all the time
just set the minimumsize of the form to the same size of there resolution on load..

another idea..

the location event on the form might be something of value as well..
"Pablo Cedeno" <do***@thecqgl. com.invalid> wrote in message
news:uG******** ******@TK2MSFTN GP12.phx.gbl...
Hi all,

I'm having a problem with a form position.
I need to prevent the user to drag the window. I tried to maximize the
window but i still can move the window.

I found something about override the WndProc method, but there are many
messages returned by the OS, and i don't know which messages should i
override. Maybe i'm working in a wrong way. I also tried with the style
borders and anything seems to work

If somebody can help me, i really appreciate that.
Regards.


Nov 16 '05 #3
Another issue that i forgot is that the problem is not maximize the form. I
need to prevent the user to drag the window as will. If it's maximized, i
think, it should be "locked" in the screen.

I don't think this is a kind of hack, i really believe this should be the
normal behavior of an application. For example, if you maximize an IE
window, you cannot drag it, the window is locked in the screen, that's what
i need and i don't know why this cannot be done in c# in a simple way(At
least i cannot figure it out)

Regards

"Mike Lundell" <wo*********@ho tmail.com> wrote in message
news:E-*************** *****@comcast.c om...
this would prolly be sort of a hack but if you want the window maximized all the time
just set the minimumsize of the form to the same size of there resolution on load..

another idea..

the location event on the form might be something of value as well..
"Pablo Cedeno" <do***@thecqgl. com.invalid> wrote in message
news:uG******** ******@TK2MSFTN GP12.phx.gbl...
Hi all,

I'm having a problem with a form position.
I need to prevent the user to drag the window. I tried to maximize the
window but i still can move the window.

I found something about override the WndProc method, but there are many
messages returned by the OS, and i don't know which messages should i
override. Maybe i'm working in a wrong way. I also tried with the style
borders and anything seems to work

If somebody can help me, i really appreciate that.
Regards.


Nov 16 '05 #4
another way might be: have a timer event check the position every second,
if moved/resized then move/resize it back

John Bickmore

"Pablo Cedeno" <do***@thecqgl. com.invalid> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Another issue that i forgot is that the problem is not maximize the form. I need to prevent the user to drag the window as will. If it's maximized, i
think, it should be "locked" in the screen.

I don't think this is a kind of hack, i really believe this should be the
normal behavior of an application. For example, if you maximize an IE
window, you cannot drag it, the window is locked in the screen, that's what i need and i don't know why this cannot be done in c# in a simple way(At
least i cannot figure it out)

Regards

"Mike Lundell" <wo*********@ho tmail.com> wrote in message
news:E-*************** *****@comcast.c om...
this would prolly be sort of a hack but if you want the window maximized all
the time
just set the minimumsize of the form to the same size of there

resolution on
load..

another idea..

the location event on the form might be something of value as well..
"Pablo Cedeno" <do***@thecqgl. com.invalid> wrote in message
news:uG******** ******@TK2MSFTN GP12.phx.gbl...
Hi all,

I'm having a problem with a form position.
I need to prevent the user to drag the window. I tried to maximize the
window but i still can move the window.

I found something about override the WndProc method, but there are many messages returned by the OS, and i don't know which messages should i
override. Maybe i'm working in a wrong way. I also tried with the style borders and anything seems to work

If somebody can help me, i really appreciate that.
Regards.



Nov 16 '05 #5
Tnx everybody,

I found a solution in another newsgroup, here's the code that i received.
This works great!!

[System.Runtime. InteropServices .StructLayout(S ystem.Runtime.I nteropServices.
LayoutKind.Sequ ential)]
private struct _WINDOWPOS
{
public IntPtr hwnd;
public IntPtr hwndInsertAfter ;
public int x;
public int y;
public int cx;
public int cy;
public uint flags;
}

private const int WM_WINDOWPOSCHA NGING = 0x0046;
private const int SWP_NOMOVE = 0x0002;

[System.Security .Permissions.Pe rmissionSet(Sys tem.Security.Pe rmissions.Secur
ityAction.Deman d, Name="FullTrust ")]
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_WINDOWPOSCHA NGING)
{
_WINDOWPOS p = (_WINDOWPOS)m.G etLParam(typeof (_WINDOWPOS));
p.flags |= SWP_NOMOVE ;
System.Runtime. InteropServices .Marshal.Struct ureToPtr(p, m.LParam,
false);
m.Result = IntPtr.Zero;
}
else
base.WndProc(re f m);
}

Regards.

"xzzy" <mr********@com cast.net> wrote in message
news:ca5Vc.2817 34$a24.10247@at tbi_s03...
another way might be: have a timer event check the position every second, if moved/resized then move/resize it back

John Bickmore

"Pablo Cedeno" <do***@thecqgl. com.invalid> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Another issue that i forgot is that the problem is not maximize the form.
I
need to prevent the user to drag the window as will. If it's maximized, i think, it should be "locked" in the screen.

I don't think this is a kind of hack, i really believe this should be the normal behavior of an application. For example, if you maximize an IE
window, you cannot drag it, the window is locked in the screen, that's

what
i need and i don't know why this cannot be done in c# in a simple way(At
least i cannot figure it out)

Regards

"Mike Lundell" <wo*********@ho tmail.com> wrote in message
news:E-*************** *****@comcast.c om...
this would prolly be sort of a hack but if you want the window maximized
all
the time
just set the minimumsize of the form to the same size of there

resolution
on
load..

another idea..

the location event on the form might be something of value as well..
"Pablo Cedeno" <do***@thecqgl. com.invalid> wrote in message
news:uG******** ******@TK2MSFTN GP12.phx.gbl...
> Hi all,
>
> I'm having a problem with a form position.
> I need to prevent the user to drag the window. I tried to maximize

the > window but i still can move the window.
>
> I found something about override the WndProc method, but there are

many > messages returned by the OS, and i don't know which messages should i > override. Maybe i'm working in a wrong way. I also tried with the style > borders and anything seems to work
>
> If somebody can help me, i really appreciate that.
> Regards.
>
>



Nov 16 '05 #6

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

Similar topics

1
19830
by: Fredje | last post by:
Hello, I want to move a control by mouse on a form. I use the following code to mouse a label for example: private void label1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { drag = true; x = e.X;
3
5750
by: Robert Lochon | last post by:
Hi ! I've got this strange problem : When I press the left-button and move my mouse, my form moves just as intended. But if I make big movements, the cursor shifts slightly. And it ends with the mouse cursor completly out of the form, which is not what I want, of course. Here's the relevant snippet of my code :
4
1565
by: Ron Mexico | last post by:
Hi, Currently have an app that maintain that is written in VB6 and uses an access db (backend db only used as a data store not writing to the db). This app is a client app not server multi-teir app. It multi-form app that takes in a lot of user input and gives out high end calculations (engineering app). This app is starting to grow beyond the design and becoming very hard to maintian. I was considering moving it to C#. All of our new...
1
2720
by: siliconpi | last post by:
I'm looking for the simplest and cleanest way of having 10 buttons on a form, on which if I move my mouse over, a label's text changes as specified. I'm using Visual Basic .NET and I'm not too familiar with its intricacies, so I'm getting a bunch of errors on certain scenarios. The code below works fine but breaks if I click on Button1 a few times without moving the program window ----------
3
3036
by: Just Me | last post by:
If I move the mouse cursor over a control and stop moving I get a MouseHover event. If I then move the cursor while staying within the control and then stop moving I do not get another MouseHover event. To get a Mousehover I must leave and reenter the control. I'd like to get an event each time the cursor stops moving.
2
3114
by: Carl Gilbert | last post by:
Hi I have a math kinda problem where I'm trying to split some lines when two or more lines connect two shapes. The reason I am doing this is to make it clear that there are multiple lines connecting the two shapes. http://www.blackwaterbadgers.co.uk/image1.bmp Image 1 shows how if you have a line between two shapes, the line is straight. if you have more than one line, the lines will start overlapping
3
2690
by: AM Hulshoff | last post by:
Can someone tell me how I can move an object, in this case a listbox, over a form. The code below works, but not when the form is custom sized. It works perfectly when the form is maximized. And what is the best way to give the object boundries to move within? Hope someone can help me. TIA, Arjan. /*Begin Code*/
2
1144
by: sling blade | last post by:
I have a form with a one panel docked to the left and a splitter control docked to the panel. I have no code, events or any other controls on the form. When I adjust the splitter (drag it to the right) I get an "External component has thrown an exception" error when I let go of the mouse button. Here is the stack trace. at
2
1237
by: nime | last post by:
Hello I made a toolbox like thing by using a panel with a label docked on top. I can move the toolbox by dragging on the label. I've coded it, VB6 style and got no problem. Then I tried to use new VB.NET way and now I'm stuck. If you examine Label1_MouseMove event you'll see both methods. Can anybody fix it? To execute the code: 1-) Add a panel: Panel1
0
1280
by: Nishanthmarathe | last post by:
Hi There!!! I am new to C# world. I am getting huge chunk of data from a 3rd party applications thru SOAP request and updating to my SQL Server. I cant implement Progress bar as there is no way to know how much data i will get back and its a complicated process. So i decided to use a dummy progress bar, that is 5 moving dots, Which in turn gives user feeling of some progress happening. But if i comment the actual getting data part...
0
9655
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
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8993
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
7517
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
6749
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();...
1
4069
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
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
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.