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:
- The first shows a part of the menubar. The font Consolas 11pt is drawed correct. The width of the buttons is calculated correct, the buttons need to be spread over two rows.
- The second image shows the same menubar with font Consolas 20pt. Now the menu needs three rows to contain all menu-items. However, the height for each separate row, is not updated. (while debugging, I see the MeasureItem override calculates the correct height for each menu-item). Below the menubar, there is a toolbar (BCGToolBar), which calculates the correct height for its bar.
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);