|
I have a RichEdit control on my dialog and i was wondering how i could make it have the nice styles...
I have a dialog box which has already been customized to have the OfficeXP styles (the menus and everything...) on the dialog, I have a RichEdit control, to which I attached a popup menu... Should the popup menu have the styles by default, given the above conditions?
Thanks,
Alex.
|
|
|
|
|
Hello,
I have followed the exact instructions in the above tutorial... However, I get some compile errors... Here's my compile log...
d:\Projects\ParallelScript\MainFrm.cpp(15): error C2509: 'OnInitMenuPopup' : member function not declared in 'CMainFrame'<br />
d:\Projects\ParallelScript\MainFrm.cpp(15): error C2509: 'OnMeasureItem' : member function not declared in 'CMainFrame'<br />
d:\Projects\ParallelScript\MainFrm.cpp(15): error C2509: 'OnDrawItem' : member function not declared in 'CMainFrame'<br />
d:\Projects\ParallelScript\MainFrm.cpp(15): error C2509: 'OnMenuChar' : member function not declared in 'CMainFrame'<br />
d:\Projects\ParallelScript\MainFrm.cpp(17): error C2059: syntax error : 'protected'<br />
Here are lines 15 and 17:
IMPLEMENT_MENUXP(CMainFrame, CFrameWnd)<br />
<br />
DECLARE_MENUXP()
I don't know what is wrong here... or what I'm doing wrong... I'm pretty new to MFC, so, please be more detailed...
Thank you,
Alex.
|
|
|
|
|
DECLARE_MENUXP() // Into the definition of the class
This line must be set in the header file (the .h file) and not in the .cpp file. (read the first point of the tutorial !)
Search for this line in the demo to have an example.
|
|
|
|
|
Thank you, I got it working now...
Sorry I misread the tutorial...
Thanks again...
|
|
|
|
|
Where do I get this file? I am getting an error pop-up saying that this file is not present. Is it a part of Visual Studio .NET? I am using VS 6.0.
Thanks
Abhijit
|
|
|
|
|
In my resource for my menu, I check the Property of Grayed for some menu items, but when I run my app, the menu items aren't grayed. Ideas?
|
|
|
|
|
Add an ON_UPDATE_COMMAND_UI message handler for your menu item. Within the method generated, put in some logic or just check a flag to figure out whether or not you want the item enabled, then use the CCmdUI pointer passed in to change the state of the item.
Example:
void CMyApp::OnUpdateViewFlatLook(CCmdUI *pCmdUI)
{
//Enables/Disables the item based on a boolean.
pCmdUI->Enable(m_bFlatLook);
}
|
|
|
|
|
I have an MDI app and the system menu is drawn very strangely. Move, Size, and Maximize have only their text displayed, and Restore, Minimize, and Close only have their icon displayed. I am using the default menus. Any ideas on what is causing the problem?
|
|
|
|
|
I can confirm this behaviour, but only on Windows XP, and only with MDI applications, including the example provided. On Windows 2000, and on Windows ME, the behaviour is correct.
When using Word XP, the system menu doesn't get the visual styles, so I suspect that it's necessary to find a way to exclude the system menu from this special handling. I tested a bit, and found that the OnDrawItem only gets called for those entries that look correctly - it doesn't get called for those entries that look strange.
|
|
|
|
|
In MenuXP.h Line 79, you can suppress the comment.
System menus will be unhandled. But their borders will stay flat !
The result is strange, but it works...
Regards
|
|
|
|
|
On XP, the system would automatically draw the shadow. How do I disable it only for my APP?
Stephane
|
|
|
|
|
The menu bar can change in my application. I got it to work by issuing CMenuXP::UpdateMenuBar(this)after SetMenu(...) to the new menu bar. I assume this will not cause problems.
I notice that DPI settings other than 100% are not handled correctly.
Some of my toolbars are oversized with large icons and that causes some display problems.
Otherwise, I am pleasantly surprised that the code handles all these situations without breaking.
|
|
|
|
|
Is There Any Chance Of An OCX Version?
Kind Regards
Gary
|
|
|
|
|
Hi!
MenuXP_src.zip - Tools - MenuXP.cpp - should be:
bool CMenuItem::Draw( ) const<br />
{<br />
<br />
rc.right = rc.left + IMGWIDTH+IMGPADDING;<br />
pDC->FillSolidRect (rc, HLS_TRANSFORM (::GetSysColor (COLOR_3DFACE), +20, 0));<br />
<br />
<br />
rc.left += IMGWIDTH+IMGPADDING+TEXTPADDING;<br />
pDC->DrawText (sCaption, rc, DT_SINGLELINE|DT_VCENTER|DT_LEFT|dwHidePrefix);<br />
<br />
}
It's proper for a "column break" or "bar break" option.
Sincerely Yours,
Kris Wojtas
|
|
|
|
|
In source files and on this page I don't found any license agreements...
|
|
|
|
|
Hello
This is very nice, but how do you add icons to the various menu items?
Hope someone can help
Thanks
Alex
|
|
|
|
|
Yo, I can't get this working either. There is a simple example (onInitDialog):
CImageList m_imgList;
m_imgList.Create (IDB_BITMAP1, 16, 0, RGB(192,192,192));
CMenuXP::SetMenuItemImage (ID_APP_ABOUT, m_imgList, 0);
CMenuXP::SetMenuItemImage (ID_FILE_ITEM1, m_imgList, 1);
CMenuXP::SetMenuItemImage (ID_FILE_ITEM2, m_imgList, 2);
CMenuXP::SetMenuItemImage (ID_FILE_ITEM3, m_imgList, 3);
but I can't get it to work for me. My create bitmap is good, but the SetMenuItemImage does nothing
aaaaaahhhhhhh!!!
|
|
|
|
|
I'm looking at the SDI example; how the menu icons are added is a TOTAL mystery, there is no code involved at all! The menu icons are just there by some weird Microsoft magic. God I hate VC++ somethings!
|
|
|
|
|
Yeah, this seems like a mystery at first, but it's automatically figured out by matching resource IDs between menus and toolbars.
A toolbar gets its icons through a single BMP file in your res folder. VC automatically edits it as you edit the toolbar in the resource editor.
Example: I have a menu resource with an ID of IDR_MAINFRAME. I also have a toolbar resource with an ID of IDR_MAINFRAME.
I have a button on my toolbar with an ID of ID_FILE_OPEN. I also have a menu item on my menu with an ID of ID_FILE_OPEN. Whatever icon the toolbar button has, the menu item will have.
I hope this helps.
|
|
|
|
|
Is it possible to popup a menu at tray icon and apply a flat style to it?
Because the parent wnd of this menu is a hidden dialog, the menu can only apply flat style within this dialog.
|
|
|
|
|
I use a popup menu in conditions you describe (hidden window) and I have no problem. I suggest that you write a small sample. If you experience some problems, send it to me, I'll correct it. After that, We can publish this sample to help anyone that try to do the same thing.
|
|
|
|
|
Followed the instructions fully, except my call to UpdateMenuBar is in the LoadFrame method of the MainFrm class file. There's no OnUpdateFrameMenu method of ChildFrm for an MDI app that I can see.
I'm using VC6.0 on Win2K.
Any ideas?
|
|
|
|
|
Putting it in a CMDIFrameWnd derived class won't work, at least for me.
CMDIChildWnd does have this method. If the wizard doesn't display it, then override it manually. It's exactly how I implemented it in my copy of VC6.
Also, if you don't automatically open a child window on application start, then read my post above about MDI apps.
|
|
|
|
|
BTW thanks for replying.
Here's what I have:
void CChildFrame::OnUpdateFrameMenu (BOOL bActivate, CWnd* pActivateWnd, HMENU hMenuAlt)
{
CMDIChildWnd::OnUpdateFrameMenu (bActivate, pActivateWnd, hMenuAlt);
CMenuXP::UpdateMenuBar (GetMDIFrame());
}
and
BOOL CChildFrame::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CMDIFrameWnd* pParentWnd, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
// Comment out this line to deactivate the XP Look & Feel
CMenuXP::SetXPLookNFeel (this,TRUE);
return CMDIChildWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, pContext);
}
Not sure what else to try.
|
|
|
|
|
Take a look at the modified version below. The hMenu check isn't required, but it's in there to be safe. You want the SetXPLookNFeel() call in this method. You do not want any of this code in your Create() method as the actual window has not been created yet.
I think you may have confused Create() with OnCreate(). Your CMainFrame should have the SetXPLookNFeel() call in its OnCreate() method AFTER the Create() method has been called. Nothing is required in the OnCreate() on your ChildFrame class.
I hope this clears things up.
//Modified method
void CChildFrame::OnUpdateFrameMenu (BOOL bActivate, CWnd* pActivateWnd, HMENU hMenuAlt)
{
CMDIChildWnd::OnUpdateFrameMenu (bActivate, pActivateWnd, hMenuAlt);
CMenuXP::UpdateMenuBar(GetMDIFrame());
HMENU hMenu = GetSystemMenu(false)->GetSafeHmenu();
if ( hMenu != NULL )
{
CMenuXP::SetXPLookNFeel(this, hMenu, true);
}
}
}
|
|
|
|