Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Resizing in applications developed with MFC

Posted on 1998-07-02
6
Medium Priority
?
522 Views
Last Modified: 2013-11-19
How can I resize the view of an SDI application (developed in C++ using MS Developer studio) so that the view fits on the screen irrespective of the resolution of the monitor it is running on ? Is there a simple way out to do so or do I need to implement a rather complex resizing logic to format the view depending on the available display area ?
0
Comment
Question by:psapra
6 Comments
 
LVL 7

Expert Comment

by:galkin
ID: 1318677
View is occupied client area of the parent frame. You need to change frame size. To maximize frame call AgxGetMainWnd()->ShowWindow(SW_SHOWMAXIMIZED)
0
 

Author Comment

by:psapra
ID: 1318678
I guess I did not make my question clear. The view has been designed using the developer studio, which means that every control on the form has a fixed position. It whole form fits nicely on a 1024x768 resolution with small fonts. If the font size is changed to large fonts, the whole application view does not fit on the window and it is necessary to scroll vertically and horizontally to see the entire window. Is there a way to fix this ?
0
 
LVL 1

Expert Comment

by:Arkadiy
ID: 1318679
You run into one of more annoying limitations of diaolg templates. However, overcoming that limitation does requre extensive coding. For a generic way to do it, look at GridBagLayout class in Java. You may come up with something much simpler according to your specific form. In any case, extensive programming is enevitable.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 4

Accepted Solution

by:
piano_boxer earned 200 total points
ID: 1318680
Place a hidden control at the bottom right position of the dialog-template, and use this to resize the frame so that all controls are visible.

BOOL CTestView::OnInitialUpdate()
{
    [......]

    CWnd* pWnd = GetDlgItem(IDC_HIDDEN_CONTROL);
    ASSERT_VALID(pWnd);
    CRect rc;
    pWnd->GetWindowRect(&rc);
    ScreenToClient(&rc);

    // Now rc contains (in left/top) the size of the view
    // that we want.

    // Adjust size of frame (and center on screen)
    CSize size(rc.left, rc.top);
    AdjustFramesizeToFit(size);

    [......]
}



void CTestView::AdjustFramesizeToFit(const CSize size)
{
    CRect rcClient, rcAdjust1, rcAdjust2, rcFrame;

    // Get frame windows client rect
    AfxGetMainWnd()->GetClientRect(&rcClient);

    // Get leftover space for view-area
    AfxGetMainWnd()->RepositionBars(0, 0xffff, AFX_IDW_PANE_FIRST, reposQuery, &rcAdjust1);

    // Now we know how much space toolbars etc. are taking.
    // Adjust size of frame window
    rcFrame.left = 0;
    rcFrame.top = 0;
    rcFrame.right = rcAdjust1.left + size.cx + (rcClient.right - rcAdjust1.right) + 4;
    rcFrame.bottom = rcAdjust1.top + size.cy + (rcClient.bottom - rcAdjust1.bottom) + 4;

    AfxGetMainWnd()->ClientToScreen(&rcFrame);
    ::AdjustWindowRectEx(&rcFrame, AfxGetMainWnd()->GetStyle(), TRUE, AfxGetMainWnd()->GetExStyle());

    AfxGetMainWnd()->SetWindowPos(
NULL,
rcFrame.left,
rcFrame.top,
rcFrame.Width(),
rcFrame.Height(),
SWP_NOZORDER|SWP_NOMOVE);

    AfxGetMainWnd()->CenterWindow();
}


.

Please note that the function WILL NOT work correctly if the menu bar wraps around because of to small frame!

0
 
LVL 3

Expert Comment

by:eugenem
ID: 1318681
For dynamic dialog templates go to
http://www.codeguru.com/dialog/dialog_toc.shtml
0
 

Author Comment

by:psapra
ID: 1318682
piano_boxer:

I tried doing what you suggested, but it still doesn't resize the application view. Can you offer any further help ?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

916 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