面对现实,超越自己
逆水行舟,不进则退
posts - 269,comments - 32,trackbacks - 0
    创建一个新类用来隐藏主对话框闪烁问题

    注释下段代码:
 1   CPrinterMonitorExDlg dlg;
 2   m_pMainWnd = &dlg;
 3   INT_PTR nResponse = dlg.DoModal();
 4   if (nResponse == IDOK)
 5   {
 6    // TODO: Place code here to handle when the dialog is
 7    //  dismissed with OK
 8   }
 9   else if (nResponse == IDCANCEL)
10   {
11    // TODO: Place code here to handle when the dialog is
12    //  dismissed with Cancel
13   }

    替换成:
1  CMainDialog dlg;  //新类对象
2  m_pMainWnd = &dlg;
3  dlg.Create(CMainDialog::IDD); 
4  dlg.ShowWindow(SW_HIDE);      
5  dlg.RunModalLoop();

    用对话框隐藏等待程序,在xp系统下会出现一个问题,就是:如果程序是system权限启动,第一次注销机器正常,但第二次注销时就会出现注销失败的情况。隐藏的对话框在注销时无法被关闭。
    可以用事件等待来代替上面的程序。
1 CEvent    m_evtWait;
2 if (WAIT_FAILED == ::WaitForSingleObject(m_evtWait, INFINITE))
3     {
4         DWORD wError = GetLastError();
5         LOG("WaitForSingleObject函数出现错误,错误代码:%d,程序退出", wError);
6         return FALSE;
7     }
posted on 2012-04-10 16:02 王海光 阅读(582) 评论(0)  编辑 收藏 引用 所属分类: MFC

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