Click here to Skip to main content
15,893,663 members
Articles / Desktop Programming / MFC

CPPHtmlStatic v1.2

Rate me:
Please Sign up or sign in to vote.
4.94/5 (69 votes)
18 May 2012CPOL10 min read 307.5K   9.3K   185  
A control based on CStatic for displaying HTML-like text formatting elements.
// PageMiscellaneous.cpp : implementation file
//

#include "stdafx.h"
#include "CPPHtmlStatic_demo.h"
#include "CPPHtmlStatic_demoDlg.h"
#include "PageMiscellaneous.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CPageMiscellaneous property page

IMPLEMENT_DYNCREATE(CPageMiscellaneous, CPropertyPage)

CPageMiscellaneous::CPageMiscellaneous() : CPropertyPage(CPageMiscellaneous::IDD)
{
	//{{AFX_DATA_INIT(CPageMiscellaneous)
	m_enable_ctrl = TRUE;
	//}}AFX_DATA_INIT
	m_bOrgSizes = TRUE;
}

CPageMiscellaneous::~CPageMiscellaneous()
{
}

void CPageMiscellaneous::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPageMiscellaneous)
	DDX_Check(pDX, IDC_CHECK1, m_enable_ctrl);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPageMiscellaneous, CPropertyPage)
	//{{AFX_MSG_MAP(CPageMiscellaneous)
	ON_BN_CLICKED(IDC_CHECK1, OnEnableControl)
	ON_BN_CLICKED(IDC_BUTTON1, OnToggleSizes)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPageMiscellaneous message handlers

BOOL CPageMiscellaneous::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	
	CPPHtmlStatic_demoDlg * pDlg = (CPPHtmlStatic_demoDlg*)GetParent()->GetParent();
	pDlg->m_static.GetWindowRect(&m_rcOrg);
	pDlg->ScreenToClient(&m_rcOrg);
	m_rcSmall = m_rcOrg;
	m_rcSmall.DeflateRect(0, 0, 50, 50);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CPageMiscellaneous::OnEnableControl() 
{
	UpdateData();
	CPPHtmlStatic_demoDlg * pDlg = (CPPHtmlStatic_demoDlg*)GetParent()->GetParent();
	pDlg->m_static.EnableWindow(m_enable_ctrl);
	
}

void CPageMiscellaneous::OnToggleSizes() 
{
	CPPHtmlStatic_demoDlg * pDlg = (CPPHtmlStatic_demoDlg*)GetParent()->GetParent();
	m_bOrgSizes = m_bOrgSizes ? FALSE : TRUE;
	pDlg->m_static.MoveWindow(m_bOrgSizes ? m_rcOrg : m_rcSmall);
}

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
Software Developer SvyazInvest
Belarus Belarus
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions