[求助]如何在应用程序中得知用户按了OK按扭?
<FONT id=text1 style="FONT-SIZE: 10pt" face="宋体,verdana, arial, helvetica">通过非模态对话框获得用户输入的数据赋值给变量,但是在XXXXCommand.cpp文件中想引用这些变量却出现“未声明变量”。后将变量声明为extern XXX,又出现link时“未解决的外部标识......"<BR><BR>这是为何?<BR>另:如何在应用程序中得知用户按了OK按扭?</FONT> <BR>回复
有程序吗?传上来吧 //-----------------------------------------------------------------------------//这是一个图框生成程序
//-----------------------------------------------------------------------------<BR>//----- DwgboxDlg.cpp : implementation file<BR>#include "StdAfx.h"<BR>#include "resource.h"<BR>#include "DwgboxDlg.h"
//-----------------------------------------------------------------------------<BR>#ifdef _DEBUG<BR>#define new DEBUG_NEW<BR>#undef THIS_FILE<BR>static char THIS_FILE[] = __FILE__;<BR>#endif
//-----------------------------------------------------------------------------<BR>IMPLEMENT_DYNAMIC (DwgboxDlg, CAcUiDialog)
BEGIN_MESSAGE_MAP(DwgboxDlg, CAcUiDialog)<BR> //{{AFX_MSG_MAP(DwgboxDlg)<BR> ON_MESSAGE(WM_ACAD_KEEPFOCUS, OnAcadKeepFocus) // Needed for modeless dialog.<BR> ON_BN_CLICKED(IDC_CHECK1, OnCheck1)<BR> ON_BN_CLICKED(IDC_CHECK2, OnCheck2)<BR> ON_BN_CLICKED(IDC_RADIO1, OnRadio1)<BR> ON_BN_CLICKED(IDC_RADIO10, OnRadio10)<BR> ON_BN_CLICKED(IDC_RADIO11, OnRadio11)<BR> ON_BN_CLICKED(IDC_RADIO12, OnRadio12)<BR> ON_BN_CLICKED(IDC_RADIO13, OnRadio13)<BR> ON_BN_CLICKED(IDC_RADIO2, OnRadio2)<BR> ON_BN_CLICKED(IDC_RADIO3, OnRadio3)<BR> ON_BN_CLICKED(IDC_RADIO4, OnRadio4)<BR> ON_BN_CLICKED(IDC_RADIO5, OnRadio5)<BR> ON_BN_CLICKED(IDC_RADIO6, OnRadio6)<BR> ON_BN_CLICKED(IDC_RADIO7, OnRadio7)<BR> ON_BN_CLICKED(IDC_RADIO8, OnRadio8)<BR> ON_BN_CLICKED(IDC_RADIO9, OnRadio9)<BR> ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)<BR> ON_EN_CHANGE(IDC_EDIT2, OnChangeEdit2)<BR> ON_EN_CHANGE(IDC_EDIT3, OnChangeEdit3)<BR> //}}AFX_MSG_MAP<BR>END_MESSAGE_MAP()
//-----------------------------------------------------------------------------<BR>DwgboxDlg::DwgboxDlg (CWnd* pParent /*=NULL*/, HINSTANCE hInstance /*=NULL*/) : CAcUiDialog (DwgboxDlg::IDD, pParent, hInstance) {<BR> //{{AFX_DATA_INIT(DwgboxDlg)<BR> m_bEnableTKtb = TRUE;<BR> m_bEnableTkhq = TRUE;<BR> m_nTKsize = 1;<BR> m_nTKHorVer = 0;<BR> m_nTKratio = 1;<BR> m_fTKwidth = 841;<BR> m_fTKhight = 594;<BR> m_fTKscale = 100;<BR> //}}AFX_DATA_INIT<BR>}
void DwgboxDlg::DoDataExchange (CDataExchange *pDX) {<BR> CAcUiDialog::DoDataExchange (pDX) ;<BR> //{{AFX_DATA_MAP(DwgboxDlg)<BR> DDX_Control(pDX, IDCANCEL, m_TKCancelMsg);<BR> DDX_Check(pDX, IDC_CHECK1, m_bEnableTKtb);<BR> DDX_Check(pDX, IDC_CHECK2, m_bEnableTkhq);<BR> DDX_Radio(pDX, IDC_RADIO1, m_nTKsize);<BR> DDX_Radio(pDX, IDC_RADIO6, m_nTKHorVer);<BR> DDX_Radio(pDX, IDC_RADIO8, m_nTKratio);<BR> DDX_Text(pDX, IDC_EDIT1, m_fTKwidth);<BR> DDX_Text(pDX, IDC_EDIT2, m_fTKhight);<BR> DDX_Text(pDX, IDC_EDIT3, m_fTKscale);<BR> //}}AFX_DATA_MAP<BR>}
// Needed for modeless dialogs to keep focus.<BR>// Return FALSE to not keep the focus, return TRUE to keep the focus<BR>LONG DwgboxDlg::OnAcadKeepFocus(UINT, UINT)<BR>{<BR> return TRUE;<BR>}
//-----------------------------------------------------------------------------
void DwgboxDlg::OnOK() <BR>{<BR> // TODO: Add extra validation here<BR> CAcUiDialog::OnOK();<BR> DestroyWindow();<BR> tk();<BR>}
void DwgboxDlg::OnCancel() <BR>{<BR> // TODO: Add extra cleanup here<BR> <BR> CAcUiDialog::OnCancel();<BR> DestroyWindow();<BR>}
void DwgboxDlg::OnCheck1() <BR>{<BR> // TODO: Add your control notification handler code here<BR> if(m_bEnableTKtb == TRUE)<BR> {<BR> m_bEnableTKtb = FALSE;<BR> }<BR> else<BR> {<BR> m_bEnableTKtb = TRUE;<BR> }<BR>}
void DwgboxDlg::OnCheck2() <BR>{<BR> // TODO: Add your control notification handler code here<BR> if(m_bEnableTkhq == TRUE)<BR> {<BR> m_bEnableTkhq = FALSE;<BR> }<BR> else<BR> {<BR> m_bEnableTkhq = TRUE;<BR> }<BR>}
void DwgboxDlg::OnChangeEdit1() <BR>{<BR> // TODO: If this is a RICHEDIT control, the control will not<BR> // send this notification unless you override the CAcUiDialog::OnInitDialog()<BR> // function and call CRichEditCtrl().SetEventMask()<BR> // with the ENM_CHANGE flag ORed into the mask.<BR> <BR> // TODO: Add your control notification handler code here<BR> BOOL UpdateData(BOOL bSaveAndValidate=TRUE);<BR>}
void DwgboxDlg::OnChangeEdit2() <BR>{<BR> // TODO: If this is a RICHEDIT control, the control will not<BR> // send this notification unless you override the CAcUiDialog::OnInitDialog()<BR> // function and call CRichEditCtrl().SetEventMask()<BR> // with the ENM_CHANGE flag ORed into the mask.<BR> <BR> // TODO: Add your control notification handler code here<BR> BOOL UpdateData(BOOL bSaveAndValidate=TRUE);<BR>}
void DwgboxDlg::OnChangeEdit3() <BR>{<BR> // TODO: If this is a RICHEDIT control, the control will not<BR> // send this notification unless you override the CAcUiDialog::OnInitDialog()<BR> // function and call CRichEditCtrl().SetEventMask()<BR> // with the ENM_CHANGE flag ORed into the mask.<BR> <BR> // TODO: Add your control notification handler code here<BR> BOOL UpdateData(BOOL bSaveAndValidate=TRUE);<BR>}
void DwgboxDlg::OnRadio1() <BR>{<BR> // TODO: Add your control notification handler code here<BR> m_nTKsize=0;<BR> m_fTKwidth = 1189.0;<BR> m_fTKhight = 841.0;<BR> BOOL UpdateData(BOOL bSaveAndValidate=FALSE);<BR>}
void DwgboxDlg::OnRadio10() <BR>{<BR> // TODO: Add your control notification handler code here<BR> m_nTKratio=2;<BR> m_fTKscale = 50.0;<BR> BOOL UpdateData(BOOL bSaveAndValidate=FALSE);<BR>}
void DwgboxDlg::OnRadio11() <BR>{<BR> // TODO: Add your control notification handler code here<BR> m_nTKratio=3;<BR> m_fTKscale = 20.0;<BR> BOOL UpdateData(BOOL bSaveAndValidate=FALSE);<BR>}
void DwgboxDlg::OnRadio12() <BR>{<BR> // TODO: Add your control notification handler code here<BR> m_nTKratio=4;<BR> m_fTKscale = 10.0;<BR> BOOL UpdateData(BOOL bSaveAndValidate=FALSE);<BR>}
void DwgboxDlg::OnRadio13() <BR>{<BR> // TODO: Add your control notification handler code here<BR> m_nTKratio=5;<BR> m_fTKscale = 1.0;<BR> BOOL UpdateData(BOOL bSaveAndValidate=FALSE);<BR>}
void DwgboxDlg::OnRadio2() <BR>{<BR> // TODO: Add your control notification handler code here<BR> m_nTKsize=1;<BR> m_fTKwidth = 841.0;<BR> m_fTKhight = 594.0;<BR> BOOL UpdateData(BOOL bSaveAndValidate=FALSE);<BR>}
void DwgboxDlg::OnRadio3() <BR>{<BR> // TODO: Add your control notification handler code here<BR> m_nTKsize=2;<BR> m_fTKwidth = 594.0;<BR> m_fTKhight = 420.0;<BR> BOOL UpdateData(BOOL bSaveAndValidate=FALSE);<BR>}
void DwgboxDlg::OnRadio4() <BR>{<BR> // TODO: Add your control notification handler code here<BR> m_nTKsize=3;<BR> m_fTKwidth = 420.0;<BR> m_fTKhight = 297.0;<BR> BOOL UpdateData(BOOL bSaveAndValidate=FALSE);<BR>}
void DwgboxDlg::OnRadio5() <BR>{<BR> // TODO: Add your control notification handler code here<BR> m_nTKsize=4;<BR> m_fTKwidth = 210.0;<BR> m_fTKhight = 297.0;<BR> BOOL UpdateData(BOOL bSaveAndValidate=FALSE);<BR>}
void DwgboxDlg::OnRadio6() <BR>{<BR> // TODO: Add your control notification handler code here<BR> m_nTKHorVer=0;<BR>}
void DwgboxDlg::OnRadio7() <BR>{<BR> // TODO: Add your control notification handler code here<BR> m_nTKHorVer=1;<BR>}
void DwgboxDlg::OnRadio8() <BR>{<BR> // TODO: Add your control notification handler code here<BR> m_nTKratio=0;<BR> m_fTKscale = 200.0;<BR> BOOL UpdateData(BOOL bSaveAndValidate=FALSE);<BR>}
void DwgboxDlg::OnRadio9() <BR>{<BR> // TODO: Add your control notification handler code here<BR> m_nTKratio=1;<BR> m_fTKscale = 100.0;<BR> BOOL UpdateData(BOOL bSaveAndValidate=FALSE);<BR>}
//-----------------------------------------------------------------------------
BOOL startDlg() <BR>{ <BR> DwgboxDlg *gpDlg=NULL;<BR> gpDlg = new DwgboxDlg(acedGetAcadFrame());<BR> gpDlg->Create(IDD_DIALOG1);<BR> gpDlg->ShowWindow(SW_SHOW);<BR> gpDlg->CenterWindow();<BR> return true;<BR>} <BR> <BR>//-----------------------------------------------------------------------------<BR> <BR>/*BOOL endDlg() <BR>{ <BR> DwgboxDlg *gpDlg=NULL;<BR> if(!gpDlg)return TRUE; <BR> BOOL b = gpDlg->DestroyWindow(); <BR> if(b)gpDlg = NULL; <BR> return b; <BR>}*/
void DwgboxDlg::PostNcDestroy() <BR>{<BR> // TODO: Add your specialized code here and/or call the base class<BR> delete this; //删除当前指针<BR> CAcUiDialog::PostNcDestroy();<BR>}
<BR> //上个程序为DwgboxDlg.cpp
//现为DwgboxDlg.h
//-------------------------------------------------------------------
//-----------------------------------------------------------------------------<BR>#if !defined(ARX__DWGBOXDLG_H__20050416_161606)<BR>#define ARX__DWGBOXDLG_H__20050416_161606
//-----------------------------------------------------------------------------<BR>#if _MSC_VER > 1000<BR>#pragma once<BR>#endif // _MSC_VER > 1000
//-----------------------------------------------------------------------------<BR>class DwgboxDlg : public CAcUiDialog {<BR> DECLARE_DYNAMIC (DwgboxDlg)
public:<BR> DwgboxDlg (CWnd* pParent =NULL, HINSTANCE hInstance =NULL) ;
//{{AFX_DATA(DwgboxDlg)<BR> enum { IDD = IDD_DIALOG1 };<BR> CButton m_TKCancelMsg;<BR> BOOL m_bEnableTKtb;<BR> BOOL m_bEnableTkhq;<BR> int m_nTKsize;<BR> int m_nTKHorVer;<BR> int m_nTKratio;<BR> float m_fTKwidth;<BR> float m_fTKhight;<BR> float m_fTKscale;<BR> //}}AFX_DATA
//{{AFX_VIRTUAL(DwgboxDlg)<BR> protected:<BR> virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support<BR> virtual void PostNcDestroy();<BR> //}}AFX_VIRTUAL
protected:<BR> //{{AFX_MSG(DwgboxDlg)<BR> afx_msg LONG OnAcadKeepFocus(UINT, UINT);<BR> virtual void OnOK();<BR> virtual void OnCancel();<BR> afx_msg void OnCheck1();<BR> afx_msg void OnCheck2();<BR> afx_msg void OnRadio1();<BR> afx_msg void OnRadio10();<BR> afx_msg void OnRadio11();<BR> afx_msg void OnRadio12();<BR> afx_msg void OnRadio13();<BR> afx_msg void OnRadio2();<BR> afx_msg void OnRadio3();<BR> afx_msg void OnRadio4();<BR> afx_msg void OnRadio5();<BR> afx_msg void OnRadio6();<BR> afx_msg void OnRadio7();<BR> afx_msg void OnRadio8();<BR> afx_msg void OnRadio9();<BR> afx_msg void OnChangeEdit1();<BR> afx_msg void OnChangeEdit2();<BR> afx_msg void OnChangeEdit3();<BR> //}}AFX_MSG
DECLARE_MESSAGE_MAP()<BR>} ;
//{{AFX_INSERT_LOCATION}}<BR>// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif //----- !defined(ARX__DWGBOXDLG_H__20050416_161606)<BR> //此为DwgboxCommand.cpp
//--------------------------------------------------------------
//<BR>// ObjectARX defined commands, created by , ,
#include "StdAfx.h"<BR>#include "StdArx.h"<BR>#include <stdio.h><BR>#include <stdlib.h><BR>#include <string.h><BR>#include <math.h><BR>#include "resource.h"<BR>#include "DwgboxDlg.h"<BR>//#include "DwgboxDlg.cpp"<BR>#include "aced.h"<BR>#include "acedads.h"<BR>#include "acutads.h"<BR>#include "rxdefs.h"<BR>#include "adslib.h"<BR>//-----------------------------------------------------------------------------<BR>void pointset();<BR>void drawbz (ads_point pt);<BR>void lineset();<BR>void drabox(ads_point p1,ads_point p2,ads_real wh);
int anset=0,ansetxy=0,ansetw=0,anseth=0,bx=0,bax=0,bcx=0,box=0,accepted=0;<BR>ads_real bbx,bbl,nx,ny;<BR>ads_point basept={0,0,0},pp={0,0,0};<BR>int change_var(char *varstr,int value,int *ocmd);<BR> float m_fTKwidth,m_fTKhight,m_fTKscale;
//-----------------------------------------------------------------------------<BR>// This is command 'DWGBOX, by , , <BR>void Dwgbox()<BR>{<BR>#ifdef OARXWIZDEBUG<BR> acutPrintf ("\nOARXWIZDEBUG - Dwgbox() called.");<BR>#endif // OARXWIZDEBUG
// TODO: Implement the command
//-----------------------------------------------------------------------------<BR>BOOL startDlg();<BR> startDlg();<BR>}
<BR>//-----------------------------------------------------------------------------<BR>void tk()<BR>{
ads_point basept1,ppt;<BR> int old1,old2,old3,valxy;
<BR> change_var("blipmode",0,&old1);<BR> change_var("cmdecho",0,&old2);<BR> change_var("osmode",0,&old3);<BR> <BR> if(m_fTKwidth!=0.0 && m_fTKhight!=0.0 && m_fTKscale!=0.0 )//此处变量无法从DwgboxDlg.cpp中定义的对话框变量传递数据.<BR> {<BR> basept=0.00;basept=0.00;basept=0.00;<BR> if((valxy=acedGetPoint(NULL,"\n请拾取图框左下角点位置:",ppt))!=RTCAN)<BR> {<BR> basept1=ppt;<BR> basept1=ppt;<BR> basept1=ppt;<BR> if (valxy==RTNONE)<BR> {<BR> drawbz(basept);<BR> }<BR> else<BR> {<BR> basept=basept1;<BR> basept=basept1;<BR> basept=basept1;<BR> drawbz(basept);<BR> }<BR> }<BR> else<BR> {<BR> nx=0;ny=0;bbx=0;anset=0;ansetxy=0;ansetw=0;anseth=0;bx=0;bax=0;bcx=0;box=0;<BR> acutPrintf("\n用户中断!\n");<BR> }<BR> pointset();<BR> }<BR> else<BR> {<BR> if(accepted==0)//此处想获得用户如果按了"取消"按钮消息,未成功.<BR> {<BR> nx=0;ny=0;bbx=0;anset=0;ansetxy=0;ansetw=0;anseth=0;bx=0;bax=0;bcx=0;box=0;<BR> acutPrintf("\n*Cancel*\n");<BR> }<BR> else<BR> {<BR> nx=0;ny=0;bbx=0;anset=0;ansetxy=0;ansetw=0;anseth=0;bx=0;bax=0;bcx=0;box=0;<BR> acutPrintf("\n参数选择错误!\n");<BR> }<BR> }<BR> if(m_fTKwidth!=0.0 && m_fTKhight!=0.0 && m_fTKscale!=0.0)<BR> {<BR> lineset();<BR> }<BR> }<BR>void pointset()<BR> {<BR> if (m_fTKwidth!=0 && m_fTKhight!=0) <BR> {<BR> pp=m_fTKwidth;<BR> pp=m_fTKhight;<BR> }<BR> if(m_fTKscale!=0)<BR> {<BR> bbl=m_fTKscale;<BR> }<BR> pp=basept+pp*bbl;<BR> pp=basept+pp*bbl;<BR> acedCommand(RTSTR,"limits",RTPOINT,basept,RTPOINT,pp,RTNONE);<BR> acedCommand(RTSTR,"zoom",RTSTR,"a",RTNONE);<BR> }
int change_var(char *varstr,int value,int *ocmd)<BR>{<BR> struct resbuf *rb0;<BR> int status;
rb0=acutNewRb(RTSHORT);<BR> status=acedGetVar(varstr,rb0);<BR> if(status != RTNORM)<BR> {<BR> acdbFail("\nacedGetVar(varstr.. fail)");<BR> return RTERROR;<BR> }<BR> *ocmd=rb0->resval.rint;<BR> rb0->resval.rint=value;<BR> rb0->rbnext=NULL;<BR> status=acedSetVar(varstr,rb0);
acutRelRb(rb0);<BR> if(status != RTNORM)<BR> {<BR> acdbFail("\nacedSetVar(varstr.. fail)");<BR> return RTERROR;<BR> }<BR> return RTNORM;<BR>}
void drawbz (ads_point pt) <BR> {<BR> struct resbuf *rb2;<BR> ads_point pp1,pp2,pp3,pp4;<BR> ads_real aa;<BR> rb2=acutNewRb(RTREAL);<BR> acedGetVar("VIEWSIZE",rb2);<BR> aa=0.020000*rb2->resval.rreal;<BR> rb2->rbnext=NULL;<BR> acutRelRb(rb2);<BR> pp1=pt+aa;pp1=pt+aa;<BR> pp2=pt-aa;pp2=pt-aa;<BR> pp3=pt+aa;pp3=pt+(-aa);<BR> pp4=pt-aa;pp4=pt-(-aa);<BR> acedGrDraw(pp1,pp2,-1,0);<BR> acedGrDraw(pp3,pp4,-1,0);<BR> }<BR>void lineset()<BR> {<BR> ads_real w;<BR> ads_point pt3={0,0,0},<BR> pt4={0,0,0},<BR> pt5={0,0,0},<BR> pt6={0,0,0};<BR> acedCommand(RTSTR,"layer",RTSTR,"m",RTSTR,"tk",RTSTR,"c",RTSTR,"cyan",RTSTR,"",RTSTR,"",RTNONE);<BR> acedCommand(RTSTR,"linetype",RTSTR,"s",RTSTR,"bylayer",RTSTR,"",RTNONE);<BR> acedCommand(RTSTR,"color",RTSTR,"bylayer",RTNONE);
drabox(basept,pp,0.0);<BR> pt3=basept+bbl*25;<BR> if(box==1)<BR> {<BR> pt3=basept+bbl*10;<BR> pt4=pp-bbl*10;<BR> pt4=pp-bbl*10;<BR> }<BR> else<BR> {<BR> pt3=basept+bbl*5;<BR> pt4=pp-bbl*5;<BR> pt4=pp-bbl*5;<BR> }<BR> w=0.700000*bbl;<BR> <BR> drabox(pt3,pt4,w);<BR> pt5=pt4;pt5=pt3;<BR> pt6=pt3;pt6=pt4;<BR> if (box==1)<BR> {<BR> acedCommand(RTSTR,"insert",RTSTR,"tb",RTPOINT,pt5,RTREAL,bbl,RTREAL,bbl,RTREAL,0.0,RTNONE);<BR> acedCommand(RTSTR,"insert",RTSTR,"hq",RTPOINT,pt6,RTREAL,bbl,RTREAL,bbl,RTREAL,0.0,RTNONE);<BR> } <BR> else <BR> {<BR> acedCommand(RTSTR,"insert",RTSTR,"tb1",RTPOINT,pt5,RTREAL,bbl,RTREAL,bbl,RTREAL,0.0,RTNONE);<BR> }<BR> acedCommand(RTSTR,"layer",RTSTR,"s",RTSTR,"0",RTSTR,"",RTNONE);<BR> box=0;bx=0;bax=0;bcx=0;anset=0;ansetxy=0;ansetw=0;anseth=0;<BR> }
void drabox(ads_point p1,ads_point p2,ads_real wh) <BR> {<BR> ads_point p3,p4;<BR> p3=p2;p3=p1;<BR> p4=p1;p4=p2;<BR> acedCommand(RTSTR,"pline",RTPOINT,p1,RTSTR,"w",RTREAL,wh,RTREAL,wh,RTPOINT,p3,RTPOINT,p2,RTPOINT,p4,RTSTR,"c",RTNONE);<BR> } 你把工程贴上来比这样要好,
压缩成rar文件 rar 文件如何传? 程序还未写完.请指教 程序上传后我怎么看不见?