-
Notifications
You must be signed in to change notification settings - Fork 1
/
ExtMemoryInfoDlg.cpp
163 lines (116 loc) · 4.04 KB
/
ExtMemoryInfoDlg.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
// ExtMemoryInfoDlg.cpp : implementation file
//
#include "stdafx.h"
#include "CPUBench2004.h"
#include "ExtMemoryInfoDlg.h"
#include "itembkdrawer.h"
#include "memoryinfo.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CExtMemoryInfoDlg dialog
CExtMemoryInfoDlg::CExtMemoryInfoDlg(CWnd* pParent /*=NULL*/)
: CDialog(CExtMemoryInfoDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CExtMemoryInfoDlg)
m_memLoadVal = _T("");
m_pageFreeVal = _T("");
m_ramFreeVal = _T("");
m_userFreeVal = _T("");
m_pageSize = _T("");
m_physMem = _T("");
m_virtualSize = _T("");
//}}AFX_DATA_INIT
}
void CExtMemoryInfoDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CExtMemoryInfoDlg)
DDX_Control(pDX, IDC_USERFREE, m_userFree);
DDX_Control(pDX, IDC_TOTALLOAD, m_totalLoad);
DDX_Control(pDX, IDC_RAMFREE, m_ramFree);
DDX_Control(pDX, IDC_PAGEFILEFREE, m_pageFileFree);
DDX_Text(pDX, IDC_MEMLOAD, m_memLoadVal);
DDX_Text(pDX, IDC_PAGEFREE, m_pageFreeVal);
DDX_Text(pDX, IDC_RAMFREEPERCENT, m_ramFreeVal);
DDX_Text(pDX, IDC_USERFREEPERCENT, m_userFreeVal);
DDX_Text(pDX, IDC_PAGESIZE, m_pageSize);
DDX_Text(pDX, IDC_PHYSMEM, m_physMem);
DDX_Text(pDX, IDC_VIRTUALSIZE, m_virtualSize);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CExtMemoryInfoDlg, CDialog)
//{{AFX_MSG_MAP(CExtMemoryInfoDlg)
ON_WM_ERASEBKGND()
ON_WM_CTLCOLOR()
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CExtMemoryInfoDlg message handlers
BOOL CExtMemoryInfoDlg::OnEraseBkgnd(CDC* pDC)
{
return TRUE;
}
HBRUSH CExtMemoryInfoDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(nCtlColor == CTLCOLOR_STATIC){
pDC->SetBkMode(TRANSPARENT);
//pDC->SetTextColor(RGB(0,0x74,0xDC));
return (HBRUSH)GetStockObject(NULL_BRUSH);
}
return hbr;
}
BOOL CExtMemoryInfoDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CMemoryInfo memInfo;
m_userFree.SetRange(0,100);
m_ramFree.SetRange(0,100);
m_totalLoad.SetRange(0,100);
m_pageFileFree.SetRange(0,100);
m_ramFree.SetAlertPos(30);
m_totalLoad.SetAlertPos(80,FALSE);
m_userFree.SetPos(12);
m_ramFree.SetPos(memInfo.GetRAMAvailablePercent());
m_totalLoad.SetPos(memInfo.GetMemLoadPercent());
m_pageFileFree.SetPos(memInfo.GetPageFileAvailablePercent());
m_userFree.SetPos(memInfo.GetVirtualAvailablePercent());
m_memLoadVal.Format("%d%c",memInfo.GetMemLoadPercent(),'%');
m_pageFreeVal.Format("%d%c",memInfo.GetPageFileAvailablePercent(),'%');
m_ramFreeVal=memInfo.GetRAMAvailable();
m_userFreeVal.Format("%d%c",memInfo.GetVirtualAvailablePercent(),'%');
m_pageSize=memInfo.GetPageFileSize();
m_physMem=memInfo.GetRAMSize();
m_virtualSize=memInfo.GetVirtualSize();
UpdateData(FALSE);
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CExtMemoryInfoDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect r;
GetClientRect(&r);
CItemBkDrawer::DrawBk(&dc,&r);
// Do not call CDialog::OnPaint() for painting messages
}
void CExtMemoryInfoDlg::Update(){
CMemoryInfo memInfo;
m_ramFree.SetPos(memInfo.GetRAMAvailablePercent());
m_totalLoad.SetPos(memInfo.GetMemLoadPercent());
m_pageFileFree.SetPos(memInfo.GetPageFileAvailablePercent());
m_userFree.SetPos(memInfo.GetVirtualAvailablePercent());
m_memLoadVal.Format("%d%c",memInfo.GetMemLoadPercent(),'%');
m_pageFreeVal.Format("%d%c",memInfo.GetPageFileAvailablePercent(),'%');
m_ramFreeVal=memInfo.GetRAMAvailable();
m_userFreeVal.Format("%d%c",memInfo.GetVirtualAvailablePercent(),'%');
m_pageSize=memInfo.GetPageFileSize();
UpdateData(FALSE);
Invalidate();
}