Click here to Skip to main content
15,885,278 members
Articles / Desktop Programming / MFC

CFlowchartEditor - linking things in CDiagramEditor

Rate me:
Please Sign up or sign in to vote.
4.94/5 (136 votes)
5 Jul 2006Public Domain8 min read 364.5K   33.9K   278  
A flowchart editor with linked objects, based on CDiagramEditor.
/* ==========================================================================
	CLabelPropertyDialog

	Author :		Johan Rosengren, Abstrakt Mekanik AB

	Date :			2004-04-29

	Purpose :		CLabelPropertyDialog is a dialog box wrapper derived 
					from CDiagramPropertyDlg, used by CFlowchartEntity-
					derived objects to edit the object title attribute.

	Description :	Class-Wizard created class.

	Usage :			In the CFlowchartEntity-derived class, add a member of 
					the CLabelPropertyDialog-derived class, and call 
					SetPropertyDialog in the constructor.

					The dialog is displayed as a modeless dialog. The 
					editor will hide the dialog automatically when another
					object is selected, no special Close-button is 
					necessary.

					The dialog template with the resource id 
					IDD_DIALOG_PROPERTY_LABEL must be added to the project.
   ========================================================================*/

#include "stdafx.h"
#include "LabelPropertyDialog.h"

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

/////////////////////////////////////////////////////////////////////////////
// CLabelPropertyDialog dialog

CLabelPropertyDialog::CLabelPropertyDialog(CWnd* pParent /*=NULL*/)
	: CDiagramPropertyDlg(CLabelPropertyDialog::IDD, pParent)
/* ============================================================
	Function :		CLabelPropertyDialog::CLabelPropertyDialog
	Description :	constructor
					
	Return :		void
	Parameters :	none

	Usage :			

   ============================================================*/
{

	//{{AFX_DATA_INIT(CPropertyDialog)
	m_text = _T("");
	//}}AFX_DATA_INIT

}

CLabelPropertyDialog::~CLabelPropertyDialog()
/* ============================================================
	Function :		CLabelPropertyDialog::~CLabelPropertyDialog
	Description :	destructor
					
	Return :		void
	Parameters :	none

	Usage :			

   ============================================================*/
{
}

void CLabelPropertyDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CLabelPropertyDialog)
	DDX_Text(pDX, IDC_EDIT_TEXT, m_text);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CLabelPropertyDialog, CDialog)
	//{{AFX_MSG_MAP(CLabelPropertyDialog)
		// NOTE: the ClassWizard will add message map macros here
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CLabelPropertyDialog message handlers

void CLabelPropertyDialog::OnOK() 
/* ============================================================
	Function :		CLabelPropertyDialog::OnOK
	Description :	Called when the Apply-key is pressed.
					
	Return :		void
	Parameters :	none

	Usage :			Called from MFC. Updates the attached object 
					and hides the modeless dialog.

   ============================================================*/
{

	UpdateData();
	GetEntity()->SetTitle( m_text );
	Redraw();
	ShowWindow( SW_HIDE );
	GetRedrawWnd()->SetFocus();

}

void CLabelPropertyDialog::OnCancel() 
/* ============================================================
	Function :		CLabelPropertyDialog::OnCancel
	Description :	Called when the ESC-key is pressed.
					
	Return :		void
	Parameters :	none

	Usage :			Called from MFC. Overridden to close the 
					dialog.

   ============================================================*/
{

	CDialog::OnCancel();
	GetRedrawWnd()->SetFocus();

}

/////////////////////////////////////////////////////////////////////////////
// CLabelPropertyDialog overrides

void CLabelPropertyDialog::SetValues() 
/* ============================================================
	Function :		CLabelPropertyDialog::SetValues
	Description :	Set the values in the dialog from the 
					attached object.
					
	Return :		void
	Parameters :	none

	Usage :			Will be called by the framework and the 
					attached object to initialize the dialog. 
					The editbox is filled with the contents of 
					the object title attribute.

   ============================================================*/
{

	m_text = GetEntity()->GetTitle();

}

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 A Public Domain dedication


Written By
Software Developer (Senior) Abstrakt Mekanik AB
Sweden Sweden
45 years old, married, three kids.

Started with computers more than 20 years ago on a CBM-64.

Read Theoretical Philosophy at the University of Lund.

Working as a C++ consultant developer.

Science-fiction freak. Enjoy vintage punkrock.

Comments and Discussions