Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

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


add the Minimize and the Maximize buttons or not, they cannot be displayed. You should
use only the following combination: WS_POPUP | WS_CAPTION | WS_SYSMENU.
Besides the regular window styles, you should combine them with one or more of the
following special styles:

??MFS_MOVEFRAME: With this style, if the user clicks and drags one (any) edge
of the frame, the frame would start moving with the same reaction as if the user were
dragging the title bar. If you apply this style, the user cannot resize the frame even if
another style would allow it
??MFS_4THICKFRAME: This style prevents the user from resizing the mini frame
??MFS_SYNCACTIVE: This style makes sure that the mini frame is activated when
its parent window is activated
??MFS_THICKFRAME: This creates a thick frame and allows the user to resize it if
necessary, provided the MFS_MOVEFRAME is not used
??MFS_BLOCKSYSMENU: This disables access to the system menu

The rect parameter specifies the location and dimensions of the frame window.

The pParentWnd argument is the CWnd parent of the window. This argument is not
required.

The nID argument is the identifier of the mini frame window. It is not required.

Besides the Create() method, the CMiniFrameWnd class also provides the CreateEx()
member function to create a miniframe window.

Here is an example:

void CMiniFrame2Dlg::OnBnClickedMiniframeBtn()
{
// TODO: Add your control notification handler code here
CMiniFrameWnd *MFW = new CMiniFrameWnd;
CString StrClassName = AfxRegisterWndClass(
CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS,
LoadCursor(NULL, IDC_ARROW),
(HBRUSH)GetStockObject(COLOR_BTNFACE+1),
LoadIcon(NULL, IDI_APPLICATION));

MFW->CreateEx(0,
StrClassName,
"Small Application",
WS_POPUP | WS_CAPTION | WS_SYSMENU |
MFS_BLOCKSYSMENU,
CRect(100, 100, 350, 420));

MFW->ShowWindow(SW_SHOW);
}
Free download pdf