Cool Popup Menu
Posted
by Dipti Alone
on January 22nd, 2000
Features
Here are just some of the cool features of this menu class.- Vertical bitmap can be shown to the left side of menu items of popup menu, just like Windows start menu.
- Child controls can be placed on the menu window.
Usage Instructions:
In order to use CBmpMenu class, user needs to use the standard functions implemented by CMenu for showing a popup menu. User creates an instance of CBmpMenu instead of CMenu and then uses LoadMenu or CreatePopupMenu followed by TrackPopupMenu.User needs to provide handle of vertical bitmap in the constructor.
CBmpMenu(int nBitmapW=0, BOOL bShowBmp4SubMenu=FALSE, HBITMAP hBitmap=0, BOOL StretchBmp=TRUE);Explanation of arguments
- nBitmapW - Width of the blank space to be shown to the left side of menu items in a popup menu.
- bShowBmp4SubMenu - If TRUE, then blank space is shown for all submenus of a popup menu. If FALSE, then blank space is shown only for main menu.
- hBitmap - If a valid handle is passed then this bitmap is drawn on the blank space
- bStretchBmp - If TRUE, then bitmap is drawn using StretchBlt. If False, then the blank space is filled with pattern brush created from the bitmap.
If user wants to place any child controls on the menu window, he needs to do the processing in WM_ENTERMENULOOP handler.
The parameters for WM_ENTERMENULOOP has been changed by CbmpMenu class.
WM_ENTERMENULOOP: // handle of menu which is entering the modal loop wParam = (HMENU)hMenu; //handle of menu window(menu window is of type CBmpMenu) lParam = (HEND)hWindow;
Using hWindow as parent window, any child controls can be created and placed on the menu window.
Downloads
Download demo project - 40 KbDownload source - 14 Kb

Comments
Dynamic creation of menus
Posted by Legacy on 01/14/2004 12:00amOriginally posted by: Priyanka
Hi,
ReplyI need the method to create menus dynamically.
thankyou,
bye
priyanka
ex(Popup)Menu
Posted by Legacy on 06/12/2002 12:00amOriginally posted by: Mike Philips
Reply32x32 pixels icons?
Posted by Legacy on 03/31/2002 12:00amOriginally posted by: MAV
How to use this class for displaying 32x32 icons ?
ReplyThanks
Problems under XP
Posted by Legacy on 02/11/2002 12:00amOriginally posted by: Jase Jennings
Under XP, separators are drawn in a gray text, although the background for the menu is white - so this menu looks plain old ugly on XP. If i find the solution, i'll post it here. In the meantime, i could use a little help :)
ReplyPopup Menu is not Displaying
Posted by Legacy on 01/03/2002 12:00amOriginally posted by: Mahesh
when i tried using the pop up menu,the menu items are not displaying properly. I created a menu in the resouce editor and used the LoadMenu method..
so can anyone help me to solve the problem.
ReplyThanks & Regards
Mahesh
bug report(new)
Posted by Legacy on 12/03/2001 12:00amOriginally posted by: xiaolei zhuansun
ReplyHow can I use this class with Pointers?
Posted by Legacy on 11/06/2000 12:00amOriginally posted by: Stephan Schumann
Because of the multiple inheritance there are to defined new operators (Both in CObject) is there a solution for this problem
ReplyI fixed a bug to be happen from clicking the area of outside.
Posted by Legacy on 08/11/2000 12:00amOriginally posted by: Cho, SungHee
I faced two major bugs using CBMPMenu.
One was a bug in case of clicking seperator,
Other was a bug in case of clicking the area of outside.
I want to help men undergo bug2 with my poor codes.
At First, Declare a boolean variable in CBMPMenu.h
Add "bool m_bEndModalLoop;" in Class CBMPMenu.
and then,
Add 2 member functions in CBMPMenu.h & CBMPMenu.cpp
Add "int RunModalLoop(DWORD dwFlags=0);" in Class CBMPMenu
and add "void EndModalLoop(int);" in Class CBMPMenu
Real source code follows as below.
int CGradientMenu::RunModalLoop(DWORD dwFlags) {
MSG msg;
m_bEndModalLoop = false;
while (m_bEndModalLoop==false) {
while ( PeekMessage (&msg, 0, 0, 0, PM_REMOVE) ) {
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
}
return 0;
}
void CGradientMenu::EndModalLoop(int nResult) {
m_bEndModalLoop = true;
::ShowWindow(m_hWnd, SW_HIDE);
}
That's all. be helpful to others.
and Thanks to Coral.
ReplySupport default menu item
Posted by Legacy on 04/22/2000 12:00amOriginally posted by: Lior
ReplyBug
Posted by Legacy on 03/20/2000 12:00amOriginally posted by: SeungKoo
After menu is shown, I clicked the area not in dialgo box.
But the menu was not destroyed and debug error dialog appeared.
How can I fix this problem?
ReplyLoading, Please Wait ...