473,400 Members | 2,145 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,400 software developers and data experts.

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 1978
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**************@TK2MSFTNGP12.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*********@hotmail.com> wrote in message
news:E-********************@comcast.com...
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**************@TK2MSFTNGP12.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*********@hotmail.com> wrote in message
news:E-********************@comcast.com...
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**************@TK2MSFTNGP12.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****************@TK2MSFTNGP09.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*********@hotmail.com> wrote in message
news:E-********************@comcast.com...
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**************@TK2MSFTNGP12.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(System .Runtime.InteropServices.
LayoutKind.Sequential)]
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_WINDOWPOSCHANGING = 0x0046;
private const int SWP_NOMOVE = 0x0002;

[System.Security.Permissions.PermissionSet(System.S ecurity.Permissions.Secur
ityAction.Demand, Name="FullTrust")]
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_WINDOWPOSCHANGING)
{
_WINDOWPOS p = (_WINDOWPOS)m.GetLParam(typeof(_WINDOWPOS));
p.flags |= SWP_NOMOVE ;
System.Runtime.InteropServices.Marshal.StructureTo Ptr(p, m.LParam,
false);
m.Result = IntPtr.Zero;
}
else
base.WndProc(ref m);
}

Regards.

"xzzy" <mr********@comcast.net> wrote in message
news:ca5Vc.281734$a24.10247@attbi_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****************@TK2MSFTNGP09.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*********@hotmail.com> wrote in message
news:E-********************@comcast.com...
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**************@TK2MSFTNGP12.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
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)...
3
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...
4
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...
1
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...
3
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...
2
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...
3
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...
2
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...
2
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...
0
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...

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.