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

Movable property...

Hello,

How to prevent user from moving the form at run time. At
the same time, I want to keep my control box and form
border.

Thanks,
Douglas ^^

Nov 20 '05 #1
10 9619
You'll have to create a new class which inherits from form, then make all
your forms inherit from this new form. Here is the class:

<WatchForWrapping>

Public Class MovableForm
Inherits System.Windows.Forms.Form

Private m_blnMovable As Boolean

Private Const WM_NCLBUTTONDOWN As Integer = &HA1
Private Const WM_SYSCOMMAND As Integer = &H112
Private Const HTCAPTION As Integer = &H2
Private Const SC_MOVE As Integer = &HF010

Public Sub New()
MyBase.New()
m_Movable = True
End Sub

<System.ComponentModel.Category("Behavior"),
System.ComponentModel.Description("Allows the form to be moved")> _
Public Property Movable() As Boolean
Get
Return m_blnMovable
End Get
Set(ByVal Value As Boolean)
m_blnMovable = Value
End Set
End Property

Protected Overrides Sub WndProc(ByRef m As Message)

If Not m_blnMovable Then
If m.Msg = WM_SYSCOMMAND And m.WParam.ToInt32 = SC_MOVE Then
Return
If m.Msg = WM_NCLBUTTONDOWN And m.WParam.ToInt32 = HTCAPTION
Then Return
End If

MyBase.WndProc(m)

End Sub
End Class

</WatchForWrapping>

This adds a Movable property to your form. Set it to false and the form
cannot be moved. The property will appear in the property browser under the
'Behavior' section. Remember: The forms you would like to have this property
must inherit from MovableForm, and the project must be built after you
create this class before your forms can inherit from it. Go into the code
and change the Inherits line of your form. Just to be safe, build your
project then view the form in the Designer, and play with your Movable
property.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit
"Hello" <do*********@texwinca.com> wrote in message
news:07****************************@phx.gbl...
Hello,

How to prevent user from moving the form at run time. At
the same time, I want to keep my control box and form
border.

Thanks,
Douglas ^^

Nov 20 '05 #2
Cor
Douglas,
This works for me
\\\\\\\\
Private Sub Form1_Move(ByVal sender As Object, ByVal e As System.EventArgs)
Handles MyBase.Move
MyBase.Location = New System.Drawing.Point(30, 30)
End Sub
/////////
Cor
Nov 20 '05 #3
Hi Tom,

Nice one, I reckon I can use that sometime - It's going into my
snippets collection. Thanks.

What is the tag <WatchForWrapping> </WatchForWrapping> for ?
You've used it before I seem to remember.

Regards,
Fergus


Nov 20 '05 #4
OE will wrap lines to 78 chars when posting a response, so anything enclosed
in <WatchForWrapping> tags should be looked at to make sure a line hasn't
wrapped, or if it has to correct piece the line back together.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit
"Fergus Cooney" <fi******@tesco.net> wrote in message
news:u3**************@TK2MSFTNGP09.phx.gbl...
Hi Tom,

Nice one, I reckon I can use that sometime - It's going into my
snippets collection. Thanks.

What is the tag <WatchForWrapping> </WatchForWrapping> for ?
You've used it before I seem to remember.

Regards,
Fergus


Nov 20 '05 #5
Thanks Tom,

Wouldn't it be nice to have a tag to tell OE <not> to wrap.

And to have OE not flag for attention my own posts

And to have OE....

Regards,
Fergus
Nov 20 '05 #6
Hello,

"Fergus Cooney" <fi******@tesco.net> schrieb:
Nice one, I reckon I can use that sometime - It's going into my
snippets collection. Thanks.
I *hate* unmoveable windows.
What is the tag <WatchForWrapping> </WatchForWrapping> for ?
You've used it before I seem to remember.


Depending on the settings of the newsreader sending the message, text will
be automatically wrapped aftet ~80 characters.

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet
Nov 20 '05 #7
> I *hate* unmoveable windows.

So do I, but I love programming ;-)
Depending on the settings of the newsreader sending the message, text will
be automatically wrapped aftet ~80 characters.
I found a setting for this in OE, to wrap text after 'n' characters

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit
"Herfried K. Wagner [MVP]" <hi*******@m.activevb.de> wrote in message
news:OY**************@tk2msftngp13.phx.gbl... Hello,

"Fergus Cooney" <fi******@tesco.net> schrieb:
Nice one, I reckon I can use that sometime - It's going into my
snippets collection. Thanks.


I *hate* unmoveable windows.
What is the tag <WatchForWrapping> </WatchForWrapping> for ?
You've used it before I seem to remember.


Depending on the settings of the newsreader sending the message, text will
be automatically wrapped aftet ~80 characters.

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet

Nov 20 '05 #8
Hi Herfried,

|| I *hate* unmoveable windows.

When I've finished KillerApp 2000 (due for release in 2006). I'll
be adding some special code to detect when it's your machine. It'll
let you move the window anywhere you like, but when you run it again,
it'll have forgotten. Haha.

Doh!, silly me, that's already standard behaviour these days.

|| I *hate* unmoveable windows.

Me too, but I think there may be a place for Tom's snippet in an
MDI app. ??

Regards,
Fergus.
Nov 20 '05 #9
> I love programming too.

;-)
Ditto.
I know about this setting, but I do not change its value (currently 76
characters).
Ditto.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit
"Herfried K. Wagner [MVP]" <hi*******@m.activevb.de> wrote in message
news:OH**************@TK2MSFTNGP12.phx.gbl... Hello,

"Tom Spink" <th**********@ntlworld.com> schrieb:
I *hate* unmoveable windows.


So do I, but I love programming ;-)


I love programming too.

;-)
Depending on the settings of the newsreader sending the message, text will be automatically wrapped aftet ~80 characters.


I found a setting for this in OE, to wrap text after 'n' characters


I know about this setting, but I do not change its value (currently 76
characters).

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet

Nov 20 '05 #10
Hi Tom,

|| Hey, that was written fresh this morning from memory.
|| I tested it out about 2 minutes before I went to work.

??

What's that got to do with using your ideas in an MDI app?

Regards,
Fergus
Nov 20 '05 #11

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

Similar topics

0
by: sean | last post by:
I'm having problems trying to sort a series of authors who post online using Movable Type. I've tried posting my problem to the Movable Type support group, but no one has even answered my question....
0
by: Fuzzyman | last post by:
Movable Python has just been released on sourceforge. Movable Python is a frozen distribution of Python. It will run python scripts without needing to be installed. ...
1
by: Mircea | last post by:
How I can create a movable component, for example a button, in run-time? Thanks
2
by: Ryan Ternier | last post by:
Hello, I'm looking at creating an application that allows users to create their own templates, and thought of using the same idea's MS used when creating http://sympatico.my.msn.com/. I looked...
0
by: Fuzzyman | last post by:
It's finally happened, `Movable Python <http://www.voidspace.org.uk/python/movpy/>`_ is finally released. Versions for Python 2.3 & 2.4 are available from `The Movable Python Shop...
1
by: loga123 | last post by:
Hi All, I am using ASP .NET 2.0. I have gridview displaying data and when a row is selected on gridview "detailsview" pops up based on the row selected from gridview. I want to make this...
3
gauravgmbhr
by: gauravgmbhr | last post by:
hello friends can some one tell me plz can I create a movable as well as resizable html component using javascript plz help me or email me some link that can be helpfull for me
3
by: anniejacob | last post by:
hi, i dragged dynamic labels from 1panel to other then once that label is placed on other panel i want that label 2 b movable on run time. my form is in C# can u help me with this bye
1
by: trint | last post by:
How can I add movable windows to my c# dotNet web app? Do I have to convert the whole thing to AJAX or is it even known how Google does this? Thanks, Trint
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.