这是我的一段程序。我想用OnButtonVisionGrab()跳出OnButtonVisionInit()中的while循环,怎么做。谢谢了!
void CTestDlg::OnButtonVisionInit()
{
// TODO: Add your control notification handler code here m_TempFlag = 1; CWnd* pStartButton = GetDlgItem(IDC_BUTTON_VISION_INIT);
if(pStartButton != NULL)
{
pStartButton->EnableWindow(FALSE);
} m_Digitizer.Halt();
m_Digitizer.Grab();
CApplicationTimer m_TimerMode;
m_TimerMode = m_Application.GetTimer();
m_TimerMode.SetSynchronizationMode(appTimerSynchronous);
m_TimerMode.Reset(); while(m_TempFlag == 1)
{
m_Digitizer.Grab();
} UpdateData(FALSE);
}void CTestDlg::OnButtonVisionGrab()
{
// TODO: Add your control notification handler code here m_TempFlag = 2; CWnd* pGrabButton = GetDlgItem(IDC_BUTTON_VISION_GRAB);
if(pGrabButton != NULL)
{
pGrabButton->EnableWindow(FALSE);
} m_Digitizer.GrabWait(digGrabEnd); UpdateData(FALSE);
}
void CTestDlg::OnButtonVisionInit()
{
// TODO: Add your control notification handler code here m_TempFlag = 1; CWnd* pStartButton = GetDlgItem(IDC_BUTTON_VISION_INIT);
if(pStartButton != NULL)
{
pStartButton->EnableWindow(FALSE);
} m_Digitizer.Halt();
m_Digitizer.Grab();
CApplicationTimer m_TimerMode;
m_TimerMode = m_Application.GetTimer();
m_TimerMode.SetSynchronizationMode(appTimerSynchronous);
m_TimerMode.Reset(); while(m_TempFlag == 1)
{
m_Digitizer.Grab();
} UpdateData(FALSE);
}void CTestDlg::OnButtonVisionGrab()
{
// TODO: Add your control notification handler code here m_TempFlag = 2; CWnd* pGrabButton = GetDlgItem(IDC_BUTTON_VISION_GRAB);
if(pGrabButton != NULL)
{
pGrabButton->EnableWindow(FALSE);
} m_Digitizer.GrabWait(digGrabEnd); UpdateData(FALSE);
}
解决方案 »
- 类型转换
- vb工程如何转为vc工程?
- 向导生成的单文档中(已经选择了文档视图支持),我要禁止在关闭程序时提示“保存”的功能该怎么办?
- 有几个问题想请教
- StaticRelease和Release的区别?如何使工程进行StaticRelsase?
- 做一个局域网 要求每台机子都是主机 在主机上网时其它机子可以上 该怎么做呀
- 紧急救助!如何得到桌面的可见区域(不包括下面的系统工具条区域)!!急,谢谢
- MFC 中如何使用 GetMenu()函数
- 写Direct3D程序的时候VC没有代码提示怎么办?
- "映射”为何物??
- 更新Micorosoft SDK后(2003) VC6.0编译出错
- 大家看下我的问题
方法就是设置一个BOOL型变量,然后直接跳出就可以了~~~
goto
:P
{
MSG msg;
while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE) && !m_bCancel)
{
if (!AfxGetThread()->PumpMessage())
return;
}
}
void CDlg::Start() // On Button Start
{
m_btnStart.EnableWindow( FALSE );
m_bCancel = false;
while( ! m_bCancel )
{
... // operator code
DoEvents();
}
m_btnStart.EnableWindow( TRUE );
}
void CDlg::BreakIt // On Button Cancel
{
m_bCancel = true;
}//
因为循环时消息是被阻塞的,所以要在循环中加入代接消息和转发消息的DoEvents
类似DoEvetns的使用在16位时代是最常用的,后来多线程出来大家都忘了.
DoEvents 的坏处是可能因用户误操作出现多次调用的问题,所以要在循环前后禁用/使能该BUTTON