resize Form/controls/fonts dynamically to fit diff screen resoluti

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?UmljaA==?=

    resize Form/controls/fonts dynamically to fit diff screen resoluti

    A lot of users at my workplace use different screen resolutions, and I build
    apps to use 1680 x 1050 pixels res by default. But some users are using 800
    x 600, and the apps are too large for their screen.

    I used to write code in Java a few years ago (2005), and you could stretch a
    form with the mouse and all the controls and fonts would resize to larger or
    smaller size. Does .Net framework 3.5 support this kind of functionality?
    Or - is it possible to change the size of a form/controls/fonts like a google
    map?

    Any suggestions appreciated how I could deal with the different screen
    resolutions with VB.Net (2005/2008).

    Thanks,
    Rich
  • Michel Posseth  [MCP]

    #2
    Re: resize Form/controls/fonts dynamically to fit diff screen resoluti


    Well actually , i was verry surprised when i switched company`s a few years
    ago that there actually are programmers who do not care about screen
    resolutions and design forms for just one standard screen size ( a few of
    my current collegues ).

    I however design all my programs to fit different screen resolutions, in
    ..Net you can do this with multiple handy controls ( table layout pannel is
    one of my favorits )
    but you get pretty far with just docking and anchoring your controls the
    right way .

    Font sizes however i do not touch as they should be system specific

    regards

    Michel Posseth
    ASP.NET hosting, SQL hosting, AJAX Hosting, Silverlight hosting, LINQ Hosting, Microsoft Windows 2012 hosting, iis8 hosting, Windows 2012 R2 hosting, iis8.5 hosting.






    "Rich" <Rich@discussio ns.microsoft.co mschreef in bericht
    news:51A91D3F-1A74-4C6A-B583-9F36359CE73E@mi crosoft.com...
    >A lot of users at my workplace use different screen resolutions, and I
    >build
    apps to use 1680 x 1050 pixels res by default. But some users are using
    800
    x 600, and the apps are too large for their screen.
    >
    I used to write code in Java a few years ago (2005), and you could stretch
    a
    form with the mouse and all the controls and fonts would resize to larger
    or
    smaller size. Does .Net framework 3.5 support this kind of
    functionality?
    Or - is it possible to change the size of a form/controls/fonts like a
    google
    map?
    >
    Any suggestions appreciated how I could deal with the different screen
    resolutions with VB.Net (2005/2008).
    >
    Thanks,
    Rich

    Comment

    • =?Utf-8?B?a2ltaXJhaWtrb25lbg==?=

      #3
      RE: resize Form/controls/fonts dynamically to fit diff screen resoluti

      Hi,
      First you can look at this documentation on MSDN:


      However, if you want to resize your form or specific control dynamically,
      you can use Screen class to determine client PC's screen resolution and
      resize by defining a new Size object like that:

      'eg: To resize form at runtime on computers
      'that have 800x600 screen
      If Screen.PrimaryS creen.Bounds.Wi dth = 800 AndAlso
      Screen.PrimaryS creen.Bounds.He ight = 600 Then
      Me.Size = New Size(width,heig ht )
      End If

      And it's good idea to put the code in Form's load event.

      And of course, it's also good to mention in readme of application that your
      application is best viewed in 1060x1050 resolution :)

      --
      Best regards,

      Onur Güzel



      "Rich" wrote:
      A lot of users at my workplace use different screen resolutions, and I build
      apps to use 1680 x 1050 pixels res by default. But some users are using 800
      x 600, and the apps are too large for their screen.
      >
      I used to write code in Java a few years ago (2005), and you could stretch a
      form with the mouse and all the controls and fonts would resize to larger or
      smaller size. Does .Net framework 3.5 support this kind of functionality?
      Or - is it possible to change the size of a form/controls/fonts like a google
      map?
      >
      Any suggestions appreciated how I could deal with the different screen
      resolutions with VB.Net (2005/2008).
      >
      Thanks,
      Rich

      Comment

      • Michel Posseth  [MCP]

        #4
        Re: resize Form/controls/fonts dynamically to fit diff screen resoluti

        Onur

        I just start my forms maximized if i want them screen filling , cause i
        guess your code has a flaw on a multi monitor system
        what if my primary screen is a 22" inch widescreen monitor , but the creen
        i want to view the app in is a 19 inch normall monitor

        Thus a system with 2 different types of monitors, in the compay i work for
        this is a common scenario
        another nice one My dev system has 2x 22" inch widescreen monitors but with
        both a different screen resolution ( i have one in front of me with VS and
        another one beside with SMS ) the primary screen has a higher resolution as
        the secondary screen , however if i start an app in VS i normally drag it to
        the secondary screen , so i can easier debug the app




        regards

        Michel



        "kimiraikko nen" <kimiraikkonen@ discussions.mic rosoft.comschre ef in bericht
        news:37708E96-B4FD-4BEB-ACD7-F19630BF7378@mi crosoft.com...
        Hi,
        First you can look at this documentation on MSDN:

        >
        However, if you want to resize your form or specific control dynamically,
        you can use Screen class to determine client PC's screen resolution and
        resize by defining a new Size object like that:
        >
        'eg: To resize form at runtime on computers
        'that have 800x600 screen
        If Screen.PrimaryS creen.Bounds.Wi dth = 800 AndAlso
        Screen.PrimaryS creen.Bounds.He ight = 600 Then
        Me.Size = New Size(width,heig ht )
        End If
        >
        And it's good idea to put the code in Form's load event.
        >
        And of course, it's also good to mention in readme of application that
        your
        application is best viewed in 1060x1050 resolution :)
        >
        --
        Best regards,
        >
        Onur Güzel
        >
        >
        >
        "Rich" wrote:
        >
        >A lot of users at my workplace use different screen resolutions, and I
        >build
        >apps to use 1680 x 1050 pixels res by default. But some users are using
        >800
        >x 600, and the apps are too large for their screen.
        >>
        >I used to write code in Java a few years ago (2005), and you could
        >stretch a
        >form with the mouse and all the controls and fonts would resize to larger
        >or
        >smaller size. Does .Net framework 3.5 support this kind of
        >functionalit y?
        >Or - is it possible to change the size of a form/controls/fonts like a
        >google
        >map?
        >>
        >Any suggestions appreciated how I could deal with the different screen
        >resolutions with VB.Net (2005/2008).
        >>
        >Thanks,
        >Rich

        Comment

        • =?Utf-8?B?UmljaA==?=

          #5
          RE: resize Form/controls/fonts dynamically to fit diff screen resoluti

          Thank you all for your replies and suggestions. I guess I will have to
          experiment a little bit. Right now what I do is I have to separate .exe
          files (if you can believe that). One .exe is for any screen res that is not
          800x600 (will still fit on the monitor - we all have the same size monitors
          except for the people using 800x600 - they get someting like a 24" monitor -
          it't not fair ! :). The other .exe is for the 800x600 people

          So I am supporting two separate apps which perform the exact same functions
          (exact same code) except one fits on 800x600. So whatever I do to one app I
          have to redo the exact same thing to the other app - this is getting old real
          fast (I have been doing this for the last 3 years hoping that later version
          of .Net framework wouild have similar functionality as Java).

          Well, I still like .Net way better than Java (not as painful) - but I guess
          Java does have this one feature that would be real nice in .Net.



          "Rich" wrote:
          A lot of users at my workplace use different screen resolutions, and I build
          apps to use 1680 x 1050 pixels res by default. But some users are using 800
          x 600, and the apps are too large for their screen.
          >
          I used to write code in Java a few years ago (2005), and you could stretch a
          form with the mouse and all the controls and fonts would resize to larger or
          smaller size. Does .Net framework 3.5 support this kind of functionality?
          Or - is it possible to change the size of a form/controls/fonts like a google
          map?
          >
          Any suggestions appreciated how I could deal with the different screen
          resolutions with VB.Net (2005/2008).
          >
          Thanks,
          Rich

          Comment

          • Cor Ligthert[MVP]

            #6
            Re: resize Form/controls/fonts dynamically to fit diff screen resoluti

            Rich,

            I will never do that, I use often the anchor and the dock, that means that
            everything streches nicely and by instance textboxes and things like that
            become wider as somebody wish that. The user can simply set his pixel size
            as he needs it.

            As somebody would give me a program that streches the program size because
            of the wide of my screen, I would be very disturbed.

            How would you like it as your Visual Studio on a wide screen was only
            showing a 3 4 part with the bottom away, because somebody has changed the
            pixel size?

            jmo

            Cor

            "Rich" <Rich@discussio ns.microsoft.co mwrote in message
            news:51A91D3F-1A74-4C6A-B583-9F36359CE73E@mi crosoft.com...
            >A lot of users at my workplace use different screen resolutions, and I
            >build
            apps to use 1680 x 1050 pixels res by default. But some users are using
            800
            x 600, and the apps are too large for their screen.
            >
            I used to write code in Java a few years ago (2005), and you could stretch
            a
            form with the mouse and all the controls and fonts would resize to larger
            or
            smaller size. Does .Net framework 3.5 support this kind of
            functionality?
            Or - is it possible to change the size of a form/controls/fonts like a
            google
            map?
            >
            Any suggestions appreciated how I could deal with the different screen
            resolutions with VB.Net (2005/2008).
            >
            Thanks,
            Rich

            Comment

            • =?Utf-8?B?a2ltaXJhaWtrb25lbg==?=

              #7
              Re: resize Form/controls/fonts dynamically to fit diff screen reso

              Hi Michel,
              The sample i've posted was just about a kind of solution for a "specific"
              computer which has 800x600 resolution. As you stated, of course, forcing to a
              fixed resolution may look weird on second monitor, however OP did not mention
              about multi-monitoring environment.

              However, beyond form resizing, if the purpose is also to align UI controls
              on form, it would be a good bet to use Anchor and Dock properties as well.

              --
              Best regards,

              Onur Güzel



              "Michel Posseth [MCP]" wrote:
              Onur
              >
              I just start my forms maximized if i want them screen filling , cause i
              guess your code has a flaw on a multi monitor system
              what if my primary screen is a 22" inch widescreen monitor , but the creen
              i want to view the app in is a 19 inch normall monitor
              >
              Thus a system with 2 different types of monitors, in the compay i work for
              this is a common scenario
              another nice one My dev system has 2x 22" inch widescreen monitors but with
              both a different screen resolution ( i have one in front of me with VS and
              another one beside with SMS ) the primary screen has a higher resolution as
              the secondary screen , however if i start an app in VS i normally drag it to
              the secondary screen , so i can easier debug the app
              >
              >
              >
              >
              regards
              >
              Michel
              >
              >
              >
              "kimiraikko nen" <kimiraikkonen@ discussions.mic rosoft.comschre ef in bericht
              news:37708E96-B4FD-4BEB-ACD7-F19630BF7378@mi crosoft.com...
              Hi,
              First you can look at this documentation on MSDN:


              However, if you want to resize your form or specific control dynamically,
              you can use Screen class to determine client PC's screen resolution and
              resize by defining a new Size object like that:

              'eg: To resize form at runtime on computers
              'that have 800x600 screen
              If Screen.PrimaryS creen.Bounds.Wi dth = 800 AndAlso
              Screen.PrimaryS creen.Bounds.He ight = 600 Then
              Me.Size = New Size(width,heig ht )
              End If

              And it's good idea to put the code in Form's load event.

              And of course, it's also good to mention in readme of application that
              your
              application is best viewed in 1060x1050 resolution :)

              --
              Best regards,

              Onur Güzel



              "Rich" wrote:
              A lot of users at my workplace use different screen resolutions, and I
              build
              apps to use 1680 x 1050 pixels res by default. But some users are using
              800
              x 600, and the apps are too large for their screen.
              >
              I used to write code in Java a few years ago (2005), and you could
              stretch a
              form with the mouse and all the controls and fonts would resize to larger
              or
              smaller size. Does .Net framework 3.5 support this kind of
              functionality?
              Or - is it possible to change the size of a form/controls/fonts like a
              google
              map?
              >
              Any suggestions appreciated how I could deal with the different screen
              resolutions with VB.Net (2005/2008).
              >
              Thanks,
              Rich
              >
              >
              >

              Comment

              • rowe_newsgroups

                #8
                Re: resize Form/controls/fonts dynamically to fit diff screenresoluti

                On Oct 27, 3:46 pm, Rich <R...@discussio ns.microsoft.co mwrote:
                A lot of users at my workplace use different screen resolutions, and I build
                apps to use 1680 x 1050 pixels res by default.  But some users are using 800
                x 600, and the apps are too large for their screen.  
                >
                I used to write code in Java a few years ago (2005), and you could stretch a
                form with the mouse and all the controls and fonts would resize to largeror
                smaller size.   Does .Net framework 3.5 support this kind of functionality?  
                Or - is it possible to change the size of a form/controls/fonts like a google
                map?  
                >
                Any suggestions appreciated how I could deal with the different screen
                resolutions with VB.Net (2005/2008).
                >
                Thanks,
                Rich
                One of the main reasons that WPF was created was to deal with issues
                of screen resolution. If you're still early in development, it might
                be worth a look to see if you could better leverage the WPF features
                than the standard WinForm controls.

                Thanks,

                Seth Rowe [MVP]

                Comment

                • =?Utf-8?B?UmljaA==?=

                  #9
                  Re: resize Form/controls/fonts dynamically to fit diff screen reso

                  I have not specifically dealt with WPF - I only know it stands for windows
                  presentation foundation. What kind of articles could I search for that may
                  have sample code which is based on WPF?



                  "rowe_newsgroup s" wrote:
                  On Oct 27, 3:46 pm, Rich <R...@discussio ns.microsoft.co mwrote:
                  A lot of users at my workplace use different screen resolutions, and I build
                  apps to use 1680 x 1050 pixels res by default. But some users are using 800
                  x 600, and the apps are too large for their screen.

                  I used to write code in Java a few years ago (2005), and you could stretch a
                  form with the mouse and all the controls and fonts would resize to larger or
                  smaller size. Does .Net framework 3.5 support this kind of functionality?
                  Or - is it possible to change the size of a form/controls/fonts like a google
                  map?

                  Any suggestions appreciated how I could deal with the different screen
                  resolutions with VB.Net (2005/2008).

                  Thanks,
                  Rich
                  >
                  One of the main reasons that WPF was created was to deal with issues
                  of screen resolution. If you're still early in development, it might
                  be worth a look to see if you could better leverage the WPF features
                  than the standard WinForm controls.
                  >
                  Thanks,
                  >
                  Seth Rowe [MVP]

                  >

                  Comment

                  • Tom Shelton

                    #10
                    Re: resize Form/controls/fonts dynamically to fit diff screen reso

                    On 2008-10-28, Rich <Rich@discussio ns.microsoft.co mwrote:
                    I have not specifically dealt with WPF - I only know it stands for windows
                    presentation foundation. What kind of articles could I search for that may
                    have sample code which is based on WPF?
                    >
                    >
                    >
                    Well googling WPF would be a good start. And if you're interested in books,
                    well I have a couple I like and they are:

                    Adam Nathan - "Windows Presentation Foundation Unleashed" - ISBN 0-672-32891-7
                    Charles Petzold - "Applicatio ns = Code + Markup: A Guide to Microsoft Windows
                    Presentation Foundation" - ISBN 0-7356-1957-3

                    The only drawback maybe if you don't know C# at all, since both books use C#
                    for their code examples (though, there are very few code examples in the Adam
                    Nathan's book - his primarily focuses on XAML, and that is the same in VB.NET
                    or C#).

                    HTH
                    --
                    Tom Shelton

                    Comment

                    • James Hahn

                      #11
                      Re: resize Form/controls/fonts dynamically to fit diff screen reso

                      The C#-only examples for WPF (which is also a significant problem in MSDN)
                      can be handled using the on-line code conversion sites - the samples are
                      well within any size limits those sites impose, and the conversion is
                      usually very good. A bigger problem is getting to grips with XAML, which
                      seems to be supported _only_ by examples with very little explanation, and
                      limited supporting utilities.

                      OP can start here:
                      Learn how to interoperate Windows Presentation Foundation's environment for creating applications and Win32 code.


                      The conversion of existing projects to WPF is best managed by hosting WPF
                      content within a Win32 application. But OP needs to be careful - there is a
                      lot of material available that does not specify the Framework version it
                      applies to, and is now seriously out of date as a result of the big changes
                      in WPF that have occurred since its release.

                      "Tom Shelton" <tom_shelton@co mcastXXXXXXX.ne twrote in message
                      news:OKFS6vTOJH A.3748@TK2MSFTN GP04.phx.gbl...
                      On 2008-10-28, Rich <Rich@discussio ns.microsoft.co mwrote:
                      >I have not specifically dealt with WPF - I only know it stands for
                      >windows
                      >presentation foundation. What kind of articles could I search for that
                      >may
                      >have sample code which is based on WPF?
                      >>
                      >>
                      >>
                      >
                      Well googling WPF would be a good start. And if you're interested in
                      books,
                      well I have a couple I like and they are:
                      >
                      Adam Nathan - "Windows Presentation Foundation Unleashed" - ISBN
                      0-672-32891-7
                      Charles Petzold - "Applicatio ns = Code + Markup: A Guide to Microsoft
                      Windows
                      Presentation Foundation" - ISBN 0-7356-1957-3
                      >
                      The only drawback maybe if you don't know C# at all, since both books use
                      C#
                      for their code examples (though, there are very few code examples in the
                      Adam
                      Nathan's book - his primarily focuses on XAML, and that is the same in
                      VB.NET
                      or C#).
                      >
                      HTH
                      --
                      Tom Shelton

                      Comment

                      Working...