⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 提醒程序.cpp

📁 介绍一下这个程序的功能: 1
💻 CPP
📖 第 1 页 / 共 5 页
字号:
MessageBox (hwnd,"输入错误!", "宇光提醒程序", MB_OK | MB_ICONEXCLAMATION);
		  return TRUE;
}
		mrdstx1[i].hour=atoi(hou);
		mrdstx1[i].minute=atoi(min);
		strcpy(mrdstx1[i].note,not);
		if(i==0)               //没有找到文件的情况
		{
			fp=fopen("mrdstx.qyg","wb");
wsprintf(all,"%d时%d分,%s",mrdstx1[i].hour,mrdstx1[i].minute,mrdstx1[i].note);
          SendDlgItemMessage(hwnd,IDC_LIST1,LB_ADDSTRING,0,(LPARAM)all);
        SendDlgItemMessage(hwnd,IDC_LIST1,LB_SETCURSEL,i,0) ;              //加密
mrdstx1[i].hour=~mrdstx1[i].hour;
mrdstx1[i].minute=~mrdstx1[i].minute;
for(int v=0;v<101;v++)
	 {if(not[v]=='\0')
	   break;
	 else 
not[v]=~not[v];
	 }
for(;v<20;v++)
	 {
not[v]='\0';
	 }
		strcpy(mrdstx1[i].note,not);
           fwrite(&mrdstx1[i],sizeof(mrdstx),1,fp);             //写入记录            //还原
mrdstx1[i].hour=~mrdstx1[i].hour;
mrdstx1[i].minute=~mrdstx1[i].minute;
for(v=0;v<101;v++)
	 {if(not[v]=='\0')
	   break;
	 else 
not[v]=~not[v];
	 }
for(;v<20;v++)
	 {
not[v]='\0';
	 }
		strcpy(mrdstx1[i].note,not);         
		  i++;countmrdstx++;
          fwrite(&i,sizeof(int),1,fp);             
          fclose(fp);open=2;
		  return TRUE;
		}
		if(i!=0)                          //i不等于0说明存在文件
		  {
			  fp=fopen("mrdstx.qyg","ab");
wsprintf(all,"%d时%d分,%s",mrdstx1[i].hour,mrdstx1[i].minute,mrdstx1[i].note);
          SendDlgItemMessage(hwnd,IDC_LIST1,LB_ADDSTRING,0,(LPARAM)all);
        SendDlgItemMessage(hwnd,IDC_LIST1,LB_SETCURSEL,i,0) ;
mrdstx1[i].hour=~mrdstx1[i].hour;
mrdstx1[i].minute=~mrdstx1[i].minute;
for(int v=0;v<101;v++)
	 {if(not[v]=='\0')
	   break;
	 else 
not[v]=~not[v];
	 }
for(;v<20;v++)
	 {
not[v]='\0';
	 }
		strcpy(mrdstx1[i].note,not);
           fwrite(&mrdstx1[i],sizeof(mrdstx),1,fp);
mrdstx1[i].hour=~mrdstx1[i].hour;
mrdstx1[i].minute=~mrdstx1[i].minute;
for(v=0;v<101;v++)                      //还原
	 {if(not[v]=='\0')
	   break;
	 else 
not[v]=~not[v];
	 }
for(;v<20;v++)
	 {
not[v]='\0';
	 }
		strcpy(mrdstx1[i].note,not);
		  i++;countmrdstx++;
          fwrite(&i,sizeof(int),1,fp);
          fclose(fp);	  
		  return TRUE;
		  }
		}
		if(i>99)
		{MessageBox (hwnd,"对不起,记录已到100条,不能再添加了,请删除过期提醒然后重试!", "宇光提醒程序", MB_OK | MB_ICONEXCLAMATION);
		}
			  } 
		default:
		return FALSE;
	}	
		return FALSE;
} 
LRESULT CALLBACK mzdstxproc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)//每周定时提醒消息处理
{
	char hou[3]="\0",min[3]="\0",not[101]="\0";
	char all[151],inttoa[11];
	static char *p[]={"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
	static open=1,k,j,candel=1,wday=1,checkwday,choosewday=1,l;
	FILE *fp;
	time_t now;
	tm then;
SendDlgItemMessage(hwnd,IDC_EDIT1,EM_LIMITTEXT,2,0);
SendDlgItemMessage(hwnd,IDC_EDIT2,EM_LIMITTEXT,2,0);
SendDlgItemMessage(hwnd,IDC_EDIT3,EM_LIMITTEXT,100,0);  
	switch (msg)
	{
case WM_INITDIALOG://初始化对话框
SendDlgItemMessage(hwnd,IDC_COMBO2,CB_ADDSTRING,0,(LPARAM)"星期日");
			 SendDlgItemMessage(hwnd,IDC_COMBO2,CB_ADDSTRING,0,(LPARAM)"星期一");
			 SendDlgItemMessage(hwnd,IDC_COMBO2,CB_ADDSTRING,0,(LPARAM)"星期二");
			 SendDlgItemMessage(hwnd,IDC_COMBO2,CB_ADDSTRING,0,(LPARAM)"星期三");
			 SendDlgItemMessage(hwnd,IDC_COMBO2,CB_ADDSTRING,0,(LPARAM)"星期四");
			 SendDlgItemMessage(hwnd,IDC_COMBO2,CB_ADDSTRING,0,(LPARAM)"星期五");
			 SendDlgItemMessage(hwnd,IDC_COMBO2,CB_ADDSTRING,0,(LPARAM)"星期六");
			 SendDlgItemMessage(hwnd,IDC_COMBO2,CB_SETCURSEL, 0, 0) ;                       //查看
						time(&now);
		then=*localtime(&now);
				SetDlgItemText (hwnd,IDC_EDIT1,itoa(then.tm_hour,inttoa,10));
			    SetDlgItemText (hwnd,IDC_EDIT2,itoa(then.tm_min,inttoa,10));
			    SetDlgItemText (hwnd,IDC_EDIT3,"\0");	
			 if(open==1)
						{
			  if(fp=fopen("mzdstx.qyg","rb"))//读入文件
			  {	
 				  fseek(fp,-4L,2);
           fread(&i,sizeof(int),1,fp);
		   rewind(fp);
		   for(j=0;j<i;j++)
		   {	
		fread(&mzdstx1[j],sizeof(mzdstx),1,fp);
		mzdstx1[j].weekday=~mzdstx1[j].weekday;
mzdstx1[j].hour=~mzdstx1[j].hour;
mzdstx1[j].minute=~mzdstx1[j].minute;
		strcpy(not,mzdstx1[j].note);
for(int v=0;v<101;v++)
	 {if(not[v]=='\0')
	   break;
	 else 
not[v]=~not[v];
	 }
for(;v<20;v++)
	 {
not[v]='\0';
	 }
		strcpy(mzdstx1[j].note,not);
				  fseek(fp,4L,1);
		wsprintf(all,"%s%d时%d分,%s",p[mzdstx1[j].weekday],mzdstx1[j].hour,mzdstx1[j].minute,mzdstx1[j].note);
        SendDlgItemMessage(hwnd,IDC_LIST1,LB_ADDSTRING,0,(LPARAM)all);
		   }open=2;
	fclose(fp);
			  }	
			  else {i=0;}
			  return TRUE;
						}
						else 
			  return TRUE;
	case WM_COMMAND:
if (LOWORD(wParam)==IDC_LIST1&&HIWORD (wParam) == LBN_SELCHANGE)              //列表框消息 
		{
k = SendDlgItemMessage(hwnd,IDC_LIST1, LB_GETCURSEL, 0, 0) ;
				  SetDlgItemText (hwnd,IDC_EDIT1,itoa(mzdstx1[k].hour,inttoa,10));//显示内容
				  SetDlgItemText (hwnd,IDC_EDIT2,itoa(mzdstx1[k].minute,inttoa,10));
				  SetDlgItemText (hwnd,IDC_EDIT3,mzdstx1[k].note);
				  SendDlgItemMessage(hwnd,IDC_COMBO2, CB_SETCURSEL, mzdstx1[k].weekday, 0) ;
				  candel=2;

return TRUE;
		}
if (LOWORD(wParam)==IDC_COMBO2&&HIWORD (wParam) == CBN_SELCHANGE)                             //下拉列表框消息
		{
l = SendDlgItemMessage(hwnd,IDC_COMBO2, CB_GETCURSEL, 0, 0) ;//出来时显示星期日
				  checkwday=l;				  
				  choosewday=2;
return TRUE;
		}

		switch(LOWORD(wParam))
		{
			case IDCANCEL:
				EndDialog(hwnd, LOWORD(wParam));
			return TRUE;
		case IDGBMZDS:                                       //关闭
			  EndDialog(hwnd, TRUE);open=1;candel=1;
			  return TRUE;
      case IDQKMZDS:                                                     //清空
                  SetDlgItemText (hwnd,IDC_EDIT2,"\0");
		          SetDlgItemText (hwnd,IDC_EDIT3,"\0");
				  SetDlgItemText (hwnd,IDC_EDIT1,"\0");
                  SendDlgItemMessage(hwnd,IDC_COMBO2, CB_SETCURSEL, 0, 0) ;
			  return TRUE;
      case IDSCMZDS:                                                 //删除
		  if(i==0)
		  {MessageBox (hwnd,"没有记录!", "宇光提醒程序",
			MB_OK | MB_ICONEXCLAMATION);			  return TRUE;
		  }
if(candel==1&&(i!=0))
	{
	MessageBox (hwnd,"请点击要删除的记录先!", "宇光提醒程序",
			MB_OK | MB_ICONEXCLAMATION);			  return TRUE;
	}
if(candel==8)
	{
	MessageBox (hwnd,"没有记录了,不能删除!", "宇光提醒程序",
			MB_OK | MB_ICONEXCLAMATION);			  return TRUE;
	}
	if(open!=1&&candel==2)
	{
		  if(IDOK==MessageBox (hwnd,"确定要删除吗?", "宇光提醒程序", MB_OKCANCEL | MB_ICONEXCLAMATION|MB_DEFBUTTON2))
		  {

              k = SendDlgItemMessage(hwnd,IDC_LIST1, LB_GETCURSEL, 0, 0) ;
        SendDlgItemMessage(hwnd,IDC_LIST1,LB_DELETESTRING,k,wParam);
		        SendDlgItemMessage(hwnd,IDC_LIST1,LB_SETCURSEL,k-1,0);
                SetDlgItemText (hwnd,IDC_EDIT2,"\0");
		          SetDlgItemText (hwnd,IDC_EDIT3,"\0");
				  SetDlgItemText (hwnd,IDC_EDIT1,"\0");
				  SendDlgItemMessage(hwnd,IDC_COMBO2, CB_SETCURSEL, 0, 0) ;
			  for(j=k;j<i;j++)                                     //后面的向前串
			  {         
				 mzdstx1[j].weekday=mzdstx1[j+1].weekday;
				 mzdstx1[j].hour=mzdstx1[j+1].hour;
				 mzdstx1[j].minute=mzdstx1[j+1].minute;
				 strcpy(mzdstx1[j].note,mzdstx1[j+1].note);
			  }
			  i--; countmzdstx--;
			  fp=fopen("mzdstx.qyg","wb");
			  for(j=1;j<i+1;j++)                                 //重写文件
			  {                               //加密
mzdstx1[j-1].weekday=~mzdstx1[j-1].weekday;
mzdstx1[j-1].hour=~mzdstx1[j-1].hour;
mzdstx1[j-1].minute=~mzdstx1[j-1].minute;
	strcpy(not,mzdstx1[j-1].note);
for(int v=0;v<101;v++)
	 {if(not[v]=='\0')
	   break;
	 else 
not[v]=~not[v];
	 }
for(;v<20;v++)
	 {
not[v]='\0';
	 }
		strcpy(mzdstx1[j-1].note,not);
           fwrite(&mzdstx1[j-1],sizeof(mzdstx),1,fp);
          fwrite(&j,sizeof(int),1,fp);                               //还原
mzdstx1[j-1].weekday=~mzdstx1[j-1].weekday;
mzdstx1[j-1].hour=~mzdstx1[j-1].hour;
mzdstx1[j-1].minute=~mzdstx1[j-1].minute;
		strcpy(not,mzdstx1[j-1].note);
for(v=0;v<101;v++)
	 {if(not[v]=='\0')
	   break;
	 else 
not[v]=~not[v];
	 }
for(;v<20;v++)
	 {
not[v]='\0';
	 }
		strcpy(mzdstx1[j-1].note,not);
			  } fclose(fp);if(i==0){DeleteFile("mzdstx.qyg");candel=8;}
		  }
			  return TRUE;
	}
	
		case IDXGMZDS:                                //修改
			if(i==0)
		  {MessageBox (hwnd,"没有记录!", "宇光提醒程序",
			MB_OK | MB_ICONEXCLAMATION);			  return TRUE;
		  }
if(candel==1&&(i!=0))
	{
	MessageBox (hwnd,"请点击要修改的记录先!", "宇光提醒程序",
			MB_OK | MB_ICONEXCLAMATION);			  return TRUE;
	}
if(open!=1&&candel==2)
	{
	GetDlgItemText(hwnd,IDC_EDIT1,hou,3);   //取得编辑框中的文本
			GetDlgItemText(hwnd,IDC_EDIT2,min,3);
			GetDlgItemText(hwnd,IDC_EDIT3,not,101);    
	if(
   (!strcmp(hou,"\0"))||(!strcmp(min,"\0"))
   ||(atoi(hou)>23)||(atoi(hou)<0)                   //判断输入是否错误
   ||(atoi(min)<0)||(atoi(min)>59)
     )
{
MessageBox (hwnd,"输入错误!", "宇光提醒程序", MB_OK | MB_ICONEXCLAMATION);
		  return TRUE;
}  
	if(choosewday==1)
{
MessageBox (hwnd,"请选择星期几!", "宇光提醒程序", MB_OK | MB_ICONEXCLAMATION);
		  return TRUE;
}
		  if(IDOK==MessageBox (hwnd,"确定要修改吗?", "宇光提醒程序", MB_OKCANCEL | MB_ICONEXCLAMATION|MB_DEFBUTTON2))
		  {			           
        mzdstx1[k].weekday=checkwday;//在这修改
		mzdstx1[k].hour=atoi(hou);
	mzdstx1[k].minute=atoi(min);
		strcpy(mzdstx1[k].note,not);
        SendDlgItemMessage(hwnd,IDC_LIST1,LB_DELETESTRING,k,wParam);             //修改列表框
 wsprintf(all,"%s%d时%d分,%s",p[checkwday],mzdstx1[k].hour,mzdstx1[k].minute,mzdstx1[k].note);
        SendDlgItemMessage(hwnd,IDC_LIST1, LB_INSERTSTRING, k, (LPARAM)all);
        SendDlgItemMessage(hwnd,IDC_LIST1,LB_SETCURSEL,k,0) ;
fp=fopen("mzdstx.qyg","wb");
			  for(j=1;j<i+1;j++)
			  {                  //加密
mzdstx1[j-1].weekday=~mzdstx1[j-1].weekday;
mzdstx1[j-1].hour=~mzdstx1[j-1].hour;
mzdstx1[j-1].minute=~mzdstx1[j-1].minute;
		strcpy(not,mzdstx1[j-1].note);
for(int v=0;v<101;v++)
	 {if(not[v]=='\0')
	   break;
	 else 
not[v]=~not[v];
	 }
for(;v<20;v++)
	 {
not[v]='\0';
	 }
		strcpy(mzdstx1[j-1].note,not);
           fwrite(&mzdstx1[j-1],sizeof(mzdstx),1,fp);           //重写文件
          fwrite(&j,sizeof(int),1,fp);                  //还原
mzdstx1[j-1].weekday=~mzdstx1[j-1].weekday;
mzdstx1[j-1].hour=~mzdstx1[j-1].hour;
mzdstx1[j-1].minute=~mzdstx1[j-1].minute;
for(v=0;v<101;v++)
	 {if(not[v]=='\0')
	   break;
	 else 
not[v]=~not[v];
	 }
for(;v<20;v++)
	 {
not[v]='\0';
	 }
		strcpy(mzdstx1[j-1].note,not);
			  } fclose(fp);
}
		  return TRUE;
	}
		case IDTJMZDS:                                    //添加
          if(open==1)
		  {	
			  if(fp=fopen("mzdstx.qyg","rb"))
			  {
				  fseek(fp,-4L,2);
           fread(&i,sizeof(int),1,fp);
		   rewind(fp);
		   for(int j=0;j<i;j++)
		   {	
		fread(&mzdstx1[j],sizeof(mzdstx),1,fp);
mzdstx1[j].weekday=~mzdstx1[j].weekday;//解密
mzdstx1[j].hour=~mzdstx1[j].hour;
mzdstx1[j].minute=~mzdstx1[j].minute;
		strcpy(not,mzdstx1[j].note);
for(int v=0;v<101;v++)
	 {if(not[v]=='\0')
	   break;
	 else 
not[v]=~not[v];
	 }
for(;v<20;v++)
	 {
not[v]='\0';
	 }
		strcpy(mzdstx1[j].note,not);
				  fseek(fp,4L,1);
		wsprintf(all,"%s%d时%d分,%s",p[mzdstx1[j].weekday],
mzdstx1[j].hour,mzdstx1[j].minute,mzdstx1[j].note);
        SendDlgItemMessage(hwnd,IDC_LIST1,LB_ADDSTRING,0,(LPARAM)all);	
		   }
	fclose(fp);open=2;
			  }	
			  else i=0;
		  }
		  if(i>99)
		{
			MessageBox (hwnd,"对不起,记录已到100条,不能再添加了,请删除过期提醒然后重试!",
				"宇光提醒程序", MB_OK | MB_ICONEXCLAMATION);
		  return TRUE;
		}
		  if(i<100)
		  {
			GetDlgItemText(hwnd,IDC_EDIT1,hou,3);
			GetDlgItemText(hwnd,IDC_EDIT2,min,3);
			GetDlgItemText(hwnd,IDC_EDIT3,not,101);
if(
   (!strcmp(hou,"\0"))||(!strcmp(min,"\0"))
   ||(atoi(hou)>23)||(atoi(hou)<0)
   ||(atoi(min)<0)||(atoi(min)>59)
   )
{
MessageBox (hwnd,"输入错误!", "宇光提醒程序", MB_OK | MB_ICONEXCLAMATION);
		  return TRUE;
}
if(choosewday==1)//没有点击下拉列表框
{
MessageBox (hwnd,"请选择星期几!", "宇光提醒程序", MB_OK | MB_ICONEXCLAMATION);
		  return TRUE;
}
        mzdstx1[i]

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -