Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
新增鼠标提示会实时更新;优化关于启动时弹出“已经有一个程序正在运行”的处理;增加无法嵌入任务栏时自动重试的处理;历史流量统计对话框中增加图…
…形指示;
- Loading branch information
1 parent
1a9716d
commit 63b17ec
Showing
19 changed files
with
1,107 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#include "stdafx.h" | ||
#include "ListCtrlEx.h" | ||
|
||
IMPLEMENT_DYNAMIC(CListCtrlEx, CListCtrl) | ||
|
||
CListCtrlEx::CListCtrlEx() | ||
{ | ||
} | ||
|
||
|
||
CListCtrlEx::~CListCtrlEx() | ||
{ | ||
} | ||
void CListCtrlEx::SetDrawItemRangeData(int item, double range, COLORREF color) | ||
{ | ||
if (item < 0) return; | ||
if (item >= m_item_rage_data.size()) | ||
m_item_rage_data.resize(item + 1); | ||
m_item_rage_data[item].data_value = range; | ||
m_item_rage_data[item].color = color; | ||
} | ||
|
||
void CListCtrlEx::SetDrawItemRangInLogScale(bool log_scale) | ||
{ | ||
m_use_log_scale = log_scale; | ||
Invalidate(); | ||
} | ||
|
||
BEGIN_MESSAGE_MAP(CListCtrlEx, CListCtrl) | ||
ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, &CListCtrlEx::OnNMCustomdraw) | ||
END_MESSAGE_MAP() | ||
|
||
|
||
void CListCtrlEx::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult) | ||
{ | ||
if (m_draw_item_range) | ||
{ | ||
*pResult = CDRF_DODEFAULT; | ||
LPNMLVCUSTOMDRAW lplvdr = reinterpret_cast<LPNMLVCUSTOMDRAW>(pNMHDR); | ||
NMCUSTOMDRAW& nmcd = lplvdr->nmcd; | ||
switch (lplvdr->nmcd.dwDrawStage) //判断状态 | ||
{ | ||
case CDDS_PREPAINT: | ||
*pResult = CDRF_NOTIFYITEMDRAW; | ||
break; | ||
case CDDS_ITEMPREPAINT: //如果为画ITEM之前就要进行颜色的改变 | ||
if (nmcd.dwItemSpec >= 0 && nmcd.dwItemSpec < m_item_rage_data.size()) | ||
{ | ||
double range = m_item_rage_data[nmcd.dwItemSpec].data_value; | ||
CDC* pDC = CDC::FromHandle(nmcd.hdc); //获取绘图DC | ||
CRect item_rect, draw_rect; | ||
GetSubItemRect(nmcd.dwItemSpec,m_draw_item_range_row, LVIR_BOUNDS, item_rect); //获取绘图单元格的矩形区域 | ||
CCommon::SetDrawArea(pDC, item_rect); //设置绘图区域为当前列 | ||
draw_rect = item_rect; | ||
if (draw_rect.Height() > 2 * m_margin) | ||
{ | ||
draw_rect.top += m_margin; | ||
draw_rect.bottom -= m_margin; | ||
} | ||
int width; | ||
if (m_use_log_scale) //使用对数比例(y=ln(x+1)) | ||
{ | ||
range = std::log(range + 1); | ||
width = static_cast<int>(range*draw_rect.Width() / std::log(1000 + 1)); | ||
} | ||
else //使用线性比例(y=x) | ||
{ | ||
width = static_cast<int>(range*draw_rect.Width() / 1000); | ||
} | ||
draw_rect.right = draw_rect.left + width; | ||
pDC->FillSolidRect(draw_rect, m_item_rage_data[nmcd.dwItemSpec].color); | ||
|
||
//当前列绘制完成后将绘图区域设置为左边的区域,防止当前列的区域被覆盖 | ||
CRect rect1{ item_rect }; | ||
rect1.left = 0; | ||
rect1.right = item_rect.left; | ||
CCommon::SetDrawArea(pDC, rect1); | ||
} | ||
*pResult = CDRF_DODEFAULT; | ||
break; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#pragma once | ||
#include "afxcmn.h" | ||
#include "Common.h" | ||
class CListCtrlEx : | ||
public CListCtrl | ||
{ | ||
DECLARE_DYNAMIC(CListCtrlEx) | ||
public: | ||
CListCtrlEx(); | ||
~CListCtrlEx(); | ||
|
||
void EnableDrawItemRange(bool draw = true) { m_draw_item_range = draw; } //设置是否要在某一列单元格中绘制表示数值大小的矩形 | ||
void SetDrawItemRangeRow(int row) { m_draw_item_range_row = row; } //设置要绘制表示数值大小的矩形的列,注意此列必须为最右边的列,否则,此列右边的所有列将无法显示 | ||
void SetDrawItemRangeData(int item, double range, COLORREF color); //设置某一行的项目数据大小(取值为1~1000)和颜色 | ||
void SetDrawItemRangMargin(int margin) { m_margin = margin; } //设置绘制绘制的矩形的边缘到单元格边框的矩形,此值越大则绘制的矩形越细,但是不能超过列表行距的一半 | ||
void SetDrawItemRangInLogScale(bool log_scale); //设置要绘制表示数值大小的矩形时是否使用对数比例,否则使用线性比例 | ||
|
||
protected: | ||
struct ItemData | ||
{ | ||
double data_value; //要绘制的矩形表示的数值大小,范围为0~1000 | ||
COLORREF color; //要绘制的矩形的颜色 | ||
}; | ||
bool m_draw_item_range{ false }; //是否需要在某一列单元格中绘制表示数值大小的矩形 | ||
int m_draw_item_range_row{}; //需要绘制表示数值大小的矩形的列 | ||
int m_margin{}; | ||
vector<ItemData> m_item_rage_data; //用于表示每一项需要绘制的数据大小和绘图的颜色 | ||
bool m_use_log_scale{ false }; //如果为true则使用对数比例绘制矩形,否则使用线性比例 | ||
|
||
DECLARE_MESSAGE_MAP() | ||
afx_msg void OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult); | ||
}; | ||
|
Oops, something went wrong.