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

📄 提醒程序.cpp

📁 介绍一下这个程序的功能: 1
💻 CPP
📖 第 1 页 / 共 5 页
字号:
not[v]='\0';
	 }
		strcpy(jnrtx1[j-1].note,not);
			  } fclose(fp);
}
		  return TRUE;
	}
		case IDTJJNR:                                    //添加
          if(open==1)//如果没有打开文件,则打开文件
		  {	
			  if(fp=fopen("jnrtx.qyg","rb"))
			  {
				  fseek(fp,-4L,2);
           fread(&i,sizeof(int),1,fp);
		   rewind(fp);
		   for(int j=0;j<i;j++)
		   {	
		fread(&jnrtx1[j],sizeof(jnrtx),1,fp);
jnrtx1[j].month=~jnrtx1[j].month;
jnrtx1[j].day=~jnrtx1[j].day;
		strcpy(not,jnrtx1[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(jnrtx1[j].note,not);
				  fseek(fp,4L,1);
		wsprintf(all,"%d月%d日,%s",jnrtx1[j].month,jnrtx1[j].day,jnrtx1[j].note);
        SendDlgItemMessage(hwnd,IDC_LIST2,LB_ADDSTRING,0,(LPARAM)all);	
		   }
	fclose(fp);open=2;//OPEN=2说明已经打开文件
			  }	
			  else i=0;
		  } 
		  if(i<100)//100条已内时
		  {
			GetDlgItemText(hwnd,IDC_EDIT1,mon,3);
			GetDlgItemText(hwnd,IDC_EDIT2,day,3);
			GetDlgItemText(hwnd,IDC_EDIT3,not,101);
if(
   (!strcmp(mon,"\0"))||(!strcmp(day,"\0"))
   ||(atoi(mon)>12)
   ||(atoi(mon)<1)
   ||(atoi(day)>31)||(atoi(day)<1) 
   )
{
MessageBox (hwnd,"输入错误!", "宇光提醒程序", MB_OK | MB_ICONEXCLAMATION);
		  return TRUE;
}
		jnrtx1[i].month=atoi(mon);
		jnrtx1[i].day=atoi(day);
		strcpy(jnrtx1[i].note,not);
		if(i==0)               //没有找到文件的情况
		{
			fp=fopen("jnrtx.qyg","wb");
wsprintf(all,"%d月%d日,%s",jnrtx1[i].month,jnrtx1[i].day,jnrtx1[i].note);
          SendDlgItemMessage(hwnd,IDC_LIST2,LB_ADDSTRING,0,(LPARAM)all);
        SendDlgItemMessage(hwnd,IDC_LIST2,LB_SETCURSEL,i,0) ;
jnrtx1[i].month=~jnrtx1[i].month;                 //加密
jnrtx1[i].day=~jnrtx1[i].day;
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(jnrtx1[i].note,not);
           fwrite(&jnrtx1[i],sizeof(jnrtx),1,fp);             //写入记录
	jnrtx1[i].month=~jnrtx1[i].month;              //还原
jnrtx1[i].day=~jnrtx1[i].day;
for(v=0;v<101;v++)
	 {if(not[v]=='\0')
	   break;
	 else 
not[v]=~not[v];
	 }
for(;v<20;v++)
	 {
not[v]='\0';
	 }
		strcpy(jnrtx1[i].note,not);         
		  i++;countjnrtx++;
          fwrite(&i,sizeof(int),1,fp);             
          fclose(fp);open=2;
		  return TRUE;
		}
		if(i!=0)                          //i不等于0说明存在文件
		  {
			  fp=fopen("jnrtx.qyg","ab");
wsprintf(all,"%d月%d日,%s",jnrtx1[i].month,jnrtx1[i].day,jnrtx1[i].note);
          SendDlgItemMessage(hwnd,IDC_LIST2,LB_ADDSTRING,0,(LPARAM)all);
        SendDlgItemMessage(hwnd,IDC_LIST2,LB_SETCURSEL,i,0) ;
jnrtx1[i].month=~jnrtx1[i].month;         //加密
jnrtx1[i].day=~jnrtx1[i].day;
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(jnrtx1[i].note,not);
           fwrite(&jnrtx1[i],sizeof(jnrtx),1,fp);
          jnrtx1[i].month=~jnrtx1[i].month;
jnrtx1[i].day=~jnrtx1[i].day;
for(v=0;v<101;v++)                      //还原
	 {if(not[v]=='\0')
	   break;
	 else 
not[v]=~not[v];
	 }
for(;v<20;v++)
	 {
not[v]='\0';
	 }
		strcpy(jnrtx1[i].note,not);
		  i++;countjnrtx++;
          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 mrdstxproc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)//每日定时提醒消息处理
{
	char hou[3]="\0",min[3]="\0",not[101]="\0";
	char all[151],inttoa[11];
	static open=1,k,j,candel=1;
	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:              //查看
				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("mrdstx.qyg","rb"))
			  {
				  fseek(fp,-4L,2);
           fread(&i,sizeof(int),1,fp);
		   rewind(fp);
		   for(j=0;j<i;j++)
		   {	
		fread(&mrdstx1[j],sizeof(mrdstx),1,fp);
mrdstx1[j].hour=~mrdstx1[j].hour;//解密
mrdstx1[j].minute=~mrdstx1[j].minute;
		strcpy(not,mrdstx1[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(mrdstx1[j].note,not);
				  fseek(fp,4L,1);
		wsprintf(all,"%d时%d分,%s",mrdstx1[j].hour,mrdstx1[j].minute,mrdstx1[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 (HIWORD (wParam) == LBN_SELCHANGE)
		{
k = SendDlgItemMessage(hwnd,IDC_LIST1, LB_GETCURSEL, 0, 0) ;
				  SetDlgItemText (hwnd,IDC_EDIT1,itoa(mrdstx1[k].hour,inttoa,10));//显示内容
				  SetDlgItemText (hwnd,IDC_EDIT2,itoa(mrdstx1[k].minute,inttoa,10));
				  SetDlgItemText (hwnd,IDC_EDIT3,mrdstx1[k].note);
				  candel=2;
return TRUE;
		}
		switch(LOWORD(wParam))
		{
			case IDCANCEL:
				EndDialog(hwnd, LOWORD(wParam));
			return TRUE;
		case IDGBMRDS:                                       //关闭
			  EndDialog(hwnd, TRUE);open=1;candel=1;
			  return TRUE;
      case IDQKMRDS:                                                     //清空
                  SetDlgItemText (hwnd,IDC_EDIT2,"\0");
		          SetDlgItemText (hwnd,IDC_EDIT3,"\0");
				  SetDlgItemText (hwnd,IDC_EDIT1,"\0");
			  return TRUE;
      case IDSCMRDS:                                                 //删除
		  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");
			  for(j=k;j<i;j++)                                     //后面的向前串
			  {         
				 mrdstx1[j].hour=mrdstx1[j+1].hour;
				 mrdstx1[j].minute=mrdstx1[j+1].minute;
				 strcpy(mrdstx1[j].note,mrdstx1[j+1].note);
			  }
			  i--; countmrdstx--;
			  fp=fopen("mrdstx.qyg","wb");
			  for(j=1;j<i+1;j++)                                 //重写文件
			  {                               //加密
mrdstx1[j-1].hour=~mrdstx1[j-1].hour;
mrdstx1[j-1].minute=~mrdstx1[j-1].minute;
	strcpy(not,mrdstx1[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(mrdstx1[j-1].note,not);
           fwrite(&mrdstx1[j-1],sizeof(mrdstx),1,fp);
          fwrite(&j,sizeof(int),1,fp);                               //还原
mrdstx1[j-1].hour=~mrdstx1[j-1].hour;
mrdstx1[j-1].minute=~mrdstx1[j-1].minute;
		strcpy(not,mrdstx1[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(mrdstx1[j-1].note,not);
			  } fclose(fp);if(i==0){DeleteFile("mrdstx.qyg");candel=8;}
		  }
			  return TRUE;
	}
	
		case IDXGMRDS:                                //修改
			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(IDOK==MessageBox (hwnd,"确定要修改吗?", "宇光提醒程序", MB_OKCANCEL | MB_ICONEXCLAMATION|MB_DEFBUTTON2))
		  {
			
		mrdstx1[k].hour=atoi(hou);//在这修改
	mrdstx1[k].minute=atoi(min);
		strcpy(mrdstx1[k].note,not);
        SendDlgItemMessage(hwnd,IDC_LIST1,LB_DELETESTRING,k,wParam);             //修改列表框
 wsprintf(all,"%d时%d分,%s",mrdstx1[k].hour,mrdstx1[k].minute,mrdstx1[k].note);
        SendDlgItemMessage(hwnd,IDC_LIST1, LB_INSERTSTRING, k, (LPARAM)all);
        SendDlgItemMessage(hwnd,IDC_LIST1,LB_SETCURSEL,k,0) ;
fp=fopen("mrdstx.qyg","wb");
			  for(j=1;j<i+1;j++)
			  {                  //加密
mrdstx1[j-1].hour=~mrdstx1[j-1].hour;
mrdstx1[j-1].minute=~mrdstx1[j-1].minute;
		strcpy(not,mrdstx1[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(mrdstx1[j-1].note,not);
           fwrite(&mrdstx1[j-1],sizeof(mrdstx),1,fp);           //重写文件
          fwrite(&j,sizeof(int),1,fp);                  //还原
mrdstx1[j-1].hour=~mrdstx1[j-1].hour;
mrdstx1[j-1].minute=~mrdstx1[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(mrdstx1[j-1].note,not);
			  } fclose(fp);
}
		  return TRUE;
	}
		case IDTJMRDS:                                    //添加
          if(open==1)
		  {	
			  if(fp=fopen("mrdstx.qyg","rb"))
			  {
				  fseek(fp,-4L,2);
           fread(&i,sizeof(int),1,fp);
		   rewind(fp);
		   for(int j=0;j<i;j++)
		   {	
		fread(&mrdstx1[j],sizeof(mrdstx),1,fp);
mrdstx1[j].hour=~mrdstx1[j].hour;
mrdstx1[j].minute=~mrdstx1[j].minute;
		strcpy(not,mrdstx1[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(mrdstx1[j].note,not);
				  fseek(fp,4L,1);
		wsprintf(all,"%d时%d分,%s",mrdstx1[j].hour,mrdstx1[j].minute,mrdstx1[j].note);
        SendDlgItemMessage(hwnd,IDC_LIST1,LB_ADDSTRING,0,(LPARAM)all);	
		   }
	fclose(fp);open=2;
			  }	
			  else i=0;
		  } 
		  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)
   )
{

⌨️ 快捷键说明

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