From: <sv...@op...> - 2024-07-22 20:52:56
|
Author: sagamusix Date: Mon Jul 22 22:52:42 2024 New Revision: 21256 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=21256 Log: [Fix] Fix various keyboard focus issues when switching between upper and lower half of editor views or switching to another application and back (https://bugs.openmpt.org/view.php?id=1799, https://bugs.openmpt.org/view.php?id=1800). [Fix] Don't allow to set keyboard focus to the tree view via keyboard shortcut if it is hidden (https://bugs.openmpt.org/view.php?id=1802). Modified: trunk/OpenMPT/mptrack/Ctrl_pat.cpp trunk/OpenMPT/mptrack/Globals.cpp trunk/OpenMPT/mptrack/Globals.h trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/View_ins.cpp trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/WindowMessages.h trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/view_com.cpp Modified: trunk/OpenMPT/mptrack/Ctrl_pat.cpp ============================================================================== --- trunk/OpenMPT/mptrack/Ctrl_pat.cpp Mon Jul 22 21:12:48 2024 (r21255) +++ trunk/OpenMPT/mptrack/Ctrl_pat.cpp Mon Jul 22 22:52:42 2024 (r21256) @@ -453,7 +453,7 @@ SetDlgItemInt(IDC_EDIT_SPACING, static_cast<UINT>(lParam)); break; - case CTRLMSG_SETFOCUS: + case CTRLMSG_PAT_SETORDERLISTFOCUS: GetParentFrame()->SetActiveView(&m_parent); m_OrderList.SetFocus(); break; Modified: trunk/OpenMPT/mptrack/Globals.cpp ============================================================================== --- trunk/OpenMPT/mptrack/Globals.cpp Mon Jul 22 21:12:48 2024 (r21255) +++ trunk/OpenMPT/mptrack/Globals.cpp Mon Jul 22 22:52:42 2024 (r21256) @@ -28,6 +28,17 @@ OPENMPT_NAMESPACE_BEGIN +static void RestoreLastFocusItem(HWND parent, HWND &lastFocusItem) +{ + if(lastFocusItem && ::IsChild(parent, lastFocusItem)) + ::SetFocus(lastFocusItem); + else if(HWND firstWnd = ::GetTopWindow(parent)) + ::SetFocus(lastFocusItem = firstWnd); + else + ::SetFocus(parent); +} + + ///////////////////////////////////////////////////////////////////////////// // CModControlDlg @@ -37,7 +48,7 @@ #if !defined(MPT_BUILD_RETRO) ON_MESSAGE(WM_DPICHANGED, &CModControlDlg::OnDPIChanged) #endif - ON_MESSAGE(WM_MOD_UNLOCKCONTROLS, &CModControlDlg::OnUnlockControls) + ON_MESSAGE(WM_MOD_UNLOCKCONTROLS, &CModControlDlg::OnUnlockControls) ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, &CModControlDlg::OnToolTipText) ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, &CModControlDlg::OnToolTipText) //}}AFX_MSG_MAP @@ -83,6 +94,20 @@ } +void CModControlDlg::SaveLastFocusItem(HWND hwnd) +{ + MPT_ASSERT(::IsChild(m_hWnd, hwnd)); + if(hwnd) + m_lastFocusItem = hwnd; +} + + +void CModControlDlg::RestoreLastFocusItem() +{ + OPENMPT_NAMESPACE::RestoreLastFocusItem(*this, m_lastFocusItem); +} + + LRESULT CModControlDlg::OnModCtrlMsg(WPARAM wParam, LPARAM lParam) { switch(wParam) @@ -101,7 +126,7 @@ case CTRLMSG_SETFOCUS: GetParentFrame()->SetActiveView(&m_parent); - SetFocus(); + RestoreLastFocusItem(); break; } return 0; @@ -110,19 +135,21 @@ LRESULT CModControlDlg::SendViewMessage(UINT uMsg, LPARAM lParam) const { - if (m_hWndView) return ::SendMessage(m_hWndView, WM_MOD_VIEWMSG, uMsg, lParam); + if(m_hWndView) + return ::SendMessage(m_hWndView, WM_MOD_VIEWMSG, uMsg, lParam); return 0; } BOOL CModControlDlg::PostViewMessage(UINT uMsg, LPARAM lParam) const { - if (m_hWndView) return ::PostMessage(m_hWndView, WM_MOD_VIEWMSG, uMsg, lParam); + if(m_hWndView) + return ::PostMessage(m_hWndView, WM_MOD_VIEWMSG, uMsg, lParam); return FALSE; } -INT_PTR CModControlDlg::OnToolHitTest(CPoint point, TOOLINFO* pTI) const +INT_PTR CModControlDlg::OnToolHitTest(CPoint point, TOOLINFO *pTI) const { INT_PTR nHit = CDialog::OnToolHitTest(point, pTI); if ((nHit >= 0) && (pTI)) @@ -137,11 +164,13 @@ } -BOOL CModControlDlg::OnToolTipText(UINT nID, NMHDR* pNMHDR, LRESULT* pResult) +BOOL CModControlDlg::OnToolTipText(UINT nID, NMHDR *pNMHDR, LRESULT *pResult) { CChildFrame *pChildFrm = (CChildFrame *)GetParentFrame(); - if (pChildFrm) return pChildFrm->OnToolTipText(nID, pNMHDR, pResult); - if (pResult) *pResult = 0; + if(pChildFrm) + return pChildFrm->OnToolTipText(nID, pNMHDR, pResult); + if(pResult) + *pResult = 0; return FALSE; } @@ -191,18 +220,17 @@ ON_WM_SIZE() ON_WM_DESTROY() ON_WM_SETFOCUS() - ON_NOTIFY(TCN_SELCHANGE, IDC_TABCTRL1, &CModControlView::OnTabSelchange) - ON_MESSAGE(WM_MOD_ACTIVATEVIEW, &CModControlView::OnActivateModView) - ON_MESSAGE(WM_MOD_CTRLMSG, &CModControlView::OnModCtrlMsg) - ON_MESSAGE(WM_MOD_GETTOOLTIPTEXT, &CModControlView::OnGetToolTipText) - ON_MESSAGE(WM_MOD_MDIDEACTIVATE, &CModControlView::OnSaveFocusItem) - ON_COMMAND(ID_EDIT_CUT, &CModControlView::OnEditCut) - ON_COMMAND(ID_EDIT_COPY, &CModControlView::OnEditCopy) - ON_COMMAND(ID_EDIT_PASTE, &CModControlView::OnEditPaste) - ON_COMMAND(ID_EDIT_MIXPASTE, &CModControlView::OnEditMixPaste) - ON_COMMAND(ID_EDIT_MIXPASTE_ITSTYLE, &CModControlView::OnEditMixPasteITStyle) - ON_COMMAND(ID_EDIT_FIND, &CModControlView::OnEditFind) - ON_COMMAND(ID_EDIT_FINDNEXT, &CModControlView::OnEditFindNext) + ON_NOTIFY(TCN_SELCHANGE, IDC_TABCTRL1, &CModControlView::OnTabSelchange) + ON_MESSAGE(WM_MOD_ACTIVATEVIEW, &CModControlView::OnActivateModView) + ON_MESSAGE(WM_MOD_CTRLMSG, &CModControlView::OnModCtrlMsg) + ON_MESSAGE(WM_MOD_GETTOOLTIPTEXT, &CModControlView::OnGetToolTipText) + ON_COMMAND(ID_EDIT_CUT, &CModControlView::OnEditCut) + ON_COMMAND(ID_EDIT_COPY, &CModControlView::OnEditCopy) + ON_COMMAND(ID_EDIT_PASTE, &CModControlView::OnEditPaste) + ON_COMMAND(ID_EDIT_MIXPASTE, &CModControlView::OnEditMixPaste) + ON_COMMAND(ID_EDIT_MIXPASTE_ITSTYLE, &CModControlView::OnEditMixPasteITStyle) + ON_COMMAND(ID_EDIT_FIND, &CModControlView::OnEditFind) + ON_COMMAND(ID_EDIT_FINDNEXT, &CModControlView::OnEditFindNext) //}}AFX_MSG_MAP END_MESSAGE_MAP() @@ -222,18 +250,10 @@ } -LRESULT CModControlView::OnSaveFocusItem(WPARAM, LPARAM) +void CModControlView::OnSetFocus(CWnd *pOldWnd) { - // Ugly workaround for focus issue in upper view (https://bugs.openmpt.org/view.php?id=1795) - m_oldWnd = ::GetFocus(); - return 0; -} - - -void CModControlView::OnSetFocus(CWnd* pOldWnd) -{ - if(m_oldWnd && ::IsChild(m_hWnd, m_oldWnd)) - ::SetFocus(m_oldWnd); + if(CModControlDlg *activeDlg = GetCurrentControlDlg()) + activeDlg->RestoreLastFocusItem(); CView::OnSetFocus(pOldWnd); } @@ -554,12 +574,13 @@ ON_WM_DESTROY() ON_WM_MOUSEWHEEL() ON_WM_MOUSEHWHEEL() + ON_WM_SETFOCUS() #if !defined(MPT_BUILD_RETRO) ON_MESSAGE(WM_DPICHANGED, &CModScrollView::OnDPIChanged) #endif - ON_MESSAGE(WM_MOD_VIEWMSG, &CModScrollView::OnReceiveModViewMsg) - ON_MESSAGE(WM_MOD_DRAGONDROPPING, &CModScrollView::OnDragonDropping) - ON_MESSAGE(WM_MOD_UPDATEPOSITION, &CModScrollView::OnUpdatePosition) + ON_MESSAGE(WM_MOD_VIEWMSG, &CModScrollView::OnReceiveModViewMsg) + ON_MESSAGE(WM_MOD_DRAGONDROPPING, &CModScrollView::OnDragonDropping) + ON_MESSAGE(WM_MOD_UPDATEPOSITION, &CModScrollView::OnUpdatePosition) //}}AFX_MSG_MAP END_MESSAGE_MAP() @@ -591,7 +612,23 @@ } -void CModScrollView::OnUpdate(CView* pView, LPARAM lHint, CObject*pHint) +void CModScrollView::SaveLastFocusItem(HWND hwnd) +{ + MPT_ASSERT(::IsChild(m_hWnd, hwnd)); + if(hwnd) + m_lastFocusItem = hwnd; +} + + +void CModScrollView::OnSetFocus(CWnd *pOldWnd) +{ + if(m_lastFocusItem && ::IsChild(m_hWnd, m_lastFocusItem)) + ::SetFocus(m_lastFocusItem); + CScrollView::OnSetFocus(pOldWnd); +} + + +void CModScrollView::OnUpdate(CView *pView, LPARAM lHint, CObject *pHint) { if (pView != this) UpdateView(UpdateHint::FromLPARAM(lHint), pHint); } @@ -608,7 +645,7 @@ case VIEWMSG_SETFOCUS: case VIEWMSG_SETACTIVE: GetParentFrame()->SetActiveView(this); - SetFocus(); + RestoreLastFocusItem(*this, m_lastFocusItem); break; } return 0; Modified: trunk/OpenMPT/mptrack/Globals.h ============================================================================== --- trunk/OpenMPT/mptrack/Globals.h Mon Jul 22 21:12:48 2024 (r21255) +++ trunk/OpenMPT/mptrack/Globals.h Mon Jul 22 22:52:42 2024 (r21256) @@ -42,6 +42,7 @@ CSoundFile &m_sndFile; CModControlView &m_parent; HWND m_hWndView = nullptr; + HWND m_lastFocusItem = nullptr; LONG m_nLockCount = 0; int m_nDPIx = 0, m_nDPIy = 0; // Cached DPI settings BOOL m_bInitialized = FALSE; @@ -61,6 +62,9 @@ bool IsLocked() const { return (m_nLockCount > 0); } virtual Setting<LONG> &GetSplitPosRef() = 0; + void SaveLastFocusItem(HWND hwnd); + void RestoreLastFocusItem(); + afx_msg void OnEditCut() { if (m_hWndView) ::SendMessage(m_hWndView, WM_COMMAND, ID_EDIT_CUT, 0); } afx_msg void OnEditCopy() { if (m_hWndView) ::SendMessage(m_hWndView, WM_COMMAND, ID_EDIT_COPY, 0); } afx_msg void OnEditPaste() { if (m_hWndView) ::SendMessage(m_hWndView, WM_COMMAND, ID_EDIT_PASTE, 0); } @@ -88,7 +92,7 @@ //{{AFX_MSG(CModControlDlg) afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg LRESULT OnUnlockControls(WPARAM, LPARAM) { if (m_nLockCount > 0) m_nLockCount--; return 0; } - afx_msg BOOL OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult); + afx_msg BOOL OnToolTipText(UINT, NMHDR *pNMHDR, LRESULT *pResult); afx_msg LRESULT OnDPIChanged(WPARAM = 0, LPARAM = 0); //}}AFX_MSG DECLARE_MESSAGE_MAP() @@ -125,7 +129,6 @@ Page m_nActiveDlg = Page::Unknown; int m_nInstrumentChanged = -1; HWND m_hWndView = nullptr, m_hWndMDI = nullptr; - HWND m_oldWnd = nullptr; protected: // create from serialization only CModControlView() = default; @@ -158,7 +161,6 @@ protected: //{{AFX_MSG(CModControlView) - afx_msg LRESULT OnSaveFocusItem(WPARAM, LPARAM); afx_msg void OnSetFocus(CWnd *pOldWnd); afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg void OnDestroy(); @@ -189,6 +191,7 @@ { protected: HWND m_hWndCtrl = nullptr; + HWND m_lastFocusItem = nullptr; int m_nScrollPosX = 0, m_nScrollPosY = 0; int m_nScrollPosXfine = 0, m_nScrollPosYfine = 0; int m_nDPIx = 0, m_nDPIy = 0; // Cached DPI settings @@ -219,9 +222,12 @@ CModControlDlg *GetControlDlg() { return static_cast<CModControlView *>(CWnd::FromHandle(m_hWndCtrl))->GetCurrentControlDlg(); } + void SaveLastFocusItem(HWND hwnd); + protected: //{{AFX_MSG(CModScrollView) afx_msg void OnDestroy(); + afx_msg void OnSetFocus(CWnd *pOldWnd); afx_msg LRESULT OnReceiveModViewMsg(WPARAM wParam, LPARAM lParam); afx_msg BOOL OnMouseWheel(UINT fFlags, short zDelta, CPoint point); afx_msg void OnMouseHWheel(UINT fFlags, short zDelta, CPoint point); Modified: trunk/OpenMPT/mptrack/MainFrm.cpp ============================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp Mon Jul 22 21:12:48 2024 (r21255) +++ trunk/OpenMPT/mptrack/MainFrm.cpp Mon Jul 22 22:52:42 2024 (r21256) @@ -147,23 +147,24 @@ // Globals OptionsPage CMainFrame::m_nLastOptionsPage = OPTIONS_PAGE_DEFAULT; -HHOOK CMainFrame::ghKbdHook = NULL; +HHOOK CMainFrame::ghKbdHook = nullptr; +HHOOK CMainFrame::g_focusHook = nullptr; // GDI -HICON CMainFrame::m_hIcon = NULL; -HFONT CMainFrame::m_hGUIFont = NULL; -HFONT CMainFrame::m_hFixedFont = NULL; -HPEN CMainFrame::penDarkGray = NULL; -HPEN CMainFrame::penGray99 = NULL; -HPEN CMainFrame::penHalfDarkGray = NULL; - -HCURSOR CMainFrame::curDragging = NULL; -HCURSOR CMainFrame::curArrow = NULL; -HCURSOR CMainFrame::curNoDrop = NULL; -HCURSOR CMainFrame::curNoDrop2 = NULL; -HCURSOR CMainFrame::curVSplit = NULL; +HICON CMainFrame::m_hIcon = nullptr; +HFONT CMainFrame::m_hGUIFont = nullptr; +HFONT CMainFrame::m_hFixedFont = nullptr; +HPEN CMainFrame::penDarkGray = nullptr; +HPEN CMainFrame::penGray99 = nullptr; +HPEN CMainFrame::penHalfDarkGray = nullptr; + +HCURSOR CMainFrame::curDragging = nullptr; +HCURSOR CMainFrame::curArrow = nullptr; +HCURSOR CMainFrame::curNoDrop = nullptr; +HCURSOR CMainFrame::curNoDrop2 = nullptr; +HCURSOR CMainFrame::curVSplit = nullptr; MODPLUGDIB *CMainFrame::bmpNotes = nullptr; -COLORREF CMainFrame::gcolrefVuMeter[NUM_VUMETER_PENS*2]; +COLORREF CMainFrame::gcolrefVuMeter[NUM_VUMETER_PENS * 2]; CInputHandler *CMainFrame::m_InputHandler = nullptr; @@ -232,6 +233,7 @@ // Setup Keyboard Hook ghKbdHook = SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, AfxGetInstanceHandle(), GetCurrentThreadId()); + g_focusHook = SetWindowsHookEx(WH_CBT, FocusChangeProc, AfxGetInstanceHandle(), GetCurrentThreadId()); // Update the tree m_wndTree.Init(); @@ -348,18 +350,24 @@ #endif // Uninstall Keyboard Hook - if (ghKbdHook) + if(ghKbdHook) { UnhookWindowsHookEx(ghKbdHook); - ghKbdHook = NULL; + ghKbdHook = nullptr; + } + if(g_focusHook) + { + UnhookWindowsHookEx(g_focusHook); + g_focusHook = nullptr; } // Kill Timer - if (m_nTimer) + if(m_nTimer) { KillTimer(m_nTimer); m_nTimer = 0; } - if (shMidiIn) midiCloseDevice(); + if(shMidiIn) + midiCloseDevice(); // Delete bitmaps delete bmpNotes; bmpNotes = nullptr; @@ -557,6 +565,57 @@ } +LRESULT CALLBACK CMainFrame::FocusChangeProc(int code, WPARAM wParam, LPARAM lParam) +{ + // Hook to keep track of last focussed GUI item. This solves various focus issues when switching between + // CModControlDlg / CModScrollView via keyboard shortcuts, or when switching to another application and back. + // See https://bugs.openmpt.org/view.php?id=1795 / https://bugs.openmpt.org/view.php?id=1799 / https://bugs.openmpt.org/view.php?id=1800 + if(code != HCBT_SETFOCUS || !wParam || !lParam) + return CallNextHookEx(g_focusHook, code, wParam, lParam); + + const HWND mainWnd = CMainFrame::GetMainFrame()->GetSafeHwnd(); + HWND lostFocusWnd = reinterpret_cast<HWND>(lParam), gainFocusWnd = reinterpret_cast<HWND>(wParam); + CModControlDlg *parentCtrl = nullptr; + CModScrollView *parentScroll = nullptr; + do + { + // Does the window that lost focus belong to the upper or lower half of a module view? + auto wnd = CWnd::FromHandlePermanent(lostFocusWnd); + if(parentCtrl = dynamic_cast<CModControlDlg *>(wnd); parentCtrl != nullptr) + break; + else if(parentScroll = dynamic_cast<CModScrollView *>(wnd); parentScroll != nullptr) + break; + + lostFocusWnd = ::GetParent(lostFocusWnd); + } while(lostFocusWnd && lostFocusWnd != mainWnd); + + if(parentCtrl || parentScroll) + { + // Focus was lost inside an MDI view. Check if the new focus item inside the same view. + // If both are part of the same view, store the new focus item, otherwise the old one. + bool sameParent = false; + do + { + if((parentCtrl && gainFocusWnd == parentCtrl->m_hWnd) || (parentScroll && gainFocusWnd == parentScroll->m_hWnd)) + { + sameParent = true; + break; + } + + gainFocusWnd = ::GetParent(gainFocusWnd); + } while(gainFocusWnd && gainFocusWnd != mainWnd); + + HWND lastFocus = sameParent ? reinterpret_cast<HWND>(wParam) : reinterpret_cast<HWND>(lParam); + if(parentCtrl && parentCtrl->m_hWnd != lastFocus) + parentCtrl->SaveLastFocusItem(lastFocus); + else if(parentScroll && parentScroll->m_hWnd != lastFocus) + parentScroll->SaveLastFocusItem(lastFocus); + } + + return CallNextHookEx(g_focusHook, code, wParam, lParam); +} + + BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) { if((pMsg->message == WM_RBUTTONDOWN) || (pMsg->message == WM_NCRBUTTONDOWN)) @@ -2554,6 +2613,8 @@ } case kcSwitchToInstrLibrary: + if(!m_wndTree.IsVisible()) + break; if(m_bModTreeHasFocus) SwitchToActiveView(); else Modified: trunk/OpenMPT/mptrack/Mainfrm.h ============================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h Mon Jul 22 21:12:48 2024 (r21255) +++ trunk/OpenMPT/mptrack/Mainfrm.h Mon Jul 22 22:52:42 2024 (r21256) @@ -144,7 +144,7 @@ // Globals static OptionsPage m_nLastOptionsPage; - static HHOOK ghKbdHook; + static HHOOK ghKbdHook, g_focusHook; // GDI static HICON m_hIcon; @@ -264,6 +264,7 @@ static HFONT &GetCommentsFont() { return m_hFixedFont; } static void UpdateAllViews(UpdateHint hint, CObject *pHint=NULL); static LRESULT CALLBACK KeyboardProc(int code, WPARAM wParam, LPARAM lParam); + static LRESULT CALLBACK FocusChangeProc(int code, WPARAM wParam, LPARAM lParam); static CInputHandler *m_InputHandler; // Misc functions Modified: trunk/OpenMPT/mptrack/View_ins.cpp ============================================================================== --- trunk/OpenMPT/mptrack/View_ins.cpp Mon Jul 22 21:12:48 2024 (r21255) +++ trunk/OpenMPT/mptrack/View_ins.cpp Mon Jul 22 22:52:42 2024 (r21256) @@ -238,7 +238,7 @@ void CViewInstrument::OnSetFocus(CWnd *pOldWnd) { - CScrollView::OnSetFocus(pOldWnd); + CModScrollView::OnSetFocus(pOldWnd); SetCurrentInstrument(m_nInstrument, m_nEnv); } Modified: trunk/OpenMPT/mptrack/View_pat.cpp ============================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp Mon Jul 22 21:12:48 2024 (r21255) +++ trunk/OpenMPT/mptrack/View_pat.cpp Mon Jul 22 22:52:42 2024 (r21256) @@ -768,7 +768,7 @@ void CViewPattern::OnSetFocus(CWnd *pOldWnd) { - CScrollView::OnSetFocus(pOldWnd); + CModScrollView::OnSetFocus(pOldWnd); m_Status.set(psFocussed); InvalidateRow(); CModDoc *pModDoc = GetDocument(); @@ -3266,7 +3266,7 @@ void CViewPattern::OnSwitchToOrderList() { - PostCtrlMessage(CTRLMSG_SETFOCUS); + PostCtrlMessage(CTRLMSG_PAT_SETORDERLISTFOCUS); } Modified: trunk/OpenMPT/mptrack/View_smp.cpp ============================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp Mon Jul 22 21:12:48 2024 (r21255) +++ trunk/OpenMPT/mptrack/View_smp.cpp Mon Jul 22 22:52:42 2024 (r21256) @@ -448,7 +448,7 @@ void CViewSample::OnSetFocus(CWnd *pOldWnd) { - CScrollView::OnSetFocus(pOldWnd); + CModScrollView::OnSetFocus(pOldWnd); SetCurrentSample(m_nSample); } @@ -764,15 +764,6 @@ GetDocument()->GetSampleUndo().PrepareUndo(m_nSample, sundo_none, "Edit OPL Patch"); break; - case VIEWMSG_SETFOCUS: - case VIEWMSG_SETACTIVE: - GetParentFrame()->SetActiveView(this); - if(IsOPLInstrument() && m_oplEditor) - m_oplEditor->SetFocus(); - else - SetFocus(); - break; - default: return CModScrollView::OnModViewMsg(wParam, lParam); } Modified: trunk/OpenMPT/mptrack/WindowMessages.h ============================================================================== --- trunk/OpenMPT/mptrack/WindowMessages.h Mon Jul 22 21:12:48 2024 (r21255) +++ trunk/OpenMPT/mptrack/WindowMessages.h Mon Jul 22 22:52:42 2024 (r21256) @@ -70,6 +70,7 @@ CTRLMSG_PAT_LOOP, CTRLMSG_PAT_NEWPATTERN, CTRLMSG_PAT_SETSEQUENCE, + CTRLMSG_PAT_SETORDERLISTFOCUS, CTRLMSG_GETCURRENTINSTRUMENT, CTRLMSG_SETCURRENTINSTRUMENT, CTRLMSG_SETSPACING, Modified: trunk/OpenMPT/mptrack/mptrack.rc ============================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc Mon Jul 22 21:12:48 2024 (r21255) +++ trunk/OpenMPT/mptrack/mptrack.rc Mon Jul 22 22:52:42 2024 (r21256) @@ -1567,7 +1567,7 @@ BEGIN CONTROL "Toolbar1",IDC_TOOLBAR1,"ToolbarWindow32",WS_GROUP | WS_TABSTOP | 0x4d,4,5,92,19 EDITTEXT IDC_EDIT_INSTRUMENT,97,7,33,12,ES_AUTOHSCROLL | ES_NUMBER - CONTROL "Spin1",IDC_SPIN_INSTRUMENT,"msctls_updown32",UDS_WRAP | UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | WS_TABSTOP,121,8,11,11 + CONTROL "Spin1",IDC_SPIN_INSTRUMENT,"msctls_updown32",UDS_WRAP | UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,121,8,11,11 EDITTEXT IDC_SAMPLE_NAME,141,7,151,12,ES_AUTOHSCROLL CTEXT "File",IDC_STATIC,299,7,35,12,SS_CENTERIMAGE,WS_EX_STATICEDGE EDITTEXT IDC_SAMPLE_FILENAME,334,7,105,12,ES_AUTOHSCROLL Modified: trunk/OpenMPT/mptrack/view_com.cpp ============================================================================== --- trunk/OpenMPT/mptrack/view_com.cpp Mon Jul 22 21:12:48 2024 (r21255) +++ trunk/OpenMPT/mptrack/view_com.cpp Mon Jul 22 22:52:42 2024 (r21256) @@ -127,9 +127,9 @@ } } GetClientRect(&rect); - m_ToolBar.Create(WS_CHILD|WS_VISIBLE|CCS_NOPARENTALIGN, rect, this, IDC_TOOLBAR_DETAILS); + m_ToolBar.Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP | CCS_NOPARENTALIGN, rect, this, IDC_TOOLBAR_DETAILS); m_ToolBar.Init(CMainFrame::GetMainFrame()->m_MiscIcons, CMainFrame::GetMainFrame()->m_MiscIconsDisabled); - m_ItemList.Create(WS_CHILD | WS_VISIBLE | LVS_REPORT | LVS_SINGLESEL | LVS_EDITLABELS | LVS_NOSORTHEADER, rect, this, IDC_LIST_DETAILS); + m_ItemList.Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP | LVS_REPORT | LVS_SINGLESEL | LVS_EDITLABELS | LVS_NOSORTHEADER, rect, this, IDC_LIST_DETAILS); m_ItemList.ModifyStyleEx(0, WS_EX_STATICEDGE); // Add ToolBar Buttons |