Skip to content

Commit

Permalink
Small code changes for CMDIChildWnd handling (#2043)
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviu22 authored Sep 25, 2023
1 parent 50a6bc9 commit 1a55a65
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
3 changes: 2 additions & 1 deletion Src/Common/MDITabBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions Src/MainFrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion Src/MainFrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class CMainFrame : public CMDIFrameWnd
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);
Expand Down
14 changes: 7 additions & 7 deletions Src/WindowsManagerDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1a55a65

Please sign in to comment.