📄 notificationdlg.cpp
字号:
// NotificationDlg.cpp : implementation file
//
#include "stdafx.h"
#include "MoneyAnyWhere.h"
#include "NotificationDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CNotificationDlg dialog
CNotificationDlg::CNotificationDlg(CWnd* pParent /*=NULL*/)
: CDialog(CNotificationDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CNotificationDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CNotificationDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CNotificationDlg)
DDX_Control(pDX, IDC_LIST_NOTIFICATION, m_ctrList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CNotificationDlg, CDialog)
//{{AFX_MSG_MAP(CNotificationDlg)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CNotificationDlg message handlers
/*************************************************
函数功能:初始化INI文件
-------------------------------------------------
修改时间:2005-3-10
修改人: 宋雷
修改内容:m_pNotiIni和m_pNotiIni2的初始化,同时将信息增加到列表中
*************************************************/
BOOL CNotificationDlg::Init()
{
m_ctrList.DeleteAllItems();
// m_pNotiIni = new CIniReader(L"\\Program Files\\理财能手\\Data\\帐户.ini");
// m_pNotiIni2 = new CIniReader(L"\\Program Files\\理财能手\\Data\\帐户.ini");
m_pNoteIni = new CIniReader(L"帐户.ini");
m_pNoteIni2 = new CIniReader(L"帐户.ini");
CNote *pNote = new CNote();
//装载和解析INI文件
if(! m_pNoteIni2->Load())
{
::AfxMessageBox(L"Can not load ini");
delete m_pNoteIni2;
m_pNoteIni2 = NULL;
return FALSE;
}
if(! m_pNoteIni2->Parse())
{
::AfxMessageBox(L"Invalid format ");
delete m_pNoteIni2;
m_pNoteIni2 = NULL;
return FALSE;
}
CSection NoteInfo= (*m_pNoteIni2)[L"Info"];
POSITION _pos = NoteInfo.m_item.GetStartPosition();
while( _pos != NULL)
{
String _key;
String _value;
NoteInfo.m_item.GetNextAssoc(_pos, _key, _value);
if((CString)_key==(CString)"note_count") //获得该现金帐户一共有多少笔交易
{
m_iCount = _wtoi(_value);
}
}
//CSection Info[m_iCount];
//装载和解析INI文件
if(! m_pNoteIni->Load())
{
::AfxMessageBox(L"Can not load Note.ini");
delete m_pNoteIni;
m_pNoteIni = NULL;
return FALSE;
}
if(! m_pNoteIni->Parse())
{
::AfxMessageBox(L"Invalid format :Note.ini");
delete m_pNoteIni;
m_pNoteIni = NULL;
return FALSE;
}
//AfxMessageBox(m_pNotiIni->GetFilePath());
for(int i=0;i<m_iCount;i++)
{
CString str;
str.Format(L"%d",i);
CSection Info= (*m_pNoteIni)[str];
m_pCNote[i] = new CNote();
POSITION pos = Info.m_item.GetStartPosition();
while( pos != NULL )
{
String key;
String value;
Info.m_item.GetNextAssoc(pos, key, value);
SetNote(key,value,i);
}
//m_pCNote[i]->time = CTime(m_tmpTime.iYear,m_tmpTime.iMonth,m_tmpTime.iDay,m_tmpTime.iHour,m_tmpTime.iMinute,0);
CString tmp;
//tmp.Format(L"%d-%d-%d",m_pCNote[i]->time.GetYear(),m_pCNote[i]->time.GetMonth(),m_pCNote[i]->time.GetDay());
// m_ctrList.AddItem(m_pCNote[i]->name,tmp,m_pCNote[i]->content);
}
}
BOOL CNotificationDlg::OnInitDialog()
{
CDialog::OnInitDialog();
//改变列表的背景色
m_ctrList.SetBkColor(COLORREF(RGB(251,251,249)));
m_ctrList.SetExtendedStyle(LVS_EX_FULLROWSELECT);//|LVS_EX_GRIDLINES);
//设置表头格式为Note/Name/Date
m_ctrList.SetHeadings(_T("计划名,60;帐户时间,60;计划内容,120"));
//宽度设置
m_ctrList.SetColumnWidth(0,80);
m_ctrList.SetColumnWidth(1,40);
m_ctrList.SetColumnWidth(2,120);
//设置背景色,列向索引/横向索引/字体颜色/字体背景色
m_ctrList.SetItemColor(0,1,RGB(255,0,0),RGB(90,125,90));
if(!Init())
return false;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CNotificationDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rect;
this->GetClientRect(&rect);
CBrush *pBrush = new CBrush(COLORREF(RGB(227,234,206)));
dc.FillRect(rect,pBrush);
dc.SetBkColor(COLORREF(RGB(227,234,206)));
}
void CNotificationDlg::SetNote(CString key, CString value,int i)
{
if(key =="name")
m_pCNote[i]->name = value;
else
if(key=="content")
m_pCNote[i]->content = value;
else
if(key=="date")
SetDate(value);
else
if(key=="time")
SetTime(value);
}
void CNotificationDlg::SetDate(CString value)
{
CString year = value.Mid(0,4);
//AfxMessageBox(year);
CString month = value.Mid(5,2);
CString day = value.Mid(8,2);
m_tmpTime.iYear = _wtoi(year);
m_tmpTime.iMonth= _wtoi(month);
m_tmpTime.iDay = _wtoi(day);
}
void CNotificationDlg::SetTime(CString value)
{
CString hour = value.Mid(0,2);
CString minute = value.Mid(3,2);
m_tmpTime.iHour = _wtoi(hour);
m_tmpTime.iMinute= _wtoi(minute);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -