Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Visual C++ and MFC Fundamentals Chapter 12: Dialog-Based Windows


void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
// TODO: Add your message handler code here and/or call default
lpMMI->ptMaxSize.x = 450;
lpMMI->ptMaxSize.y = 325;

CFrameWnd::OnGetMinMaxInfo(lpMMI);
}

The ptMaxPosition member variable is the location of the window when it gets
maximized. Normally, when the window gets maximized, it starts occupying the monitor
screen from the top-left corner. The ptMaxPosition allows you to change that default
behavior. The ptMaxPosition.x is the distance from the left border of the monitor to the
left border of the maximized window. The ptMaxPosition.y is the distance from the top
border of the monitor to the top border of the maximized window.

The ptMinTrackSize member variable is the minimum size the window must assume
when it gets maximized. Normally, when a window frame gets maximized, it occupies
the whole screen area. This member variable can be used to control that size. The
ptMinTrackSize.x is the minimum width. The ptMinTrackSize.y is the minimum height.

The ptMaxTrackSize member variable is the maximum size the window must have when
it is maximized. The ptMaxTrackSize.x is the minimum width. The ptMaxTrackSize.y is
the minimum height.

Practical Learning: Setting the Window Location and Dimensions



  1. Apply the default location and dimensions to the window with the
    CW_USEDEFAULT constant as follows:
    //---------------------------------------------------------------------------
    INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow )
    {


hWnd = CreateWindowEx(0,
StrClassName,
StrWndName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT, );

return 0;
}
//---------------------------------------------------------------------------


  1. Save All


10.2.6..Window's Parenting............................................................................


If the window you are creating has a parent, obtain its handle and pass it as the
hWndParent argument of the CreateWindow() or the CreateWindowEx() functions for a
Free download pdf