473,498 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

unmoveable Form

hi all,

how can i create unmoveable form with c#?
in vb6, its very simple
me.moveable = false

in CSharp . .. ?

i want a form with title bar.
but i dont want to allow user to move form location.
how can i ?

thanks,
cyberclone

--
Message posted via http://www.dotnetmonster.com
Mar 15 '06 #1
2 4451
vj
The code.. is in VB, i hope you can convert to c-sharp... Paste it your
Form, you will get a moveable property

#Region " Form Move Code "

Private Declare Function EnableMenuItem Lib "user32.dll" Alias
"EnableMenuItem" (ByVal hMenu As IntPtr, ByVal uIDEnableItem As Int32, ByVal
uEnable As Int32) As Int32

Private Const HTCAPTION As Int32 = &H2

Private Const MF_BYCOMMAND As Int32 = &H0&
Private Const MF_ENABLED As Int32 = &H0&
Private Const MF_GRAYED As Int32 = &H1&
Private Const MF_DISABLED As Int32 = &H2&

Private Const SC_MOVE As Int32 = &HF010&

Private Const WM_NCLBUTTONDOWN As Int32 = &HA1
Private Const WM_SYSCOMMAND As Int32 = &H112
Private Const WM_INITMENUPOPUP As Int32 = &H117&

Private bMoveable As Boolean = True

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

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)

If m.Msg = WM_INITMENUPOPUP Then
'handles popup of system menu
If m.LParam.ToInt32 \ 65536 <> 0 Then 'divide by 65536 to get hiword
Dim AbleFlags As Int32 = MF_ENABLED
If Not Moveable Then AbleFlags = MF_DISABLED Or MF_GRAYED
EnableMenuItem(m.WParam, SC_MOVE, MF_BYCOMMAND Or AbleFlags)
End If
End If

If Not Moveable Then
If m.Msg = WM_NCLBUTTONDOWN Then
'cancels any attempt to drag the window by it's caption
If m.WParam.ToInt32 = HTCAPTION Then
Return
End If
End If
If m.Msg = WM_SYSCOMMAND Then
'redundant but cancels any clicks on the Move system menu item
If (m.WParam.ToInt32 And &HFFF0) = SC_MOVE Then
Return
End If
End If
End If
'return control to base message handler
MyBase.WndProc(m)
End Sub
#End Region

VJ
"cyberclone via DotNetMonster.com" <u5716@uwe> wrote in message
news:5d4ac5672a327@uwe...
hi all,

how can i create unmoveable form with c#?
in vb6, its very simple
me.moveable = false

in CSharp . .. ?

i want a form with title bar.
but i dont want to allow user to move form location.
how can i ?

thanks,
cyberclone

--
Message posted via http://www.dotnetmonster.com

Mar 15 '06 #2
Thanks

--
Message posted via http://www.dotnetmonster.com
Mar 16 '06 #3

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

Similar topics

3
5633
by: John | last post by:
Dear all, It been more than 3 days I am trying to debug this program, I interpret it using activePerl and it is giving (perl -wc code_process.pl) no error syntax but when I put it online, change...
5
6068
by: Richard Cornford | last post by:
I am interested in hearing opinions on the semantic meaning of FORM (elements) in HTML. I have to start of apologising because this question arose in a context that is not applicable to the...
4
2095
by: Targa | last post by:
Trying to total some price fields in a form but doesnt work when all the referenced form fields dont exisit. This is for an invoice - pulled prom a database and the form doesnt always contain the...
25
10162
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the...
19
3584
by: Raposa Velha | last post by:
Hello to all! Does any of you want to comment the approach I implement for instantiating a form? A description and an example follow. Cheers, RV jmclopesAThotmail.com replace the AT with the...
11
18799
by: Jozef | last post by:
I have some old code that I use from the Access 95 Developers handbook. The code works very well, with the exception that it doesn't seem to recognize wide screens, and sizes tab controls so that...
5
73174
by: RAJ | last post by:
hi plz tell me how to know "how window is going to close"... i have to right code for X button of forms... plz telll me thanks bye
6
3213
by: Gary Miller | last post by:
Does anyone know how to detect a modeless form on closing by the form that invoked the modeless form? form.Show();
4
4560
by: Alex Sibilev | last post by:
Hello, I have a really weird problem I've been trying to solve it without any luck for the last couple of hours :( I'm writing a "conference board" application (quite similar to ASP.NET...
0
7125
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,...
1
6887
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...
0
5462
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,...
0
4590
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...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1419
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 ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
291
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...

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.