|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
unmoveable Formhi 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 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...Show quoteHide quote > 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
Other interesting topics
Reading keys from HKEY_CURRENT_USER from an impersonated Web Service
static class confirmation vb.net to c# eventhandler conversion help Problem displaying 40,000 - 60 char entries in a text box. Non-default values for a struct ? C# application listen to update random access to elements of a disk-based XML file C# connection and file access question A problem with UserControls and MessageBoxes How to access a network file path \\foo\bar.txt from an .aspx and from a custom IHttpHandler? |
|||||||||||||||||||||||