|
|
Comments and Discussions
|
|
 |

|
Hi,
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?
[img]http://666kb.com/i/bvzhc6qs3qeuim0j5.gif[/img]
|
|
|
|

|
Hi Dieter,
I've got the very same problem. In Debug mode I also get an Assertion from BCMenu, in function InsertSpaces(), when trying to get the NONECLIENTMETRICS.
VERIFY(SystemParametersInfo(SPI_GETNONCLIENTMETRICS, nm.cbSize, &nm, 0));
SystemParametersInfo() returns false. But I have changed the code to retieve the error by GetLastError(), which returns 0!!
I can only guess of some memory/pointer management problem in the code which is damaging something severe...
Did you find a solution, yet???
Thanks for any hint!
- Harald
|
|
|
|

|
Same problem here, looks fine in Vista and 7 after building with 2010 but all the menu contract down to a very narrow width is the same 2010 built exe is launched on XP. Any ideas at all yet ?
|
|
|
|

|
Hi,
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...
Kind Regards, H@r@ld
|
|
|
|

|
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
#ifndef _WIN64 #define WINVER 0x0502 #define _WIN32_WINNT 0x0502 // Keep XP-Kompatibility! #endif #include <SDKDDKVer.h> // Target OS infos
Regards, H@r@ld
|
|
|
|

|
at void BCMenu::InsertSpaces(void)
insert lines:
OSVERSIONINFO osvi;
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
::GetVersionEx(&osvi);
bool bIsWindowsVer6Later = (osvi.dwMajorVersion > 5);
ZeroMemory ((PVOID) &m_lf,sizeof (LOGFONT));
NONCLIENTMETRICS nm;
#if(WINVER >= 0x0600) //*** Note ***
if (bIsWindowsVer6Later)
{
nm.cbSize = sizeof (NONCLIENTMETRICS) - sizeof(nm.iPaddedBorderWidth);
}
else
#endif /* WINVER >= 0x0600 */
{
nm.cbSize = sizeof (NONCLIENTMETRICS);//original line
}
|
|
|
|

|
if you include lines in stdafx.h
#ifndef _WIN64
#define WINVER 0x0501
#define _WIN32_WINNT 0x0501 // Keep XP-Kompatibility!
#define _WIN32_WINDOWS 0x0501
#endif
#include // Target OS infos
then be careful check the WINVER value, since SDKDDKVer.h can change you WINVER to SDK version value. I.E. WINVER maybe bigger than 0x0501
these lines came from Owner Drawn Menu with Icons, Titles and Shading[^]
#if (WINVER < 0x0600)
nm.cbSize = sizeof(NONCLIENTMETRICS);
#else
/*
http://msdn.microsoft.com/en-us/library/ms724506(VS.85).aspx
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.
*/
OSVERSIONINFO OSVersionInfo;
OSVersionInfo.dwOSVersionInfoSize = sizeof(OSVersionInfo);
GetVersionEx(&OSVersionInfo);
if (OSVersionInfo.dwMajorVersion < 6)
nm.cbSize = sizeof(NONCLIENTMETRICS) - sizeof(int); // nm.iPaddedBorderWidth int
else
nm.cbSize = sizeof(NONCLIENTMETRICS);
#endif
modified 17 Jul '12 - 20:23.
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
This class implements an owner drawn menu class that mimics the menu style used in XP, Office and Visual C++
| Type | Article |
| Licence | CPOL |
| First Posted | 18 Nov 1999 |
| Views | 758,134 |
| Downloads | 13,605 |
| Bookmarked | 263 times |
|
|