Solved

Windows FormView Application: How do I ensure that forms fit display without scrolling.

Posted on 2014-10-13
6
166 Views
Last Modified: 2014-10-23
I am working on a Windows Application written In Visual Studio MFC. The application has CFormView  derived child windows.  
The application was written for 14" CRT monitors. Now all the users have 24" monitors and so the forms appear small. In short, we are not making full use of screen real estate. So we decided to enlarge the forms for 1980x1080 resolution (the recommended resolution for most users).  This was good for most users, however some critical users are complaining. They are those who use dual monitors, different screen resolutions, fonts, font size. They want original screen size back. How to deal with such a situation? Is there a programmatic way?
0
Comment
Question by:vakils
  • 3
  • 3
6 Comments
 
LVL 32

Accepted Solution

by:
sarabande earned 500 total points
ID: 40379271
there are two ways:

1. you may have two dialog resources for each form one for 1024x768 screens and one for 1980x1080 displays.

    when you create the form you may choose the one or the other dialog id depending
    on the current screen resolution (or on user preference).
    that could be done in the constructor of your formview class where the IDD was passed as argument.
   
   
CTestFormView::CTestFormView()
	: CFormView(CTestFormView::IDD)
    {
	// TODO: add construction code here
    }

Open in new window


     you would replace the CTestFormView::IDD argument like

   
CTestFormView::CTestFormView()
	: CFormView(CTestForm::UseWideResolution()? CTestFormView::IDDW : CTestFormView::IDDS)
    {
	// TODO: add construction code here
    }

Open in new window


   where TestForm::UseWideResolution would be a static function of your
   application class which returns true if a wide resolution was required.
   
   note, both the forms must have same controls.

2. You may enlarge the forms dynamically after loading the 1024x768 form resources.

     that could be done in the OnInitialUpdate function of your formview class. you would change
     font, size and/or position of the form and each control. calculating the new sizes is somewhat
     difficult as the form size is based on "dialog units" which are not scaling linearly.

Sara
0
 

Author Comment

by:vakils
ID: 40385337
Hi Sara,
Option 2 is not feasible as we have about 40 form views each having lots of controls. Option 1, needs to be tweaked for run time. But, creating another set of views for low resolution is again a time consuming effort, which we don't have. I was looking for a solution like in web based application, Ctrl + or - would change the size of page you are viewing.  It seems that there is no such easy option for apps where each user has personalized resolution, font and it's size. Some have dual monitors. So we are going back to original resolution.
0
 
LVL 32

Expert Comment

by:sarabande
ID: 40386164
I was looking for a solution like in web based application, Ctrl + or - would change the size of page you are viewing.
why not changing your form views to html views?

Option 2 is not feasible as we have about 40 form views each having lots of controls.
you may derive a class from CFormView and derive all your form view classes from that. then you could encapsulate all the resizing stuff into the new class.

from my experience option 1 is the easiest, best looking and less error-prone method. you probably already have both the resources and the concept easily could be enhanced to additional scales if required.

Sara
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:vakils
ID: 40395801
Hi Sara,
Sorry for delayed reply. Can you attach a small sample using html view?
0
 
LVL 32

Expert Comment

by:sarabande
ID: 40396393
0
 

Author Comment

by:vakils
ID: 40400599
Hi Sara,
Thanks for the link. From samples,  CHTMLView is used basically to render a web page or for making web browser based app, which is not the intent here. Our forms have grids and controls and data is pulled from database. and to render them in HTML would take resources (time and money) that otherwise will be used in enhancing/adding functionality to the app. Also, a HTML based web client is being developed to replace C++ MFC front-end.
In short, it's a low priority item.
But, thanks anyway, it seems the solution you gave- have two resource ID's per form window form, is simplest and elegant, but again it gets convoluted where we invoke a form window from another form window using resource ID or check whether user has access permission to a particular form.
Regards,
-vakils-
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now