Avoid spurious error messages for WM_MDISETMENU under Windows XP.

WM_MDISETMENU handler doesn't seem to reset the last error under Windows XP
and this could result in spurious debug error messages when setting the
initial menu in which case NULL is returned to indicate that there was no
previous menu, but this doesn't indicate that an error occurred.

Explicitly reset the last error to ERROR_SUCCESS ourselves before using
WM_MDISETMENU to ensure that the last error can only be set after its return
if it was really done by the code handling it, i.e. if an error really
happened.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78056 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-10-24 13:45:41 +00:00
parent 4a34c928e5
commit 9650c5b55b

View File

@@ -1442,13 +1442,18 @@ void MDISetMenu(wxWindow *win, HMENU hmenuFrame, HMENU hmenuWindow)
{
if ( hmenuFrame || hmenuWindow )
{
// Under XP, the last error seems to be not reset by this function, so
// ensure we don't report spurious errors below when setting the menu
// initially.
::SetLastError(ERROR_SUCCESS);
if ( !::SendMessage(GetWinHwnd(win),
WM_MDISETMENU,
(WPARAM)hmenuFrame,
(LPARAM)hmenuWindow) )
{
DWORD err = ::GetLastError();
if ( err )
const DWORD err = ::GetLastError();
if ( err != ERROR_SUCCESS )
{
wxLogApiError(wxT("SendMessage(WM_MDISETMENU)"), err);
}