- UID
- 38377
- 积分
- 135
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2003-3-25
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
- // (C) Copyright 2002-2005 by Autodesk, Inc.
- //
- // Permission to use, copy, modify, and distribute this software in
- // object code form for any purpose and without fee is hereby granted,
- // provided that the above copyright notice appears in all copies and
- // that both that copyright notice and the limited warranty and
- // restricted rights notice below appear in all supporting
- // documentation.
- //
- // AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
- // AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
- // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
- // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
- // UNINTERRUPTED OR ERROR FREE.
- //
- // Use, duplication, or disclosure by the U.S. ** is subject to
- // restrictions set forth in FAR 52.227-19 (Commercial Computer
- // Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
- // (Rights in Technical Data and Computer Software), as applicable.
- //
- //-----------------------------------------------------------------------------
- //----- TextBox.cpp : Implementation of TextBox
- //-----------------------------------------------------------------------------
- #include "StdAfx.h"
- #include "resource.h"
- #include "TextBox.h"
- //-----------------------------------------------------------------------------
- IMPLEMENT_DYNAMIC (TextBox, CAcUiDialog)
- BEGIN_MESSAGE_MAP(TextBox, CAcUiDialog)
- ON_MESSAGE(WM_ACAD_KEEPFOCUS, OnAcadKeepFocus)
- END_MESSAGE_MAP()
- //-----------------------------------------------------------------------------
- TextBox::TextBox (CWnd *pParent /*=NULL*/, HINSTANCE hInstance /*=NULL*/)
- : CAcUiDialog (TextBox::IDD, pParent, hInstance) , m_editBoxString(_T("")) , m_labelString(_T(""))
- {
- }
- //-----------------------------------------------------------------------------
- void TextBox::DoDataExchange (CDataExchange *pDX) {
- CAcUiDialog::DoDataExchange (pDX) ;
- DDX_Text(pDX, IDC_EDIT1, m_editBoxString);
- DDX_Text(pDX, IDC_LABEL, m_labelString);
- DDX_Control(pDX, IDC_EDIT1, m_editControl);
- }
- //-----------------------------------------------------------------------------
- //----- Needed for modeless dialogs to keep focus.
- //----- Return FALSE to not keep the focus, return TRUE to keep the focus
- LRESULT TextBox::OnAcadKeepFocus (WPARAM, LPARAM) {
- return (TRUE) ;
- }
- //
- BOOL TextBox::OnInitDialog()
- {
- CAcUiDialog::OnInitDialog();
- //set the caption
- SetWindowText(m_caption);
- //set focus to the editbox
- m_editControl.SetFocus();
- return FALSE;
- // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- //-----------------------------------------------------------------------------
- #pragma region //DlgTextBox
- //(crptextbox "Title" "Label" "Default Text")
- int DlgTextBox(void)
- {
- LPCTSTR pszCaption;
- LPCTSTR pszLabel;
- LPCTSTR pszText;
- //get args from lisp
- struct resbuf *pArgs = acedGetArgs();
- if (pArgs == NULL)
- return acedRetNil();
- //get caption string
- if (pArgs->restype != RTSTR )
- return acedRetNil();
- pszCaption = pArgs->resval.rstring;
- //get label string
- if ((pArgs = pArgs->rbnext) == NULL || pArgs->restype != RTSTR )
- return acedRetNil();
- pszLabel = pArgs->resval.rstring;
- //get the defaul text
- if ((pArgs = pArgs->rbnext) == NULL || pArgs->restype != RTSTR )
- pszText = _T("");
- else
- pszText = pArgs->resval.rstring;
- ///////Dialog Stuff
- CAcExtensionModule objResOverride;
- TextBox dlg(CWnd::FromHandle(adsw_acadMainWnd()));
- //
- dlg.m_caption = pszCaption;
- dlg.m_editBoxString = pszText;
- dlg.m_labelString = pszLabel;
- int m_dlgResult = dlg.DoModal();
- if ( m_dlgResult != IDOK )
- return acedRetNil();
- else
- pszText = dlg.m_editBoxString;
- //
- if ( _tcslen(pszText) == 0 )
- return acedRetNil();
- acedRetStr(pszText);
- return (RSRSLT) ;
- }
- #pragma endregion
- #pragma region //DlgIntBox
- //(crpintbox "Title" "Label" 12)
- int DlgIntBox(void)
- {
- LPCTSTR pszCaption;
- LPCTSTR pszLabel;
- LPCTSTR pszIntText;
- ACHAR buf[256] = {0};
- int iInt;
- //
- struct resbuf *pArgs = acedGetArgs() ;
- if (pArgs == NULL)
- return acedRetNil();
- //
- if (pArgs->restype != RTSTR )
- return acedRetNil();
- else
- pszCaption = pArgs->resval.rstring;
- //
- if ((pArgs = pArgs->rbnext) == NULL || pArgs->restype != RTSTR )
- return acedRetNil();
- else
- pszLabel = pArgs->resval.rstring;
- //
- if ((pArgs = pArgs->rbnext) != NULL )
- {
- if (pArgs->restype == RTSHORT)
- pszIntText = _itot(pArgs->resval.rint , buf, 10);
- else if (pArgs->restype == RTLONG)
- pszIntText = _itot(pArgs->resval.rlong ,buf, 10);
- else if (pArgs->restype == RTREAL)
- pszIntText = _itot((int)pArgs->resval.rreal , buf, 10);
- else
- pszIntText = _T("");
- }
- else
- {
- pszIntText = _T("");
- }
- ///////Dialog Stuff
- CAcExtensionModule objResOverride;
- //
- TextBox dlg(CWnd::FromHandle(adsw_acadMainWnd()));
- //
- dlg.m_caption = pszCaption;
- dlg.m_labelString = pszLabel;
- dlg.m_editBoxString = pszIntText;
- //
- int m_dlgResult = dlg.DoModal();
- //
- if ( m_dlgResult != IDOK )
- return acedRetNil();
- else
- pszIntText = dlg.m_editBoxString;
- if ( _tcslen(pszIntText) == 0 )
- return acedRetNil();
- //
- iInt = _ttoi(pszIntText);
- //
- acedRetInt(iInt);
- return (RSRSLT) ;
- }
- #pragma endregion
- #pragma region //DlgRealBox
- //(crprealbox "Title" "Label" 12.23)
- int DlgRealBox(void)
- {
- LPCTSTR pszCaption;
- LPCTSTR pszLabel;
- LPCTSTR pszRealText;
- ACHAR buf[256];
- double dReal;
- //
- struct resbuf *pArgs = acedGetArgs() ;
- if (pArgs == NULL)
- return acedRetNil();
- //
- if (pArgs->restype != RTSTR )
- return acedRetNil();
- pszCaption = pArgs->resval.rstring;
- //
- if ((pArgs = pArgs->rbnext) == NULL || pArgs->restype != RTSTR )
- return acedRetNil();
- pszLabel = pArgs->resval.rstring;
- //
- if ((pArgs = pArgs->rbnext) != NULL)
- {
- if (pArgs->restype == RTREAL )
- _stprintf(buf , _T("%0.2f") , (double)pArgs->resval.rreal );
- else if (pArgs->restype == RTLONG)
- _stprintf(buf, _T("%0.2f") , (double)pArgs->resval.rlong );
- else if (pArgs->restype == RTSHORT)
- _stprintf( buf , _T("%0.2f") ,(double)pArgs->resval.rint );
- else
- buf[0] = '\0';
- }
- else
- buf[0] = '\0';
- pszRealText = buf;
- ///////Dialog Stuff
- CAcExtensionModule objResOverride;
- //
- TextBox dlg(CWnd::FromHandle(adsw_acadMainWnd()));
- //
- dlg.m_caption = pszCaption;
- dlg.m_labelString = pszLabel;
- dlg.m_editBoxString = pszRealText;
- //
- int m_dlgResult = dlg.DoModal();
- if ( m_dlgResult != IDOK )
- return acedRetNil();
- else
- pszRealText = dlg.m_editBoxString;
- //
- if ( _tcslen(pszRealText) == 0 )
- return acedRetNil();
- //
- dReal = _tstof(pszRealText);
- //
- acedRetReal(dReal);
- return (RSRSLT) ;
- }
- #pragma endregion
|
|