MDIForm


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 11 of 11

Thread: MDIForm

Hybrid View

  1. #1
    Join Date
    Jun 2007
    Posts
    36

    MDIForm

    I have an MDI Form but i want to keep it a desired size, how can i disable the maximize button and the top? It does not seem to be listed in the properties box like it is with normal forms?

  2. #2
    Join Date
    Jun 2007
    Posts
    36
    I figured out you could use this:

    Code:
    Private Sub MDIForm_Resize()
        If Me.WindowState = vbMaximized Then
            Me.WindowState = vbNormal
            MsgBox "You cannot maximise this form", vbExclamation, App.Title
        End If
    End Sub
    a bit messy though

  3. #3
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Perhaps a bit messy, but that is exactly what I would have suggested, so, you have answered your own question.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  4. #4
    Join Date
    Feb 2004
    Location
    Sydney, Australia
    Posts
    498
    Or check out the BorderStyle property ... and the MaxButton and MinButton properties of your Form ....

  5. #5
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    BorderStyle, Min and MaxButton are not properties of the MDIForm.

    It is possible with the help of some API.
    Removing the buttons is easy using SetWindowLong, but then you have to remove also the items from the Form menu.
    I got this code so long ago, I do not remember from where (almost sure was a MicroSoft forum), and it works great:

    Code:
    Option Explicit
    
    Private Declare Function SetWindowLong Lib "user32" Alias _
       "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, _
       ByVal dwNewLong As Long) As Long
    Private Declare Function GetWindowLong Lib "user32" Alias _
       "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) _
       As Long
    Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, _
        ByVal bRevert As Long) As Long
    Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As _
        Long
    Private Declare Function DeleteMenu Lib "user32" _
        (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
    
    Private Const MF_BYPOSITION = &H400&
    Private Const WS_MINIMIZEBOX = &H20000
    Private Const WS_MAXIMIZEBOX = &H10000
    Private Const GWL_STYLE = (-16)
    
    
    Private Sub MDIForm_Load()
    
        '' remove Min and Max buttons
        Dim L As Long
        L = GetWindowLong(Me.hwnd, GWL_STYLE)
        L = L And Not (WS_MINIMIZEBOX)
        L = L And Not (WS_MAXIMIZEBOX)
        L = SetWindowLong(Me.hwnd, GWL_STYLE, L)
        
        Dim lNumItems As Long
        Dim lMenu As Long
        
        lMenu = GetSystemMenu(hwnd, 0)
        lNumItems = GetMenuItemCount(lMenu) - 1
            
        '' remove all menu items, except for Move and Close
        If lNumItems > 0 Then
            Dim i As Long
            DeleteMenu lMenu, i, MF_BYPOSITION
            For i = lNumItems - 2 To 1 Step -1
                DeleteMenu lMenu, i, MF_BYPOSITION
            Next
        End If
    
    End Sub
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  6. #6
    Join Date
    Feb 2004
    Location
    Sydney, Australia
    Posts
    498
    MDI? Who said anything about MDI? Oh, I hear you say, the initial question did! Should have read it more closely! :-(

  7. #7
    Join Date
    Mar 2008
    Location
    Lancashire, UK
    Posts
    156
    Nuts! mstraf beat me to it.

    All i have to say, is that his code doesn't remove the dragable border, you'd need to add

    Code:
    Private Const WS_THICKFRAME = &H40000
    
    -----
    
    L = L And Not (WS_THICKFRAME)

  8. #8
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    True, thanks!

    But... because I removed the "Size" from the titlebar menu, even with the thick frame was not possible to resize the Form
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  9. #9
    Join Date
    Mar 2008
    Location
    Lancashire, UK
    Posts
    156
    Ah. Ok then, i'll let you off

  10. #10
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    @westweb: Has this been resolved for you or do you still have questions?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  11. #11
    Join Date
    Jun 2007
    Posts
    36
    Yes it has been resolved thanks

Similar Threads

  1. Need help asap!!!
    By vpatel in forum VB Classic
    Replies: 10
    Last Post: 12-20-2006, 11:56 AM
  2. displaying a mdiform in a frame in a form
    By Rahul singh in forum VB Classic
    Replies: 2
    Last Post: 04-11-2002, 05:11 AM
  3. Detecting change of MDI child form
    By Tim Coulter in forum VB Classic
    Replies: 20
    Last Post: 02-01-2001, 07:49 AM
  4. Re: Don't Show in task bar a mdiForm
    By Phil Weber in forum vb.announcements
    Replies: 0
    Last Post: 11-16-2000, 02:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center