From 1a55a65e21380bb04800762b29d62938f1cd3c39 Mon Sep 17 00:00:00 2001 From: Flaviu_ <37621568+flaviu22@users.noreply.github.com> Date: Mon, 25 Sep 2023 17:10:52 +0300 Subject: [PATCH] Small code changes for CMDIChildWnd handling (#2043) --- Src/Common/MDITabBar.cpp | 3 ++- Src/MainFrm.cpp | 10 +++++----- Src/MainFrm.h | 2 +- Src/WindowsManagerDialog.cpp | 14 +++++++------- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Src/Common/MDITabBar.cpp b/Src/Common/MDITabBar.cpp index a98039e5f77..4275d409817 100644 --- a/Src/Common/MDITabBar.cpp +++ b/Src/Common/MDITabBar.cpp @@ -184,7 +184,8 @@ void CMDITabBar::OnContextMenu(CWnd *pWnd, CPoint point) CPoint ptClient = point; ScreenToClient(&ptClient); int index = GetItemIndexFromPoint(ptClient); - if (index < 0) return; + if (index < 0) + return; TCITEM tci; tci.mask = TCIF_PARAM; diff --git a/Src/MainFrm.cpp b/Src/MainFrm.cpp index a747592457c..d5358d30d27 100644 --- a/Src/MainFrm.cpp +++ b/Src/MainFrm.cpp @@ -2167,13 +2167,13 @@ BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) // Check if we got 'ESC pressed' -message if ((pMsg->message == WM_KEYDOWN) && (pMsg->wParam == VK_ESCAPE)) { - int nEscCloses = GetOptionsMgr()->GetInt(OPT_CLOSE_WITH_ESC); - if ((theApp.m_bEscShutdown || nEscCloses == 3) && m_wndTabBar.GetItemCount() <= 1) + const int nEscCloses = GetOptionsMgr()->GetInt(OPT_CLOSE_WITH_ESC); + if ((theApp.m_bEscShutdown || 3 == nEscCloses) && m_wndTabBar.GetItemCount() <= 1) { AfxGetMainWnd()->SendMessage(WM_COMMAND, ID_APP_EXIT); return TRUE; } - else if (nEscCloses == 1 && m_wndTabBar.GetItemCount() == 0) + else if (1 == nEscCloses && 0 == m_wndTabBar.GetItemCount()) { AfxGetMainWnd()->PostMessage(WM_COMMAND, ID_APP_EXIT); return FALSE; @@ -3503,7 +3503,7 @@ LRESULT CMainFrame::OnChildFrameAdded(WPARAM wParam, LPARAM lParam) } } - m_arrChild.InsertAt(0, (CMDIChildWnd*)lParam); + m_arrChild.InsertAt(0, reinterpret_cast(lParam)); return 1; } @@ -3550,7 +3550,7 @@ LRESULT CMainFrame::OnChildFrameActivated(WPARAM wParam, LPARAM lParam) } } - m_arrChild.InsertAt(0, (CMDIChildWnd*)lParam); + m_arrChild.InsertAt(0, reinterpret_cast(lParam)); return 1; } diff --git a/Src/MainFrm.h b/Src/MainFrm.h index 1ba8ac32820..081c2e4f17b 100644 --- a/Src/MainFrm.h +++ b/Src/MainFrm.h @@ -216,7 +216,7 @@ class CMainFrame : public CMDIFrameWnd const std::vector& events, bool addAllMenu, unsigned baseId); static String GetPluginPipelineByMenuId(unsigned idSearch, const std::vector& events, unsigned baseId); DropHandler *GetDropHandler() const { return m_pDropHandler; } - const CTypedPtrArray* GetChildArray() const { return &m_arrChild; } + const CTypedPtrArray& GetChildArray() const { return m_arrChild; } IMergeDoc* GetActiveIMergeDoc(); DirWatcher* GetDirWatcher() { return m_pDirWatcher.get(); } void WatchDocuments(IMergeDoc* pMergeDoc); diff --git a/Src/WindowsManagerDialog.cpp b/Src/WindowsManagerDialog.cpp index b88ea1935b3..9932fdd72d6 100644 --- a/Src/WindowsManagerDialog.cpp +++ b/Src/WindowsManagerDialog.cpp @@ -112,25 +112,25 @@ void CWindowsManagerDialog::PopulateList() m_List.DeleteAllItems(); CString sText; - const CTypedPtrArray* pArrChild = m_pFrame->GetChildArray(); - for (int i = 0; i < pArrChild->GetSize(); ++i) + const CTypedPtrArray& arrChild = m_pFrame->GetChildArray(); + for (int i = 0; i < arrChild.GetSize(); ++i) { sText.Empty(); - HICON hIcon = pArrChild->GetAt(i)->GetIcon(FALSE); + HICON hIcon = arrChild.GetAt(i)->GetIcon(FALSE); if (NULL == hIcon) { - hIcon = pArrChild->GetAt(i)->GetIcon(TRUE); + hIcon = arrChild.GetAt(i)->GetIcon(TRUE); if (NULL == hIcon) hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } m_pIL->Add(hIcon); - const CDocument* pDoc = pArrChild->GetAt(i)->GetActiveDocument(); + const CDocument* pDoc = arrChild.GetAt(i)->GetActiveDocument(); if (nullptr != pDoc) sText = pDoc->GetPathName(); if (sText.IsEmpty()) - pArrChild->GetAt(i)->GetWindowText(sText); + arrChild.GetAt(i)->GetWindowText(sText); m_List.InsertItem(i, sText, m_pIL->GetImageCount() - 1); - m_List.SetItemData(i, reinterpret_cast(pArrChild->GetAt(i))); + m_List.SetItemData(i, reinterpret_cast(arrChild.GetAt(i))); } } // adjust size to listctrl column and dialog