Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7073827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:58:36+00:00 2026-05-28T05:58:36+00:00

MFC doc/view architecture, sdi (more precisely multiple top-level windows). In my view class, I

  • 0

MFC doc/view architecture, sdi (more precisely multiple top-level windows).

In my view class, I set my “playground” (i.e. logical space) with SetScrollSizes(); Then I want to limit maximum frame window size to that of view’s maximum size.

Here is what I’m doing but I think there might be better solution, please advice:

I’m implementing OnGetMinMaxInfo() in my CMainFrame. There I try to get active view’s scroll sizes, and set lpMMI->ptMaxTrackSize appropriately. Below is the code:

void CMainFrame::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
{
    // Call base version:

    CFrameWndEx::OnGetMinMaxInfo(lpMMI);

    // Get active view:

    CScrollView *pScrollView = (CScrollView *)GetActiveView();

    if (pScrollView && pScrollView->IsKindOf(RUNTIME_CLASS(CMyFckinView)))
    {
        // Get total size of playground:

        CSize sizePlayground = pScrollView->GetTotalSize();

        // Test if the size is non-zero, i.e. there is at least one node displayed:

        if (sizePlayground.cx && sizePlayground.cy/* && !IsPrintPreview()*/)
        {
            // Set maximum window size to match our playground size:

            CRect rectClient, rectWindow;

            pScrollView->GetClientRect(&rectClient);
            this->GetWindowRect(&rectWindow);

            if (rectWindow.top > -5000 && rectWindow.left > -5000) // Avoid when minimized...
            {
                lpMMI->ptMaxTrackSize.x = sizePlayground.cx + (rectWindow.Width() -  rectClient.Width());
                lpMMI->ptMaxTrackSize.y = sizePlayground.cy + (rectWindow.Height() - rectClient.Height());

                return;
            }
        }
    }
}

This works but has one problem: When print preview is displayed (standard MFC print preview), I obviously want to allow free window resizing, so I use runtime info GetActiveView()->IsKindOf(…) to determine that active view is really my view, and not print-preview’s view (which is CPreviewViewEx). But when I close the print preview, OnGetMinMaxInfo is not called, so I’m unable to adjust frame size according to my view again. As soon as I move the window OnGetMinMaxInfo gets called again and correctly adjusts frame size, but without manually moving the window old size (to which the print preview was sized to) is retained and has ugly artifact.

What can I do? Basically if I could trap the moment when print preview is closed, I could use following trick:

// Trigger the WM_MINMAXINFO message:

CFrameWnd *pFrame = GetParentFrame();
RECT rectWindow;
pFrame->GetWindowRect(&rectWindow);
pFrame->MoveWindow(&rectWindow);

But I don’t know how to trap print-preview closure.

What I’m trying to accomplish seems quite standard: who would want to have frame window resized bigger than view’s logical size (set by SetScrollSizes())? So there should be some more natural solution maybe?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:58:36+00:00Added an answer on May 28, 2026 at 5:58 am

    In your CMyFckinView, handle a message that is reliably sent when the print preview is closed and then post a user message to the mainframe which will trigger your “force minmax” code. Perhaps WM_FOCUS or WM_ACTIVATE?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

MFC doc/view architecture, GDI drawing/printing. I have a DIB backbuffer I need to display
I'm using MFC's doc/view architecture to implement printing. I use double buffering, I draw
How do I persuade the MFC Doc/View architecture to let me simultaneously display two
In MFC I'm trying to set a null handler timer (ie. no windows). But
In a NON doc/view MFC application with office-like ribbon, with one CView, how do
I wrote a porgram with a few standard dialogs in an SDI (Doc/View enabled)
In MFC, a CListBox has a disable no scroll property. When you set it
I'm using the Qt/MFC Migration Framework tool following this example: http://doc.qt.nokia.com/solutions/4/qtwinmigrate/winmigrate-qt-dll-example.html The dll I
The MFC has all class names that start with C. For example, CFile and
In my MFC application, I am using CFile class to write data to file.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.