c++初学者

专注技术开发

用WaitForSingleObject等待事件处理

 1void ClearMessage(HWND hWnd,BOOL bExtMsg)
 2{
 3    MSG GetMsg;
 4    while(PeekMessage(&GetMsg,hWnd,0,0,PM_REMOVE))
 5    {        
 6        if(GetMsg.message == WM_TIMER) continue;
 7        TranslateMessage(&GetMsg);
 8        DispatchMessage(&GetMsg);
 9    }
            
10    if(hWnd != NULL && bExtMsg)
11    {    
12        while(PeekMessage(&GetMsg,NULL,WM_WINDOWPOSCHANGING,WM_WINDOWPOSCHANGED,PM_REMOVE))
13        {        
14            TranslateMessage(&GetMsg);
15            DispatchMessage(&GetMsg);
16        }
                                
17        while(PeekMessage(&GetMsg,NULL,0,0,PM_QS_PAINT))
18        {        
19            TranslateMessage(&GetMsg);
20            DispatchMessage(&GetMsg);
21        }

22    }

23}

24
25void CExportRegeditToXml::OnBnClickedCancel()
26{
27
28
29    if ( ( NULL != m_TransRegedit )  && ( !pThreadData->m_brepalce) ) 
30    {
31        if(MessageBox(_T("目前正在导出注册表,是否取消!"),_T("警告"),MB_YESNO)!=IDYES)
32            return;
33        pThreadData->m_brepalce = TRUE;
34
35        while (m_TransRegedit && WaitForSingleObject(m_TransRegedit->m_hThread,40)!=WAIT_OBJECT_0) 
36        {
37            ClearMessage(NULL, TRUE);
38        }

39        m_TransRegedit = NULL;
40    }

41
42    OnCancel();
43}

posted on 2009-01-12 10:17 大海 阅读(2440) 评论(0)  编辑 收藏 引用 所属分类: C++


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   博问   Chat2DB   管理