Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

OnNcCalcSize...

Posted on 1997-05-12
11
Medium Priority
?
1,191 Views
Last Modified: 2013-11-20
I'm looking for a way to override the OnNcCalcSize member function to only allow my CView derived class (and it's FrameWindow of course!)  to be a certain width -  XWIDTH.  I want to be able to change my resizing values if they are greater than XWIDTH, to equal XWIDTH.  What is the best way to do this?  I attempted to change the values of lpncsp->rgrc[0], and then call the default CWnd::OnNcCalcSize() function with very bizarre results...  Any suggestions?
0
Comment
Question by:salamander
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
11 Comments
 
LVL 3

Expert Comment

by:Melange
ID: 1301476
Are you simply attempting to prevent a user from sizing your window too big? Or do you need to do something more complex?

To keep the window within a certain size override the WM_GETMINMAXINFO message for that window (or frame).

For example in an SDI app:

void CMainFrame::OnGetMinMaxInfo( MINMAXINFO *lpMMI )
{
    lpMMI->ptMaxSize.x = 500;
    lpMMI->ptMaxSize.y = 300;

    CFrameWnd::OnGetMinMaxInfo( lpMMI );
}

0
 

Author Comment

by:salamander
ID: 1301477
I added this function to my CView class, with values for lpMMI->ptMaxSize.x and lpMMI->ptMaxSize.y, yet my application allowed resizing past these values.  This is my code:

void CReviewView::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
      lpMMI->ptMaxSize.x = 641;
      lpMMI->ptMaxSize.y = 300;

      CWnd::OnGetMinMaxInfo(lpMMI);
}

This is an MDI application.  Any suggestions?
0
 

Author Comment

by:salamander
ID: 1301478
I added this function to my CView class, with values for lpMMI->ptMaxSize.x and lpMMI->ptMaxSize.y, yet my application allowed resizing past these values.  This is my code:

void CReviewView::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
      lpMMI->ptMaxSize.x = 641;
      lpMMI->ptMaxSize.y = 300;

      CWnd::OnGetMinMaxInfo(lpMMI);
}

This is an MDI application.  Any suggestions?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:salamander
ID: 1301479
I added this function to my CView class, with values for lpMMI->ptMaxSize.x and lpMMI->ptMaxSize.y, yet my application allowed resizing past these values.  This is my code:

void CReviewView::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
      lpMMI->ptMaxSize.x = 641;
      lpMMI->ptMaxSize.y = 300;

      CWnd::OnGetMinMaxInfo(lpMMI);
}

This is an MDI application.  Any suggestions?
0
 
LVL 3

Expert Comment

by:Melange
ID: 1301480
You need to do it to the frame window for the view. The view window is actually a child window inside the frame window and doesn't include the borders and title bar. It's actually the frame window that you are resizing.
0
 

Author Comment

by:salamander
ID: 1301481
I have removed the CView code and inserted it into my CChildFrame code as such:

void CChildFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
      lpMMI->ptMaxSize.x = 641;
      lpMMI->ptMaxSize.y = 300;

      CWnd::OnGetMinMaxInfo(lpMMI);
}

When I run this, it still doesn't work.  The values after calling the default OnGetMinMaxInfo() return to what they were.
0
 

Author Comment

by:salamander
ID: 1301482
It doesn't work if you leave out the default call, either.
0
 
LVL 3

Accepted Solution

by:
Melange earned 100 total points
ID: 1301483
You need to set the MaxTrackSize values in the MINMAXINFO structure. This will do it.

Add these two lines to OnGetMinMaxInfo:

lpMMI->ptMaxTrackSize.x = MaxXValue;
lpMMI->ptMaxTrackSize.y = MaxYValue;

also set the ptMinTrackSize values if you want the window to be at LEAST a certain size.

0
 

Author Comment

by:salamander
ID: 1301484
This works (thank you!)  but how do I change these values on the fly?  For example, how can I check the document associated with this child frame to get the values for MaxX and MaxY?
0
 
LVL 3

Expert Comment

by:Melange
ID: 1301485
The WM_GETMINMAXINFO message keeps getting sent (I believe, but not entirely sure) every time the user attempts to size the window.

To check your current desired size you can use any number of approaches, but the main problem is how do you get access to your document, right? You can call the CFrameWnd function GetActiveDocument which will return a CDocument pointer for the document that the window currently represents. Then, you'll need to cast it to the correct document to access the appropraite class members.

0
 

Author Comment

by:salamander
ID: 1301486
Thanks a lot.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

636 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