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

📄 qw2.cpp

📁 名片管理程序
💻 CPP
📖 第 1 页 / 共 5 页
字号:
   {wsprintf(addBuffer,"姓名为    %s   的名片将会被删除,确定?",szBuffer);
     if(IDOK==MessageBox (hwnd, addBuffer, "宇光名片管理程序", MB_DEFBUTTON2|MB_OKCANCEL | MB_ICONEXCLAMATION))
	 {
      j = SendMessage (hwndList, LB_GETCURSEL, 0, 0) ;
		   for(;j<i;j++)
		   {
             strcpy(informa[j].name,informa[j+1].name);
             strcpy(informa[j].workplace, informa[j+1].workplace);
             strcpy(informa[j].hometel ,informa[j+1].hometel);
             strcpy(informa[j].worktel, informa[j+1].worktel);
             strcpy(informa[j].freetel ,informa[j+1].freetel);
             strcpy(informa[j].bp ,informa[j+1].bp);
             strcpy(informa[j].fax ,informa[j+1].fax);
             strcpy(informa[j].email, informa[j+1].email);
             strcpy(informa[j].web, informa[j+1].web);
             strcpy(informa[j].oicq, informa[j+1].oicq);
             strcpy(informa[j].workadd ,informa[j+1].workadd);
             strcpy(informa[j].homeadd, informa[j+1].homeadd);
             strcpy(informa[j].post ,informa[j+1].post);
             strcpy(informa[j].worksubstance ,informa[j+1].worksubstance);
             strcpy(informa[j].work, informa[j+1].work);
             strcpy(informa[j].sex ,informa[j+1].sex);
             strcpy(informa[j].age, informa[j+1].age);
             strcpy(informa[j].blood, informa[j+1].blood);
             strcpy(informa[j].year, informa[j+1].year);
             strcpy(informa[j].month, informa[j+1].month);
             strcpy(informa[j].day ,informa[j+1].day);
             strcpy(informa[j].temperament, informa[j+1].temperament);
             strcpy(informa[j].like ,informa[j+1].like);
             strcpy(informa[j].note ,informa[j+1].note);
		   }
	i--;
	//获取当前选中的项的位置值
					k = SendMessage (hwndList, LB_GETCURSEL, 0, 0) ;
					//发送删除消息
					SendMessage(hwndList,LB_DELETESTRING,k,wParam);
					//选中上一个项
					SendMessage (hwndList, LB_SETCURSEL,k-1,0) ;
               SendMessage (hwndList, LB_GETTEXT, k-1,(LPARAM) szBuffer) ;
SetWindowText (hwndedit[0], "\0");
         SetWindowText (hwndedit[1], "\0");
         SetWindowText (hwndedit[2], "\0");
         SetWindowText (hwndedit[3],"\0");
         SetWindowText (hwndedit[4],"\0");
         SetWindowText (hwndedit[5],"\0");
         SetWindowText (hwndedit[6], "\0");//清空编辑区
         SetWindowText (hwndedit[7],"\0");
         SetWindowText (hwndedit[8],"\0");
         SetWindowText (hwndedit[9], "\0");
         SetWindowText (hwndedit[10], "\0");
         SetWindowText (hwndedit[11], "\0");
         SetWindowText (hwndedit[12], "\0");
         SetWindowText (hwndedit[13], "\0");
         SetWindowText (hwndedit[14], "\0");
         SetWindowText (hwndedit[15], "\0");
         SetWindowText (hwndedit[16], "\0");
         SetWindowText (hwndedit[17], "\0");
         SetWindowText (hwndedit[18], "\0");
         SetWindowText (hwndedit[19], "\0");
         SetWindowText (hwndedit[20], "\0");
         SetWindowText (hwndedit[21], "\0");
         SetWindowText (hwndedit[22],"\0");
         SetWindowText (hwndedit[23], "\0");
     delPopFileWrite (i, szFileName);
          SetWindowText (record[1],itoa (i, file, 10));
	 }	 return 0;
   }
else
 return 0;
	 case  92:
if(i!=0)
{wsprintf(addBuffer,"刚才姓名为    %s   的名片将会被修改,确定?",szBuffer);
   if(IDOK==MessageBox (hwnd, addBuffer, "宇光名片管理程序", MB_DEFBUTTON2|MB_OKCANCEL | MB_ICONEXCLAMATION))
   {
     GetWindowText(hwndedit[0],infor.name,21);
     GetWindowText(hwndedit[1],infor.workplace,201);
     GetWindowText(hwndedit[2],infor.hometel,101);
     GetWindowText(hwndedit[3],infor.worktel,101);
     GetWindowText(hwndedit[4],infor.freetel,101);
     GetWindowText(hwndedit[5],infor.bp,101);
     GetWindowText(hwndedit[6],infor.fax,101);
     GetWindowText(hwndedit[7],infor.email,101);
     GetWindowText(hwndedit[8],infor.web,101);
     GetWindowText(hwndedit[9],infor.oicq,101);
     GetWindowText(hwndedit[10],infor.workadd,201);
     GetWindowText(hwndedit[11],infor.homeadd,201);
     GetWindowText(hwndedit[12],infor.post,101);
     GetWindowText(hwndedit[13],infor.worksubstance,101);
     GetWindowText(hwndedit[14],infor.work,101);
     GetWindowText(hwndedit[15],infor.sex,3);
     GetWindowText(hwndedit[16],infor.age,4);
     GetWindowText(hwndedit[17],infor.blood,4);
     GetWindowText(hwndedit[18],infor.year,5);
     GetWindowText(hwndedit[19],infor.month,3);
     GetWindowText(hwndedit[20],infor.day,3);
     GetWindowText(hwndedit[21],infor.temperament,101);
     GetWindowText(hwndedit[22],infor.like,101);
     GetWindowText(hwndedit[23],infor.note,201);
	j = SendMessage (hwndList, LB_GETCURSEL, 0, 0) ;		
            if(strcmp(informa[j].name,infor.name))
            {strcpy(informa[j].name,infor.name);
			//获取当前选中的项的位置值
			k = SendMessage (hwndList, LB_GETCURSEL, 0, 0) ;
					//发送删除消息
			SendMessage(hwndList,LB_DELETESTRING,k,wParam);
		SendMessage (hwndList, LB_INSERTSTRING, k, (LPARAM)infor.name);
					//选中上一个项	
					SendMessage (hwndList, LB_SETCURSEL,k,0) ;
	
			}
            if(strcmp(informa[j].workplace, infor.workplace))
            strcpy(informa[j].workplace, infor.workplace);
            if(strcmp(informa[j].hometel ,infor.hometel))
            strcpy(informa[j].hometel ,infor.hometel);
           if(strcmp(informa[j].worktel, infor.worktel))
          strcpy(informa[j].worktel, infor.worktel);
          if(strcmp(informa[j].freetel ,infor.freetel))
             strcpy(informa[j].freetel ,infor.freetel);
         if(strcmp(informa[j].bp ,infor.bp))
             strcpy(informa[j].bp ,infor.bp);
           if(strcmp(informa[j].fax ,infor.fax))
            strcpy(informa[j].fax ,infor.fax);
          if(strcmp(informa[j].email, infor.email))
             strcpy(informa[j].email, infor.email);
           if(strcmp(informa[j].web, infor.web))
            strcpy(informa[j].web, infor.web);
             if(strcmp(informa[j].oicq, infor.oicq))
             strcpy(informa[j].oicq, infor.oicq);
           if(strcmp(informa[j].workadd ,infor.workadd))
             strcpy(informa[j].workadd ,infor.workadd);
          if(strcmp(informa[j].homeadd, infor.homeadd))
             strcpy(informa[j].homeadd, infor.homeadd);
            if(strcmp(informa[j].post ,infor.post))
             strcpy(informa[j].post ,infor.post);
           if(strcmp(informa[j].worksubstance ,infor.worksubstance))
             strcpy(informa[j].worksubstance ,infor.worksubstance);
            if(strcmp(informa[j].work, infor.work))
             strcpy(informa[j].work, infor.work);
           if(strcmp(informa[j].sex ,infor.sex))
             strcpy(informa[j].sex ,infor.sex);
           if(strcmp(informa[j].age, infor.age))
             strcpy(informa[j].age, infor.age);
            if(strcmp(informa[j].blood, infor.blood))
             strcpy(informa[j].blood, infor.blood);
            if(strcmp(informa[j].year, infor.year))
             strcpy(informa[j].year, infor.year);
           if(strcmp(informa[j].month, infor.month))
            strcpy(informa[j].month, infor.month);
           if(strcmp(informa[j].day ,infor.day))
             strcpy(informa[j].day ,infor.day);
            if(strcmp(informa[j].temperament, infor.temperament))
             strcpy(informa[j].temperament, infor.temperament);
           if(strcmp(informa[j].like ,infor.like))
             strcpy(informa[j].like ,infor.like);
            if(strcmp(informa[j].note ,infor.note))
             strcpy(informa[j].note ,infor.note);
	   delPopFileWrite (i, szFileName);    
          SetWindowText (record[1],itoa (i, file, 10));	  
          } return 0;
 }
else 
return 0;
     case 93:
         SetWindowText (hwndedit[0], "\0");
         SetWindowText (hwndedit[1], "\0");
         SetWindowText (hwndedit[2], "\0");
         SetWindowText (hwndedit[3],"\0");
         SetWindowText (hwndedit[4],"\0");
         SetWindowText (hwndedit[5],"\0");
         SetWindowText (hwndedit[6], "\0");
         SetWindowText (hwndedit[7],"\0");
         SetWindowText (hwndedit[8],"\0");
         SetWindowText (hwndedit[9], "\0");
         SetWindowText (hwndedit[10], "\0");
         SetWindowText (hwndedit[11], "\0");
         SetWindowText (hwndedit[12], "\0");
         SetWindowText (hwndedit[13], "\0");
         SetWindowText (hwndedit[14], "\0");
         SetWindowText (hwndedit[15], "\0");
         SetWindowText (hwndedit[16], "\0");
         SetWindowText (hwndedit[17], "\0");
         SetWindowText (hwndedit[18], "\0");
         SetWindowText (hwndedit[19], "\0");
         SetWindowText (hwndedit[20], "\0");
         SetWindowText (hwndedit[21], "\0");
         SetWindowText (hwndedit[22],"\0");
         SetWindowText (hwndedit[23], "\0");
		       SetFocus (hwndedit[0]);
return 0;
	 case IDM_FIND:
DialogBox(hInstance, (LPCTSTR)IDD_DIALOG1, hwnd, (DLGPROC)find);
break;
     case IDM_FINDOTHER:
DialogBox(hInstance, (LPCTSTR)IDD_DIALOG2, hwnd, (DLGPROC)findother);
break;
  case IDM_SECRET:
DialogBox(hInstance, (LPCTSTR)IDD_DIALOG4, hwnd, (DLGPROC)secre);	  
break;
			case IDM_ABOUT :
			 		//弹出菜单消息框
					MessageBox (hwnd, "程序设计:秦伟,完成于2002年7月13日\n    如发现该程序有问题或功能不全,请与我联系,我会尽快为你解决。联系方式:吉林大学朝阳校区4009班,Email:qinweisuperman@etang.com,OICQ:1508789", "宇光提醒程序", MB_OK | MB_ICONEXCLAMATION);			
					return 0 ;
			case IDM_USE :
					MessageBox (hwnd, "添加名片:打开或新建一个文件,然后点“清空”,清空编辑区,输入名片,点“添加”即可。删除名片:打开一个文件,选则一个名片点“删除”。修改名片:点击一个名片,输入要修改的内容,点“修改”。 ",
						"宇光名片管理程序", MB_ICONEXCLAMATION | MB_OK) ;
					return 0 ;
			case IDM_END:
				if(newsec[0]!='\0')
				{
				FILE *fq;
			if(!(fq=fopen("mpsec.qyg","wb")))
			{fq=fopen("mpsec.qyg","wb");}
for(int g=0;g<16;g++)
	 {if(newsec[g]=='\0')
	   break;
	 else 
newsec[g]=~newsec[g];
	 }
				fwrite(newsec,sizeof(sec),1,fq);
				fclose(fq);
				}
        PostQuitMessage(0);
   break;
	 }
	return 0;
        case WM_DESTROY:
				if(newsec[0]!='\0')
				{
				FILE *fw;
			if(!(fw=fopen("mpsec.qyg","wb")))
			{fw=fopen("mpsec.qyg","wb");}
for(int g=0;g<16;g++)
	 {if(newsec[g]=='\0')
	   break;
	 else 
newsec[g]=~newsec[g];
	 }
				fwrite(newsec,sizeof(sec),1,fw);
				fclose(fw);
				}
        PostQuitMessage(0);
         break;
	  default:
   return DefWindowProc(hwnd,message,wParam,lParam);
   }
     return DefWindowProc(hwnd,message,wParam,lParam);                                           
}
//函数:PopFileInitialize
//作用:初始化全局变量ofn
void PopFileInitialize (HWND hwnd)
{
     static char szFilter[]= "名片文件(*.qwm)\0*.qwm\0"
		                     "所有文件(*.*)\0*.*\0"; 		                                                  
     ofn.lStructSize= sizeof (OPENFILENAME) ;
     ofn.hwndOwner= hwnd ;
     ofn.hInstance= NULL ;
     ofn.lpstrFilter= szFilter ;
     ofn.lpstrCustomFilter = NULL ;
     ofn.nMaxCustFilter= 0 ;
     ofn.nFilterIndex= 0 ;
     ofn.lpstrFile= NULL ;         
     ofn.nMaxFile= _MAX_PATH ;
     ofn.lpstrFileTitle= NULL ;          
     ofn.nMaxFileTitle= _MAX_FNAME + _MAX_EXT ;
     ofn.lpstrInitialDir= NULL ;
     ofn.lpstrTitle= NULL ;
     ofn.Flags= 0 ;            
     ofn.nFileOffset= 0 ;
     ofn.nFileExtension= 0 ;
     ofn.lpstrDefExt= "qw" ;
     ofn.lCustData= 0L ;
     ofn.lpfnHook= NULL ;
     ofn.lpTemplateName= NULL ;
}
//函数:PopFileOpenDlg
//作用:弹出Open对话框
BOOL PopFileOpenDlg (HWND hwnd, PSTR pstrFileName, PSTR pstrTitleName)
{
     ofn.hwndOwner= hwnd ;
     ofn.lpstrFile= pstrFileName ;
     ofn.lpstrFileTitle= pstrTitleName ;
     ofn.Flags= OFN_HIDEREADONLY;
     return GetOpenFileName (&ofn) ;//弹出Open对话框
}
//函数:PopFileSaveDlg
//作用:弹出Save As对话框
BOOL PopFileSaveDlg (HWND hwnd, PSTR pstrFileName, PSTR pstrTitleName)
{
     ofn.hwndOwner= hwnd ;
     ofn.lpstrFile= pstrFileName ;
     ofn.lpstrFileTitle= pstrTitleName ;
     ofn.Flags= OFN_OVERWRITEPROMPT ;
     return GetSaveFileName (&ofn) ;
}
BOOL PopFileRead       ( PSTR pstrFileName)
{
FILE  *file;
	//打开文件
     if (NULL == (file = fopen (pstrFileName, "rb")))
          return FALSE;
	 i=-1;
while(!feof(file))
 {	i++;
     fread (&informa[i], sizeof(struct information), 1, file);	//读取文件		  
             strcpy(infor.name,informa[i].name);
             strcpy(infor.workplace,informa[i].workplace );
             strcpy(infor.hometel,informa[i].hometel );
             strcpy(infor.worktel,informa[i].worktel );
             strcpy(infor.freetel,informa[i].freetel );
             strcpy(infor.bp,informa[i].bp );
             strcpy(infor.fax,informa[i].fax );
             strcpy(infor.email,informa[i].email );
             strcpy(infor.web, informa[i].web);
             strcpy(infor.oicq, informa[i].oicq);
             strcpy(infor.workadd ,informa[i].workadd);
             strcpy(infor.homeadd,informa[i].homeadd );
             strcpy(infor.post,informa[i].post );
             strcpy(infor.worksubstance,informa[i].worksubstance );
             strcpy(infor.work,informa[i].work );
             strcpy(infor.sex,informa[i].sex );
             strcpy(infor.age,informa[i].age );
             strcpy(infor.blood,informa[i].blood );
             strcpy(infor.year,informa[i].year );
             strcpy(infor.month,informa[i].month );
             strcpy(infor.day,informa[i].day );
             strcpy(infor.temperament, informa[i].temperament);
             strcpy(infor.like,informa[i].like );
             strcpy(infor.note,informa[i].note );
for(int v=0;v<20;v++)
	 {if(infor.name[v]=='\0')
	   break;
	 else 
infor.name[v]=~infor.name[v];
	 }
	for(v=0;v<200;v++)
	 {if(infor.workplace[v]=='\0')
	   break;
	 else 
infor.workplace[v]=~infor.workplace[v];
	 }
	for(v=0;v<100;v++)
	 {if(infor.hometel[v]=='\0')
	   break;
	 else 
infor.hometel[v]=~infor.hometel[v];
	 }
	for(v=0;v<100;v++)
	 {if(infor.worktel[v]=='\0')
	   break;
	 else 
infor.worktel[v]=~infor.worktel[v];
	 }
	for(v=0;v<100;v++)
	 {if(infor.freetel[v]=='\0')
	   break;
	 else 
infor.freetel[v]=~infor.freetel[v];
	 }
	for(v=0;v<100;v++)
	 {if(infor.bp[v]=='\0')
	   break;
	 else 
infor.bp[v]=~infor.bp[v];
	 }
	for(v=0;v<100;v++)
	 {if(infor.fax[v]=='\0')
	   break;
	 else 
infor.fax[v]=~infor.fax[v];
	 }
	for(v=0;v<100;v++)
	 {if(infor.email[v]=='\0')
	   break;
	 else 
infor.email[v]=~infor.email[v];
	 }
	for(v=0;v<100;v++)
	 {if(infor.web[v]=='\0')
	   break;
	 else 
infor.web[v]=~infor.web[v];
	 }
	for(v=0;v<100;v++)
	 {if(infor.oicq[v]=='\0')
	   break;
	 else 
infor.oicq[v]=~infor.oicq[v];
	 }
	for(v=0;v<200;v++)
	 {if(infor.workadd[v]=='\0')
	   break;
	 else 
infor.workadd[v]=~infor.workadd[v];
	 }
	for(v=0;v<200;v++)
	 {if(infor.homeadd[v]=='\0')
	   break;
	 else 
infor.homeadd[v]=~infor.homeadd[v];
	 }
	for(v=0;v<100;v++)
	 {if(infor.post[v]=='\0')
	   break;
	 else 
infor.post[v]=~infor.post[v];
	 }
	for(v=0;v<100;v++)
	 {if(infor.worksubstance[v]=='\0')

⌨️ 快捷键说明

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