CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2000
    Posts
    200

    Form is MAXIMUM size ???

    Has the min/max/close buttons in top-right corner, but form ALWAYS max. (?) Is their a property I'm not seeing? I want it to be smaller when it opens.

    Thanks for any assistance!


  2. #2
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: Form is MAXIMUM size ???

    Check the WindowState property of the form.


  3. #3
    Join Date
    May 2001
    Location
    Russia
    Posts
    200

    Re: Form is MAXIMUM size ???

    In design time set form properties WindowState as Maximized

    After this insert this code

    private Sub Form_Resize()
    If Not Form1.WindowState = vbMaximized then Form1.WindowState = vbMaximized
    End Sub




    Andy Tower

  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Form is MAXIMUM size ???

    >>I want it to be smaller when it opens.
    after the loading of form, and before it is being showed, resize event for the form is called.
    You can put code in load event or in resize event depending if you want it executed once (on load) or each time it is resized.
    If you want it smaller on openig, you can code in load event or set the appropiate width and height in design mode. You will have to play with the screen.width and height to find out how many pixel you can draw.
    Ie: here some code you can play with

    option Explicit

    private Sub Form_DblClick()
    Call Form_Load
    End Sub

    private Sub Form_Load()
    Dim maxWidth as Single
    Dim maxHeight as Single
    'save previous value
    maxWidth = me.Width
    maxHeight = me.Height
    'set the state to normal, or you will not
    'be able to move or resize
    me.WindowState = vbNormal
    'restore previous dimensions even if
    'diffrent from the ones it had last time
    'it was "normal"
    me.Width = maxWidth
    me.Height = maxHeight
    'take screen dimensions
    maxWidth = Screen.Width
    maxHeight = Screen.Height
    'now check for dimensions
    If me.Height >= maxHeight - 1000 then
    me.Height = maxHeight * 0.75
    End If
    If me.Width >= maxWidth - 1000 then
    me.Width = maxWidth * 0.75
    End If
    End Sub






    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  5. #5
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Playing with resolution

    You may find this interesting:
    http://codeguru.earthweb.com/cgi-bin...collapsed&sb=5

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

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

Featured