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

x
?
Solved

CMDIChildWnd maintain a given frame aspect ratio.

Posted on 2001-06-14
6
Medium Priority
?
356 Views
Last Modified: 2013-11-20
VC6/MFC/Win32
I have a MDI that opens various CMDIChildWnd at the same time.  My question is this:  Each CMDIChildWnd must maintain a given aspect ratio.  If I change the size cx, I want cy to move automatically to maintain the set aspect ratio.  If I change the cy I also want cx to also maintain the set aspect ratio.  All suggestions welcome and code samples greatly appreciated.
Surfer
0
Comment
Question by:Surfer
[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
  • 3
  • 2
6 Comments
 
LVL 12

Expert Comment

by:migel
ID: 6190068
Hi!
you can write something like this:
add Windows message handler for WM_SIZE to the your Child frame:

void CChildFrame::OnSize(UINT nType, int cx, int cy)
{
     static bool bReEntrant = false;
     if (!bReEntrant)
          {
          bReEntrant = true;
// aspect ratio 3:1
          if (m_bTrackVertPos)
               cx = 3*cy;
          else
               cy = cx/3;
          SetWindowPos(NULL, 0, 0, cx, cy, SWP_NOMOVE|SWP_NOZORDER);
          bReEntrant = false;
          }
     CMDIChildWnd::OnSize(nType, cx, cy);
}

CChildFrame::CChildFrame()
{
     // TODO: add member initialization code here
     m_bTrackVertPos = false;     // flag set when use resize vertical size of the window
}

to handle user click on the top/bottom resizing frame of the window you have to add next message (WM_NCHITTEST) handler:

UINT CChildFrame::OnNcHitTest(CPoint point)
{
     // TODO: Add your message handler code here and/or call default
     UINT uMsg = CMDIChildWnd::OnNcHitTest(point);
     m_bTrackVertPos = (uMsg == HTBOTTOM || uMsg == HTTOP);
     return uMsg;
}

note WM_NCHITTESTappear in the messages list if you select filter "Window"
0
 
LVL 2

Expert Comment

by:GloriousRain
ID: 6190084
Override OnSize (
UINT nType,
int cx,
int cy );
Checking cx,cy for your problem
0
 
LVL 2

Expert Comment

by:GloriousRain
ID: 6190091
sorry migel, your comment had posted while i was typing :)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 12

Expert Comment

by:migel
ID: 6190133
take it easy :-)
0
 
LVL 12

Accepted Solution

by:
migel earned 800 total points
ID: 6276402
Hi!
anybody here??
none??
so I lock this Q.
0
 

Author Comment

by:Surfer
ID: 6278004
Sorry about the delay.  You answered my question.
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

618 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