WindoTypeDlg.cpp
资源名称:toolbar.rar [点击查看]
上传用户:rundaa
上传日期:2009-05-24
资源大小:44k
文件大小:5k
源码类别:
CAD
开发平台:
Visual C++
- // WindoTypeDlg.cpp : implementation file
- //
- #include "StdAfx.h"
- #include "StdArx.h"
- #include "resource.h"
- #include "WindoTypeDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- extern CWindoTypeDlg *g_pWindoTypeDlg;
- extern CAcToolBar *g_pAcToolBar;
- extern CTBGenWnd *g_pTBGenWnd;
- /////////////////////////////////////////////////////////////////////////////
- // CWindoTypeDlg dialog
- CWindoTypeDlg::CWindoTypeDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CWindoTypeDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CWindoTypeDlg)
- m_nWindType = windInfo.m_nWindType;
- m_nCols = windInfo.m_nCols;
- m_nRows = windInfo.m_nRows;
- m_dHeight = windInfo.m_dWindHt;
- m_dWidth = windInfo.m_dWindWt;
- m_dXVal = windInfo.m_startPt.x;
- m_dYVal = windInfo.m_startPt.y;
- //}}AFX_DATA_INIT
- }
- void CWindoTypeDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CWindoTypeDlg)
- DDX_Radio(pDX, IDC_RB_TYPERECT, m_nWindType);
- DDX_Text(pDX, IDC_EDIT_COLS, m_nCols);
- DDV_MinMaxInt(pDX, m_nCols, 1, 10);
- DDX_Text(pDX, IDC_EDIT_ROWS, m_nRows);
- DDV_MinMaxInt(pDX, m_nRows, 1, 10);
- DDX_Text(pDX, IDC_EDIT_HEIGHT, m_dHeight);
- DDV_MinMaxDouble(pDX, m_dHeight, 20., 300.);
- DDX_Text(pDX, IDC_EDIT_WIDTH, m_dWidth);
- DDV_MinMaxDouble(pDX, m_dWidth, 20., 300.);
- DDX_Text(pDX, IDC_EDIT_XVAL, m_dXVal);
- DDX_Text(pDX, IDC_EDIT_YVAL, m_dYVal);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CWindoTypeDlg, CDialog)
- //{{AFX_MSG_MAP(CWindoTypeDlg)
- ON_BN_CLICKED(IDC_BTN_PICKPT, OnBtnPickPt)
- ON_BN_CLICKED(IDC_CHK_VISTB, OnChkViewToolBar)
- ON_BN_CLICKED(IDC_BTN_HIDEDLG, OnBtnHideDlg)
- //}}AFX_MSG_MAP
- ON_MESSAGE (WM_ACAD_KEEPFOCUS, onAcadKeepFocus)
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CWindoTypeDlg message handlers
- LONG CWindoTypeDlg::onAcadKeepFocus(UINT, LONG)
- {
- return (TRUE) ;
- }
- BOOL CWindoTypeDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- CSpinButtonCtrl* pSpin;
- pSpin = (CSpinButtonCtrl*) GetDlgItem(IDC_SPIN_COLS);
- pSpin->SetRange(1, 10);
- pSpin = (CSpinButtonCtrl*) GetDlgItem(IDC_SPIN_ROWS);
- pSpin->SetRange(1, 10);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CWindoTypeDlg::PostNcDestroy()
- {
- delete this;
- g_pWindoTypeDlg = NULL;
- CDialog::PostNcDestroy();
- }
- void CWindoTypeDlg::OnCancel()
- {
- // Do NOT call CDialog::OnCancel();
- // Remember we're modeless,
- // Call DestroyWindow() instead!
- DestroyWindow();
- }
- void CWindoTypeDlg::OnOK()
- {
- if (!UpdateData(TRUE))
- {
- return;
- }
- // Transfer the values in the dialog
- // back to the global variables
- windInfo.m_dWindHt = m_dHeight;
- windInfo.m_dWindWt = m_dWidth;
- windInfo.m_nCols = m_nCols;
- windInfo.m_nRows = m_nRows;
- windInfo.m_nWindType = m_nWindType;
- windInfo.m_startPt.x = m_dXVal;
- windInfo.m_startPt.y = m_dYVal;
- drawWindo();
- }
- void CWindoTypeDlg::OnBtnPickPt()
- {
- // Here we hide our modal dialog
- // to allow the user to pick a point
- AcGePoint3d pkPt;
- int retCode;
- ShowWindow(SW_HIDE); // Hide our dialog
- acedInitGet(NULL, NULL);
- retCode = acedGetPoint(NULL, "nPick lower left corner of window: ",
- asDblArray(pkPt));
- switch(retCode)
- {
- case RTCAN :
- case RTNONE :
- pkPt.set(0.0, 0.0, 0.0);
- break;
- case RTNORM :
- break;
- }
- m_dXVal = pkPt.x;
- m_dYVal = pkPt.y;
- ShowWindow(SW_SHOW); // Display our dialog again
- // Transfer the data values from the member variables
- // to the dialog.
- UpdateData(FALSE);
- }
- void CWindoTypeDlg::OnBtnHideDlg()
- {
- ShowWindow(SW_HIDE);
- }
- void CWindoTypeDlg::OnChkViewToolBar()
- {
- CMDIFrameWnd *pAcadFrame = acedGetAcadFrame();
- if(g_pAcToolBar != NULL && g_pAcToolBar->IsWindowVisible())
- {
- ((CButton*) GetDlgItem(IDC_CHK_VISTB))->SetCheck(0);
- pAcadFrame->ShowControlBar(g_pAcToolBar, FALSE, FALSE);
- GetDlgItem(IDC_BTN_HIDEDLG)->EnableWindow(FALSE);
- }
- else if(g_pAcToolBar != NULL)
- {
- ((CButton*) GetDlgItem(IDC_CHK_VISTB))->SetCheck(1);
- pAcadFrame->ShowControlBar(g_pAcToolBar, TRUE, FALSE);
- GetDlgItem(IDC_BTN_HIDEDLG)->EnableWindow(TRUE);
- }
- else
- {
- pAcadFrame->EnableDocking(CBRS_ALIGN_ANY);
- pAcadFrame->RecalcLayout();
- CAcModuleResourceOverride resOverride;
- // Does the CTBGenWnd already exist?
- if(g_pTBGenWnd == NULL)
- {
- g_pTBGenWnd = new CTBGenWnd;
- g_pTBGenWnd->Create (NULL,
- NULL,
- WS_CHILD | WS_MINIMIZE,
- CRect (0,0,1,1),
- pAcadFrame,
- 10);
- }
- g_pAcToolBar = new CAcToolBar;
- g_pAcToolBar->Create(pAcadFrame, g_pTBGenWnd);
- g_pAcToolBar->LoadToolBar(IDR_TB_WINDDLG);
- g_pAcToolBar->EnableDocking(CBRS_ALIGN_ANY);
- g_pAcToolBar->SetWindowText(_T("ARX Window")) ;
- pAcadFrame->FloatControlBar(g_pAcToolBar, CPoint (100, 200), CBRS_ALIGN_TOP) ;
- pAcadFrame->ShowControlBar(g_pAcToolBar, TRUE, FALSE) ;
- ((CButton*) GetDlgItem(IDC_CHK_VISTB))->SetCheck(1);
- GetDlgItem(IDC_BTN_HIDEDLG)->EnableWindow(TRUE);
- }
- }