Results 1 to 30 of 30

Thread: minimize + maximize + X *RESOLVED*

  1. #1

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740

    minimize + maximize + X *RESOLVED*

    Ok, I have searched through several threads looking for info on minimizing, maximize and X for forms. I have found several interesting threads, but I can't seem to find what I am looking for.

    I have two forms open, one is my main form. If I click the minimize control, I want both form to minimize and and only show as one form in the task bar.

    If I open the form up again, I want everything to open up as it was before. Now the part I seem to be missing is how to indicate in my code that the minimize or maximize or X control has been clicked.

    I know for example if I don't want my other form in the task bar to use something like this and to open the forms together with this.
    VB Code:
    1. frmOtherForm.show, frmMain
    2. ShowInTaskBar = false
    Last edited by Navarone; Feb 3rd, 2004 at 03:50 PM.
    He who never made a mistake never made a discovery?

  2. #2
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253
    This should get you going:

    VB Code:
    1. if me.windowstate = vbminimized then
    2. '---
    3. end if

    You should get the rest figured out from that

  3. #3

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740
    this question is also related why can't I do this in VB6

    VB Code:
    1. frmIntro.MaxButton = False
    He who never made a mistake never made a discovery?

  4. #4
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253
    Im not sure, but maybe because its a read only property, meaning you can only set the caption buttons at design time. Does it error when you try that code, if so what error do you get?

    That code is perfect you see

  5. #5

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740
    yes, I get a compile error:

    Code:
    Function or interface marked as restricted, or the function uses an Automation type not supported in Visual Basic
    The only reason I tried it, is I found it a thread during a Google search.
    He who never made a mistake never made a discovery?

  6. #6
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253
    Well it must be only set at design time then

  7. #7
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    You can't set that during Runtime.
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Originally posted by Navarone
    this question is also related why can't I do this in VB6

    VB Code:
    1. frmIntro.MaxButton = False
    You need to use APIs to remove the Max button from a form during runtime.
    VB Code:
    1. option explicit
    2.  
    3. Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, _
    4. ByVal wFlags As Long) As Long
    5.  
    6. Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
    7.  
    8. Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
    9.  
    10. Private Const MF_BYCOMMAND = &H0&
    11. Private Const SC_MAXIMIZE As Long = &HF030
    12.  
    13. Private sub Form_Load()
    14.     Dim hMenu as long
    15.     hMenu = GetSystemMenu(Me.hwnd, False)
    16.     Call RemoveMenu(hMenu, SC_MAXIMIZE, MF_BYCOMMAND)
    17.     Call DrawMenuBar(Me.hwnd)
    18. End sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    This will NOT give the Max button the disabled look, but it will be
    removed from the system menu. Thus, disabling the Max button.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  10. #10

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740
    RobDog888

    I tried using the code snippet you posted but when My form loads I get a compile error for this line, "sub or function not declared"

    VB Code:
    1. hMenu = GetSystemMenu(Me.hwnd, False)
    He who never made a mistake never made a discovery?

  11. #11
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Can you post your form load procedure?
    The APIs need to be declared in either the forms general
    declarations section or in a module and change the APIs to be
    Public instead of Private.
    If you copy and paste the code I posted into another new
    standard vb project it will run and you can see the results.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Here is the complete effect of a disabled Max button set during runtime.
    Paste into a new vb project and run.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, _
    4. ByVal wFlags As Long) As Long
    5.  
    6. Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
    7.  
    8. Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
    9.  
    10. Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
    11.  
    12. Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    13.  
    14. Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    15.  
    16. Private Const MF_BYCOMMAND = &H0&
    17. Private Const SC_MAXIMIZE As Long = &HF030
    18. Private Const WS_MAXIMIZEBOX As Long = &H10000
    19. Private Const GWL_STYLE As Long = -16
    20.  
    21. Private Sub Form_Load()
    22.    
    23.     Dim hMenu As Long
    24.     Dim lstyle As Long
    25.    
    26.     hMenu = GetSystemMenu(Me.hwnd, False)
    27.     Call RemoveMenu(hMenu, SC_MAXIMIZE, MF_BYCOMMAND)
    28.     Call DrawMenuBar(Me.hwnd)
    29.     lstyle = GetWindowLong(Me.hwnd, GWL_STYLE)
    30.     lstyle = lstyle - WS_MAXIMIZEBOX
    31.     Call SetWindowLong(Me.hwnd, GWL_STYLE, lstyle)
    32.    
    33. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  13. #13

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740
    Ok, Cool.

    I tried this in a new project and I see what you mean. When I copied the code into my project, I put all the private declarations in my module and made them public the same with the private Const, they are now public too.

    I then put the Sub Form_load code in my forms Sub and when I run the app, the maximize button is disabled, but it's not grayed out.
    He who never made a mistake never made a discovery?

  14. #14
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Strange, try putting the code at the end of the Form_Load.
    Maybe there is something that is changing it back? Post you
    Form_Load procedure if you can.

    What is the Form borderstyle?
    If it is set to none then this will not work.
    It needs to be either 1 - Fixed or 2 - Sizable

    Are there any forms that this works on in your project?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  15. #15

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740
    ok, on the off-chance that there is something wierd going on, I took everything out of the module, put stuff back to Private and added it to the top declaration of my form. The form by the way is set to 2-sizable. This is my sub routine

    VB Code:
    1. Private Sub Form_Load()
    2.    
    3.     'disable the maximize button from the form
    4.     Dim hMenu As Long
    5.     Dim lstyle As Long
    6.    
    7.     hMenu = GetSystemMenu(Me.hwnd, False)
    8.     Call RemoveMenu(hMenu, SC_MAXIMIZE, MF_BYCOMMAND)
    9.     Call DrawMenuBar(Me.hwnd)
    10.     lstyle = GetWindowLong(Me.hwnd, GWL_STYLE)
    11.     lstyle = lstyle - WS_MAXIMIZEBOX
    12.     Call SetWindowLong(Me.hwnd, GWL_STYLE, lstyle)
    13.  
    14.  
    15.     'load background image
    16.     frmIntro.Picture = LoadPicture(App.Path & "\" & "Pictures" & "\" & "mainBackground.jpg")
    17.    
    18.     'set top menu to invisible
    19.     frmIntro.HoverCommand6.Visible = False
    20.     frmIntro.HoverCommand7.Visible = False
    21.     frmIntro.HoverCommand8.Visible = False
    22.     frmIntro.HoverCommand9.Visible = False
    23.     frmIntro.HoverCommand10.Visible = False
    24.    
    25.     'set caption for form at runtime
    26.     frmIntro.Caption = "1:1 card " & Chr(147) & "Because every customer is different" & Chr(153) & Chr(46) & Chr(148)
    27.    
    28.     'set label for copywrite
    29.     frmIntro.Label11.Caption = "© Copyright 2004 Virtual Horizons,Inc. All rights reserved."
    30.    
    31.     'create directories if they do not already exist
    32.     If Dir(App.Path & "\" & "CDTypes", vbDirectory) = "" Then
    33.         'MsgBox "Directory doesn't exist"
    34.         MkDir (App.Path & "\" & "CDTypes") ' make new directory
    35.         MkDir (App.Path & "\" & "Images") 'make images directory
    36.         MkDir (App.Path & "\" & "WavFiles") 'make wavFile directory
    37.         MkDir (App.Path & "\" & "pdfs") 'make pdf directory
    38.      Else
    39.          'MsgBox "Directory Exist"
    40.     End If
    41.  
    42. End Sub
    He who never made a mistake never made a discovery?

  16. #16
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    If you had this code in the module then the me.hwnd will be incorrect.
    VB Code:
    1. hMenu = GetSystemMenu([color=red]Me[/color].hwnd, False)
    2. Call RemoveMenu(hMenu, SC_MAXIMIZE, MF_BYCOMMAND)
    3. Call DrawMenuBar([color=red]Me[/color].hwnd)
    4. lstyle = GetWindowLong([color=red]Me[/color].hwnd, GWL_STYLE)
    5. lstyle = lstyle - WS_MAXIMIZEBOX
    6. Call SetWindowLong([color=red]Me[/color].hwnd, GWL_STYLE, lstyle)
    Try changing the Me keyword to your form name - frmIntro.hwnd
    and move the code to be the last lines of code in the Form_Load event.
    VB Code:
    1. 'set caption for form at runtime
    2.     frmIntro.Caption = "1:1 card " & Chr(147) & "Because every customer is different" & Chr(153) & Chr(46) & Chr(148)
    May have something to do with it.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  17. #17
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    So it should look like this.
    VB Code:
    1. Private Sub Form_Load()
    2.    
    3.     'disable the maximize button from the form
    4.     Dim hMenu As Long
    5.     Dim lstyle As Long
    6.    
    7.     'load background image
    8.     frmIntro.Picture = LoadPicture(App.Path & "\" & "Pictures" & "\" & "mainBackground.jpg")
    9.    
    10.     'set top menu to invisible
    11.     frmIntro.HoverCommand6.Visible = False
    12.     frmIntro.HoverCommand7.Visible = False
    13.     frmIntro.HoverCommand8.Visible = False
    14.     frmIntro.HoverCommand9.Visible = False
    15.     frmIntro.HoverCommand10.Visible = False
    16.    
    17.     'set caption for form at runtime
    18.     frmIntro.Caption = "1:1 card " & Chr(147) & "Because every customer is different" & Chr(153) & Chr(46) & Chr(148)
    19.    
    20.     'set label for copywrite
    21.     frmIntro.Label11.Caption = "© Copyright 2004 Virtual Horizons,Inc. All rights reserved."
    22.    
    23.     'create directories if they do not already exist
    24.     If Dir(App.Path & "\" & "CDTypes", vbDirectory) = "" Then
    25.         'MsgBox "Directory doesn't exist"
    26.         MkDir (App.Path & "\" & "CDTypes") ' make new directory
    27.         MkDir (App.Path & "\" & "Images") 'make images directory
    28.         MkDir (App.Path & "\" & "WavFiles") 'make wavFile directory
    29.         MkDir (App.Path & "\" & "pdfs") 'make pdf directory
    30.      Else
    31.          'MsgBox "Directory Exist"
    32.     End If
    33.  
    34.     hMenu = GetSystemMenu(frmIntro.hWnd, False)
    35.     Call RemoveMenu(hMenu, SC_MAXIMIZE, MF_BYCOMMAND)
    36.     Call DrawMenuBar(frmIntro.hWnd)
    37.     lstyle = GetWindowLong(frmIntro.hWnd, GWL_STYLE)
    38.     lstyle = lstyle - WS_MAXIMIZEBOX
    39.     Call SetWindowLong(frmIntro.hWnd, GWL_STYLE, lstyle)
    40.    
    41. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  18. #18

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740
    ok, I removed everything from my module and put it in my form. and changed the code to this:
    VB Code:
    1. 'disable the maximize button from the form
    2.     Dim hMenu As Long
    3.     Dim lstyle As Long
    4.    
    5.     hMenu = GetSystemMenu(frmIntro.hwnd, False)
    6.     Call RemoveMenu(hMenu, SC_MAXIMIZE, MF_BYCOMMAND)
    7.     Call DrawMenuBar(frmIntro.hwnd)
    8.     lstyle = GetWindowLong(frmIntro.hwnd, GWL_STYLE)
    9.     lstyle = lstyle - WS_MAXIMIZEBOX
    10.     Call SetWindowLong(frmIntro.hwnd, GWL_STYLE, lstyle)

    The results were the same, the button itself is disabled, it's just not grayed out.

    However, if I comment out this line as you implied, it works.
    VB Code:
    1. 'set caption for form at runtime
    2.     frmIntro.Caption = "1:1 card " & Chr(147) & "Because every customer is different" & Chr(153) & Chr(46) & Chr(148)

    So, I then tried moving the code to the last lines in the form, and it appears to be working correctly now. So, thnks.

    In the future, if I want to change the minimize or close button, how would I do that?
    He who never made a mistake never made a discovery?

  19. #19
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    The close button is -
    VB Code:
    1. Private Const WM_CLOSE = &H10
    2. 'and in your load procedure.
    3. Call RemoveMenu(hMenu, SC_CLOSE, MF_BYCOMMAND)
    For the minimize button follow the same logic as the Max button but use the consts.
    VB Code:
    1. Private Const SC_MINIMIZE As Long = &HF020
    2. Private Const WS_MINIMIZEBOX As Long = &H20000
    I thought that the setting of the form caption was reverting the
    Max button setting.

    Glad its working for you.

    PS. you could create a Public function and pass the form byref so
    you can centralize the function instead of having it in every form.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  20. #20

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740
    One last question. Can I control the arrows that allow me to resize the window with this code.
    He who never made a mistake never made a discovery?

  21. #21
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    If you are asking about making the form non-resizeable, you can
    just set the form's borderstyle to Fixed or remove the size system
    menu item. If you are asking about only letting a user resize the
    form vertically or something like that then you have to sub-class
    the form. It could be a pain.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  22. #22

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740
    I want the user to beable to minimize the form and close it, but no resize of any kind.
    He who never made a mistake never made a discovery?

  23. #23
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Easiest way is to change the forms borderstyle to fixed in design
    mode. It will not allow any resizing of any direction. Only
    minimize, move, and close.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  24. #24

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740
    If I do that though, I can't minimize, can I?
    He who never made a mistake never made a discovery?

  25. #25
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Whenever you change the form's borderstyle property in design
    mode, it will remove the max and min buttons. Just set the min
    property to true after you change the borderstyle to fixed and
    you can minimize.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  26. #26

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740
    Hmm. I didn't know that I learned something new today!
    He who never made a mistake never made a discovery?

  27. #27
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253
    How about disabling the X button? I had the code, but lost it

  28. #28
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    VB Code:
    1. Public Declare Function GetMenuItemCount _
    2. Lib "user32" (ByVal hMenu As Long) As _
    3. Long
    4.  
    5. Public Declare Function GetSystemMenu Lib _
    6. "user32" (ByVal hwnd As Long, ByVal _
    7. bRevert As Long) As Long
    8.  
    9. Public Declare Function RemoveMenu Lib _
    10. "user32" (ByVal hMenu As Long, ByVal _
    11. nPosition As Long, ByVal wFlags As Long) _
    12. As Long
    13.  
    14. Public Declare Function DrawMenuBar Lib _
    15. "user32" (ByVal hwnd As Long) As Long
    16.  
    17. Public Const MF_REMOVE = &H1000&
    18. Public Const MF_INSERT = &H0&
    19. Public Const MF_ENABLED = &H0&
    20. Public Const MF_BYPOSITION = &H400&
    21.  
    22. Public Sub DisableX(frm As Form, blnDisabled As Boolean)
    23. Dim hMenu As Long
    24. Dim nCount As Long
    25.  
    26. If blnDisabled = True Then
    27. hMenu = GetSystemMenu(frm.hwnd, 0)
    28. nCount = GetMenuItemCount(hMenu)
    29. Call RemoveMenu(hMenu, nCount - 1, MF_REMOVE Or MF_BYPOSITION)
    30. Call RemoveMenu(hMenu, nCount - 2, MF_REMOVE Or MF_BYPOSITION)
    31. DrawMenuBar frm.hwnd
    32. Else
    33. hMenu = GetSystemMenu(frm.hwnd, True)
    34. DrawMenuBar frm.hwnd
    35. End If
    36. End Sub


    Has someone helped you? Then you can Rate their helpful post.

  29. #29
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253
    Thanks

  30. #30
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171


    Has someone helped you? Then you can Rate their helpful post.

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