Designing an MFC application that will work in all resolutions?

I am currently developing my first GUI for Windows. I use MFC and Visual Studio 2008. The monitor that I developed for my program has 1680x1050 native resolution. If I compile and send my program to one of my employees to work on my computer (usually a laptop running 1024x768), my program will not fit on their screen.

I am trying to read how to create an MFC application so that it runs at all permissions, but I continue to find misleading information. Everywhere I look, it seems that DLU should resize your application for you, and that the only time you should run into problems is when you have an actual bitmap whose resolution you need to worry about. But if so, why will my program no longer be on my screen when I set my monitor to a lower resolution? Instead of my program “shrinking” to tackle the same amount of screen real estate that it uses at 1680x1050, it becomes huge and grainy.

The “obvious” solution here is to set my resolution to 1024x768 and redesign my program to fit on the screen. Except that I have already fastened everything in my dialogs as much as possible in order to try to configure my program on the screen with a resolution of 1024x768. My dialog fonts are installed in Microsoft Sans Serif 8, but when working with a resolution of 1024x768 they still seem huge (much more than 8 points).

I know there must be a way to get my program to maintain the same scaling ... right? Or is this the wrong approach to solving the problem? What is the correct / standard way to develop an MFC program so that it can work at many resolutions, say, 800x600 and higher?

+4
source share
3 answers

I assume that your application GUI is based on a dialog (the main window is a dialog)?

In this case, you have a problem because, as you have discovered, MFC does not support the correct resizing of the dialog box. Your options:

  • Redesign your GUI to use the SDI or MDI GUI.
  • Use the extension to resize the dialog box. There are many available, for some very good suggestions, see this question . Other options are this and this .
  • Do not use MFC. wxWidgets has much better support for modifying dialogs.
+2
source

MFC is just a thin shell over the Windows API. They both make an assumption that is hardly ever true: if you have a higher resolution screen, you will adjust the DPI or font size on Windows to get larger characters. In most cases, a larger screen size means a larger physical monitor or laptop, where you want to compress as much information as possible onto a small screen; people value more information in more detail. Thus, the assumption fails.

If you cannot compress the entire user interface to the smallest screen size that you need to support, you will have to find another way to reduce it. Without knowing anything about your user interface, I would suggest using tabs to group controls into pages.

I am fortunate that my windows are resized so that people with large screens can see more information right away. You need to do this in a complex way by responding to the WM_SIZE message in the window and determining which controls should be enlarged and which should just be moved.

+2
source

There is no automatic way to resize your dialogs when you change the resolution. So you need to set some boundaries.

Option 1. If you are developing your application for clients, select one minimum resolution (for example, 1024x7678), redesign your dialogs so that everything matches. It is possible to split some into several or to use a strip control tablet.

Option 2. Create separate dialog forms for each permission that you want to support, but use the same class to handle it. At run time, determine the resolution and use the appropriate form.

Option 3. Write your own resizing functions so that the user can customize the size of your dialogs to your liking.

+1
source

Source: https://habr.com/ru/post/1286781/


All Articles