From 993b0cb651279e41ee489edc5ea47bf1eda00517 Mon Sep 17 00:00:00 2001 From: Johannes Schultz Date: Tue, 9 Apr 2024 17:02:30 +0000 Subject: [PATCH] [New] Templates can now be opened from the "New" icon in the main toolbar (https://bugs.openmpt.org/view.php?id=254). git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@20543 56274372-70c3-4bfc-bfc3-4c3a0b034d27 --- mptrack/Mainbar.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mptrack/Mainbar.cpp b/mptrack/Mainbar.cpp index 96695044554..a4508571b9b 100644 --- a/mptrack/Mainbar.cpp +++ b/mptrack/Mainbar.cpp @@ -642,7 +642,17 @@ void CMainToolBar::OnTbnDropDownToolBar(NMHDR *pNMHDR, LRESULT *pResult) switch(pToolBar->iItem) { case ID_FILE_NEW: - CMainFrame::GetMainFrame()->GetFileMenu()->GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pToolBar->rcButton.left, pToolBar->rcButton.bottom, this); + { + auto *mainFrm = CMainFrame::GetMainFrame(); + CMenu *newMenu = mainFrm->GetFileMenu()->GetSubMenu(0); + CMenu *templateMenu = mainFrm->GetFileMenu()->GetSubMenu(2); + const bool hasTemplates = templateMenu->GetMenuItemID(0) != 0; + if(hasTemplates) + newMenu->AppendMenu(MF_POPUP, reinterpret_cast(templateMenu->m_hMenu), _T("&Templates")); + newMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pToolBar->rcButton.left, pToolBar->rcButton.bottom, this); + if(hasTemplates) + newMenu->RemoveMenu(newMenu->GetMenuItemCount() - 1, MF_BYPOSITION); + } break; case ID_MIDI_RECORD: // Show a list of MIDI devices