设为首页收藏本站

中国膜结构网

 找回密码
 立即注册
膜结构车棚
膜结构车棚膜结构资质国产膜材 膜结构网中国膜结构协会
查看: 87|回复: 0

接受LISP参数,实现文本编辑框

[复制链接]
  • TA的每日心情
    开心
    2021-3-9 08:49
  • 签到天数: 1442 天

    连续签到: 21 天

    [LV.10]以坛为家III

    发表于 2021-1-17 20:40 | 显示全部楼层 |阅读模式
    http://www.mjgw.org/ 专业从事膜结构设计、制作加工、施工安装的膜结构咨询服务,能够为客户提供专业的膜结构整体解决方案。做中国最好的膜结构综合服务平台。欢迎大家联系QQ:463017170.
    1. // (C) Copyright 2002-2005 by Autodesk, Inc.
    2. //
    3. // Permission to use, copy, modify, and distribute this software in
    4. // object code form for any purpose and without fee is hereby granted,
    5. // provided that the above copyright notice appears in all copies and
    6. // that both that copyright notice and the limited warranty and
    7. // restricted rights notice below appear in all supporting
    8. // documentation.
    9. //
    10. // AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
    11. // AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
    12. // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK, INC.
    13. // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
    14. // UNINTERRUPTED OR ERROR FREE.
    15. //
    16. // Use, duplication, or disclosure by the U.S. ** is subject to
    17. // restrictions set forth in FAR 52.227-19 (Commercial Computer
    18. // Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
    19. // (Rights in Technical Data and Computer Software), as applicable.
    20. //

    21. //-----------------------------------------------------------------------------
    22. //----- TextBox.cpp : Implementation of TextBox
    23. //-----------------------------------------------------------------------------
    24. #include "StdAfx.h"
    25. #include "resource.h"
    26. #include "TextBox.h"

    27. //-----------------------------------------------------------------------------
    28. IMPLEMENT_DYNAMIC (TextBox, CAcUiDialog)

    29. BEGIN_MESSAGE_MAP(TextBox, CAcUiDialog)
    30.   ON_MESSAGE(WM_ACAD_KEEPFOCUS, OnAcadKeepFocus)
    31. END_MESSAGE_MAP()

    32. //-----------------------------------------------------------------------------
    33. TextBox::TextBox (CWnd *pParent /*=NULL*/, HINSTANCE hInstance /*=NULL*/)
    34. : CAcUiDialog (TextBox::IDD, pParent, hInstance) , m_editBoxString(_T("")) , m_labelString(_T(""))
    35. {
    36. }

    37. //-----------------------------------------------------------------------------
    38. void TextBox::DoDataExchange (CDataExchange *pDX) {
    39.   CAcUiDialog::DoDataExchange (pDX) ;
    40.   DDX_Text(pDX, IDC_EDIT1, m_editBoxString);
    41.   DDX_Text(pDX, IDC_LABEL, m_labelString);
    42.   DDX_Control(pDX, IDC_EDIT1, m_editControl);
    43. }

    44. //-----------------------------------------------------------------------------
    45. //----- Needed for modeless dialogs to keep focus.
    46. //----- Return FALSE to not keep the focus, return TRUE to keep the focus
    47. LRESULT TextBox::OnAcadKeepFocus (WPARAM, LPARAM) {
    48.   return (TRUE) ;
    49. }

    50. //
    51. BOOL TextBox::OnInitDialog()
    52. {
    53.   CAcUiDialog::OnInitDialog();

    54.   //set the caption
    55.   SetWindowText(m_caption);

    56.   //set focus to the editbox
    57.   m_editControl.SetFocus();
    58.   return FALSE;
    59.   // return TRUE unless you set the focus to a control
    60.   // EXCEPTION: OCX Property Pages should return FALSE
    61. }

    62. //-----------------------------------------------------------------------------
    63. #pragma region //DlgTextBox

    64. //(crptextbox "Title" "Label" "Default Text")
    65. int DlgTextBox(void)
    66. {
    67.   LPCTSTR pszCaption;
    68.   LPCTSTR pszLabel;
    69.   LPCTSTR pszText;

    70.   //get args from lisp
    71.   struct resbuf *pArgs = acedGetArgs();

    72.   if (pArgs == NULL)
    73.     return acedRetNil();

    74.   //get caption string
    75.   if (pArgs->restype != RTSTR )
    76. return acedRetNil();

    77.   pszCaption = pArgs->resval.rstring;

    78.   //get label string
    79.   if ((pArgs = pArgs->rbnext) == NULL || pArgs->restype != RTSTR )
    80.   return acedRetNil();

    81.   pszLabel = pArgs->resval.rstring;

    82.   //get the defaul text
    83.   if ((pArgs = pArgs->rbnext) == NULL || pArgs->restype != RTSTR  )
    84.     pszText = _T("");
    85.   else
    86.     pszText = pArgs->resval.rstring;

    87.   ///////Dialog Stuff
    88.   CAcExtensionModule objResOverride;

    89.   TextBox dlg(CWnd::FromHandle(adsw_acadMainWnd()));

    90.   //
    91.   dlg.m_caption = pszCaption;
    92.   dlg.m_editBoxString = pszText;
    93.   dlg.m_labelString = pszLabel;

    94.   int m_dlgResult = dlg.DoModal();

    95.   if ( m_dlgResult != IDOK )
    96.    return acedRetNil();
    97.   else
    98.     pszText = dlg.m_editBoxString;

    99.   //
    100.   if ( _tcslen(pszText) == 0 )
    101.     return acedRetNil();

    102.   acedRetStr(pszText);
    103.   return (RSRSLT) ;
    104. }
    105. #pragma endregion

    106. #pragma region //DlgIntBox

    107. //(crpintbox "Title" "Label" 12)
    108. int DlgIntBox(void)
    109. {
    110.   LPCTSTR pszCaption;
    111.   LPCTSTR pszLabel;
    112.   LPCTSTR pszIntText;
    113.   ACHAR buf[256] = {0};

    114.   int iInt;

    115.   //
    116.   struct resbuf *pArgs = acedGetArgs() ;

    117.   if (pArgs == NULL)
    118.     return acedRetNil();

    119.   //
    120.   if (pArgs->restype != RTSTR )
    121.    return acedRetNil();
    122.   else
    123.     pszCaption = pArgs->resval.rstring;

    124.   //
    125.   if ((pArgs = pArgs->rbnext) == NULL || pArgs->restype != RTSTR )
    126.     return acedRetNil();
    127.   else
    128.     pszLabel = pArgs->resval.rstring;

    129.   //
    130.   if ((pArgs = pArgs->rbnext) != NULL )
    131.   {
    132.     if (pArgs->restype == RTSHORT)
    133.       pszIntText = _itot(pArgs->resval.rint , buf, 10);
    134.     else if (pArgs->restype == RTLONG)
    135.       pszIntText = _itot(pArgs->resval.rlong ,buf, 10);
    136.     else if (pArgs->restype == RTREAL)
    137.       pszIntText = _itot((int)pArgs->resval.rreal , buf, 10);
    138.     else
    139.       pszIntText = _T("");
    140.   }
    141.   else
    142.   {
    143.     pszIntText = _T("");
    144.   }

    145.   ///////Dialog Stuff
    146.   CAcExtensionModule objResOverride;

    147.   //
    148.   TextBox dlg(CWnd::FromHandle(adsw_acadMainWnd()));

    149.   //
    150.   dlg.m_caption = pszCaption;
    151.   dlg.m_labelString = pszLabel;
    152.   dlg.m_editBoxString = pszIntText;

    153.   //
    154.   int m_dlgResult = dlg.DoModal();

    155.   //
    156.   if ( m_dlgResult != IDOK )
    157.    return acedRetNil();
    158.   else
    159.     pszIntText = dlg.m_editBoxString;

    160.   if ( _tcslen(pszIntText) == 0 )
    161.     return acedRetNil();

    162.   //
    163.   iInt = _ttoi(pszIntText);
    164.   //
    165.   acedRetInt(iInt);
    166.   return (RSRSLT) ;
    167. }
    168. #pragma endregion

    169. #pragma region //DlgRealBox
    170. //(crprealbox "Title" "Label" 12.23)
    171. int DlgRealBox(void)
    172. {
    173.   LPCTSTR pszCaption;
    174.   LPCTSTR pszLabel;
    175.   LPCTSTR pszRealText;
    176.   ACHAR buf[256];

    177.   double dReal;
    178.   //
    179.   struct resbuf *pArgs = acedGetArgs() ;

    180.   if (pArgs == NULL)
    181.    return acedRetNil();


    182.   //
    183.   if (pArgs->restype != RTSTR )
    184.    return acedRetNil();

    185.   pszCaption =  pArgs->resval.rstring;

    186.   //
    187.   if ((pArgs = pArgs->rbnext) == NULL || pArgs->restype != RTSTR )
    188.     return acedRetNil();

    189.   pszLabel = pArgs->resval.rstring;

    190.   //
    191.   if ((pArgs = pArgs->rbnext) != NULL)
    192.   {
    193.     if (pArgs->restype == RTREAL )
    194.       _stprintf(buf , _T("%0.2f") , (double)pArgs->resval.rreal );
    195.     else if (pArgs->restype == RTLONG)
    196.       _stprintf(buf, _T("%0.2f") ,  (double)pArgs->resval.rlong );
    197.     else if (pArgs->restype == RTSHORT)
    198.       _stprintf( buf , _T("%0.2f") ,(double)pArgs->resval.rint );
    199.     else
    200.       buf[0] = '\0';
    201.   }
    202.   else
    203.     buf[0] = '\0';

    204.   pszRealText = buf;

    205.   ///////Dialog Stuff
    206.   CAcExtensionModule objResOverride;

    207.   //
    208.   TextBox dlg(CWnd::FromHandle(adsw_acadMainWnd()));

    209.   //
    210.   dlg.m_caption = pszCaption;
    211.   dlg.m_labelString = pszLabel;
    212.   dlg.m_editBoxString = pszRealText;

    213.   //
    214.   int m_dlgResult = dlg.DoModal();
    215.   if ( m_dlgResult != IDOK )
    216.    return acedRetNil();
    217.   else
    218.     pszRealText = dlg.m_editBoxString;

    219.   //
    220.   if ( _tcslen(pszRealText) == 0 )
    221.     return acedRetNil();

    222.   //
    223.   dReal = _tstof(pszRealText);

    224.   //
    225.   acedRetReal(dReal);
    226.   return (RSRSLT) ;
    227. }
    228. #pragma endregion
    复制代码
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    关闭

    推荐膜材品牌上一条 /5 下一条

    进口膜材 国产膜材 pvdf膜材ptfe膜材ETFE膜材
    最好的膜结构公司 一级膜结构资质 膜结构一级资质
    膜结构设计-膜结构十大品牌-etfe设计-充气膜结构
    诺科膜结构
    遨都膜结构设计
    中国膜结构网
    中国空间膜结构协会

    QQ|申请友链|Archiver|手机版|中国膜结构论坛

    GMT+8, 2021-3-9 13:05 , Processed in 0.268934 second(s), 23 queries .

    Powered by 中国膜结构网->膜材采购->膜结构设计->膜结构安装->膜结构维修

    © 2014-2020 膜结构协会->进口膜材->国产膜材->PVDF膜材->PTFE膜材->ETFE膜材.

    快速回复 返回顶部 返回列表