Results 1 to 24 of 24

Thread: I need to make my form not resize to anything smaller than...

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2006
    Posts
    389

    I need to make my form not resize to anything smaller than...

    basicly what I need is to make it so my form cant get any smaller than 11640 width X 6105 height but can resize to any size bigger...
    Visual Basic Rules!!!!!

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: I need to make my form not resize to anything smaller than...

    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

  3. #3

  4. #4
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: I need to make my form not resize to anything smaller than...

    vb Code:
    1. Private Sub Form_Resize()
    2. If Me.Width <= 11640 And Me.Height <= 6105 Then
    3. Me.Width = 11640
    4. Me.Height = 6105
    5. End If
    6. End Sub

    Try that.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    May 2006
    Posts
    389

    Re: I need to make my form not resize to anything smaller than...

    would't that cause flickering?
    Visual Basic Rules!!!!!

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    May 2006
    Posts
    389

    Re: I need to make my form not resize to anything smaller than...

    that crashed my app...
    Visual Basic Rules!!!!!

  7. #7
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: I need to make my form not resize to anything smaller than...

    No no flickering. Test it

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    May 2006
    Posts
    389

    Re: I need to make my form not resize to anything smaller than...

    Quote Originally Posted by Hell-Lord
    No no flickering. Test it

    yes yes flickering... just resize it smaller... it goes crazy...
    Visual Basic Rules!!!!!

  9. #9
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: I need to make my form not resize to anything smaller than...

    No doesn't do that for me, it just jumps straight away to the smallest size allowed. No consistent flickering. However i will test the code in rob's link and see how that compares.

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    May 2006
    Posts
    389

    Re: I need to make my form not resize to anything smaller than...

    ok do this take an resize the form to the smallest size you can get it then let go of the mouse and while you do that you can see the flickering
    Visual Basic Rules!!!!!

  11. #11
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: I need to make my form not resize to anything smaller than...

    O btw it should be
    vb Code:
    1. Or
    instead of
    vb Code:
    1. And
    in the code

  12. #12
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: I need to make my form not resize to anything smaller than...

    Quote Originally Posted by vbman213
    ok do this take an resize the form to the smallest size you can get it then let go of the mouse and while you do that you can see the flickering
    No flickering at all for me, it just goes immediately back to the smallest allowed size and thats it It might be your computer.

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    May 2006
    Posts
    389

    Re: I need to make my form not resize to anything smaller than...

    umm weird
    Visual Basic Rules!!!!!

  14. #14
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: I need to make my form not resize to anything smaller than...

    I tested the code in the link, it works well. I would probably use it over mine Have a look at it

  15. #15
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: I need to make my form not resize to anything smaller than...

    Quote Originally Posted by vbman213
    that crashed my app...
    Before you subclass make sure there are no other sources of error in your source code or handle them accordingly.

  16. #16
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: I need to make my form not resize to anything smaller than...

    Yes, the link I posted used subclassing so you can not stop the program from running by pressing the stop button on the VB IDE or it will crash your app. You need to press your close button or the 'x' close button.

    You can modify the faq code to do whatever you want as it uses subclassing there will be absolutely no flickering.
    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

    Thread Starter
    Hyperactive Member
    Join Date
    May 2006
    Posts
    389

    Re: I need to make my form not resize to anything smaller than...

    Ok thanks so much... now I have one more question...

    the lines of that code that are the const. for the max width and height... how can I calculate that with the current users screen size so it will maximize properly or how can I just disable the Max_width, Max_Height
    Visual Basic Rules!!!!!

  18. #18
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,448

    Re: I need to make my form not resize to anything smaller than...

    Just remove the sections of code concerned with Max Width/Height, the form will maximize correctly

  19. #19
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: I need to make my form not resize to anything smaller than...

    If your computer is set to show windows contents while dragging, it triggers the form paint event constantly while resizing the window. Perhaps that is why some people are seeing flickering and others are not.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  20. #20

    Thread Starter
    Hyperactive Member
    Join Date
    May 2006
    Posts
    389

    Re: I need to make my form not resize to anything smaller than...

    I removed that and it crashes...
    Visual Basic Rules!!!!!

  21. #21
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,448

    Re: I need to make my form not resize to anything smaller than...

    Quote Originally Posted by vbman213
    I removed that and it crashes...
    You do have to be careful when sub classing

    Did you remove
    Code:
     'Keep the form only as wide as MAX_WIDTH
            If (r.RIGHT - r.Left > MAX_WIDTH) Then
                Select Case wParam
                    Case WMSZ_LEFT, WMSZ_BOTTOMLEFT, WMSZ_TOPLEFT
                        r.Left = r.RIGHT - MAX_WIDTH
                    Case WMSZ_RIGHT, WMSZ_BOTTOMRIGHT, WMSZ_TOPRIGHT
                        r.RIGHT = r.Left + MAX_WIDTH
                End Select
            End If
            
            'Keep the form only as tall as MAX_HEIGHT
            If (r.Bottom - r.Top > MAX_HEIGHT) Then
                Select Case wParam
                    Case WMSZ_TOP, WMSZ_TOPLEFT, WMSZ_TOPRIGHT
                        r.Top = r.Bottom - MAX_HEIGHT
                    Case WMSZ_BOTTOM, WMSZ_BOTTOMLEFT, WMSZ_BOTTOMRIGHT
                        r.Bottom = r.Top + MAX_HEIGHT
                End Select
            End If
    because thats what I meant and it works for me.

  22. #22
    New Member
    Join Date
    Jun 2007
    Posts
    9

    Re: I need to make my form not resize to anything smaller than...

    The other way around is to put the resize command at Mouse Up event. So let the user resize the window as they like but once the Mouse up event occurs, it will be back to the desired size.

    At lease there will no flickering, i promise

  23. #23
    Frenzied Member
    Join Date
    Sep 2006
    Location
    Scotland
    Posts
    1,054

    Re: I need to make my form not resize to anything smaller than...

    Quote Originally Posted by Hell-Lord
    O btw it should be
    vb Code:
    1. Or
    instead of
    vb Code:
    1. And
    in the code
    Would it not be better to use two seperate if statements like this:

    vb Code:
    1. Private Sub Form_Resize()
    2. If Me.Width < 11640 Then Me.Width = 11640
    3. If Me.Height < 6105 Then Me.Height = 6105
    4. End Sub

    This way it means that the width can be reset while leaving the height alone and vice versa.

  24. #24
    Banned
    Join Date
    Jul 2007
    Posts
    400

    Re: I need to make my form not resize to anything smaller than...

    Quote Originally Posted by vbman213
    I removed that and it crashes...


    i believe this is a bugs

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