lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] 'GetMenuString' failed with error 0x00000057


From: Vadim Zeitlin
Subject: Re: [lmi] 'GetMenuString' failed with error 0x00000057
Date: Sun, 31 May 2015 18:36:38 +0200

On Sat, 30 May 2015 17:18:22 +0000 Greg Chicares <address@hidden> wrote:

GC> >From time to time I've been seeing this message on the console:
GC> 
GC>   In file ../src/msw/mdi.cpp at line 1575: \
GC>   'GetMenuString' failed with error 0x00000057 (the parameter is 
incorrect.).
GC> 
GC> Unfortunately, I can't say under what conditions it occurs,
GC> or even whether it ever occurred before our latest wx update.
GC> Any thoughts?

 Summary: I am pretty sure this message is harmless but I also modified
wxWidgets to try to avoid giving it.


 More details: I've spent quite some time trying to reproduce it under
Windows 7 first and then under XP but unfortunately couldn't do it, so I'm
still not completely sure why were you seeing it. However it seems that the
existing code in mdi.cpp is wrong as GetMenuString() can't be trusted to
set the last error correctly because MSDN documentation[1] for it doesn't
mention that it does it and looking at its disassembly it indeed just
doesn't seem to call SetLastError(). So my best hypothesis is that
something was passing an invalid parameter to some other, completely
unrelated, Windows function and GetMenuString() failed for some reason and
just returned the last error set by that function. FWIW I can reproduce
the error message above easily by inserting a call to a random Windows
function with an invalid parameter before calling GetMenuString(), I just
can't do it without modifying the code.

 Moreover, the only way for GetMenuString() in the current code I know of
is to ask it to retrieve the label of a non-text menu item. And the only
non-text menu item in the MDI frame menu bar is the "MDI system" menu (the
one activated by "Alt+-", similarly to how the main window menu is
activated by "Alt+Space"). As this menu is part of the parent frame menu
if, and only if, the MDI child is maximized, I believe you must have
received this message when closing the last maximized MDI child.

 If this was indeed the case, the error of GetMenuString() is normal and
expected and handled correctly. The only remaining question is which
function had previously failed with "incorrect parameter" error. I can't
answer it, but I don't think this should really be a cause of concern, the
failures of the MSW API functions are generally dealt with correctly by
wxMSW, so unless there is some other reason to believe there is a bug here,
I wouldn't worry about it.

 OTOH if your window was not maximized, then there be another failure more
for GetMenuString() that I'm not aware of and this is potentially more
concerning as it could result in the "Window" menu not being inserted in
the right place, i.e. a user-visible problem. So please let me know if you
do _not_ maximize your child MDI windows.

 Finally, independently of the above, MSDN recommends using
GetMenuItemInfo() instead of GetMenuString() and the former does set the
last error correctly (according to both the documentation and my tests), so
I've changed the code to use it now and the problem shouldn't occur any
more once you update to a latest version of wxWidgets which will include
the commit[2] doing it.


 Please let me know if you have any more questions about this,
VZ

[1] https://msdn.microsoft.com/en-us/library/windows/desktop/ms647983.aspx
[2] 
https://github.com/wxWidgets/wxWidgets/commit/c485f44ba0338ee51c6e5b09f958e76a776de332

reply via email to

[Prev in Thread] Current Thread [Next in Thread]