Home

The Mini Frame Window

 

Introduction

A mini frame is a window that is mostly used as a floating object that accompany another window, the main object of an application. It appears as a normal frame window we have seen so far with borders and a client area but a mini frame window is used a tool instead of as a main window. For this functionality, it does not have the System minimize and maximize buttons. As a tool window, it appears with a short title bar and is equipped with a system close button.

Creation of a Mini Frame Window

The mini frame window is based on the CMiniFrameWnd class. To create a mini frame window, first declare a variable or a pointer to CMiniFrameWnd. You can define its class using the AfxRegisterWndClass() function. You can then pass the return value of that function to its Create() method. The syntax of this method is:

virtual BOOL Create(
LPCTSTR lpClassName,
LPCTSTR lpWindowName,
DWORD dwStyle,
const RECT& rect,
CWnd* pParentWnd = NULL,
UINT nID = 0
);

The lpClassName parameter should be a value returned from the AfxRegisterWndClass() function.

The lpWindowName is the caption displayed in the title bar of the window.

The dwStyle parameter is the style to apply to the window. Normally, it would use the regular styles of a normal window but many styles are invalid. For example, whether you 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 mini frame 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);
}
 

Copyright © 2003-2015, FunctionX