|
Great! But I want one more thing - the blue border on
the menu bar (&File, &Edit, etc...) I know there is
the WTL version uploaded but it can't be used WTL
codes on my MFC app.
|
|
|
|
|
WTL doesn't use true MenuBar. It is replaced by an ownerdrawn toolbar. You must do the same thing with MFC to have the same effect. Other articles show you how to do (like the BCGControlBar library).
My goal isn't to make my sample as big as this library so I don't want to extend it.
|
|
|
|
|
er,Does this function take too many works ?
Because every XP menu style has this - when your mouse point a menu ,that
occur the blue border.
I like your Class as the usage is very easy ,not need to modify a lots of
code .
tomPeakz
|
|
|
|
|
The last version implements it !
|
|
|
|
|
I don't know why Boundschecker says
'Assigning pointer out of range' in MenuXP.
That is..
SetWinXPStyle()
{
////////////////
//////////////
CMenuXP::m_sCaptions.SetAt (mii.wID, sBuff);
//////////////
///////////////
}
|
|
|
|
|
i have try the thing for SDI application. it dont have any error when compiling but it displays 6 errors for the linking obj file. may i know how to solve the problem?
|
|
|
|
|
I creat a Dialog based application,but when I use the MenuXP,it cant works perfect!!!!!
can anyppl tell me how to do???!!!
thx alot!
my MSN:KingStudio@msn.com
thx very very much!!!!
|
|
|
|
|
Just follow the instructions:
In your MyDlg.cpp file
BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
//{{AFX_MSG_MAP(CMyDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_MENUXP_MESSAGES()
END_MESSAGE_MAP()
IMPLEMENT_MENUXP(CMyDlg, CDialog, true);
And in the MyDlg.h
#include "Tools\MenuXP.h"
And after the message map declaration
DECLARE_MESSAGE_MAP()
DECLARE_MENUXP()
Works Great!!
Neil
|
|
|
|
|
啊哈!很好啊!!谢谢你啊!!
aha!very good!thank you very much!!
我们交个朋友吧,我来自中国!
Can i add you to my friend list,I come from china!
我刚开始学习C++,水平还不是很好。
I learned C++ language just 1 month!
我的联系方法:
how to touch me:
mainbox:KingStudio@msn.com
|
|
|
|
|
no no no!!!!!
HAVE NO ICON!!!!!!!!!!!!!!!!!!LEFT TO MENUITEM!!!!!!
|
|
|
|
|
Yeah! I noticed that. Not quite sure, as I couldn't immediately see anything in the original source code to associate icons.
Sure it must be fairly simple. May look at it in the next couple of days & post when I've worked it out.
There is other stuff about bitmaps & menus in the main article list if you are in a hurry. Interesting looking one by Brent Corkum.
Regards,
Neil
|
|
|
|
|
I creat a Dialog based application,but when I use the MenuXP,it cant works perfect!!!!!
can anyppl tell me how to do???!!!
thx alot!
my MSN:KingStudio@msn.com
thx very very much!!!!
|
|
|
|
|
I creat a Dialog based application,but when I use the MenuXP,it cant works perfect!!!!!
can anyppl tell me how to do???!!!
thx alot!
my MSN:KingStudio@msn.com
thx very very much!!!!
|
|
|
|
|
and the color of the menu?
|
|
|
|
|
Great Project.
I implemented your menu in one of my program an it works without Icons. I would like to have some Icons.
My project has no toolbar showed and I don't know how to resolve it.
Can someone help me.
thx for helping
Pascal
|
|
|
|
|
Creating toolbar and to disable it.
Steps:
1. Insert new resource toolbar
2. Add any icons to toolbar
3. In CMainFrame.cpp:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
/*... something ...*/
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD |
WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
// IMPORTANT!!! After creating toolbar to disable it
ShowControlBar (&m_wndToolBar, FALSE, TRUE);
/*... something ...*/
}
May be exist another ways...
Simvolokov Michael
|
|
|
|
|
Great program!I want to use this in dialog.
but I can't add icon in it conventially.
can you give me some adise ,Sir?
|
|
|
|
|
Great job! For anyone elses knowledge, if you are using the statusbar component which adds the current system date and time to the statusbar, you might have some code conflicts.
|
|
|
|
|
Overall I would say this is excellent, and is easy to integrate
Four suggestions for improvements (or questions):
1. What about the system menu?
2. What about handling if the toolbar is (slightly) not standard size? Maybe there could be a function to pass a menu-only toolbar bitmap with normal sized buttons to the menu code, even if the app's actual toolbar is not the standard button size.
3. Radio marks on menus show as checks, not dots
4. Is there a way to use the same underlying code to use on popup menus? (you know ones we create with TrackPopupMenu when a user right clicks on an item or something)
|
|
|
|
|
For the 4th point, it should work in the demo !?!
|
|
|
|
|
Thanks
I just stuck a copy of your code (without even looking at the sample) in 2 programs I had handy to see if it worked. These both have multiple popups and it didn't work on any of these popups. They just came up as normal popups.
I took a look at your sample, and yes it works on that.
There are 2 differences I think in the 2 programs I tried it on:
1. Build their popup menus on the fly, using AppendMenu etc
2. TPM_RETURNCMD in the popup code.
I haven't yet tested this out at all, and may not for some time, but my guess is TPM_RETURNCMD is the problem.
To be fair this is not really a weakness of your code, but it does mean it's not quite a drop in replacement.
|
|
|
|
|
Look at the 4th parameter of the TrackPopupMenu call:
pPopup->TrackPopupMenu (TPM_RIGHTBUTTON, pt.x, pt.y, GetParentFrame()); In my demo, this is the frame.
The window passed as 4th parameter must handle the MENUXP macros: ON_MENUXP_MESSAGES, DECLARE_MENUXP and IMPLEMENT_MENUXP.
Add them in your programs and it should work !
Bye
|
|
|
|
|
I did already and it didn't make a difference.
The problem seems to be the TrackPopupMenu call had TPM_NONOTIFY flag set
Removing this flag fixes the problem with display (tried on only 1 menu so far). However this then causes a knock on problem as the menu items are now all disabled, presumably because there is no code to handle the pCmdUI->Enable(...) etc stuff for these items.
So I know how to fix it in that program, but unless there is a trick I'm not aware of, it would be a fairly major job as it requires turning the code around: instead of building a popup with the right items enabled/disabled, I think that I would need to move move the enable/disable logic into separate handlers, and decide about each menu item, after the menu has been built rather than before.
|
|
|
|
|
a little impovement for MDI with multiple documents:
Change CMenuXP class in:
class CMenuXP : public CMenu
{
// Attributes
public:
static CMap <int, int, CString, CString&> m_sCaptions;
static CMap <int, int, CImgDesc, CImgDesc&> m_Images;
// Operations
public:
static void SetWinXPStyle (HMENU hMenu, CWnd* pWnd = NULL);
static bool IsOwnerDrawn (HMENU hMenu);
static void OnMeasureItem (MEASUREITEMSTRUCT* pMeasureItemStruct);
static void OnDrawItem (DRAWITEMSTRUCT* pDrawItemStruct);
static LRESULT OnMenuChar (HMENU hMenu, UINT nChar, UINT nFlags);
protected:
//
// new code !
//
static CImageList m_ImageList;
//
static int AddImage(HIMAGELIST hSourceImgList,int sourceImageIndex);
//
// end new code...
//
};
add in menuxp.cpp
CMap <int, int, CString, CString&> CMenuXP::m_sCaptions;
CMap <int, int, CImgDesc, CImgDesc&> CMenuXP::m_Images;
CImageList CMenuXP::m_ImageList; // new initialization
int CMenuXP::AddImage(HIMAGELIST hSourceImgList,int sourceImageIndex)
{
int index=-1;
//
if( hSourceImgList && sourceImageIndex > -1 ){
HICON hIcon = ::ImageList_ExtractIcon(
NULL ,
hSourceImgList ,
sourceImageIndex );
if( hIcon ){
//
if( CMenuXP::m_ImageList.m_hImageList == NULL )
CMenuXP::m_ImageList.Create(16 , // cx,
16 , // cy,
ILC_MASK , // nFlags,
0 , // int nInitial,
16 ); // grow...
//
if( CMenuXP::m_ImageList.m_hImageList != NULL ){
index=m_ImageList.GetImageCount();
CMenuXP::m_ImageList.Add(hIcon);
}
::DestroyIcon(hIcon);
}
}
return index;
}
and in the function SetWinXPStyle sostitute:
//
//----------- Previus code:
//
// CImgDesc imgDesc (
// (HIMAGELIST)pBar->SendMessage (TB_GETIMAGELIST, 0, 0), tbbi.iImage);
// m_Images.SetAt (mii.wID, imgDesc);
//
// ---------- New code...
//
if( (nMyImageIndex=AddImage(
(HIMAGELIST)pBar->SendMessage(TB_GETIMAGELIST, 0, 0),
tbbi.iImage)) > -1 ){
CImgDesc imgDesc(CMenuXP::m_ImageList.m_hImageList,nMyImageIndex);
m_Images.SetAt( mii.wID, imgDesc );
}
break;
In this way if you destroy some toolbars etc.. at runtime the image is correct..
Sorry for my poor english and thanks for your job
|
|
|
|
|
Hello!
This class is really cool and so easy to use! But there's one thing I'm missing. The original office xp menus have this blue border if you move your mouse over the menu. This class (http://www.codeproject.com/menu/shadowmenu.asp) has that effect.
I would be really gratefull if you could include this feature.
Bye,
Gertschi
|
|
|
|