Results 1 to 7 of 7

Thread: Stop maximized form from moving

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Location
    California, USA
    Posts
    111

    Question

    I am using a picturebox as a container to act as a mdiparent because only 1 midparent is allowed when I need 2. When I maximize a "child" form, the title bar is still visible which enable the user to move the max form. I get an error when I set moveable=false during runtime. Is there any way to stop the maxed form from moving? Thanks.

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Well you could remove the titlebar?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Location
    California, USA
    Posts
    111
    If I remove the titlebar then the user can't use the 3 buttons in the titlebar to min, max, exit.

  4. #4
    Guest

    Thumbs up

    I believe this is what you want to do:

    Code:
    Dim iLeft As Integer
    Dim iTop As Integer
    
    Private Sub Form_Resize()
    On Error Resume Next
    iLeft = Me.Left
    iTop = Me.Top
    If Me.WindowState = vbMaximized Then
    Me.Left = iLeft
    Me.Top = iTop
    End If
    End Sub

  5. #5
    Guest
    This will remove the move command from the Form
    Code:
    Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
    Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
    Private Const MF_BYPOSITION = &H400&
    
    Private Sub Form_Load()
        RemoveMenu GetSystemMenu(hwnd, 0), 1, MF_BYPOSITION
    End Sub

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Location
    California, USA
    Posts
    111
    Matthew Gates code gives me the error: A form can't be moved or resized while minimized or maximized.

  7. #7
    Guest
    Originally posted by vbuser1
    Matthew Gates code gives me the error: A form can't be moved or resized while minimized or maximized.
    That is why the On Error Resume Next is there...to ignore it.

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