Click here to Skip to main content
16,017,922 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I have a developed a modal dialog based application in 1152x864 resolution. when i run this in another resolution the window gets truncated.
How to adjust the dialog so that it works adjustable with the resolution with out truncating the windows display when run in the different resolution.
Posted

What «Superman», said is technically correct, but ... you should consider a better GUI design for your application, because ... it doesn't fit the usability requiremts.

The first thing I shold ask myself is why is the dialog so wide.
Is it because it has been required as such? If yes, then your application must nor run on screen smaller than the required size: you should state that in the release note, wharning the user that using that app on a smaller device is not supported because ... it has been required to "not support it"!

If no, than you should make no assumption about the size of the device ad assuming that -if the user has a wide device- may be it is not to have wider window but to have many windos on it. Your design should take the minimum space required to the dialog to be profiquely usable.
If there is too much empty space or very wide controls the user will never fill up completely, reduce them.
If there are control that are "poorly related" (in the sense that what they represent is not mutually dependent on others) they can sit on different dialogs, may be represented as pages;of a container tabbed window.

In general consider that a dialog that's wider to 800x600 (or 1024 x 800 in more extreme cases) is a badly designed dialog. This independently on the width, in pixels, of the screen.

The reason is that the density of a screen is defined to let the screen observed from a fixed distance (usually 50 to 80 centimeter). With the normal resolution of the eyes, this result in a 96dpi density.

The user that has al 1920 or more wider screen, if sitting at 80 cm from it, cannot "focalize" on it entirely: his attention will go to an area that is just 800 pixels wide. He can choose which part of the screen to focalize, but cannot focalize it all. if you fill-up all the screen with controls, the user will never look them all-together simultaneously: he will see some of them, with all the other as just noise around. You had better to capture its attention only to things that are important to be seen together, making those things to fit that area.
So divide your control in "affnity clusters" and give each cluster a different page.

To better feel what I am saying, try opening a long article page, and size your browser to be 1024 pixel wide (no mater how high): you can read the text from top to bottom with just a small movement of the eyes.
Not make your browser 1920 pixel wide: you have to even move your head left to right: reading that text looks like watching a tennis match, and you cannot see the beginning of the line when you are at end, so making the "return" to the next line problematic. that's the reason why wide newspapers are written in "columns". Or... the text itself will not have so wide lines, and the wide browser if left with some empty (wasted) space, that makes the user to resize the browser and eventually open another one aside.

The same happen with application and dialogs. Take care of it!
 
Share this answer
 
v3
Following is the sample code, which you can modify as per your need. You may also need to add the code to move the controls (if any) present on your dialog accordingly.

HWND hwndOwner = NULL; 
    RECT rc, rcDlg, rcOwner; 

    // Get the owner window and dialog box rectangles. 

    hwndOwner = GetDesktopWindow(); 

    GetWindowRect(hwndOwner, &rcOwner); 
    GetWindowRect(hwndDlg, &rcDlg); 
    CopyRect(&rc, &rcOwner); 

    // Offset the owner and dialog box rectangles so that right and bottom 
    // values represent the width and height, and then offset the owner again 
    // to discard space taken up by the dialog box. 

    OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top); 
    OffsetRect(&rc, -rc.left, -rc.top); 
    OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom); 

    SetWindowPos(hwndDlg, 
                 HWND_TOP, 
                 rcOwner.left + (rc.right / 2), 
                 rcOwner.top + (rc.bottom / 2), 
                 0, 0,          // Ignores size arguments. 
                 SWP_NOSIZE); 
 
Share this answer
 
You can use the MoveWindow or SetWindowPos APIs to adjust the size of your dialog.
But you will also need to use the above APIs on every control in the dialog to move or resize them so that they will all be visible when the size of the dialog is changed.

You can get the resolution of the screen using the API GetDeviceCaps using the HORZRES and VERTRES parameters.
You can also use the SystemParametesInfo API with the SPI_GETWORKAREA parameter to get the screen resolution.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900