日程备忘录实习报告.docx
- 文档编号:6054526
- 上传时间:2023-01-03
- 格式:DOCX
- 页数:13
- 大小:38.62KB
日程备忘录实习报告.docx
《日程备忘录实习报告.docx》由会员分享,可在线阅读,更多相关《日程备忘录实习报告.docx(13页珍藏版)》请在冰豆网上搜索。
日程备忘录实习报告
一、实验名称
日程管理系统。
二、实验目的
1.掌握类和对象的使用;
2.掌握定时器等的使用。
三、实验要求
开发一个日程管理程序,程序提供添加日程任务功能,如几点几分要做某事,当机器时间到此时刻后系统会弹出该日程提示。
可查看添加过的所有任务,系统可最小化到任务栏。
四、实验步骤
1.题目分析
开发一个日程备忘录程序,有添加日程事务及时间功能,按添加键可将添加事务在列表中显示以备查看,到所定时间会有窗口提示用户,也可最小化到任务栏。
2.构造界面
3.关键类和函数设计
4.编译、调试并运行
五、实验数据及处理结果
1.程序功能介绍
a.添加日程事务;
b.日程提醒;
c.查看日程事务;
d.最小化到托盘;
e.超链接XX。
2.关键代码
//CRichengDlgdialog
CRichengDlg:
:
CRichengDlg(CWnd*pParent/*=NULL*/)
:
CDialog(CRichengDlg:
:
IDD,pParent)
{
//{{AFX_DATA_INIT(CRichengDlg)
m_date=0;//初始化数据
m_time=0;
m_event=_T("");
//}}AFX_DATA_INIT
//NotethatLoadIcondoesnotrequireasubsequentDestroyIconinWin32
m_hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
voidCRichengDlg:
:
DoDataExchange(CDataExchange*pDX)
{
CDialog:
:
DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRichengDlg)
DDX_Control(pDX,IDC_STATIC1,m_num);
DDX_Control(pDX,IDC_LIST1,m_listc);
DDX_DateTimeCtrl(pDX,IDC_DATETIMEPICKER1,m_date);
DDX_DateTimeCtrl(pDX,IDC_DATETIMEPICKER2,m_time);
DDX_Text(pDX,IDC_EDIT1,m_event);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CRichengDlg,CDialog)
//{{AFX_MSG_MAP(CRichengDlg)
ON_WM_SYSCOMMAND()//消息映射定义
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1,Ontianjia)
ON_NOTIFY(NM_CLICK,IDC_LIST1,OnClickList1)
ON_MESSAGE(WM_NC,OnNotifyIcon)
ON_WM_TIMER()
ON_NOTIFY(NM_RCLICK,IDC_LIST1,OnRclickList1)
ON_COMMAND(IDS_menu,Onmenu)
ON_BN_CLICKED(IDC_STATIC2,Onlink)
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//CRichengDlgmessagehandlers
BOOLCRichengDlg:
:
OnInitDialog()
{
CDialog:
:
OnInitDialog();
num=0;//列表初始化
CStringmm;
mm.Format("共有记录%d条",num);
m_num.SetWindowText(mm);
DWORDdwStyle;
dwStyle=m_listc.GetStyle();
dwStyle|=LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT|LVS_SHOWSELALWAYS;
m_listc.SetExtendedStyle(dwStyle);
m_listc.SetBkColor(RGB(234,234,234));
m_listc.SetTextBkColor(RGB(221,221,221));
m_listc.InsertColumn(0,"时间",LVCFMT_LEFT,168);
m_listc.InsertColumn(1,"待办事务",LVCFMT_LEFT,237);
num=0;
SetTimer(1,1000,NULL);//设定计时器
//Add"About..."menuitemtosystemmenu.
//IDM_ABOUTBOXmustbeinthesystemcommandrange.
ASSERT((IDM_ABOUTBOX&0xFFF0)==IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX<0xF000);
CMenu*pSysMenu=GetSystemMenu(FALSE);
if(pSysMenu!
=NULL)
{
CStringstrAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if(!
strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING,IDM_ABOUTBOX,strAboutMenu);
}
}
//Settheiconforthisdialog.Theframeworkdoesthisautomatically
//whentheapplication'smainwindowisnotadialog
SetIcon(m_hIcon,TRUE);//Setbigicon
SetIcon(m_hIcon,FALSE);//Setsmallicon
//TODO:
Addextrainitializationhere
returnTRUE;//returnTRUEunlessyousetthefocustoacontrol
}
voidCRichengDlg:
:
OnSysCommand(UINTnID,LPARAMlParam)
{
if((nID&0xFFF0)==IDM_ABOUTBOX)
{
CAboutDlgdlgAbout;
dlgAbout.DoModal();
}
elseif((nID&0xFFF0)==SC_MINIMIZE)
{
toTray();//放入托盘的函数
}
else
{
CDialog:
:
OnSysCommand(nID,lParam);
}
}
//Ifyouaddaminimizebuttontoyourdialog,youwillneedthecodebelow
//todrawtheicon.ForMFCapplicationsusingthedocument/viewmodel,
//thisisautomaticallydoneforyoubytheframework.
voidCRichengDlg:
:
OnPaint()
{
if(IsIconic())
{
CPaintDCdc(this);//devicecontextforpainting
SendMessage(WM_ICONERASEBKGND,(WPARAM)dc.GetSafeHdc(),0);
//Centericoninclientrectangle
intcxIcon=GetSystemMetrics(SM_CXICON);
intcyIcon=GetSystemMetrics(SM_CYICON);
CRectrect;
GetClientRect(&rect);
intx=(rect.Width()-cxIcon+1)/2;
inty=(rect.Height()-cyIcon+1)/2;
//Drawtheicon
dc.DrawIcon(x,y,m_hIcon);
}
else
{
CRectrect;
CPaintDCdc(this);
GetClientRect(rect);
dc.FillSolidRect(rect,RGB(222,247,252));//设置背景颜色
CDialog:
:
OnPaint();
}
}
//Thesystemcallsthistoobtainthecursortodisplaywhiletheuserdrags
//theminimizedwindow.
HCURSORCRichengDlg:
:
OnQueryDragIcon()
{
return(HCURSOR)m_hIcon;
}
voidCRichengDlg:
:
Ontianjia()//添加按钮功能实现
{
UpdateData(TRUE);//数据导入
CStringdate,time;
GetDlgItem(IDC_DATETIMEPICKER1)->GetWindowText(date);//获取日期
GetDlgItem(IDC_DATETIMEPICKER2)->GetWindowText(time);//获取时间
m_listc.InsertItem(num,date+""+time);
m_listc.SetItemText(num,1,m_event);//日期时间事务在列表中显示
num++;
//TODO:
Addyourcontrolnotificationhandlercodehere
}
voidCRichengDlg:
:
OnClickList1(NMHDR*pNMHDR,LRESULT*pResult)
{
//TODO:
Addyourcontrolnotificationhandlercodehere
LPNMITEMACTIVATEpNMItemActivate=reinterpret_cast
if(pNMItemActivate->iItem!
=-1)
choose=pNMItemActivate->iItem;
*pResult=0;
}
BOOLCRichengDlg:
:
OnNotify(WPARAMwParam,LPARAMlParam,LRESULT*pResult)
{
//TODO:
Addyourspecializedcodehereand/orcallthebaseclass
returnCDialog:
:
OnNotify(wParam,lParam,pResult);
}
voidCRichengDlg:
:
OnNotifyIcon(WPARAMwParam,LPARAMIParam)
{
if(IParam==WM_LBUTTONUP)
{
//左键单击弹出主界面
ModifyStyleEx(0,WS_EX_TOPMOST);
ShowWindow(SW_SHOW);
}
elseif(IParam==WM_RBUTTONDOWN)
{
//右键单击弹出主菜单
}
}
voidCRichengDlg:
:
toTray()
{
m_NotifyIcon.cbSize=sizeof(NOTIFYICONDATA);
m_NotifyIcon.hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);//装载程序图标
m_NotifyIcon.hWnd=m_hWnd;
lstrcpy(m_NotifyIcon.szTip,"beskitv1.0");//这里是鼠标移到托盘图标时的提示信息
m_NotifyIcon.uCallbackMessage=WM_NC;
m_NotifyIcon.uFlags=NIF_ICON|NIF_MESSAGE|NIF_TIP;
Shell_NotifyIcon(NIM_ADD,&m_NotifyIcon);//添加托盘图标
ShowWindow(SW_HIDE);//隐藏主窗口
}
voidCRichengDlg:
:
OnTimer(UINTnIDEvent)//响应定时器
{
//TODO:
Addyourmessagehandlercodehereand/orcalldefault
CStringmm;
mm.Format("共有记录%d条",num);
m_num.SetWindowText(mm);
inti,j,k;
SYSTEMTIMEtime;
CStringtemp;
CStringtemp_1;
GetLocalTime(&time);
temp.Format("%d年%d月%d日%d:
%d:
%d",time.wYear,time.wMonth,time.wDay,time.wHour,time.wMinute,time.wSecond);
k=0;
for(i=0;i { CStringtemp_2; temp_1=m_listc.GetItemText(i,0); temp_2+=temp_1.GetAt(0); for(j=1;j { if(j { if(temp_1.GetAt(j)=='0'&&(temp_1.GetAt(j+2)==': '||temp_1.GetAt(j-1)==': ')) j++; } else if(temp_1.GetAt(j)=='0'&&temp_1.GetAt(j-1)==': ') j++; charcheck[20]; if(j+k { intk; for(k=0;k<4;k++) check[k]=temp_1.GetAt(j+k); check[k]='\0'; if(strcmp(check,"星期")==0) j+=6; } //if(strcmp(check,"星期")! =0) temp_2+=temp_1.GetAt(j); } if(temp_2==temp) { CStringa; a=m_listc.GetItemText(i,1); m_listc.DeleteItem(i); num--; PlaySound(MAKEINTRESOURCE(IDR_WAVE1),AfxGetResourceHandle(),SND_ASYNC|SND_RESOURCE|SND_NODEFAULT);//设置提醒音乐 MessageBox(a);//设置提醒窗口 } } CDialog: : OnTimer(nIDEvent); } voidCRichengDlg: : OnRclickList1(NMHDR*pNMHDR,LRESULT*pResult) { //TODO: Addyourcontrolnotificationhandlercodehere LPNMITEMACTIVATEpNMItemActivate=reinterpret_cast if(pNMItemActivate->iItem! =-1) { choose=pNMItemActivate->iItem; CPointpt; CMenumenu; : : GetCursorPos(&pt); menu.CreatePopupMenu(); menu.AppendMenu(MF_STRING,IDS_menu,"删除记录");//删除记录 menu.TrackPopupMenu(TPM_LEFTALIGN,pt.x,pt.y,this); menu.DestroyMenu(); } *pResult=0; } voidCRichengDlg: : Onmenu(UINT) { m_listc.DeleteItem(choose); num--; } voidCRichengDlg: : Onlink() { //TODO: Addyourcontrolnotificationhandlercodehere ShellExecute(NULL,NULL,_T(""),NULL,NULL,SW_SHOWNORMAL); } HBRUSHCRichengDlg: : OnCtlColor(CDC*pDC,CWnd*pWnd,UINTnCtlColor) //颜色设定 { HBRUSHhbr=CDialog: : OnCtlColor(pDC,pWnd,nCtlColor); switch(nCtlColor) { caseCTLCOLOR_STATIC: //静态文本 { pDC->SetBkMode(TRANSPARENT); HBRUSHB=CreateSolidBrush(RGB(222,247,252));//控件背景颜色 pDC->SetTextColor(RGB(51,51,255));//控件中的文字颜色 return(HBRUSH)B; } caseCTLCOLOR_LISTBOX: //列表框 { pDC->SetBkMode(TRANSPARENT); HBRUSHB=CreateSolidBrush(RGB(234,234,234)); pDC->SetTextColor(RGB(255,0,0)); return(HBRUSH)B; } caseCTLCOLOR_DLG: //对话框 { pDC->SetBkMode(TRANSPARENT); HBRUSHB=CreateSolidBrush(RGB(222,247,252)); pDC->SetTextColor(RGB(255,0,0)); return(HBRUSH)B; } caseCTLCOLOR_EDIT: //文本编辑框 { pDC->SetBkMode(TRANSPARENT); HBRUSHB=CreateSolidBrush(RGB(255,255,255)); pDC->SetTextColor(RGB(8,8,8)); return(HBRUSH)B; } default: { pDC->SetBkMode(TRANSPARENT); HBRUSHB=CreateSolidBrush(RGB(222,247,252)); pDC->SetTextColor(RGB(255,0,0)); return(HBRUSH)B; } } returnhbr; //TODO: ChangeanyattributesoftheDChere //TODO: Returnadifferentbrushifthedefaultisnotdesired } 3.用户操作方法 a.输入您要添加的事务; b.输入事务提醒的时间; c.点击添加按钮,即已添加事务; d.左键点击需要删除的事务,右键进行删除操作; e.点击最小化按钮则窗口最小盘到任务栏; f.点击任务栏图标可查看已添加的事务也可再次添加事务; 4.输出结果 操作界面 提示窗口 六、上机心得体会 七、参考资料 1、谭浩强.C++面向对象程序设计题解与上机指导.北京: 清华大学出版社,2006,4. 2、候俊杰.深入浅出MFC.武汉: 华中科技大学出版社,2003,7. 3、VisualC++程序设计基础(第二版): 中国铁道出版社,2007.8
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 日程 备忘录 实习 报告
![提示](https://static.bdocx.com/images/bang_tan.gif)