Click here to Skip to main content
15,896,464 members
Articles / Desktop Programming / MFC

Automatic Resizing of a FormView Based Application When the User Toggles the Control Bars On or Off

Rate me:
Please Sign up or sign in to vote.
4.00/5 (12 votes)
26 Feb 2004CPOL2 min read 127.6K   2.2K   36  
Explains how to implement an application which automatically resizes itself when the user toggles the control bars on or off.
// MainFrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_MAINFRM_H__00F4938D_D238_4B40_8B55_DF6BC81D5B3D__INCLUDED_)
#define AFX_MAINFRM_H__00F4938D_D238_4B40_8B55_DF6BC81D5B3D__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class CMainFrame : public CFrameWnd
{
	
protected: // create from serialization only
	CMainFrame();
	DECLARE_DYNCREATE(CMainFrame)

// Attributes
public:

// Operations
public:

	void SetMinSize(const CPoint& point = CPoint(0, 0)); // Help method to set m_ptMin.

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CMainFrame)
	public:
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	virtual void RecalcLayout(BOOL bNotify = TRUE);
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CMainFrame();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:  // control bar embedded members
	CStatusBar  m_wndStatusBar;
	CToolBar    m_wndToolBar;
	CToolBar    m_wndToolBar2;

// Generated message map functions
protected:
	//{{AFX_MSG(CMainFrame)
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
private:

	int m_nControlBarsHeight; // The old height of control bars.
	int m_nControlBarsWidth; // The old width of control bars.

	bool m_bCtrlBarsChanged; // Ignore calls to RecalcLayout when true.

	CPoint m_ptMin; // Minimum size the frame window can be resized to. Only needed when OnGetMinMaxInfo is used. 

};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MAINFRM_H__00F4938D_D238_4B40_8B55_DF6BC81D5B3D__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
I'm a software developer from Sweden who got tired of snow and cold weather and moved to USA. I choose New York City, so I wouldn't totally miss out on snow and cold weather. I work on Wall Street with financial systems (not much else to do in this neighborhood). I primarily use Visual C++/MFC or C#/.NET as development tool.

The picture is of my wife and me in Cannes, France, drinking the most expensive Coke we ever had.

Comments and Discussions