DoModal Returns -1 Getlasterror 说句柄无效
DoModal Returns -1 Getlasterror says Invalid handle
我正在使用 Win32 应用程序,在此 DoModal 函数中 returns -1 和 GetlastError() returns 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
}
为什么我没有收到对话框?
DoModal() returns -1 当您的资源未正确映射到对话框时。如果你进入 DoModal() 你会发现 statement
// return -1 in case of failure to load the dialog template resource
我建议您在 DoModal().
之前调用 AfxSetResourceHandle(); 函数
我正在使用 Win32 应用程序,在此 DoModal 函数中 returns -1 和 GetlastError() returns 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
}
为什么我没有收到对话框?
DoModal() returns -1 当您的资源未正确映射到对话框时。如果你进入 DoModal() 你会发现 statement
// return -1 in case of failure to load the dialog template resource
我建议您在 DoModal().
之前调用 AfxSetResourceHandle(); 函数