⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subject_39133.htm

📁 一些关于vc的问答
💻 HTM
字号:
<p>
序号:39133 发表者:maginn 发表日期:2003-05-08 14:06:22
<br>主题:如何显示我的一个对话框中的变量
<br>内容:如何显示我的一个对话框中的变量<BR>用那menu显示我的mydialog<BR>我在mydialog中定义了一个数组 并用edit给他赋值,可以显示在mydialog的<BR>一个edit中,一切正常。<BR>然后关闭mydialog<BR><BR>到主菜单中调用show 显示到主窗体的中,可是不行<BR>代码如下:<BR>void Mydialog::OnOK() <BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;// TODO: Add extra validation here<BR>&nbsp;&nbsp;&nbsp;&nbsp;UpdateData(true);<BR>//&nbsp;&nbsp;&nbsp;&nbsp;m_sum=m_00+m_01+m_10+m_11;<BR>&nbsp;&nbsp;&nbsp;&nbsp;array[0][0]=m_00;<BR>&nbsp;&nbsp;&nbsp;&nbsp;array[0][1]=m_01;<BR>&nbsp;&nbsp;&nbsp;&nbsp;array[1][0]=m_01;<BR>&nbsp;&nbsp;&nbsp;&nbsp;array[1][1]=m_11;<BR>&nbsp;&nbsp;&nbsp;&nbsp;UpdateData(false);<BR><BR>}<BR><BR>void CAaaView::Onshow() <BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;// TODO: Add your command handler code here<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Mydialog a;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CDC* pDC ;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;pDC-&gt;TextOut(20,20,a.array[0][0]);<BR>&nbsp;&nbsp;&nbsp;&nbsp;pDC-&gt;TextOut(20,20,a.array[0][1]);<BR>&nbsp;&nbsp;&nbsp;&nbsp;pDC-&gt;TextOut(20,20,a.array[1][0]);<BR>&nbsp;&nbsp;&nbsp;&nbsp;pDC-&gt;TextOut(20,20,a.array[1][1]);<BR>}<BR>
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:ohye212 回复日期:2003-05-08 14:38:39
<br>内容:当然不行<BR>void CAaaView::Onshow() <BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;// TODO: Add your command handler code here<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Mydialog a;&nbsp;&nbsp;//a不是你先前的哪个输数的哪个对话框<BR>是你新建的Mydialog 当然a.array[0][0] <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a.array[0][1] <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a.array[1][0] <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a.array[1][1] <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 没有数据了!!!!!!!!!!!<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CDC* pDC ;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;pDC-&gt;TextOut(20,20,a.array[0][0]);<BR>&nbsp;&nbsp;&nbsp;&nbsp;pDC-&gt;TextOut(20,20,a.array[0][1]);<BR>&nbsp;&nbsp;&nbsp;&nbsp;pDC-&gt;TextOut(20,20,a.array[1][0]);<BR>&nbsp;&nbsp;&nbsp;&nbsp;pDC-&gt;TextOut(20,20,a.array[1][1]);<BR>}<BR><BR><BR>你可以把Mydialog a;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 定义为CAaaView的变量<BR><BR>这样你在打开a后输入数据后<BR>再<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;pDC-&gt;TextOut(20,20,a.array[0][0]);<BR>&nbsp;&nbsp;&nbsp;&nbsp;pDC-&gt;TextOut(20,20,a.array[0][1]);<BR>&nbsp;&nbsp;&nbsp;&nbsp;pDC-&gt;TextOut(20,20,a.array[1][0]);<BR>&nbsp;&nbsp;&nbsp;&nbsp;pDC-&gt;TextOut(20,20,a.array[1][1]);<BR>就可以了<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:maginn 回复日期:2003-05-08 15:42:47
<br>内容:a 已经定义成mydialog的对象了,那还怎么定义成CAaaView的变量阿??<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:maginn 回复日期:2003-05-08 15:53:17
<br>内容:a 被定义成Mydialog的对象,而array[][]数组是Mydialog类的成员数组,<BR>用a调用他的成员数组不对吗??<BR><BR>“你可以把Mydialog a;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 定义为CAaaView的变量”<BR>怎么做到阿??<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:ohye212 回复日期:2003-05-08 16:09:47
<br>内容:在CAaaView.h 文件里定义<BR><BR>class AaaView: public CView<BR>{<BR>protected:<BR>&nbsp;&nbsp;&nbsp;&nbsp;// protected constructor used by dynamic creation<BR>&nbsp;&nbsp;&nbsp;&nbsp;DECLARE_DYNCREATE(printview)<BR><BR><BR>// Attributes<BR>public:<BR>&nbsp;&nbsp;&nbsp;&nbsp;Mydialog a; ////////////////记得加Mydialog 头文件!!<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:maginn 回复日期:2003-05-09 09:59:59
<br>内容:sorry<BR>when i put the "show"menu <BR>still that error<BR>:<BR>unhandled expection in aaa.exe(MFC42D.DLL)0xc00000005:Access Voilation
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:楚天琪 回复日期:2003-05-09 10:50:02
<br>内容:可以把A定义成全局的来调用。。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:晚风也渡 回复日期:2003-05-09 11:22:51
<br>内容:像ohye212所说的那样,在AaaView中声明一个Mydialog a; <BR>在void CAaaView::Onshow()中,显示对话框,就是<BR>&nbsp;&nbsp;a.DoModal();<BR>不要忘了加上#include"mydialog.h"
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:ohye212 回复日期:2003-05-09 11:49:33
<br>内容:找个书上的例子看看就知道了!很简单!!!
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:maginn 回复日期:2003-05-09 14:21:50
<br>内容:我已经在AaaView中定义了<BR>public:<BR>&nbsp;&nbsp;&nbsp;&nbsp;Mydialog a; <BR><BR>我在nemu中有两项<BR><BR>1是open 打开mydialog :a.DoModal();<BR>显示mydialog对话框,然后添加数据。<BR>在mydialog中点ok 完成添加(显示数据正常),然后点cancel退出mydialog<BR><BR>2:点menu中的show:<BR>CDC *pDC;<BR>pDC-&gt;TextOut(20,20,a.array[0][0]);<BR>在执行的时候出现问题了,就是我说的那个问题<BR><BR>这个该死的问题已经烦我2天了,我也知道简单,可是。。。,我快失去信息了:(<BR>麻烦您了!thanks&nbsp;&nbsp;&nbsp;&nbsp;<BR><BR>烦劳问一句 在不同地方定义变量有什么区别如:<BR>#endif // _MSC_VER &gt; 1000<BR><BR><BR>class CMyarrayView : public CView<BR>{<BR>protected: // create from serialization only<BR>&nbsp;&nbsp;&nbsp;&nbsp;CMyarrayView();<BR>&nbsp;&nbsp;&nbsp;&nbsp;DECLARE_DYNCREATE(CMyarrayView)<BR><BR>// Attributes<BR>public:<BR>&nbsp;&nbsp;&nbsp;&nbsp;CMyarrayDoc* GetDocument();<BR>&nbsp;&nbsp;&nbsp;&nbsp;mydialog a;××××××××××××××××××××××在这里定义<BR>// Operations<BR>public:<BR><BR>// Overrides<BR>&nbsp;&nbsp;&nbsp;&nbsp;// ClassWizard generated virtual function overrides<BR>&nbsp;&nbsp;&nbsp;&nbsp;//{{AFX_VIRTUAL(CMyarrayView)<BR>&nbsp;&nbsp;&nbsp;&nbsp;public:<BR>&nbsp;&nbsp;&nbsp;&nbsp;virtual void OnDraw(CDC* pDC);&nbsp;&nbsp;// overridden to draw this view<BR>&nbsp;&nbsp;&nbsp;&nbsp;virtual BOOL PreCreateWindow(CREATESTRUCT&amp; cs);<BR>&nbsp;&nbsp;&nbsp;&nbsp;protected:<BR>&nbsp;&nbsp;&nbsp;&nbsp;virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);<BR>&nbsp;&nbsp;&nbsp;&nbsp;virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);<BR>&nbsp;&nbsp;&nbsp;&nbsp;virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);<BR>&nbsp;&nbsp;&nbsp;&nbsp;//}}AFX_VIRTUAL<BR><BR>// Implementation<BR>public:<BR>&nbsp;&nbsp;&nbsp;&nbsp;mydialog* cc;<BR>×××××××××××××××××××××××××在这里定义mydialog a<BR>&nbsp;&nbsp;&nbsp;&nbsp;virtual ~CMyarrayView();<BR>#ifdef _DEBUG<BR><BR>在这两个地方定义有什么区别?<BR>还有如果在cpp文件中直接定义的全局变量和在这里定义的有什么区别阿??<BR>2003-5-9 14:26:41

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -