 |
|
 |
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
|
|
|
|
 |
|
 |
BCMenu cMenu;
BCMenu cPopUp;
int i=1000;
cMenu.CreatePopupMenu();
cMenu.AppendMenu(MF_STRING, i++, "Test 1");
cMenu.AppendMenu(MF_STRING|MF_CHECKED, i++, "Test 2");
cPopUp.CreatePopupMenu();
cMenu.AppendMenu(MF_POPUP,(UINT)cPopUp.GetSafeHmenu(),"PopUp");
cPopUp.AppendMenu(MF_STRING,i++,"Test 4");
cPopUp.AppendMenu(MF_STRING,i++,"Test 5");
//cPopUp.Detach(); if not comment crash in other function
CRect rect;
GetDlgItem(IDC_BUTTON1)->GetClientRect(&rect);
ClientToScreen(&rect);
cMenu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON ,
rect.left,rect.bottom,this);
cMenu.DestroyMenu();
/*
if "cPopUp.Detach();" is comment crash in "BOOL BCMenu::DestroyMenu()"
if "cPopUp.Detach();" is not comment crash in "void BCMenu::SynchronizeMenu(void)"
*/
|
|
|
|
 |
|
 |
Hi there,
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
Regards..
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
|
|
|
|
 |
|
 |
Problem is more or less solved..
I still get the warnings that confuse me, but the visualisation error is gone.
What went wrong: mixing release-mode compilation of my application with a debug-mode compilation of the OCX-control doesn't do any good
After registering the release-mode comp. everything works fine..
|
|
|
|
 |
|
 |
Hmm... Well, the problem is still existant, but vice versa:
I compiled the ocx in release mode and gave it for implementation to a colleague. He - of course - compiles his program in debug mode. But if he tries to open the context menu, he gets a debug assertion..
Any hint would be appreciated!
|
|
|
|
 |
|
 |
Can't work in VS 2008, crashed when m_menu.LoadMenu(IDR_MYTYPE);
|
|
|
|
 |
|
 |
Hi
this is a very nice class. My icons appear very nicely. However, I want to use icon only, and remove the text, so I use:
menuView.SetMenuText(MY_MENU_COMMAND,"",MF_BYCOMMAND);
There are no more text, but there is a little gap on the right of the icon. How can I get ride of it?
Thanks!
Mat
|
|
|
|
 |
|
 |
I find the menu crops if I am using Russian text (in English windows).
Andrew
|
|
|
|
 |
|
 |
Hi, when i tried this owner draw menu, why did the DrawItem function are not being triggered??
Because when i tried other owner draw menu, even if i did not click the menu item[on the menu bar] it will trigger the DrawItem.
I'm trying to change the font's color of the menu item text[on the menu bar]
I already succeeded to change the font color of the submenu items.. which it will trigger DrawItem function when i click it.
is that a bug or ??
Regards,
KH
good
|
|
|
|
 |
|
 |
I used the BCMenu in my application, and it worked great. That was until I changed the menu text. My application can change languages on the fly.
I start my application in one language and set all the menu text. OnMeasureItem gets called to get the size of each menu as I use it. It will never be called again. I then change languages and change all the menu text. The problem is the menu sizes don't fit the new text.
I figured a way to fool windows into thinking that the menu text changed. It requires three extra lines in BCMenu.cpp:SetMenuText function. I'm using BCMenu 3.036
Hopefully this will help if anyone else is having trouble with this problem.
BOOL BCMenu::SetMenuText(UINT id, CString string, UINT nFlags/*= MF_BYPOSITION*/ )
{
BOOL returnflag=FALSE;
if(MF_BYPOSITION&nFlags)
{
UINT numMenuItems = m_MenuList.GetUpperBound();
if(id<=numMenuItems){
#ifdef UNICODE
m_MenuList[id]->SetWideString((LPCTSTR)string);
#else
m_MenuList[id]->SetAnsiString(string);
#endif
returnflag=TRUE;
}
<code>//BK: this forces windows to get the menu dimensions again after changing the menu text
int id2 = GetMenuItemID(id); //id in this case is the position
if (id2 != 0 && id2 != -1)
ModifyMenu(id, MF_BYPOSITION, id2, ""); //no text needed as it //BK: end of changes</code>
}
else{
int uiLoc;
BCMenu* pMenu = FindMenuOption(id,uiLoc);
if(NULL!=pMenu) returnflag = pMenu->SetMenuText(uiLoc,string);
}
return(returnflag);
}
|
|
|
|
 |
|
 |
Your code makes my icon to disapear...
Mat
|
|
|
|
 |
|
 |
Hello
I decided I wanted to try try and use the native CMenu objects again for my MDI IDR_MAINFRAME in my project.
So I remmed out the two lines of code in my InitInstance class which indicated would revert it back to normal.
However, when I do this, I find the last but one menu refuses to display. I get no crashes. If I add further menus, then it will display. Only the last but one refuses to show.
If I put the two lines back into InitInstance, the menu fully operations.
I have trie dremoving BCMenu completely from my project and I still get this behavior.
Ideas?
|
|
|
|
 |
|
 |
Hhhmm. If I also rem this out:
//pMainFrame->OnUpdateFrameMenu(pMainFrame->m_hMenuDefault);
I get a complete old style menu again - fully operational.
|
|
|
|
 |
|
 |
Hi,Brent Corkum
Thank you for your work.I can not add a icon int the menuitem,can you help me?of course i could convert a bitmap to icon,but you know ,it is not easy ,I was a beginner of vc 6.0,your answer is important to me,could you give me a complete reference of BCMenu if you have . I think I could learn more easy than before .Thank You!!Email zhangleibaobaoz@163.com
|
|
|
|
 |
|
 |
I compiled the demo program in vs2008 and there is no error.
However, when I execute the program, there is one problem occurred.
The program cannot be executed on the following line in void BCMenu::InsertSpaces().
VERIFY (SystemParametersInfo (SPI_GETNONCLIENTMETRICS,nm.cbSize,&nm,0));
|
|
|
|
 |
|
 |
I answer by myself.
The problem is the same as NewMenu.
I should assign the correct WINVER.
Please see below.
---------------------------------
Probably you did not set the right WINVER versionsnumber and the size of NONCLIENTMETRICS will be wrong for XP (Vista will be ok)
=> If the function fails, the return value is zero. To get extended error information, call GetLastError.
Check this output!
#pragma message(" WINVER not defined. Defaulting to 0x0600 (Windows Vista)")
Windows Vista:
#define WINVER 0x0600
Windows Server 2003 SP1, Windows XP SP2
#define WINVER 0x0502
Windows Server 2003, Windows XP
#define WINVER 0x0501
Windows 2000
#define WINVER 0x0500
|
|
|
|
 |
|
|
 |
|
 |
Yes it does compile with VC++ 2005. I think you may have problems with VC++ 2008 though.
|
|
|
|
 |
|
 |
Thank you for your reply. I do find that I get depracation warnings related to the use of various buffer functions. If I don't want to switch the depracation warnings off it means I have to resolve these issues.
Is it not possible for a "out of the box" VS2005 build to be made available?
Thanks.
|
|
|
|
 |
|
 |
I am working with Greek Unicode characters on Vista. I discovered that on Vista, when the "Current language for the non-unicode programs" is set to English, the Unicode menus with Greek characters appear truncated i.e. the words have been cut at the end, with whole words missing some times.
BCMenu predates the release of MS Vista, and digging into the code I discovered that it has a function with the name
Win32Type IsShellType()
which determines the OS type that is used. As it predates Vista, when is run on Vista it defaults to WINNT3! And this causes all the problems. I have changed the function so when run under MS Vista (or any future versions MS Windows) it returns WINXP as the OS type. This has solved the problem of the truncated menu width.
Now all the tests when run on a 32bit Vista installation. The change most probably will work also for Vist 64-bit.
I include the changed code of the function for your reference:
Win32Type IsShellType()
{
Win32Type ShellType;
DWORD winVer;
OSVERSIONINFO *osvi;
winVer=GetVersion();
if(winVer<0x80000000){/*NT */
osvi= (OSVERSIONINFO *)malloc(sizeof(OSVERSIONINFO));
if (osvi!=NULL){
memset(osvi,0,sizeof(OSVERSIONINFO));
osvi->dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
GetVersionEx(osvi);
if(osvi->dwMajorVersion==3L)ShellType=WinNT3;
else if(osvi->dwMajorVersion==4L)ShellType=WinNT4;
else if(osvi->dwMajorVersion==5L&&osvi->dwMinorVersion==0L)ShellType=Win2000;
else if(osvi->dwMajorVersion==5L&&osvi->dwMinorVersion==1L)ShellType=WinXP;
else if(osvi->dwMajorVersion==6L&&osvi->dwMinorVersion==0L)ShellType=WinXP; //- Windows Vista
else ShellType=WinXP; //- For future versions of Windows default to WinXP
free(osvi);
}
}
else if (LOBYTE(LOWORD(winVer))<4)
ShellType=Win32s;
else{
ShellType=Win95;
osvi= (OSVERSIONINFO *)malloc(sizeof(OSVERSIONINFO));
if (osvi!=NULL){
memset(osvi,0,sizeof(OSVERSIONINFO));
osvi->dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
GetVersionEx(osvi);
if(osvi->dwMajorVersion==4L&&osvi->dwMinorVersion==10L)ShellType=Win98;
else if(osvi->dwMajorVersion==4L&&osvi->dwMinorVersion==90L)ShellType=WinME;
free(osvi);
}
}
return ShellType;
}
|
|
|
|
 |