I am working with MFC and I have created succesfully custom-drawn menus. Each menu-item is measured and drawn correctly, except the mainlevel-items. The only thing I can't get done is redrawing the application menubar.
I attached two images:
So whatever the fontsize is, the Application Menu Bar will never change its height?
How can I resize the application menu bar in this MFC application?
Things I have tried so far is following lines of code in different orders:
RECT barRect;
barRect.top = 0;
barRect.left = 0;
barRect.bottom = 100;
barRect.right = 1020;
m_pMainWnd->RepositionBars(0, 0, 0, 2, &barRect);
m_pMainWnd->GetTopLevelFrame()->RecalcLayout();
m_pMainWnd->DrawMenuBar();
for (POSITION pos = m_pMainWnd->GetTopLevelFrame()->m_listControlBars.GetHeadPosition(); pos != NULL;)
{
CControlBar* controlBar = reinterpret_cast<CControlBar*>(m_pMainWnd->GetTopLevelFrame()->m_listControlBars.GetNext(pos));
controlBar = nullptr; //Let's see what we can do with this. Is the menuBar a ControlBar? Didnt think so.
}
m_pMainWnd->RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);
The first part is not an answer to the direct question but it should clarify why there is no need for it.
The menu is part of the global UI. Also the size of a menu items is part of the global settings.
If the user wants it, he can change the windows settings to get a larger menu.
I don't think it is a good way to change the standard behaviour. A UI should be stable, persistent and consistent. All programs should have the same look and feel. This includes the menu bar.
Now to your question.
You receive the WM_MEASUREITEM
message. Respond to it and you can change the height for an onwerdraw menu.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.