Results 1 to 31 of 31

Thread: how to fix the form size to screen

  1. #1

    Thread Starter
    Hyperactive Member wizkid's Avatar
    Join Date
    Dec 2005
    Location
    uk
    Posts
    405

    how to fix the form size to screen

    I've created a form with sstab control on my pc(1280X768 screen resolution)
    And i am trying to run the form on other pc(with 1280 X1024 screen resolution).The Form is fully designed with different controls(SStab..combo etc...)

    I have the problem that the form is not displaying completely,
    i can view only one part of the form.

    Is it a problem with the screen resolution??
    I used the following different types of code for resize.

    but it is not working
    ??Any suggestionos please

    VB Code:
    1. Private Sub Form_Load()
    2.    Me.Height = Screen.Height
    3.     Me.Width = Screen.Width
    4. End Sub
    5.  
    6. Private Sub Form_Load()
    7. fme.Move Screen.Width - me.Width, Screen.Height - Me.Height
    8. end sub
    9.  
    10. Private Sub Form_Load()
    11.  
    12. Me.Move (Screen.Width - Me.Width) / 2, _
    13.    (Screen.Height - Me.Height) / 2
    14. end sub
    Thanks

  2. #2
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: how to fix the form size to screen

    I actually posted something like this recently where I used me.width=screen.width (BTW, you forgot me.top = 0 and me.left=0 to make sure the form is at the top left) but there's a better way :-)

    click on the form and in properties scroll down to "windowstate"...set this to maximised (and you could also set borderstyle to none if you want it looking totally full-screen :-))

  3. #3

    Thread Starter
    Hyperactive Member wizkid's Avatar
    Join Date
    Dec 2005
    Location
    uk
    Posts
    405

    Re: how to fix the form size to screen

    ok i will try with this modification
    thanks

  4. #4
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: how to fix the form size to screen

    I think this can be achieved if you set WindowState = 2-Maximized in design mode to your form.

    No need to set height and width in form load event.
    CS

  5. #5
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: how to fix the form size to screen

    I would use the .Move property instead of the individual properties (.Left, .Top, etc.) so that the form re-size event only fires once.
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  6. #6
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: how to fix the form size to screen

    CS

  7. #7

    Thread Starter
    Hyperactive Member wizkid's Avatar
    Join Date
    Dec 2005
    Location
    uk
    Posts
    405

    Re: how to fix the form size to screen

    No it is not working

    Me.Height = Screen.Height
    Me.Top = 0
    Me.Left = 0
    Me.Width = Screen.Width

  8. #8

    Thread Starter
    Hyperactive Member wizkid's Avatar
    Join Date
    Dec 2005
    Location
    uk
    Posts
    405

    Re: how to fix the form size to screen

    me.Move Screen.Width - me.Width, Screen.Height - Me.Height
    it is also no working

    i changed the design time properties to window state 2
    but no use

  9. #9
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: how to fix the form size to screen

    do you have any other code in form resize?
    CS

  10. #10
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: how to fix the form size to screen

    Quote Originally Posted by cssriraman
    I think this can be achieved if you set WindowState = 2-Maximized in design mode to your form.

    No need to set height and width in form load event.
    Read my reply...'s what I said :-P

  11. #11

    Thread Starter
    Hyperactive Member wizkid's Avatar
    Join Date
    Dec 2005
    Location
    uk
    Posts
    405

    Re: how to fix the form size to screen

    click on the form and in properties scroll down to "windowstate"...set this to maximised (and you could also set borderstyle to none if you want it looking totally full-screen :-)) ..This one??
    Yes i used this one also smux


    no there is no other code to change the form design,cssriraman

    border style=none
    window state maximized

    VB Code:
    1. Me.Move (Screen.Width - Me.Width) / 2, _
    2.    (Screen.Height - Me.Height) / 2

    Or
    i am trying with
    No it is not working

    VB Code:
    1. Me.Height = Screen.Height
    2. Me.Top = 0
    3. Me.Left = 0
    4. Me.Width = Screen.Width

  12. #12
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: how to fix the form size to screen

    there's not much I can say except at the END of the form_load put "msgbox form1.windowstate" (replace form1 with the form's name) and see if that returns "maximised"...if not, try putting "form1.windowstate = maximised" IN the actual Form_Load (again, replace name)

  13. #13
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: how to fix the form size to screen

    is your problem that it's not displaying maximized or that it's cutting the controls off?

    if the latter then you have to position your controls in the Form_Resize event of the form - it won't do it automatically for you.

  14. #14

    Thread Starter
    Hyperactive Member wizkid's Avatar
    Join Date
    Dec 2005
    Location
    uk
    Posts
    405

    Re: how to fix the form size to screen

    Even i put my windowstate maximize state it is not full maximizing in other pc
    my sstab fully not visible

  15. #15

    Thread Starter
    Hyperactive Member wizkid's Avatar
    Join Date
    Dec 2005
    Location
    uk
    Posts
    405

    Re: how to fix the form size to screen

    other thing is i am trying to print windowstate
    like msgbox form1.windowstate in form load then
    it is giving value 0 not 2

  16. #16
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: how to fix the form size to screen

    Then it's telling you that it isn't doing it. Make the FIRST line in form_load "form1.windowstate = 2"

    Sometimes you have to poke VB with a sharp stick to make it do things, it doesn't like your choices in properties and decides to use its own...you have to manually set them in the code :-)

  17. #17

    Thread Starter
    Hyperactive Member wizkid's Avatar
    Join Date
    Dec 2005
    Location
    uk
    Posts
    405

    Re: how to fix the form size to screen

    Already i did it
    but no use
    it is showing as 0
    form1.WindowState = 2

  18. #18
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: how to fix the form size to screen

    me.windowstate = 2 also works and would work in any form_load for any form...try commenting out everything else in the form.

    And when you say "isn't working" what exactly is the problem?

  19. #19

    Thread Starter
    Hyperactive Member wizkid's Avatar
    Join Date
    Dec 2005
    Location
    uk
    Posts
    405

    Re: how to fix the form size to screen

    yes i just tried taking a new project and only with one form,without any code
    and in form load just one message.
    Form design properties windowstate =2

    Sub Form_Load()

    MsgBox Form1.WindowState

    End Sub

    it returns 0
    i don't know why?

  20. #20
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: how to fix the form size to screen

    as I said above, put "form1.windowstate = 2" INTO form_load on the new project...it's exactly what I did and it works fine

  21. #21

    Thread Starter
    Hyperactive Member wizkid's Avatar
    Join Date
    Dec 2005
    Location
    uk
    Posts
    405

    Re: how to fix the form size to screen

    Private Sub Command1_Click()
    MsgBox Form1.WindowState
    End Sub

    Private Sub Form_Load()
    MsgBox Form1.WindowState
    End Sub

    in form load it is showing 0
    and in command1_click it is showing 2

    i don't know what it is?

  22. #22
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: how to fix the form size to screen

    it returns 0 because the form is not maximized.

    If you set the WindowState in the property window then the form will be set to that state once Form_Load() has finished.

  23. #23

    Thread Starter
    Hyperactive Member wizkid's Avatar
    Join Date
    Dec 2005
    Location
    uk
    Posts
    405

    Re: how to fix the form size to screen

    but in design time i change the property to 2
    .If i want put it in form load what should i do?

  24. #24
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: how to fix the form size to screen

    http://www.vbforums.com/showpost.php...9&postcount=20

    I just told you EXACTLY what to do to put it into form_load...not put msgbox line but put the line I said in post 20

  25. #25
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: how to fix the form size to screen

    when initially loaded all forms have their windowstate set to 0 - regardless of what you did at design time.

    why is that problem? - when the form is shown it will be maximized.

  26. #26

    Thread Starter
    Hyperactive Member wizkid's Avatar
    Join Date
    Dec 2005
    Location
    uk
    Posts
    405

    Re: how to fix the form size to screen

    Still my form is not completely maximized in my frd system.

  27. #27
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

    Re: how to fix the form size to screen

    Start a new project with no code in the form, set Windowstate to maximised in the "Properties" window.
    Run it in the IDE. If it's NOT maximised, you may have to re-install VB.
    If it IS maximised, create the exe and see what it does on BOTH PCs.
    If it works on yours but not on the other..........

  28. #28

    Thread Starter
    Hyperactive Member wizkid's Avatar
    Join Date
    Dec 2005
    Location
    uk
    Posts
    405

    Re: how to fix the form size to screen

    That is the problem,
    In my system it is working,i.e. maximized., but not in other system

  29. #29
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

    Re: how to fix the form size to screen

    Then the problem is with your 2nd PC, not your program.
    Last edited by schoolbusdriver; Jun 10th, 2006 at 02:11 AM. Reason: Clarification...

  30. #30
    Junior Member teamer's Avatar
    Join Date
    May 2006
    Posts
    17

    Re: how to fix the form size to screen

    And try deleting that sstab control !!!!

  31. #31

    Thread Starter
    Hyperactive Member wizkid's Avatar
    Join Date
    Dec 2005
    Location
    uk
    Posts
    405

    Re: how to fix the form size to screen

    yes the problem with second pc, not with my pc

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