CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 31
  1. #16
    Join Date
    Dec 2009
    Location
    Kathmandu,Nepal
    Posts
    168

    Re: Screen Resolution!!

    OK! I am little confused between the terms "resizing" application and changing the resolution of screen....any way little hint or piece of code for me to work on please.....

  2. #17
    Join Date
    Apr 2007
    Location
    Florida
    Posts
    403

    Re: Screen Resolution!!

    Resizing the application means, you should redesign your UI to make it work on any reasonable resolution the display might happen to be in.

    Changing the resolution of the screen means running your application in full screen mode or in windowed mode typically.

  3. #18
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Screen Resolution!!

    Changing the resolution also means that you alter the user's display settings. For example, because your program can only handle 1024 x 768 resolution, the program programatically changes the system resolution to 1024 x 768.

    As mentioned in a previous post, a well behaved program should not alter user display settings.

  4. #19
    Join Date
    Dec 2009
    Location
    Kathmandu,Nepal
    Posts
    168

    Re: Screen Resolution!!

    Yes Exactly! I thought it would be easier to change the resolution of computer until i got answer from you guys.......the programs I designed have picbox, buttons etc...If computer's resolution is not in exactly 1024 X 768 the whole orientation goes wrong...so what should i do to avoid this....

  5. #20
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Screen Resolution!!

    I can't really stress the importance of leaving the user settings alone.

    Imagine if I wrote a program that moved the taskbar to the left side of the screen, change the resolution to 640 x480 and minimized all open applications to the taskbar. Then after running for 5 minutes, I closed all other running programs.

    Do you think users would like this app?

    Proper app design means that your app runs in the environment is it given and doesn't alter that environment.

  6. #21
    Join Date
    Apr 2007
    Location
    Florida
    Posts
    403

    Re: Screen Resolution!!

    Although WPF applications are a lot easier to scale to window sizes/resolutions, you can still do the same in WinForm.

    I suggest taking a look at the Docking patterns that WinForm (and WPF) provides. With docking, you can essentially force UI elements to alway stay a certain distance away from edges of other UI elements, or borders of the window. This will allow the UI to scale as the size changes.

  7. #22
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Screen Resolution!!

    Quote Originally Posted by rocky_upadhaya View Post
    Yes Exactly! I thought it would be easier to change the resolution of computer until i got answer from you guys.......the programs I designed have picbox, buttons etc...If computer's resolution is not in exactly 1024 X 768 the whole orientation goes wrong...so what should i do to avoid this....
    As explained earlier, you need to respond to resize events and resize the controls. See the attached app and look at the Anchor styles for each control. Between this style and an the Dock style mentioned by Mario, you can get the controls on the form to auto-resize. The first step is to get the form to resize it's controls when the user changes the size of the form (by dragging the resize chevron in the lower right corner of the form).

    See the attached project for a basic form that resizes the controls when the user changes the form size.

    Once you get that down, then the next step is to respond to an DisplaySettings change event (as already outlined in the other post) and programmatically set the form size. If you've done the resizing work here (as shown by the attached project), then the controls will resize when you set the form size.
    Attached Files Attached Files

  8. #23
    Join Date
    Nov 2002
    Location
    .NET 3.5 VS2008
    Posts
    1,039

    Re: Screen Resolution!!

    Quote Originally Posted by rocky_upadhaya View Post
    Yes Exactly! I thought it would be easier to change the resolution of computer until i got answer from you guys.......the programs I designed have picbox, buttons etc...If computer's resolution is not in exactly 1024 X 768 the whole orientation goes wrong...so what should i do to avoid this....
    Here's my advice. Give the picture box fixed dimensions and do the same for the buttons. Change your screen resolution to the minimum resolution you intend to support. Try the application in that resolution and make any adjustments necessary. I've not seen anything in your requirements that indicates the screen has to scale up or down depending on the resolution. You should be able to disable the 'Maximise' button so that your form always has the size (i.e. just big enough to fit all the controls inside it. That way it will look the same in all the resolutions you want to support. Of course under higher higher resolutions your form will take up less space...

  9. #24
    Join Date
    Dec 2009
    Location
    Kathmandu,Nepal
    Posts
    168

    Re: Screen Resolution!!

    Superb!! Exactly what I wanted....Thanks......

  10. #25
    Join Date
    Jul 2004
    Posts
    8

  11. #26
    Join Date
    Dec 2009
    Location
    Kathmandu,Nepal
    Posts
    168

    Re: Screen Resolution!!

    Suppose I have lots of adjecent rtfboxes side by side(say 20)....So only the rightmost rtf box is stretched......is there any way to make this streching or resizing rationally?? ie every rtf boxes should strech equally......

  12. #27
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Screen Resolution!!

    Quote Originally Posted by rocky_upadhaya View Post
    Suppose I have lots of adjecent rtfboxes side by side(say 20)....So only the rightmost rtf box is stretched......is there any way to make this streching or resizing rationally?? ie every rtf boxes should strech equally......
    You'll need to handle the onsize event of the form, get the width of the form and manually resize each of the text boxes.

  13. #28
    Join Date
    Dec 2009
    Location
    Kathmandu,Nepal
    Posts
    168

    Re: Screen Resolution!!

    Code:
                int HtScreen = SystemInformation.PrimaryMonitorSize.Height;
                int WtScreen = SystemInformation.PrimaryMonitorSize.Width;
               
                if (HtScreen < 1030 || HtScreen > 805 && WtScreen<770||WtScreen>595) // checks the screen resolution
                {
                     this.ClientSize = new System.Drawing.Size(1024, 768);  //resizes the size of screen
                    this.rtfBox1.Size = new System.Drawing.Size(80, 200); //resizes from 30,200->80,200
                }
    Is this code valid?? not workin with me....
    Last edited by rocky_upadhaya; February 5th, 2010 at 11:29 AM.

  14. #29
    Join Date
    Dec 2009
    Location
    Kathmandu,Nepal
    Posts
    168

    Re: Screen Resolution!!

    Code:
    
    this.Resize += new System.EventHandler(this.ResizeMy_Resize);
    
    //My Event Defintion
    private void ResizeMy_Resize(object sender, System.EventArgs e)
            {
                int HtScreen = SystemInformation.PrimaryMonitorSize.Height;
                int WtScreen = SystemInformation.PrimaryMonitorSize.Width;
                //this.ClientSize = new System.Drawing.Size(WtScreen , HtScreen );
                this.rtfBox1.Size = new System.Drawing.Size(80, 200);
            }
    Now that I have learned to resize my form according to the screen resolution(I think it is working....do I have to place anchoring code for buttons after resizing too??
    secondly....this.rtfBox1.Size=new System.Drawing.Size(80,200) is not working..........

  15. #30
    Join Date
    Apr 2007
    Location
    Florida
    Posts
    403

    Re: Screen Resolution!!

    Anchoring/Docking is a one time setup. Do it in your designer view or in the control setup code.

Page 2 of 3 FirstFirst 123 LastLast

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