Click here to Skip to main content
15,892,746 members
Articles / Desktop Programming / MFC

ControlObjectList

Rate me:
Please Sign up or sign in to vote.
3.00/5 (6 votes)
16 Aug 2002CPOL 62.6K   2.1K   25  
Add/Remove/Scroll/Sort Object List (CButton, CStatic, etc..)
#if !defined(AFX_FORMATICON_H__8663EBF5_EAFD_4964_B606_8EAC95BC0181__INCLUDED_)
#define AFX_FORMATICON_H__8663EBF5_EAFD_4964_B606_8EAC95BC0181__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// FormatIcon.h : header file
//

class CFormatDlg;
/////////////////////////////////////////////////////////////////////////////
// CFormatIcon window

class CFormatIcon : public CStatic
{
// Construction
public:
	CFormatIcon(CFormatDlg* pParent);

// Attributes
public:
private:
	CFormatDlg* m_pParent;
	CRect m_Rect;
	int m_nColor;
	CSize m_Size;
	int m_nID;

// Operations
public:
    static int CompBackward(CFormatIcon* pFirstObj, CFormatIcon* pSecondObj)
    {
		if (pFirstObj->m_Size.cx <= pSecondObj->m_Size.cx) {

			if (pFirstObj->m_Size.cy <= pSecondObj->m_Size.cy) {
				if (pFirstObj->GetFormatColor() <= pSecondObj->GetFormatColor())
					return -1;
				else if (pFirstObj->m_Size.cx < pSecondObj->m_Size.cx)
					return -1;
				else if (pFirstObj->m_Size.cy < pSecondObj->m_Size.cy)
					return -1;
			}
			else if (pFirstObj->GetFormatColor() >= pSecondObj->GetFormatColor()) {
				if (pFirstObj->m_Size.cx != pSecondObj->m_Size.cx)
					return -1;
			}
		}

        return 1;
    }

	void AddFormat(CSize Size, int nColor, int nID);
	void SetBoxRect(CRect rc, BOOL bRedraw = FALSE);
	CSize GetFormatSize() { return m_Size; }
	int GetFormatColor() { return m_nColor; }
	CRect GetBoxRect() { return m_Rect; }
	int GetID() { return m_nID; }

private:
	void NotifyScroll();
	
// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CFormatIcon)
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CFormatIcon();

	// Generated message map functions
protected:
	//{{AFX_MSG(CFormatIcon)
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnPaint();
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()
};

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

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

#endif // !defined(AFX_FORMATICON_H__8663EBF5_EAFD_4964_B606_8EAC95BC0181__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
CEO
Canada Canada

Comments and Discussions