473,320 Members | 1,854 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,320 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 9616
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.