TextWriteDlg.cpp
上传用户:y440e3
上传日期:2010-03-08
资源大小:200k
文件大小:5k
源码类别:

GIS编程

开发平台:

Visual C++

  1. // TextWriteDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "Draw.h"
  5. #include "DrawDoc.h"
  6. #include "Drawview.h"
  7. #include "TextWriteDlg.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // TextWriteDlg dialog
  15. TextWriteDlg::TextWriteDlg(CWnd* pParent /*=NULL*/)
  16. : CDialog(TextWriteDlg::IDD, pParent)
  17. {
  18. m_pView=NULL;
  19. m_FontHeight = 20;
  20. m_FontWide = 8;
  21. m_Angle1 = 0;
  22. m_Angle2 = 0;
  23. m_FontBetween = 1;
  24. //{{AFX_DATA_INIT(TextWriteDlg)
  25. m_Text = _T("");
  26. //}}AFX_DATA_INIT
  27. }
  28. TextWriteDlg::TextWriteDlg(CWnd* pParent,CString Text,float FontHeight,float FontWide,float Angle1,float Angle2,float FontBetween)
  29. : CDialog(TextWriteDlg::IDD, pParent)
  30. {
  31. m_pView=(CDrawView*)pParent;
  32. m_FontHeight = FontHeight;
  33. m_FontWide = FontWide;
  34. m_Angle1 = Angle1;
  35. m_Angle2 = Angle2;
  36. m_FontBetween = FontBetween;
  37. m_Text=Text;
  38. }
  39. void TextWriteDlg::Init(CString Text,float FontHeight,float FontWide,float Angle1,float Angle2,float FontBetween)
  40. {
  41. m_FontHeight = FontHeight;
  42. m_FontWide = FontWide;
  43. m_Angle1 = Angle1;
  44. m_Angle2 = Angle2;
  45. m_FontBetween = FontBetween;
  46. m_Text=Text;
  47. }
  48. void TextWriteDlg::DoDataExchange(CDataExchange* pDX)
  49. {
  50. CDialog::DoDataExchange(pDX);
  51. //{{AFX_DATA_MAP(TextWriteDlg)
  52. DDX_Text(pDX, IDC_TEXT_EDIT1, m_Text);
  53. DDV_MaxChars(pDX, m_Text, 300);
  54. //}}AFX_DATA_MAP
  55. }
  56. BEGIN_MESSAGE_MAP(TextWriteDlg, CDialog)
  57. //{{AFX_MSG_MAP(TextWriteDlg)
  58. ON_BN_CLICKED(IDC_CS, OnTextFont)
  59. ON_EN_CHANGE(IDC_TEXT_EDIT1, OnChangeText)
  60. //}}AFX_MSG_MAP
  61. END_MESSAGE_MAP()
  62. /////////////////////////////////////////////////////////////////////////////
  63. // TextWriteDlg message handlers
  64. BOOL TextWriteDlg::IsVisible()
  65. {
  66. if(!IsOpen())
  67. return FALSE;
  68. WINDOWPLACEMENT scrn;
  69. GetWindowPlacement(&scrn);
  70. if(scrn.showCmd==SW_SHOW)
  71. return TRUE;
  72. else
  73. return FALSE;
  74. }
  75. BOOL TextWriteDlg::IsOpen()
  76. {
  77. return(m_hWnd?TRUE:FALSE);
  78. }
  79. /////////////////////////////////////////////////////////////////////////////
  80. // TextFontDlg dialog
  81. TextFontDlg::TextFontDlg(CWnd* pParent /*=NULL*/)
  82. : CDialog(TextFontDlg::IDD, pParent)
  83. {
  84. //{{AFX_DATA_INIT(TextFontDlg)
  85. m_FontHeight = 0.0f;
  86. m_FontWide = 0.0f;
  87. m_Angle1 = 0.0f;
  88. m_Angle2 = 0.0f;
  89. m_FontBetween = 0.0f;
  90. //}}AFX_DATA_INIT
  91. }
  92. TextFontDlg::TextFontDlg(float FontHeight,float FontWide,float Angle1,float Angle2,float FontBetween,CWnd* pParent /*= NULL*/)
  93. : CDialog(TextFontDlg::IDD, pParent)
  94. {
  95. m_FontHeight = FontHeight;
  96. m_FontWide = FontWide;
  97. m_Angle1 = Angle1;
  98. m_Angle2 = Angle2;
  99. m_FontBetween = FontBetween;
  100. }
  101. void TextFontDlg::DoDataExchange(CDataExchange* pDX)
  102. {
  103. CDialog::DoDataExchange(pDX);
  104. //{{AFX_DATA_MAP(TextFontDlg)
  105. DDX_Text(pDX, IDC_EDIT1, m_FontHeight);
  106. DDX_Text(pDX, IDC_EDIT2, m_FontWide);
  107. DDX_Text(pDX, IDC_EDIT3, m_Angle1);
  108. DDX_Text(pDX, IDC_EDIT4, m_Angle2);
  109. DDX_Text(pDX, IDC_EDIT5, m_FontBetween);
  110. //}}AFX_DATA_MAP
  111. }
  112. BEGIN_MESSAGE_MAP(TextFontDlg, CDialog)
  113. //{{AFX_MSG_MAP(TextFontDlg)
  114. // NOTE: the ClassWizard will add message map macros here
  115. //}}AFX_MSG_MAP
  116. END_MESSAGE_MAP()
  117. /////////////////////////////////////////////////////////////////////////////
  118. // TextFontDlg message handlers
  119. void TextWriteDlg::OnTextFont() 
  120. {
  121. // TODO: Add your control notification handler code here
  122. TextFontDlg pDg1(m_FontHeight,m_FontWide,m_Angle1,m_Angle2,m_FontBetween);
  123. if(pDg1.DoModal()==IDOK)
  124. {
  125. m_FontHeight=pDg1.m_FontHeight;
  126. m_FontWide=pDg1.m_FontWide;
  127. m_Angle1=pDg1.m_Angle1;
  128. m_Angle2=pDg1.m_Angle2;
  129. m_FontBetween=pDg1.m_FontBetween;
  130. UpdateData();
  131. m_pView->SendMessage(WM_COMMAND,ID_TEXT_MESSAGE);
  132. }
  133. }
  134. void TextWriteDlg::OnChangeText() 
  135. {
  136. UpdateData();
  137. m_pView->SendMessage(WM_COMMAND,ID_TEXT_MESSAGE);
  138. // TODO: If this is a RICHEDIT control, the control will not
  139. // send this notification unless you override the CDialog::OnInitDialog()
  140. // function to send the EM_SETEVENTMASK message to the control
  141. // with the ENM_CHANGE flag ORed into the lParam mask.
  142. // TODO: Add your control notification handler code here
  143. }
  144. void TextWriteDlg::OnOK() 
  145. {
  146. // TODO: Add extra validation here
  147. UpdateData();
  148. m_pView->SendMessage(WM_COMMAND,ID_TEXT_ONOK);
  149. CDialog::OnOK();
  150. }
  151. void TextWriteDlg::OnCancel() 
  152. {
  153. // TODO: Add extra cleanup here
  154. m_pView->SendMessage(WM_COMMAND,ID_TEXT_ONCANCEL);
  155. CDialog::OnCancel();
  156. }
  157. BOOL TextWriteDlg::OnInitDialog() 
  158. {
  159. CDialog::OnInitDialog();
  160. CEdit *pedit=(CEdit *)GetDlgItem(IDC_TEXT_EDIT1);
  161. pedit->SetFocus();
  162. // TODO: Add extra initialization here
  163. return TRUE;  // return TRUE unless you set the focus to a control
  164.               // EXCEPTION: OCX Property Pages should return FALSE
  165. }