Results 1 to 11 of 11

Thread: Moveable...? [Resolved]

  1. #1

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091

    Moveable...? [Resolved]

    Is there a way to make a form unmoveable in .NET?

    Last edited by crptcblade; Feb 7th, 2003 at 09:18 AM.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  2. #2
    Addicted Member ProgrammerJon's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    203
    Code:
        Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
            Form1.ActiveForm.Width = 200
            Form1.ActiveForm.Height = 200
        End Sub
    You can do it this way but there probably is a better way.

  3. #3

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    I was hoping for a more unflickery way (provided you really meant to use OnMove, otherwise I have no idea where you are going). I could set the borderstyle to None, but I would rather not. Thanks anyway.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  4. #4
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by crptcblade
    I was hoping for a more unflickery way (provided you really meant to use OnMove, otherwise I have no idea where you are going). I could set the borderstyle to None, but I would rather not. Thanks anyway.

    umm can you do it in vb6? maybe someone could help you convert the APIs to .NET
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  5. #5

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Originally posted by MrPolite
    umm can you do it in vb6? maybe someone could help you convert the APIs to .NET
    VB6 is easy. Moveable = False at design time .

    The only other way I know to do it is to remove the Move option from the system menu of the form. Anybody want to point in the right direction?

    I'd rather work the actual code out for myself, seeing as how I'm trying to get used to all this .NET malarky. Just a nice push will do.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    well , you have either use this flickry code or to to make your
    form's border style to none and create your own titlebar.
    VB Code:
    1. Dim LastLocation As Point
    2.  
    3.     Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As _
    4.        System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
    5.  
    6.         If e.Button = MouseButtons.Left Then
    7.             LastLocation = Me.Location
    8.         End If
    9.     End Sub
    10.  
    11. Private Sub Form1_Move(ByVal sender As Object, ByVal e As _
    12.        System.EventArgs) Handles MyBase.Move
    13.         Me.Location = LastLocation
    14. End Sub

  7. #7

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Well, that sucks. But if I must, then I must.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  8. #8
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I know it's silly but If you could overcome that flickring , it would be great .

  9. #9

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Well, I hacked it a bit. I overrode the WndProc method of the form and checked for a left mouse down message on the titlebar. If I get it, then I cancel the message.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  10. #10
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by crptcblade
    Well, I hacked it a bit. I overrode the WndProc method of the form and checked for a left mouse down message on the titlebar. If I get it, then I cancel the message.

    can you post your code anyways ?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  11. #11

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Sure...
    Code:
    Private Const WM_NCLBUTTONDOWN = &HA1
    Private Const HTCAPTION = 2
    
    
    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        Dim i As IntPtr = New IntPtr(0)
        Dim cap As IntPtr = New IntPtr(HTCAPTION)
    
        If (m.Msg.Equals(WM_NCLBUTTONDOWN)) And (m.WParam.Equals(cap)) Then
            m.Result = i
            Exit Sub
        End If
    
        MyBase.WndProc(m)
    End Sub
    It could probably stand to be cleaned up a little, but it works.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width