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!
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.
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*/ )
UINT numMenuItems = m_MenuList.GetUpperBound();
<code>//BK: this forces windows toget the menu dimensions again after changing the menu text
int id2 = GetMenuItemID(id); //id in this caseis the position
if (id2 != 0 && id2 != -1)
ModifyMenu(id, MF_BYPOSITION, id2, ""); //no text needed as it's owner-drawn
//BK: endof changes</code>
BCMenu* pMenu = FindMenuOption(id,uiLoc);
if(NULL!=pMenu) returnflag = pMenu->
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 email@example.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)")
#define WINVER 0x0600
Windows Server 2003 SP1, Windows XP SP2
#define WINVER 0x0502
Windows Server 2003, Windows XP
#define WINVER 0x0501
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?
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
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:
In Demo "BCDialogMenu303".Although the LoadToolbar() function is called , but there wasn't any toolbar show on the dialog. why?
Do you know of an web article describing how somebody can imitate the painting of the highlighted menu items background?
1. highlighted menu items in normal applications running on Microsoft Vista (e.g NotePad ) have a nice blue background
2. highlighted menu items in Office 2007 (on Windows XP and Windows Vista, doesn't matter, the menu looks the same) have a nice "reflecting light" orange gradient.
By reading various articles, I've seen two approaches:
- Use themes API functions like DrawThemeBackground(). Is this possible for menus ?
- Use gradient API functions like GradientFill() with GRADIENT_FILL_RECT_V?
In this case, by applying this function twice with different limiting colors for the first half and the second half of the button would produce something aproximating the "reflecting light" gradient we are seeing in Office 2007)
I would like to know how the Microsoft programmers implemented these menus.
Let me say thanks first for this wonderful help .
I am using this code to my SDI application. I am using 3.03 version of bcmenu.
I am facing the problem appling the true color bitmap strip at menubar. My strip background color is RGB(192,192,192) and Even i ve set the function SetBitmapbackground(RGB(192,192,192)). But still it is not showing the transparent background colors of menubar
have created an owner drawn menu item and done required drawing in the
DrawItem function. The drawing code works as I expected bu the problems is a
box appearing outside the menu. how can I remove it? please see the following
pictured to see the output.
I have some problem in VC++ 2005.
When i use this command, the return value is true: UNIT rt = menu->GetMenuItemCount();
But when i use these functions(here is some examples): GetMenuText(pos, tmp, MF_BYPOSITION); //error: Unhandled exception at 0x004788f3 in App.exe: 0xC0000005: Access violation reading location 0xcdcdcdcd. At "string=m_MenuList[id]->GetString();" in your code
GetMenuItemID(pos); // value of this function always is "-1"
GetMenuString(pos, tmp, MF_BYPOSITION);//this function always L""
Why? I am wrong in use params or the library can not work in VC++ 2005?
I've discover that if I remove the 'ON_COMMAND( ..., ... )' for an menu item, this one will appear disabled, and then do not send any message when clicked etc..
Is there a way to not getting in charge of adding such command in message map ? I explain myself, I buid dynamicly my menu and so i can't add the ON_COMMAND. I resolve this by using ON_COMMAND_EX_RANGE but I dislike that...
Its a nice class to make our menus XP Style.I am facing an issue that hotkeys are not working when i use BCMenu as POP Up menu although they are working normally when when i dont use them as context menu..here is sample code
I got the solution after one month when i posted this thread. Actually in the instruction it was clearly mention to override 3 functions in mainframe.
My problem was that i was using menu in other classes despite mainframe(altough they were part of my project) and i was not overriding these function in my classes. So the solution was to override these function in that particulare class where u want to work with BCMenu.
That mean if i used these function in one of my class CSiteTree then need to override these functions again in that particular class.
Now, i am programing my program with BCMenu class.
this program should be made in each language type. and then i have used SetMenuText function for changing menu string.
but i couldn't change upper menu string.
> some code
m_menu.SetMenuText(0,"FILE(&F)"); <-- it didn't change
m_menu.SetMenuText(ID_PHONE_CONNECT,"CONNECT", MF_BYCOMMAND); <-- it changed.
How can change upper menu string ?
please help me.. ..