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

📄 subject_66929.htm

📁 vc
💻 HTM
字号:
<p>
序号:66929 发表者:egg007 发表日期:2003-12-27 19:04:05
<br>主题:请教一个问题(我不知道是哪儿的问题)!!!谢谢
<br>内容:我得程序为什么如果没有while循环,程序运行正常,但是加上循环以后,不能执行OnTimer里的操作,我的OnTimer函数里执行的是发送和接收数据的操作,我的程序就是希望在我点击发送按钮后可以自动的每隔几秒就发送接收一次数据,但是为什么在我点击发送以后不能执行OnTimer里的操作,点击一次停止按钮以后才执行,再点击一次停止按钮才能停止,这是为什么,这个问题好像和while循环有关,我应该怎么解决这个问题呢???我得代码在下面,希望得到高手的指点!谢谢<BR><BR>//以下为点击发送按钮后的事件<BR>stopcycle=0;&nbsp;&nbsp; //用来中止循环,在停止按钮的点击事件里被置为1&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>MSG pMsg;<BR>pMsg.hwnd = this-&gt;m_hWnd;<BR>pMsg.lParam = pMsg.wParam = 0;<BR>pMsg.message = WM_PAINT;<BR>pMsg.time = 0;<BR>while(!stopcycle)<BR>{<BR>&nbsp;&nbsp; PeekMessage(&amp;pMsg, NULL, 0, 0, PM_REMOVE);<BR>&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TranslateMessage(&amp;pMsg);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DispatchMessage(&amp;pMsg);<BR>&nbsp;&nbsp; }<BR>&nbsp;&nbsp; //AfxMessageBox(&#34;begin&#34;);&nbsp;&nbsp;//如果在此处弹出对话框,则程序执行也正常<BR>&nbsp;&nbsp; SetTimer(1,500,NULL);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>}<BR>2003-12-27 20:28:16

⌨️ 快捷键说明

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