if I compile the example with old compiler 6 everything is fine.
If I compile it with dev studio 2010, the program runs on Windows 7 also fine, but the same .exe, running on a Windows XP system doesn't work. The menus are too wide or too narrow.
Does anybody know a solution?
the reason is: Win7 knows how to handle dufferent versions of struct "nm" in the call SystemParametersInfo(SPI_GETNONCLIENTMETRICS, nm.cbSize, &nm, 0). But XP is not able to handle the new size used in the Windows 7 SDK . I have decided to compile my app for Windows XP (setting WINVER, _WIN32_WINNT, etc). The result works fine for Win 7 and XP. If you need special enhancements for Win 7 and must compile with Win 7 SDK and WINVER, _WIN32_WINNT set to Window 7 you should change the code in bcmenu to use the old struct if running under XP. You would need to define the old structure from the XP SDK in your code and use it in SystemParametersInfo() if you detect XP as running OS (you have to check this with GetVersionEx()). Else use the standard structure for Win 7. That should work...
Thanks for this, tried it but no joy - I did notice however that all my menus have the correct width on both Win7 and XP as long as there are no sub-menus in there. Could this be something to do with the problem ?
Hi, this is my change that worked. Please try this. And make sure your solution builds against the Win 7 SDK. It worked for me. If this doesn't resolve your problem, I have no glue what else could be the solution...
Use this in your precompiled header (stdafx.h) or in targetver.h
#if (WINVER < 0x0600)
nm.cbSize = sizeof(NONCLIENTMETRICS);
If the iPaddedBorderWidth member of the NONCLIENTMETRICS structure is present, this structure is 4 bytes larger than for an application that is compiled with _WIN32_WINNT less than or equal to 0x0502. For more information about conditional compilation, see Using the Windows Headers.
Windows Server 2003 and Windows XP/2000: If an application that is compiled for Windows Server 2008 or Windows Vista must also run on Windows Server 2003 or Windows XP/2000, use the GetVersionEx function to check the operating system version at run time and, if the application is running on Windows Server 2003 or Windows XP/2000, subtract the size of the iPaddedBorderWidth member from the cbSize member of the NONCLIENTMETRICS structure before calling the SystemParametersInfo function.
first of all thanks for your contribution.
But I have a problem I can't handle.
In Debug-mode the menu works fine, but delivers X messages in the output box like
"Warning: unknown WM_MEASUREITEM for menu item 0xYYYY", with X being the number of menu items.
If I compile in Release-mode, the menu is just a vertical stripe of about 15px width, so the width could not be estimated correctly.
What I did:
I overrode OnMeasureItem in my class and did an explicit MeasureItem, which doesn't fail (while debugging, I see values, that should be correct), but the menu is still just a vertical stripe.
So I debugged a little more and got to the OnMeasureItem of CWnd, where the warning is generated (wincore.cpp#1297).
Noteworthy is that the method is called twice for each item-id. First, the item is not recognized as menu in #1316 (_AfxFindPopupMenuFromID delivers NULL). Then, the second time, it is recognized, and gets through the MeasureItem call (#1318).
I don't know what to do now...
Any help would be appreciated
Addendum: the menu is implemented as a context menu in an ActiveX control (CListCtrl subclassed), embedded in a dialog based window.
modified on Monday, December 13, 2010 5:29 AM
Last Visit: 31-Dec-99 19:00 Last Update: 25-Dec-14 10:48