📄 subject_18165.htm
字号:
<p>
序号:18165 发表者:mini 发表日期:2002-10-18 10:51:11
<br>主题:菜鸟的愿望——VC编程篇
<br>内容:void CWlyuanzhuView::OnRButtonDown(UINT nFlags, CPoint point) //VC技术内幕<BR>{<BR> Dlg dlg;<BR> dlg.m_h=300;<BR> dlg.m_r=150;<BR> dlg.m_x=200;<BR> dlg.m_y=300;<BR> int ret=dlg.DoModal();<BR> TRACE("EDIT1=%d,EDIT2=%d,EDIT3=%d,EDIT4=%d,\n",<BR> dlg.m_h,dlg.m_r,dig.m_x,dlg.m_y);}//TRACE 是不是跟踪输入的值啊<BR>void Dlg::OnOK() <BR>{<BR> UpdateData(TRUE);<BR> r = dlg.m_r;<BR> x = dlg.m_x;<BR> y = dlg.m_y;<BR> h = dlg.m_h;}<BR><BR>void Dlg::OnPaint()//技术内幕<BR>{<BR> CPaintDC dc(this); // device context for painting<BR> <BR> // TODO: Add your message handler code here<BR> CWnd*pWnd=GetDlgItem(IDC_STATIC1);<BR> CDC*pControlDC=pWnd->GetDC();<BR> pWnd->Invalidate();<BR> pWnd->UpdateWindow();<BR><BR> r1=r-100;<BR> pControlDC->MoveTo(x-r,y);<BR> pControlDC->LineTo(x-r,y+h);<BR> pControlDC->MoveTo(x+r,y);<BR> pControlDC->LineTo(x+r,y+h);<BR> pControlDC->Ellipse(CRect(x-r,y-r+100,x+r,y+r-100));<BR> pControlDC->Arc(x-r,y+h-r1,x+r,y+h+r1,x-r,y+h,x+r,y+h);<BR> float i,j=0;<BR><BR> for (i=x+r;i>x+r/2.0;i=i-j)<BR> { <BR> pControlDC->MoveTo(i,y+r1*sqrt(1-(i-x)*(i-x)/(r*r)));<BR> pControlDC->LineTo(i,h+y+r1*sqrt(1-(i-x)*(i-x)/(r*r)));<BR> j=j+1;}<BR> <BR> pWnd->ReleaseDC(pControlDC);<BR> // Do not call CDialog::OnPaint() for painting messages<BR>}<BR>我想建立对话框,设置X,Y,H,R四个EDIT1-4。<BR>在ONDRAW 里调用按右键开始,要出现对话框,付值完毕按OK键,然后绘图。<BR>目前编译不通,请多多指教。<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>
回复者:CDMA2000 回复日期:2002-10-18 10:55:18
<br>内容:出现什么错误啊<BR>你应该在OnOK()最后调用那个<BR>Invalidrate()来通知重绘啊
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:mini 回复日期:2002-10-18 11:33:28
<br>内容:文件夹\wlyuanzhu\Dlg.cpp(58) : error C2065: 'r' : undeclared identifier<BR>C:\新建文件夹\wlyuanzhu\Dlg.cpp(58) : error C2065: 'dlg' : undeclared identifier<BR>C:\新建文件夹\wlyuanzhu\Dlg.cpp(58) : error C2228: left of '.m_r' must have class/struct/union type<BR>C:\新建文件夹\wlyuanzhu\Dlg.cpp(59) : error C2065: 'x' : undeclared identifier<BR>C:\新建文件夹\wlyuanzhu\Dlg.cpp(59) : error C2228: left of '.m_x' must have class/struct/union type<BR>C:\新建文件夹\wlyuanzhu\Dlg.cpp(60) : error C2065: 'y' : undeclared identifier<BR>C:\新建文件夹\wlyuanzhu\Dlg.cpp(60) : error C2228: left of '.m_y' must have class/struct/union type<BR>C:\新建文件夹\wlyuanzhu\Dlg.cpp(61) : error C2065: 'h' : undeclared identifier<BR>C:\新建文件夹\wlyuanzhu\Dlg.cpp(61) : error C2228: left of '.m_h' must have class/struct/union type<BR>C:\新建文件夹\wlyuanzhu\Dlg.cpp(75) : error C2065: 'IDC_STATIC1' : undeclared identifier<BR>C:\新建文件夹\wlyuanzhu\Dlg.cpp(80) : error C2065: 'r1' : undeclared identifier<BR>C:\新建文件夹\wlyuanzhu\Dlg.cpp(89) : warning C4244: '=' : conversion from 'int' to 'float', possible loss of data<BR>C:\新建文件夹\wlyuanzhu\Dlg.cpp(91) : error C2065: 'sqrt' : undeclared identifier<BR>C:\新建文件夹\wlyuanzhu\Dlg.cpp(91) : warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data<BR>C:\新建文件夹\wlyuanzhu\Dlg.cpp(92) : warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data<BR>wlyuanzhuView.cpp<BR>C:\新建文件夹\wlyuanzhu\wlyuanzhuView.cpp(21) : error C2259: 'CWlyuanzhuView' : cannot instantiate abstract class due to following members:<BR> c:\新建文件夹\wlyuanzhu\wlyuanzhuview.h(13) : see declaration of 'CWlyuanzhuView'<BR>C:\新建文件夹\wlyuanzhu\wlyuanzhuView.cpp(21) : warning C4259: 'void __thiscall CView::OnDraw(class CDC *)' : pure virtual function was not defined<BR> c:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(3594) : see declaration of 'OnDraw'<BR>C:\新建文件夹\wlyuanzhu\wlyuanzhuView.cpp(21) : error C2259: 'CWlyuanzhuView' : cannot instantiate abstract class due to following members:<BR> c:\新建文件夹\wlyuanzhu\wlyuanzhuview.h(13) : see declaration of 'CWlyuanzhuView'<BR>C:\新建文件夹\wlyuanzhu\wlyuanzhuView.cpp(21) : warning C4259: 'void __thiscall CView::OnDraw(class CDC *)' : pure virtual function was not defined<BR> c:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(3594) : see declaration of 'OnDraw'<BR>C:\新建文件夹\wlyuanzhu\wlyuanzhuView.cpp(58) : error C2509: 'OnDraw' : member function not declared in 'CWlyuanzhuView'<BR> c:\新建文件夹\wlyuanzhu\wlyuanzhuview.h(13) : see declaration of 'CWlyuanzhuView'<BR>Generating Code...<BR>Error executing cl.exe.<BR><BR>wlyuanzhu.exe - 15 error(s), 5 warning(s)<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>回复者:fl 回复日期:2002-10-18 11:45:49
<br>内容:你的程序 我大体做了一遍,也许结果不是你想要得,有几个问题:<BR>1 x,y,r,h,要在WlyuanzhuView.h,中定义。<BR>其他几个在程序中 你重点看看dlg::ONOK的实现,和CWlyuanzhuView::ONPAINT 的实现,<BR>2创建了Dlg后,要在WlyuanzhuView.cpp 中将dlg.h加进去!<BR><BR>你看看这几个文件:<BR>void CWlyuanzhuView::OnRButtonDown(UINT nFlags, CPoint point) <BR>void Dlg::OnOK() <BR>void Dlg::OnPaint()<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>
回复者:mini 回复日期:2002-10-18 15:08:40
<br>内容:sunshinef1:<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>
回复者:fl 回复日期:2002-10-18 15:15:43
<br>内容:狂晕 俺是新手
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -