TextWriteDlg.cpp
上传用户:y440e3
上传日期:2010-03-08
资源大小:200k
文件大小:5k
- // TextWriteDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "Draw.h"
- #include "DrawDoc.h"
- #include "Drawview.h"
- #include "TextWriteDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // TextWriteDlg dialog
- TextWriteDlg::TextWriteDlg(CWnd* pParent /*=NULL*/)
- : CDialog(TextWriteDlg::IDD, pParent)
- {
- m_pView=NULL;
- m_FontHeight = 20;
- m_FontWide = 8;
- m_Angle1 = 0;
- m_Angle2 = 0;
- m_FontBetween = 1;
- //{{AFX_DATA_INIT(TextWriteDlg)
- m_Text = _T("");
- //}}AFX_DATA_INIT
- }
- TextWriteDlg::TextWriteDlg(CWnd* pParent,CString Text,float FontHeight,float FontWide,float Angle1,float Angle2,float FontBetween)
- : CDialog(TextWriteDlg::IDD, pParent)
- {
- m_pView=(CDrawView*)pParent;
- m_FontHeight = FontHeight;
- m_FontWide = FontWide;
- m_Angle1 = Angle1;
- m_Angle2 = Angle2;
- m_FontBetween = FontBetween;
- m_Text=Text;
- }
- void TextWriteDlg::Init(CString Text,float FontHeight,float FontWide,float Angle1,float Angle2,float FontBetween)
- {
- m_FontHeight = FontHeight;
- m_FontWide = FontWide;
- m_Angle1 = Angle1;
- m_Angle2 = Angle2;
- m_FontBetween = FontBetween;
- m_Text=Text;
- }
- void TextWriteDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(TextWriteDlg)
- DDX_Text(pDX, IDC_TEXT_EDIT1, m_Text);
- DDV_MaxChars(pDX, m_Text, 300);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(TextWriteDlg, CDialog)
- //{{AFX_MSG_MAP(TextWriteDlg)
- ON_BN_CLICKED(IDC_CS, OnTextFont)
- ON_EN_CHANGE(IDC_TEXT_EDIT1, OnChangeText)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // TextWriteDlg message handlers
- BOOL TextWriteDlg::IsVisible()
- {
- if(!IsOpen())
- return FALSE;
- WINDOWPLACEMENT scrn;
- GetWindowPlacement(&scrn);
- if(scrn.showCmd==SW_SHOW)
- return TRUE;
- else
- return FALSE;
- }
- BOOL TextWriteDlg::IsOpen()
- {
- return(m_hWnd?TRUE:FALSE);
- }
- /////////////////////////////////////////////////////////////////////////////
- // TextFontDlg dialog
- TextFontDlg::TextFontDlg(CWnd* pParent /*=NULL*/)
- : CDialog(TextFontDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(TextFontDlg)
- m_FontHeight = 0.0f;
- m_FontWide = 0.0f;
- m_Angle1 = 0.0f;
- m_Angle2 = 0.0f;
- m_FontBetween = 0.0f;
- //}}AFX_DATA_INIT
- }
- TextFontDlg::TextFontDlg(float FontHeight,float FontWide,float Angle1,float Angle2,float FontBetween,CWnd* pParent /*= NULL*/)
- : CDialog(TextFontDlg::IDD, pParent)
- {
- m_FontHeight = FontHeight;
- m_FontWide = FontWide;
- m_Angle1 = Angle1;
- m_Angle2 = Angle2;
- m_FontBetween = FontBetween;
- }
- void TextFontDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(TextFontDlg)
- DDX_Text(pDX, IDC_EDIT1, m_FontHeight);
- DDX_Text(pDX, IDC_EDIT2, m_FontWide);
- DDX_Text(pDX, IDC_EDIT3, m_Angle1);
- DDX_Text(pDX, IDC_EDIT4, m_Angle2);
- DDX_Text(pDX, IDC_EDIT5, m_FontBetween);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(TextFontDlg, CDialog)
- //{{AFX_MSG_MAP(TextFontDlg)
- // NOTE: the ClassWizard will add message map macros here
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // TextFontDlg message handlers
- void TextWriteDlg::OnTextFont()
- {
- // TODO: Add your control notification handler code here
- TextFontDlg pDg1(m_FontHeight,m_FontWide,m_Angle1,m_Angle2,m_FontBetween);
- if(pDg1.DoModal()==IDOK)
- {
- m_FontHeight=pDg1.m_FontHeight;
- m_FontWide=pDg1.m_FontWide;
- m_Angle1=pDg1.m_Angle1;
- m_Angle2=pDg1.m_Angle2;
- m_FontBetween=pDg1.m_FontBetween;
- UpdateData();
- m_pView->SendMessage(WM_COMMAND,ID_TEXT_MESSAGE);
- }
- }
- void TextWriteDlg::OnChangeText()
- {
- UpdateData();
- m_pView->SendMessage(WM_COMMAND,ID_TEXT_MESSAGE);
- // TODO: If this is a RICHEDIT control, the control will not
- // send this notification unless you override the CDialog::OnInitDialog()
- // function to send the EM_SETEVENTMASK message to the control
- // with the ENM_CHANGE flag ORed into the lParam mask.
-
- // TODO: Add your control notification handler code here
-
- }
- void TextWriteDlg::OnOK()
- {
- // TODO: Add extra validation here
- UpdateData();
- m_pView->SendMessage(WM_COMMAND,ID_TEXT_ONOK);
- CDialog::OnOK();
- }
- void TextWriteDlg::OnCancel()
- {
- // TODO: Add extra cleanup here
- m_pView->SendMessage(WM_COMMAND,ID_TEXT_ONCANCEL);
- CDialog::OnCancel();
- }
- BOOL TextWriteDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- CEdit *pedit=(CEdit *)GetDlgItem(IDC_TEXT_EDIT1);
- pedit->SetFocus();
- // TODO: Add extra initialization here
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }