Avoid bogus debug errors from wxWindow::SetId() in wxMSW
::SetWindowLong() can return 0 even if no error occurred but the previous value of the ID just was 0, so we need to examine the last error to know whether there really was an error -- and also to reset it to 0 before calling the function as it wouldn't reset it if it succeeds, it only sets it if it fails.
This commit is contained in:
@@ -512,8 +512,14 @@ void wxWindowMSW::SetId(wxWindowID winid)
|
||||
// changing its ID because Windows still uses the old one.
|
||||
if ( GetHwnd() )
|
||||
{
|
||||
::SetLastError(0);
|
||||
|
||||
if ( !::SetWindowLong(GetHwnd(), GWL_ID, winid) )
|
||||
wxLogLastError(wxT("SetWindowLong(GWL_ID)"));
|
||||
{
|
||||
const DWORD err = ::GetLastError();
|
||||
if ( err )
|
||||
wxLogApiError(wxT("SetWindowLong(GWL_ID)"), err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user