|
#if !defined(AFX_RESIZABLEFORMVIEW_H__5FCBDA95_C53B_11D4_B7AB_0050DAB84384__INCLUDED_)
#define AFX_RESIZABLEFORMVIEW_H__5FCBDA95_C53B_11D4_B7AB_0050DAB84384__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ResizableFormView.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CResizableFormView form view
#ifndef __AFXEXT_H__
#include <afxext.h>
#endif
#ifndef __AFXTEMPL_H
#include <afxtempl.h>
#endif
#if !defined(__SIZE_ANCHORS_)
#define __SIZE_ANCHORS_
const CSize
NOANCHOR(-1,-1),
TOP_LEFT(0,0), TOP_CENTER(50,0), TOP_RIGHT(100,0),
MIDDLE_LEFT(0,50), MIDDLE_CENTER(50,50), MIDDLE_RIGHT(100,50),
BOTTOM_LEFT(0,100), BOTTOM_CENTER(50,100), BOTTOM_RIGHT(100,100);
#endif // !defined(__SIZE_ANCHORS_)
// jms - 11/28/00 - new code starts
struct FORMCONTROL
{
UINT nID;
CRect rect;
CSize tlType;
CSize brType;
HWND hWnd;
};
// jms - 11/28/00 - new code stops
class CResizableFormView : public CFormView
{
protected:
CResizableFormView(); // protected constructor used by dynamic creation
CResizableFormView(UINT nIDTemplate);
DECLARE_DYNCREATE(CResizableFormView)
// Attributes
private:
// flags
BOOL m_bShowGrip;
BOOL m_bUseMaxTrack;
BOOL m_bUseMinTrack;
BOOL m_bUseMaxRect;
BOOL m_bEnableSaveRestore;
// internal status
CString m_sSection; // section name and
CString m_sEntry; // entry for save/restore
BOOL m_bInitDone; // if all internal vars initialized
SIZE m_szGripSize; // set at construction time
CRect m_rcGripRect; // current pos of grip
POINT m_ptMinTrackSize; // min tracking size
POINT m_ptMaxTrackSize; // max tracking size
POINT m_ptMaxPos; // maximized position
POINT m_ptMaxSize; // maximized size
CPtrList m_plLayoutList; // list of repositionable controls
class Layout
{
public:
HWND hwnd;
BOOL adj_hscroll;
BOOL need_refresh;
// upper-left corner
SIZE tl_type;
SIZE tl_margin;
// bottom-right corner
SIZE br_type;
SIZE br_margin;
public:
Layout(HWND hw, SIZE tl_t, SIZE tl_m,
SIZE br_t, SIZE br_m, BOOL hscroll, BOOL refresh)
{
hwnd = hw;
adj_hscroll = hscroll;
need_refresh = refresh;
tl_type = tl_t;
tl_margin = tl_m;
br_type = br_t;
br_margin = br_m;
};
};
// Form Data
public:
//{{AFX_DATA(CResizableFormView)
enum { IDD = 0};
//}}AFX_DATA
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CResizableFormView)
public:
virtual void OnInitialUpdate();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
virtual ~CResizableFormView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
// used internally
private:
void Construct();
void ArrangeLayout();
// callable from derived classes
//protected:
public:
// Generated message map functions
//{{AFX_MSG(CResizableFormView)
afx_msg void OnSize(UINT nType, int cx, int cy);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
protected:
void AddAnchor(HWND wnd, CSize tl_type, CSize br_type = NOANCHOR); // add anchors to a control
void AddAnchor(UINT ctrl_ID, CSize tl_type, CSize br_type = NOANCHOR) // add anchors to a control
{
AddAnchor(::GetDlgItem(*this, ctrl_ID), tl_type, br_type);
};
// functions added by jms
protected:
CTypedPtrArray<CPtrArray, FORMCONTROL*> m_tpaControls;
void AddResizedControl(UINT nID, CSize tl_type, CSize br_type = NOANCHOR);
void AnchorControls();
FORMCONTROL* GetFormControl(HWND hWnd);
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_RESIZABLEFORMVIEW_H__5FCBDA95_C53B_11D4_B7AB_0050DAB84384__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.
I've been paid as a programmer since 1982 with experience in Pascal, and C++ (both self-taught), and began writing Windows programs in 1991 using Visual C++ and MFC. In the 2nd half of 2007, I started writing C# Windows Forms and ASP.Net applications, and have since done WPF, Silverlight, WCF, web services, and Windows services.
My weakest point is that my moments of clarity are too brief to hold a meaningful conversation that requires more than 30 seconds to complete. Thankfully, grunts of agreement are all that is required to conduct most discussions without committing to any particular belief system.