• 选择生日


    BOOL CMEcomDlg::OnInitDialog()
    {
          .....
          .....
    	// TODO: 在此添加额外的初始化代码
    	CString year ,month ,day;
    	for(int i=0; i<=50 ;i++){
    		year.Format(_T("%d"),2013-i) ;
    		M_year.InsertString(i,year) ;
     	}
    	for(int i=0; i<12; i++){
    		month.Format(_T("%d"),i+1) ;
    		M_month.InsertString(i,month) ;
    	}
    
    	return TRUE;  // 除非将焦点设置到控件,否则返回 TRUE
    }
    
    /*对于选定年月设定日*/
    void CMEcomDlg::Set_day(int year, int month){ int all_day ; int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; if(month==2){ if(year%4==0&&year%100!=0||year%400==0) all_day=d[month]+1 ; else all_day=d[month] ; } else all_day=d[month] ; CString day ; for(int i=1;i<=all_day;i++){ day.Format(_T("%d"),i) ; //将i转成Cstring M_day.InsertString(i-1,day) ; //插入 } }

      

    void CMEcomDlg::OnSelchangeComboMonth(){
    	// TODO: 在此添加控件通知处理程序代码
    	M_day.ResetContent() ; //清空
    	CString month ,year;   
    	M_year.GetWindowText(year) ;   
    	M_month.GetLBText(M_month.GetCurSel(),month) ; //得到当前选定月份
    	int Y=_ttoi(year);   //Cstring转成int
    	int M=_ttoi(month) ;
    	Set_day(Y,M) ;
    	UpdateData(false) ;
    }
    

      

    void CMEcomDlg::OnClickedButtonQuery(){
    	// TODO: 在此添加控件通知处理程序代码
    	CString str ,year ,month ,day;
    	M_year.GetWindowText(year) ;
    	M_month.GetWindowText(month) ;
    	M_day.GetWindowText(day) ;
    	str+="您的生日是:
    "  ;
    	str+=year ;
    	str+="年" ;
    	str+=month ;
    	str+="月" ;
    	str+=day ;
    	str+="日
    " ;
    	MessageBox(str) ;
    }
    

      

  • 相关阅读:
    与(&,&&)和或(|,||)的区别
    vue笔记(更新中)
    echarts实现心脏图的滚动三种实现方法
    生成四则运算
    软件工程第四次作业
    软件工程第三次作业
    软件工程第二次作业
    软件工程第一次作业
    前端优化
    关于事件监听
  • 原文地址:https://www.cnblogs.com/liyangtianmen/p/3365814.html
Copyright © 2020-2023  润新知