I have a CMFCMenuButton
control on my dialog:
CONTROL "Lookup",IDC_MFCMENUBUTTON_LOOKUP_PUBLISHER,
"MfcMenuButton",WS_TABSTOP,106,254,45,14
I initialize it like this:
m_menuLookupPublisher.LoadMenu(IDR_MENU_LOOKUP_PUBLISHER);
m_btnLookupPublisher.m_hMenu = m_menuLookupPublisher.GetSubMenu(0)->GetSafeHmenu();
It works fine:
Update
I have added some extra code (based on answer provided to me):
m_menuLookupPublisher.LoadMenu(IDR_MENU_LOOKUP_PUBLISHER);
m_btnLookupPublisher.m_hMenu = m_menuLookupPublisher.GetSubMenu(0)->GetSafeHmenu();
m_btnLookupPublisher.m_nFlatStyle = CMFCButton::BUTTONSTYLE_SEMIFLAT;
m_btnLookupPublisher.m_bDrawFocus = FALSE;
This improves the look and feel of the button now, but it is still not 100% the same. Here is what it looks like now when it does not have focus:
It is just the way the border is displayed that is not correct. EnableWindowsThemeing
is TRUE
by default so I am not sure what else I need to do here.
What's annoying is that in the VS IDE it looks fine:
My question concerns the visual display of the menu button. The border looks different that the other buttons. Can it be made to look the same without too much work?
Update
I stumbled on this question which is now pointing me in the right direction. If I add this code:
m_btnLookupPublisher.ModifyStyle(BS_OWNERDRAW, 0, 0);
Then is draws the border correctly etc. but renders other aspects of the button useless so it is not a viable solution. But the remainder of the answer is what I needed:
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
Are you talking about 3D look? Then you need to specify "flat" style
BUTTONSTYLE_FLAT
:https://learn.microsoft.com/en-us/cpp/mfc/reference/cmfcbutton-class?view=msvc-160#m_nflatstyle