【发布时间】:2015-05-18 04:38:17
【问题描述】:
我正在使用 Win32 应用程序,在此 DoModal 函数中返回 -1 并且 GetlastError() 返回 6(无效句柄)。我尝试删除 GDI 句柄以修复 GDI 排气,结果失败。
附加信息: 我正在使用 Visual Studio 2012,此应用程序适用于 Compact 2013。
if(!bDeviceOpened)
{
bDeviceOpened=OpenDriver();
if(bDeviceOpened == 0)
{
AfxMessageBox(_T("Please make sure the driver is up and runnning"));
return FALSE;
}
}
//Reading the Driver version
DWORD nBytesReturned = 0;
if(!GetOID(OID_RPS_DRIVER_STATS, &stats, sizeof(stats), &nBytesReturned) )
{
AfxMessageBox(_T("Failed to query the stats"));
}
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
为什么我没有收到对话框?
【问题讨论】:
-
你能调用“CommDlgExtendedError()”吗?
-
现在 CommDlgExtendedError() 和 GetLastError() 返回 0,仍然 DoModal 为 -1
-
不要不使用 GetLastError(),当 DoModal() 返回 -1 时,它不会告诉你任何可靠的信息。该返回码只是意味着无法创建对话框,请使用调试器找出原因。单步执行代码。
标签: c++ visual-studio-2012 mfc dialog windows-ce