|
any idea of how to make a toolbar in office 2003-stlye?
thanx a lot!!
|
|
|
|
|
When I follow the steps.The error are:
--------------------Configuration: test2 - Win32 Debug--------------------
Compiling...
test2.cpp
Linking...
test2.obj : error LNK2001: unresolved external symbol "public: static void __cdecl CMenuXP::InitializeHook(void)" (?InitializeHook@CMenuXP@@SAXXZ)
test2.obj : error LNK2001: unresolved external symbol "public: static void __cdecl CMenuXP::UninitializeHook(void)" (?UninitializeHook@CMenuXP@@SAXXZ)
MainFrm.obj : error LNK2001: unresolved external symbol "public: static void __cdecl CMenuXP::SetXPLookNFeel(class CWnd *,struct HMENU__ *,bool,bool)" (?SetXPLookNFeel@CMenuXP@@SAXPAVCWnd@@PAUHMENU__@@_N2@Z)
MainFrm.obj : error LNK2001: unresolved external symbol "public: static bool __cdecl CMenuXP::GetXPLookNFeel(class CWnd const *)" (?GetXPLookNFeel@CMenuXP@@SA_NPBVCWnd@@@Z)
MainFrm.obj : error LNK2001: unresolved external symbol "public: static void __cdecl CMenuXP::OnMeasureItem(struct tagMEASUREITEMSTRUCT *)" (?OnMeasureItem@CMenuXP@@SAXPAUtagMEASUREITEMSTRUCT@@@Z)
MainFrm.obj : error LNK2001: unresolved external symbol "public: static void __cdecl CMenuXP::OnDrawItem(struct tagDRAWITEMSTRUCT *,struct HWND__ *)" (?OnDrawItem@CMenuXP@@SAXPAUtagDRAWITEMSTRUCT@@PAUHWND__@@@Z)
MainFrm.obj : error LNK2001: unresolved external symbol "public: static long __cdecl CMenuXP::OnMenuChar(struct HMENU__ *,unsigned int,unsigned int)" (?OnMenuChar@CMenuXP@@SAJPAUHMENU__@@II@Z)
MainFrm.obj : error LNK2001: unresolved external symbol "public: static bool __cdecl CMenuXP::IsOwnerDrawn(struct HMENU__ *)" (?IsOwnerDrawn@CMenuXP@@SA_NPAUHMENU__@@@Z)
MainFrm.obj : error LNK2001: unresolved external symbol "public: static void __cdecl CMenuXP::UpdateMenuBar(class CWnd *)" (?UpdateMenuBar@CMenuXP@@SAXPAVCWnd@@@Z)
Debug/test2.exe : fatal error LNK1120: 9 unresolved externals
Error executing link.exe.
test2.exe - 10 error(s), 0 warning(s)
who can tell me why? thanks.
I want fly.help me.thanks
|
|
|
|
|
Did you add the MenuXP.cpp file into your project ?
|
|
|
|
|
For some reason the CMenuXP::UpdateMenuBar(this) isn't working for
drawing the outline around the menus in my SDI application's menubar.
It doesn't even look like the LoadFrame is ever being called. It never
hit the break point I set there. The rest of the menus look like the
new style.
Nice work BTW on the class. Love it.
|
|
|
|
|
Hi,
What message do I add in order for the macro ON_MENUXP_MESSAGES() to be created in the BEGIN MESSAGE MAP
...END MESSAGE MAP section?
If I add it in manually, the code run, but I can't view the CMainFrm class using ClassWizard.
What am I missing?
|
|
|
|
|
I too faced the same problem.
There is a simple work around. Just enter the ON_MENUXP_MESSAGES()
line after the text
//}}AFX_MSG_MAP
which is generated by the class wizard.
|
|
|
|
|
First of all, excellent job, looks great.
I'm having a problem getting the menu to show Bitmaps that are NOT also found in the toolbar which are picked automatically.
I am dynamically inserting Menu items at runtime using: AppendMenu
How do I now assign Bitmaps for each entry?
Have tried SetMenuItemBitmaps but has not worked, the function returns as successful, but no bitmaps are displayed.
Any help would be greatly appreciated.
Thanks,
John
|
|
|
|
|
My class is not designed to allow that.
I do not envisage to improve it for the moment.
You can try to add code in the painting function to retrieve your bitmap and use it instead of toolbar bitmaps.
|
|
|
|
|
At first, thank you for your effort.
But when I use this program, I have a problem.
I make a owner-drawn menu with DrawItem.
However, this is hooked all message, so that menu is not drawn..
I want some menu of mine to be NOT affected CMenuXP.
How??
Plz help me~
|
|
|
|
|
BOOL CMainFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext)
{
if (!CFrameWnd::LoadFrame (nIDResource, dwDefaultStyle, pParentWnd, pContext) )
{
return false;
}
CMenuXP::UpdateMenuBar (this);
return true;
}
My code only work when i add this code on the function, because you only say about "CMenuXP::UpdateMenuBar (this);", and does not work whit this line only.
But it's the greatest and very simple code.... i haven't works to say TY!!!
REALLY KOOL!!!!!!!
|
|
|
|
|
You did a great job! But when I tried in dialog based application, it didn't work. Would you please give some suggestions?
|
|
|
|
|
You're wrong, it works:
1. Do the step LE FOL described in his article.
2. Create a menu resource
3. In your OnInitDialog() method of the main dialog, add the following code:
CMenu pMenu;<br />
pMenu.LoadMenu(YOUR_MENU_RES);<br />
SetMenu(&pMenu);<br />
pMenu.Detach();<br />
<br />
CMenuXP::SetXPLookNFeel(this, true);<br />
CMenuXP::UpdateMenuBar(this);
regards,
Happosai
------------------------------------
http://www.happosai.tk
|
|
|
|
|
|
Hi,
Thank you so much for your work. It is excellent under Windows 2000. But I just noticed that when i tried to run your demo(MDI for example) under Windows XP, the shadow effect looks just weird, something like double shadow...... Can you help me?
|
|
|
|
|
|
How would you take this code and make it work on an application that is already compiled, but can run dll exports and pass its hwnd? Is that even possible if it makes sence?
Would love to know how to do that
|
|
|
|
|
It should be possible by using the subclassing on the hwnd.
|
|
|
|
|
Thanks for replying, but i have no idea how to subclass hwnd If you could point me to an article on how to do that i would love it
|
|
|
|
|
i am a VB.Net coder. I found the vc++ files. I do not have any experience it them.
Can you help me, how to use them in my VB.code.
|
|
|
|
|
Hi. Just a small problem. I have implemented your code following exactly EACH step without forgotting anything in ChildFrm & MainFrm .cpp & .h files. When I run the sample without the ON_MENUXP_MESSAGES()in CMainFrm.cpp it works but the menus does not get the full XP-style. When I add ON_MENUXP_MESSAGES() in the CMainFrame message map, it hangs the software when I click a menu. I can't find the reason because I have watched your sample and I'm doing exactly the same.
The only major difference is that my application is of course more complex than your small dedicated sample and my CMainframe message map is bigger (see below):
My guess about this error is : would it be possible that the MenuXP hook function is also called for each CMainframe handled message and that some of my code can not be hooked by CMenuXP (because as you can see I am not only handling windows messages, but also some application specific messages) ??
If this is the reason, how can I determine for each CMainframe message implementation, if I am running a CMainframe message or a CMenu message ??
If not, do you have any idea of the problem ?
Many Thanks in advance for your lights about this
ON_WM_CREATE()
ON_WM_PALETTECHANGED()
ON_WM_QUERYNEWPALETTE()
ON_MESSAGE(WM_TRAYCALLBACK, OnTrayCallback)
ON_MESSAGE(WM_COMBOSEARCH, OnComboSearch)
ON_WM_WINDOWPOSCHANGED()
ON_WM_DESTROY()
ON_WM_CONTEXTMENU()
ON_WM_CLOSE()
ON_COMMAND(ID_VIEW_EDITBAR, OnViewEditbar)
ON_UPDATE_COMMAND_UI(ID_VIEW_EDITBAR, OnUpdateViewEditbar)
ON_COMMAND(ID_VIEW_ADVBAR, OnViewAdvBar)
ON_UPDATE_COMMAND_UI(ID_VIEW_ADVBAR, OnUpdateViewAdvBar)
ON_COMMAND(ID_UTIL_COLUM, OnUtilEditColumn)
ON_COMMAND(ID_UTIL_TYPE, OnUtilTypes)
ON_COMMAND(ID_VIEW_MENUBTN, OnViewMenuButtons)
ON_UPDATE_COMMAND_UI(ID_VIEW_MENUBTN, OnUpdateViewMenuButtons)
ON_COMMAND(ID_MEDIA_VIEW2, OnMediaViewInfoDlg)
ON_UPDATE_COMMAND_UI(ID_MEDIA_VIEW2, OnUpdateMediaInfoDlg)
ON_NOTIFY(TBN_DROPDOWN, AFX_IDW_TOOLBAR, OnToolbarDropDown)
ON_UPDATE_COMMAND_UI(ID_DROP_PRINT, OnUpdateDropPrint)
ON_COMMAND(ID_DROP_PRINT11, OnDropPrint11)
ON_COMMAND(ID_DROP_PRINT12, OnDropPrint12)
ON_COMMAND(ID_DROP_PRINT21, OnDropPrint21)
ON_COMMAND(ID_DROP_PRINT22, OnDropPrint22)
ON_COMMAND(ID_DROP_PRINT23, OnDropPrint23)
ON_COMMAND(ID_DROP_PRINT24, OnDropPrint24)
ON_COMMAND(ID_UTIL_RINFO, OnRestoreInfoDlg)
ON_COMMAND(ID_MEDIA_COPYIMG, OnMediaCopyImage)
ON_UPDATE_COMMAND_UI(ID_MEDIA_COPYIMG, OnUpdateMediaCopyImage)
ON_UPDATE_COMMAND_UI(ID_VIEW_ICONS3, OnUpdateDropView)
|
|
|
|
|
Sorry, my mistake ! this problem has been corrected, it was my fault. But I wanted to share the case here because it could also happen to other developers :
My application had already a menu hooking class designed to include icons within menus (icons stored in a dummy toolbar in project resources).
When I implemented the CMenuXP class in my code, I forgot to remove the previous hooking functions. So it seems that Windows or MFC could not support twice hooking, or maybe functions overlapped.
Anyway, that's the bottom line : do NOT forget to remove your previous menu hooking functions before setting this new one !
See ya.
|
|
|
|
|
Thanks for this great code that allows to implement XP style on Menus, but the interface like have some lacks if it can not be completed with a XP-style toolbar, with rounded buttons like in Internet Explorer 6 under Windows XP, see what I mean ?
Is a XP-style toolbar scheduled for design ?
Otherwise, does anyone here knows were such code can be found ?
Regards,
|
|
|
|
|
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
...
// Comment this line to deactivate the XP Look & Feel
CMenuXP::SetXPLookNFeel (this);
...
}
|
|
|
|
|
|
Congratulations, very good and useful article!
I suggest a little improvement regarding the usage of toolbars with more colors than by defalt.
I am using true colors toolbars. To get this functionality three bitmaps are to be provided - normal, disabled and hot version of toolbar images.
Since CMenuXP gets its images from the standard toolbar bitmap it can not take advantage of these true color bitmaps. However, with few simple changes this functionality can be achieved and still retain the normal behavior with simple toolbars.
Changes in MenuXP.h:
Change class CImgDesc into:
class CImgDesc
{
public:
HIMAGELIST m_hImgList;
HIMAGELIST m_hImgHotList;
HIMAGELIST m_hImgDisList;
int m_nIndex;
CImgDesc (HIMAGELIST hImgList = NULL, HIMAGELIST hImgHotList = NULL, HIMAGELIST hImgDisList = NULL, int nIndex = 0)
: m_hImgList (hImgList), m_hImgHotList (hImgHotList), m_hImgDisList (hImgDisList), m_nIndex (nIndex)
{
}
};
Changes in MenuXP.cpp:
Change drawing code in CMenuItem::Draw() to:
if ( GetDisabled() || (bSelected && !GetChecked()) )
{
if(m_ImgDesc.m_hImgDisList && GetDisabled())
::ImageList_Draw (m_ImgDesc.m_hImgDisList, m_ImgDesc.m_nIndex, pDC->m_hDC,
pRect->left+3, rc.top+3, ILD_TRANSPARENT);
else
{
HICON hIcon = ImageList_ExtractIcon (NULL, m_ImgDesc.m_hImgList, m_ImgDesc.m_nIndex);
pDC->DrawState (CPoint (pRect->left + ( bOver ? 4 : 3 ), rc.top + ( bOver ? 4 : 3 )),
CSize (IMGWIDTH, IMGHEIGHT), hIcon, DSS_MONO,
CBrush (bOver ? HLS_TRANSFORM (::GetSysColor (COLOR_HIGHLIGHT), +50, -66) : HLS_TRANSFORM (::GetSysColor (COLOR_3DFACE), -27, 0)));
DestroyIcon (hIcon);
}
}
if ( !GetDisabled() )
{
if(m_ImgDesc.m_hImgHotList && bSelected)
::ImageList_Draw (m_ImgDesc.m_hImgHotList, m_ImgDesc.m_nIndex, pDC->m_hDC,
pRect->left+(!GetChecked()? 2 : 3 ), rc.top+(!GetChecked()? 2 : 3 ), ILD_TRANSPARENT);
else
::ImageList_Draw (m_ImgDesc.m_hImgList, m_ImgDesc.m_nIndex, pDC->m_hDC,
pRect->left+( (bSelected && !GetChecked()) ? 2 : 3 ), rc.top+( (bSelected && !GetChecked()) ? 2 : 3 ), ILD_TRANSPARENT);
}
Change reading of the images from the toolbar in CMenuXP::SetXPLookNFeel()
CImgDesc imgDesc ((HIMAGELIST)pBar->SendMessage (TB_GETIMAGELIST, 0, 0),
(HIMAGELIST)pBar->SendMessage (TB_GETHOTIMAGELIST, 0, 0),
(HIMAGELIST)pBar->SendMessage (TB_GETDISABLEDIMAGELIST, 0, 0),tbbi.iImage);
|
|
|
|
|