WindoTypeDlg.cpp
上传用户:rundaa
上传日期:2009-05-24
资源大小:44k
文件大小:5k
源码类别:

CAD

开发平台:

Visual C++

  1. // WindoTypeDlg.cpp : implementation file
  2. //
  3. #include "StdAfx.h"
  4. #include "StdArx.h"
  5. #include "resource.h"
  6. #include "WindoTypeDlg.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. extern CWindoTypeDlg *g_pWindoTypeDlg;
  13. extern CAcToolBar  *g_pAcToolBar;
  14. extern CTBGenWnd  *g_pTBGenWnd;
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CWindoTypeDlg dialog
  17. CWindoTypeDlg::CWindoTypeDlg(CWnd* pParent /*=NULL*/)
  18. : CDialog(CWindoTypeDlg::IDD, pParent)
  19. {
  20. //{{AFX_DATA_INIT(CWindoTypeDlg)
  21. m_nWindType = windInfo.m_nWindType;
  22. m_nCols = windInfo.m_nCols;
  23. m_nRows = windInfo.m_nRows;
  24. m_dHeight = windInfo.m_dWindHt;
  25. m_dWidth = windInfo.m_dWindWt;
  26. m_dXVal = windInfo.m_startPt.x;
  27. m_dYVal = windInfo.m_startPt.y;
  28. //}}AFX_DATA_INIT
  29. }
  30. void CWindoTypeDlg::DoDataExchange(CDataExchange* pDX)
  31. {
  32. CDialog::DoDataExchange(pDX);
  33. //{{AFX_DATA_MAP(CWindoTypeDlg)
  34. DDX_Radio(pDX, IDC_RB_TYPERECT, m_nWindType);
  35. DDX_Text(pDX, IDC_EDIT_COLS, m_nCols);
  36. DDV_MinMaxInt(pDX, m_nCols, 1, 10);
  37. DDX_Text(pDX, IDC_EDIT_ROWS, m_nRows);
  38. DDV_MinMaxInt(pDX, m_nRows, 1, 10);
  39. DDX_Text(pDX, IDC_EDIT_HEIGHT, m_dHeight);
  40. DDV_MinMaxDouble(pDX, m_dHeight, 20., 300.);
  41. DDX_Text(pDX, IDC_EDIT_WIDTH, m_dWidth);
  42. DDV_MinMaxDouble(pDX, m_dWidth, 20., 300.);
  43. DDX_Text(pDX, IDC_EDIT_XVAL, m_dXVal);
  44. DDX_Text(pDX, IDC_EDIT_YVAL, m_dYVal);
  45. //}}AFX_DATA_MAP
  46. }
  47. BEGIN_MESSAGE_MAP(CWindoTypeDlg, CDialog)
  48. //{{AFX_MSG_MAP(CWindoTypeDlg)
  49. ON_BN_CLICKED(IDC_BTN_PICKPT, OnBtnPickPt)
  50. ON_BN_CLICKED(IDC_CHK_VISTB, OnChkViewToolBar)
  51. ON_BN_CLICKED(IDC_BTN_HIDEDLG, OnBtnHideDlg)
  52. //}}AFX_MSG_MAP
  53. ON_MESSAGE (WM_ACAD_KEEPFOCUS, onAcadKeepFocus)
  54. END_MESSAGE_MAP()
  55. /////////////////////////////////////////////////////////////////////////////
  56. // CWindoTypeDlg message handlers
  57. LONG CWindoTypeDlg::onAcadKeepFocus(UINT, LONG) 
  58. {
  59. return (TRUE) ;
  60. }
  61. BOOL CWindoTypeDlg::OnInitDialog() 
  62. {
  63. CDialog::OnInitDialog();
  64. CSpinButtonCtrl* pSpin;
  65.     pSpin = (CSpinButtonCtrl*) GetDlgItem(IDC_SPIN_COLS);
  66. pSpin->SetRange(1, 10);
  67.     pSpin = (CSpinButtonCtrl*) GetDlgItem(IDC_SPIN_ROWS);
  68. pSpin->SetRange(1, 10);
  69. return TRUE;  // return TRUE unless you set the focus to a control
  70.               // EXCEPTION: OCX Property Pages should return FALSE
  71. }
  72. void CWindoTypeDlg::PostNcDestroy() 
  73. {
  74. delete this;
  75. g_pWindoTypeDlg = NULL;
  76. CDialog::PostNcDestroy();
  77. }
  78. void CWindoTypeDlg::OnCancel() 
  79. {
  80. // Do NOT call CDialog::OnCancel(); 
  81. // Remember we're modeless,
  82. // Call DestroyWindow() instead!
  83. DestroyWindow();
  84. }
  85. void CWindoTypeDlg::OnOK() 
  86. {
  87. if (!UpdateData(TRUE))
  88. {
  89. return;
  90. }
  91. // Transfer the values in the dialog
  92. // back to the global variables
  93. windInfo.m_dWindHt = m_dHeight;
  94. windInfo.m_dWindWt = m_dWidth;
  95. windInfo.m_nCols = m_nCols;
  96. windInfo.m_nRows = m_nRows;
  97. windInfo.m_nWindType = m_nWindType;
  98. windInfo.m_startPt.x = m_dXVal;
  99. windInfo.m_startPt.y = m_dYVal;
  100. drawWindo();
  101. }
  102. void CWindoTypeDlg::OnBtnPickPt() 
  103. {
  104. // Here we hide our modal dialog
  105. // to allow the user to pick a point
  106. AcGePoint3d pkPt;
  107. int retCode;
  108. ShowWindow(SW_HIDE); // Hide our dialog
  109. acedInitGet(NULL, NULL);
  110. retCode = acedGetPoint(NULL, "nPick lower left corner of window: ",
  111. asDblArray(pkPt));
  112. switch(retCode)
  113. {
  114. case RTCAN  :
  115. case RTNONE :
  116. pkPt.set(0.0, 0.0, 0.0);
  117. break;
  118. case RTNORM :
  119. break;
  120. }
  121. m_dXVal = pkPt.x;
  122. m_dYVal = pkPt.y;
  123. ShowWindow(SW_SHOW); // Display our dialog again
  124. // Transfer the data values from the member variables
  125. // to the dialog.
  126. UpdateData(FALSE);
  127. }
  128. void CWindoTypeDlg::OnBtnHideDlg() 
  129. {
  130. ShowWindow(SW_HIDE);
  131. }
  132. void CWindoTypeDlg::OnChkViewToolBar() 
  133. {
  134. CMDIFrameWnd *pAcadFrame = acedGetAcadFrame();
  135. if(g_pAcToolBar != NULL && g_pAcToolBar->IsWindowVisible())
  136. {
  137. ((CButton*) GetDlgItem(IDC_CHK_VISTB))->SetCheck(0);
  138. pAcadFrame->ShowControlBar(g_pAcToolBar, FALSE, FALSE);
  139. GetDlgItem(IDC_BTN_HIDEDLG)->EnableWindow(FALSE);
  140. }
  141. else if(g_pAcToolBar != NULL)
  142. {
  143. ((CButton*) GetDlgItem(IDC_CHK_VISTB))->SetCheck(1);
  144. pAcadFrame->ShowControlBar(g_pAcToolBar, TRUE, FALSE);
  145. GetDlgItem(IDC_BTN_HIDEDLG)->EnableWindow(TRUE);
  146. }
  147. else
  148. {
  149. pAcadFrame->EnableDocking(CBRS_ALIGN_ANY);
  150. pAcadFrame->RecalcLayout();
  151. CAcModuleResourceOverride resOverride;
  152. // Does the CTBGenWnd already exist?
  153. if(g_pTBGenWnd == NULL)
  154. {
  155. g_pTBGenWnd = new CTBGenWnd;
  156. g_pTBGenWnd->Create (NULL,
  157.      NULL,
  158.      WS_CHILD | WS_MINIMIZE,
  159.      CRect (0,0,1,1),
  160.      pAcadFrame,
  161.      10);
  162. }
  163. g_pAcToolBar = new CAcToolBar;
  164. g_pAcToolBar->Create(pAcadFrame, g_pTBGenWnd);
  165. g_pAcToolBar->LoadToolBar(IDR_TB_WINDDLG);
  166. g_pAcToolBar->EnableDocking(CBRS_ALIGN_ANY);
  167. g_pAcToolBar->SetWindowText(_T("ARX Window")) ;
  168. pAcadFrame->FloatControlBar(g_pAcToolBar, CPoint (100, 200), CBRS_ALIGN_TOP) ;
  169. pAcadFrame->ShowControlBar(g_pAcToolBar, TRUE, FALSE) ;
  170. ((CButton*) GetDlgItem(IDC_CHK_VISTB))->SetCheck(1);
  171. GetDlgItem(IDC_BTN_HIDEDLG)->EnableWindow(TRUE);
  172. }
  173. }