OSDN Git Service

Small code changes for CMDIChildWnd handling (#2043)
authorFlaviu_ <37621568+flaviu22@users.noreply.github.com>
Mon, 25 Sep 2023 14:10:52 +0000 (17:10 +0300)
committerGitHub <noreply@github.com>
Mon, 25 Sep 2023 14:10:52 +0000 (23:10 +0900)
Src/Common/MDITabBar.cpp
Src/MainFrm.cpp
Src/MainFrm.h
Src/WindowsManagerDialog.cpp

index a98039e..4275d40 100644 (file)
@@ -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;
index a747592..d5358d3 100644 (file)
@@ -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<CMDIChildWnd*>(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<CMDIChildWnd*>(lParam));
 
        return 1;
 }
index 1ba8ac3..081c2e4 100644 (file)
@@ -216,7 +216,7 @@ public:
                const std::vector<std::wstring>& events, bool addAllMenu, unsigned baseId);
        static String GetPluginPipelineByMenuId(unsigned idSearch, const std::vector<std::wstring>& events, unsigned baseId);
        DropHandler *GetDropHandler() const { return m_pDropHandler; }
-       const CTypedPtrArray<CPtrArray, CMDIChildWnd*>* GetChildArray() const { return &m_arrChild; }
+       const CTypedPtrArray<CPtrArray, CMDIChildWnd*>& GetChildArray() const { return m_arrChild; }
        IMergeDoc* GetActiveIMergeDoc();
        DirWatcher* GetDirWatcher() { return m_pDirWatcher.get(); }
        void WatchDocuments(IMergeDoc* pMergeDoc);
index b88ea19..9932fdd 100644 (file)
@@ -112,25 +112,25 @@ void CWindowsManagerDialog::PopulateList()
        m_List.DeleteAllItems();
 
        CString sText;
-       const CTypedPtrArray<CPtrArray, CMDIChildWnd*>* pArrChild = m_pFrame->GetChildArray();
-       for (int i = 0; i < pArrChild->GetSize(); ++i)
+       const CTypedPtrArray<CPtrArray, CMDIChildWnd*>& 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<DWORD_PTR>(pArrChild->GetAt(i)));
+               m_List.SetItemData(i, reinterpret_cast<DWORD_PTR>(arrChild.GetAt(i)));
        }
 }
 // adjust size to listctrl column and dialog