提交 | 用户 | age
|
0ed438
|
1 |
|
Q |
2 |
#include "pch.h"
|
|
3 |
#include "framework.h"
|
|
4 |
|
|
5 |
#include "OutputWnd.h"
|
|
6 |
#include "Resource.h"
|
|
7 |
#include "MainFrm.h"
|
|
8 |
|
|
9 |
#ifdef _DEBUG
|
|
10 |
#define new DEBUG_NEW
|
|
11 |
#undef THIS_FILE
|
|
12 |
static char THIS_FILE[] = __FILE__;
|
|
13 |
#endif
|
|
14 |
|
|
15 |
/////////////////////////////////////////////////////////////////////////////
|
|
16 |
// COutputBar
|
|
17 |
|
|
18 |
COutputWnd::COutputWnd() noexcept
|
|
19 |
{
|
|
20 |
}
|
|
21 |
|
|
22 |
COutputWnd::~COutputWnd()
|
|
23 |
{
|
|
24 |
}
|
|
25 |
|
|
26 |
BEGIN_MESSAGE_MAP(COutputWnd, CDockablePane)
|
|
27 |
ON_WM_CREATE()
|
|
28 |
ON_WM_SIZE()
|
|
29 |
END_MESSAGE_MAP()
|
|
30 |
|
|
31 |
int COutputWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
|
32 |
{
|
|
33 |
if (CDockablePane::OnCreate(lpCreateStruct) == -1)
|
|
34 |
return -1;
|
|
35 |
|
|
36 |
CRect rectDummy;
|
|
37 |
rectDummy.SetRectEmpty();
|
|
38 |
|
|
39 |
// 创建选项卡窗口:
|
|
40 |
if (!m_wndTabs.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, 1))
|
|
41 |
{
|
|
42 |
TRACE0("未能创建输出选项卡窗口\n");
|
|
43 |
return -1; // 未能创建
|
|
44 |
}
|
|
45 |
|
|
46 |
// 创建输出窗格:
|
|
47 |
const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL;
|
|
48 |
|
|
49 |
if (!m_wndOutputBuild.Create(dwStyle, rectDummy, &m_wndTabs, 2) ||
|
|
50 |
!m_wndOutputDebug.Create(dwStyle, rectDummy, &m_wndTabs, 3) ||
|
|
51 |
!m_wndOutputFind.Create(dwStyle, rectDummy, &m_wndTabs, 4))
|
|
52 |
{
|
|
53 |
TRACE0("未能创建输出窗口\n");
|
|
54 |
return -1; // 未能创建
|
|
55 |
}
|
|
56 |
|
|
57 |
UpdateFonts();
|
|
58 |
|
|
59 |
CString strTabName;
|
|
60 |
BOOL bNameValid;
|
|
61 |
|
|
62 |
// 将列表窗口附加到选项卡:
|
|
63 |
bNameValid = strTabName.LoadString(IDS_BUILD_TAB);
|
|
64 |
ASSERT(bNameValid);
|
|
65 |
m_wndTabs.AddTab(&m_wndOutputBuild, strTabName, (UINT)0);
|
|
66 |
bNameValid = strTabName.LoadString(IDS_DEBUG_TAB);
|
|
67 |
ASSERT(bNameValid);
|
|
68 |
m_wndTabs.AddTab(&m_wndOutputDebug, strTabName, (UINT)1);
|
|
69 |
bNameValid = strTabName.LoadString(IDS_FIND_TAB);
|
|
70 |
ASSERT(bNameValid);
|
|
71 |
m_wndTabs.AddTab(&m_wndOutputFind, strTabName, (UINT)2);
|
|
72 |
|
|
73 |
// 使用一些虚拟文本填写输出选项卡(无需复杂数据)
|
|
74 |
FillBuildWindow();
|
|
75 |
FillDebugWindow();
|
|
76 |
FillFindWindow();
|
|
77 |
|
|
78 |
return 0;
|
|
79 |
}
|
|
80 |
|
|
81 |
void COutputWnd::OnSize(UINT nType, int cx, int cy)
|
|
82 |
{
|
|
83 |
CDockablePane::OnSize(nType, cx, cy);
|
|
84 |
|
|
85 |
// 选项卡控件应覆盖整个工作区:
|
|
86 |
m_wndTabs.SetWindowPos (nullptr, -1, -1, cx, cy, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
|
|
87 |
}
|
|
88 |
|
|
89 |
void COutputWnd::AdjustHorzScroll(CListBox& wndListBox)
|
|
90 |
{
|
|
91 |
CClientDC dc(this);
|
|
92 |
CFont* pOldFont = dc.SelectObject(&afxGlobalData.fontRegular);
|
|
93 |
|
|
94 |
int cxExtentMax = 0;
|
|
95 |
|
|
96 |
for (int i = 0; i < wndListBox.GetCount(); i ++)
|
|
97 |
{
|
|
98 |
CString strItem;
|
|
99 |
wndListBox.GetText(i, strItem);
|
|
100 |
|
|
101 |
cxExtentMax = max(cxExtentMax, (int)dc.GetTextExtent(strItem).cx);
|
|
102 |
}
|
|
103 |
|
|
104 |
wndListBox.SetHorizontalExtent(cxExtentMax);
|
|
105 |
dc.SelectObject(pOldFont);
|
|
106 |
}
|
|
107 |
|
|
108 |
void COutputWnd::FillBuildWindow()
|
|
109 |
{
|
|
110 |
m_wndOutputBuild.AddString(_T("生成输出正显示在此处。"));
|
|
111 |
m_wndOutputBuild.AddString(_T("输出正显示在列表视图的行中"));
|
|
112 |
m_wndOutputBuild.AddString(_T("但您可以根据需要更改其显示方式..."));
|
|
113 |
}
|
|
114 |
|
|
115 |
void COutputWnd::FillDebugWindow()
|
|
116 |
{
|
|
117 |
m_wndOutputDebug.AddString(_T("调试输出正显示在此处。"));
|
|
118 |
m_wndOutputDebug.AddString(_T("输出正显示在列表视图的行中"));
|
|
119 |
m_wndOutputDebug.AddString(_T("但您可以根据需要更改其显示方式..."));
|
|
120 |
}
|
|
121 |
|
|
122 |
void COutputWnd::FillFindWindow()
|
|
123 |
{
|
|
124 |
m_wndOutputFind.AddString(_T("查找输出正显示在此处。"));
|
|
125 |
m_wndOutputFind.AddString(_T("输出正显示在列表视图的行中"));
|
|
126 |
m_wndOutputFind.AddString(_T("但您可以根据需要更改其显示方式..."));
|
|
127 |
}
|
|
128 |
|
|
129 |
void COutputWnd::UpdateFonts()
|
|
130 |
{
|
|
131 |
m_wndOutputBuild.SetFont(&afxGlobalData.fontRegular);
|
|
132 |
m_wndOutputDebug.SetFont(&afxGlobalData.fontRegular);
|
|
133 |
m_wndOutputFind.SetFont(&afxGlobalData.fontRegular);
|
|
134 |
}
|
|
135 |
|
|
136 |
/////////////////////////////////////////////////////////////////////////////
|
|
137 |
// COutputList1
|
|
138 |
|
|
139 |
COutputList::COutputList() noexcept
|
|
140 |
{
|
|
141 |
}
|
|
142 |
|
|
143 |
COutputList::~COutputList()
|
|
144 |
{
|
|
145 |
}
|
|
146 |
|
|
147 |
BEGIN_MESSAGE_MAP(COutputList, CListBox)
|
|
148 |
ON_WM_CONTEXTMENU()
|
|
149 |
ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
|
|
150 |
ON_COMMAND(ID_EDIT_CLEAR, OnEditClear)
|
|
151 |
ON_COMMAND(ID_VIEW_OUTPUTWND, OnViewOutput)
|
|
152 |
ON_WM_WINDOWPOSCHANGING()
|
|
153 |
END_MESSAGE_MAP()
|
|
154 |
/////////////////////////////////////////////////////////////////////////////
|
|
155 |
// COutputList 消息处理程序
|
|
156 |
|
|
157 |
void COutputList::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
|
|
158 |
{
|
|
159 |
CMenu menu;
|
|
160 |
menu.LoadMenu(IDR_OUTPUT_POPUP);
|
|
161 |
|
|
162 |
CMenu* pSumMenu = menu.GetSubMenu(0);
|
|
163 |
|
|
164 |
if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx)))
|
|
165 |
{
|
|
166 |
CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu;
|
|
167 |
|
|
168 |
if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE))
|
|
169 |
return;
|
|
170 |
|
|
171 |
((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu);
|
|
172 |
UpdateDialogControls(this, FALSE);
|
|
173 |
}
|
|
174 |
|
|
175 |
SetFocus();
|
|
176 |
}
|
|
177 |
|
|
178 |
void COutputList::OnEditCopy()
|
|
179 |
{
|
|
180 |
MessageBox(_T("复制输出"));
|
|
181 |
}
|
|
182 |
|
|
183 |
void COutputList::OnEditClear()
|
|
184 |
{
|
|
185 |
MessageBox(_T("清除输出"));
|
|
186 |
}
|
|
187 |
|
|
188 |
void COutputList::OnViewOutput()
|
|
189 |
{
|
|
190 |
CDockablePane* pParentBar = DYNAMIC_DOWNCAST(CDockablePane, GetOwner());
|
|
191 |
CMDIFrameWndEx* pMainFrame = DYNAMIC_DOWNCAST(CMDIFrameWndEx, GetTopLevelFrame());
|
|
192 |
|
|
193 |
if (pMainFrame != nullptr && pParentBar != nullptr)
|
|
194 |
{
|
|
195 |
pMainFrame->SetFocus();
|
|
196 |
pMainFrame->ShowPane(pParentBar, FALSE, FALSE, FALSE);
|
|
197 |
pMainFrame->RecalcLayout();
|
|
198 |
|
|
199 |
}
|
|
200 |
}
|