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

📄 mypropertypage1.cpp

📁 mytoolpad 源码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
	m_memdc->FillRect(&CRect(0,m_itemh,m_rectgong.Width(),m_rectgong.Height()),&CBrush(RGB(192,192,192)));
	CPen m_pen(PS_SOLID,2,RGB(0,0,0));
	m_oldpen=m_memdc->SelectObject(&m_pen);
	m_memdc->MoveTo(1,m_rectgong.Height());
	m_memdc->LineTo(1,1);
	m_memdc->LineTo(m_rectgong.Width(),1);
	if(m_oldpen)
		m_memdc->SelectObject(m_oldpen);

	CPen m_pen1(PS_SOLID,1,RGB(255,255,255));
	m_oldpen=m_memdc->SelectObject(&m_pen1);
	m_memdc->MoveTo(1,m_rectgong.Height()-1);
	m_memdc->LineTo(m_rectgong.Width()-1,m_rectgong.Height()-1);
	m_memdc->LineTo(m_rectgong.Width()-1,0);
	m_memdc->MoveTo(2,m_rectgong.Height()-2);
	m_memdc->LineTo(m_rectgong.Width()-2,m_rectgong.Height()-2);
	m_memdc->LineTo(m_rectgong.Width()-2,1);
	if(m_oldpen)
		m_memdc->SelectObject(m_oldpen);

	m_memdc->SetTextColor(RGB(0,0,0));
	int m_days=m_cal.GetGongMonthDays(m_gong.year,m_gong.month);
	CALENDAR m_gongli(m_gong.year,m_gong.month,1);
	m_gongweekstart=m_cal.GetWeekInfo(m_gongli);
	int m_startx=0;
	int m_starty=0;
	int m_index=0,m_ver=0;
	char buffer[10];
	for(int i=0;i<m_days;i++)
	{
		m_index=(i+m_gongweekstart)%7;
		m_ver=(i+m_gongweekstart)/7+1;
		m_startx=m_index*m_itemw+2;
		m_starty=m_ver*m_itemh+2;
		wsprintf(buffer,"%2d",i+1);
		m_memdc->TextOut(m_startx,m_starty,buffer,strlen(buffer));
	}

	m_index=(m_gong.day+m_gongweekstart-1)%7;
	m_ver=(m_gong.day+m_gongweekstart-1)/7+1;
	int m_left=m_index*m_itemw;
	int m_top=m_ver*m_itemh;
	CRect m_thisrect(m_left,m_top+1,m_left+m_itemw-2,m_top+m_itemh-2);
	CPen m_pen2(PS_SOLID,1,RGB(0,0,0));
	m_oldpen=m_memdc->SelectObject(&m_pen2);
	m_memdc->MoveTo(m_thisrect.left,m_thisrect.bottom);
	m_memdc->LineTo(m_thisrect.left,m_thisrect.top);
	m_memdc->LineTo(m_thisrect.right,m_thisrect.top);
	if(m_oldpen)
		m_memdc->SelectObject(m_oldpen);

	CPen m_pen3(PS_SOLID,1,RGB(255,255,255));
	m_oldpen=m_memdc->SelectObject(&m_pen3);
	m_memdc->MoveTo(m_thisrect.left,m_thisrect.bottom);
	m_memdc->LineTo(m_thisrect.right,m_thisrect.bottom);
	m_memdc->LineTo(m_thisrect.right,m_thisrect.top);
	if(m_oldpen)
		m_memdc->SelectObject(m_oldpen);
	m_memdc->SetTextColor(RGB(255,255,0));
	wsprintf(buffer,"%2d",m_gong.day);
	m_memdc->TextOut(m_left+2,m_top+2,buffer,strlen(buffer));
}
void CMyPropertyPage4::DrawNongDay()
{
	int  m_left=m_rectnong.Width()+1;
	int  m_right=m_left+m_rectnong.Width()-1;
	int  m_bottom=m_rectnong.Height();

	m_memdc->FillRect(&CRect(m_left,m_itemh,m_right,m_rectgong.Height()),&CBrush(RGB(192,192,192)));
	CPen m_pen(PS_SOLID,2,RGB(0,0,0));
	m_oldpen=m_memdc->SelectObject(&m_pen);
	m_memdc->MoveTo(m_left+1,m_bottom);
	m_memdc->LineTo(m_left+1,1);
	m_memdc->LineTo(m_right,1);
	m_memdc->SelectObject(&m_oldpen);

	CPen m_pen1(PS_SOLID,1,RGB(255,255,255));
	m_oldpen=m_memdc->SelectObject(&m_pen1);
	m_memdc->MoveTo(m_left,m_bottom-1);
	m_memdc->LineTo(m_right-1,m_bottom-1);
	m_memdc->LineTo(m_right-1,0);
	m_memdc->MoveTo(m_left+1,m_bottom-2);
	m_memdc->LineTo(m_right-2,m_bottom-2);
	m_memdc->LineTo(m_right-2,1);
	m_memdc->SelectObject(&m_oldpen);


	int m_days=m_cal.GetNongMonthDays(m_nong.year,m_nong.month,m_nong.isrunyue);
	CALENDAR m_nongli(m_nong.year,m_nong.month,1);
	m_nongli.isrunyue=m_nong.isrunyue;
	CALENDAR m_gongli=m_cal.ConvertToGongLi(m_nongli);
	m_nongweekstart=m_cal.GetWeekInfo(m_gongli);
	int m_startx=0;
	int m_starty=0;
	int m_index=0,m_ver=0;
	char buffer[10];
	m_memdc->SetTextColor(RGB(0,0,0));
	for(int i=0;i<m_days;i++)
	{
		m_index=(i+m_nongweekstart)%7;
		m_ver=(i+m_nongweekstart)/7+1;
		m_startx=m_left+m_index*m_itemw+2;
		m_starty=m_ver*m_itemh+2;
		wsprintf(buffer,"%2d",i+1);
		m_memdc->TextOut(m_startx,m_starty,buffer,strlen(buffer));
	}

	m_index=(m_nong.day+m_nongweekstart-1)%7;
	m_ver=(m_nong.day+m_nongweekstart-1)/7+1;
	m_startx=m_left+m_index*m_itemw;
	m_starty=m_ver*m_itemh;

	CRect m_thisrect(m_startx,m_starty+1,m_startx+m_itemw-2,m_starty+m_itemh-2);
	CPen m_pen2(PS_SOLID,1,RGB(0,0,0));
	m_oldpen=m_memdc->SelectObject(&m_pen2);
	m_memdc->MoveTo(m_thisrect.left,m_thisrect.bottom);
	m_memdc->LineTo(m_thisrect.left,m_thisrect.top);
	m_memdc->LineTo(m_thisrect.right,m_thisrect.top);
	if(m_oldpen)
		m_memdc->SelectObject(m_oldpen);

	CPen m_pen3(PS_SOLID,1,RGB(255,255,255));
	m_oldpen=m_memdc->SelectObject(&m_pen3);
	m_memdc->MoveTo(m_thisrect.left,m_thisrect.bottom);
	m_memdc->LineTo(m_thisrect.right,m_thisrect.bottom);
	m_memdc->LineTo(m_thisrect.right,m_thisrect.top);
	if(m_oldpen)
		m_memdc->SelectObject(m_oldpen);

	m_memdc->SetTextColor(RGB(255,255,0));
	wsprintf(buffer,"%2d",m_nong.day);
	m_memdc->TextOut(m_startx+2,m_starty+2,buffer,strlen(buffer));
}

void CMyPropertyPage4::GetAllInformation()
{
	m_nongrect.GetWindowRect(&m_rectnong);
	m_gongrect.GetWindowRect(&m_rectgong);

	ScreenToClient(&m_rectnong);
	ScreenToClient(&m_rectgong);

	m_nongrect.ShowWindow(SW_HIDE);
	m_gongrect.ShowWindow(SW_HIDE);

	m_itemw=m_rectnong.Width()/7;
	m_itemh=m_rectnong.Height()/7;

	CreateMemdc();
}

void CMyPropertyPage4::CreateMemdc()
{
	CBitmap m_bitmap,m_xiaobit;

	int m_width =m_rectnong.Width()+m_rectgong.Width();
	int m_height=m_rectnong.Height();
	CClientDC dc(this);
	int m_bits=dc.GetDeviceCaps(BITSPIXEL);
	m_memdc=new CDC;
	m_memdc->CreateCompatibleDC(&CClientDC(this));
	m_bitmap.CreateBitmap(m_width,m_height,1,m_bits,NULL);
	m_oldbit=m_memdc->SelectObject(&m_bitmap);
	m_memdc->FillRect(&CRect(0,0,m_width,m_height),&CBrush(RGB(192,192,192)));
	m_memdc->FillRect(&CRect(0,0,m_width,m_itemh),&CBrush(RGB(0,128,128)));
	m_memdc->SetTextColor(RGB(255,255,0));
	m_memdc->SetBkMode(TRANSPARENT);
	char buffer[20]="日一二三四五六";
	for(int i=0;i<7;i++)
	{
		m_memdc->TextOut(m_itemw*i+2,2,(char *)&buffer[i*2],2);
		m_memdc->TextOut(m_rectgong.Width()+3+m_itemw*i,2,(char *)&buffer[i*2],2);
	}

	DrawPanel();
}

void CMyPropertyPage4::ReleaseMemdc()
{
	if(m_memdc)
	{
		if(m_oldbit)
		{
			CBitmap * m_bit=m_memdc->SelectObject(m_oldbit);
			if(m_bit)
				m_bit->DeleteObject();
		}
		delete m_memdc;
	}
}

BOOL CMyPropertyPage4::IsValidateNongDay(int m_day)
{
	int m_days=m_cal.GetNongMonthDays(m_nong.year,m_nong.month,m_nong.isrunyue);
	BOOL m_valid=(m_day>0 && m_day<=m_days);
	if(!m_valid)
		m_nong.day=1;
	return m_valid;
}
BOOL CMyPropertyPage4::IsValidateGongDay(int m_day)
{
	int m_days=m_cal.GetGongMonthDays(m_gong.year,m_gong.month);
	BOOL m_valid=(m_day>0 && m_day<=m_days);
	if(!m_valid)
		m_gong.day=1;
	return m_valid;
}

void CMyPropertyPage4::OnLButtonDown(UINT nFlags, CPoint point) 
{
	int m_left,m_top,m_x,m_y;

	CClientDC dc(this);
	if(m_rectgong.PtInRect(point))
	{
		m_left=point.x-m_rectgong.left;
		m_top=point.y-m_rectgong.top-m_itemh;
		m_x=m_left/m_itemw;
		m_y=m_top/m_itemh;
		int day=m_y*7+m_x-m_gongweekstart+1;
		if(IsValidateGongDay(day))
		{
			m_gong.day=day;
			GongDayChanged();
		}
	}
	if(m_rectnong.PtInRect(point))
	{
		m_left=point.x-m_rectnong.left;
		m_top=point.y-m_rectnong.top-m_itemh;
		m_x=m_left/m_itemw;
		m_y=m_top/m_itemh;
		int day=m_y*7+m_x-m_nongweekstart+1;
		if(IsValidateNongDay(day))
		{
			m_nong.day=day;
			NongDayChanged();
		}
	}

	CPropertyPage::OnLButtonDown(nFlags, point);
}

void CMyPropertyPage4::OnChangeGongyear() 
{
	UpdateData(TRUE);
	if(m_gongyear>1949 && m_gongyear<2050)
	{
		m_gong.year=m_gongyear;
		GongYearChanged();
		m_ganzhi=m_cal.GetGanZhi(m_nong.year);
		UpdateData(FALSE);
	}
}

void CMyPropertyPage4::OnChangeNongyear() 
{
	UpdateData(TRUE);
	if(m_nongyear>1949 && m_nongyear<2050)
	{
		m_nong.year=m_nongyear;
		NongYearChanged();
		m_ganzhi=m_cal.GetGanZhi(m_nong.year);
		UpdateData(FALSE);
	}
}

void CMyPropertyPage4::GongYearChanged()
{
	GongMonthChanged();
}
void CMyPropertyPage4::GongMonthChanged()
{
	GongDayChanged();
}
void CMyPropertyPage4::GongDayChanged()
{
	IsValidateGongDay(m_gong.day);
	GongToNong();
	DrawGongDay();
	CClientDC dc(this);
	ShowGongDay(dc);
	UpdateNongli();
}
void CMyPropertyPage4::UpdateGongli()
{
	m_gongyear=m_gong.year;
	m_gongmonth.SetCurSel(m_gong.month-1);
	DrawGongDay();
	CClientDC dc(this);
	ShowGongDay(dc);
	UpdateData(FALSE);
}


void CMyPropertyPage4::NongYearChanged()
{
	NongMonthToList();
	OnSelchangeNongmonth();
//	NongMonthChanged();
}
void CMyPropertyPage4::NongMonthChanged()
{
	NongDayChanged();
}
void CMyPropertyPage4::NongDayChanged()
{
	IsValidateNongDay(m_nong.day);
	NongToGong();
	DrawNongDay();
	CClientDC dc(this);
	ShowNongDay(dc);
	UpdateGongli();
}
void CMyPropertyPage4::UpdateNongli()
{
	m_nongyear=m_nong.year;
	NongMonthToList();
	DrawNongDay();
	CClientDC dc(this);
	ShowNongDay(dc);
	UpdateData(FALSE);
}


void CMyPropertyPage4::NongMonthToList()
{
	m_cal.NongMonthToList(m_nongyear,m_nongmonth);
	int m_run=m_cal.GetNongRunYue(m_nongyear);
	m_gongmonth.SetCurSel(m_gong.month-1);
	if(m_nong.month<m_run)
		m_nongmonth.SetCurSel(m_nong.month-1);
	else
	{
		if(m_nong.month==m_run)
		{
			if(m_nong.isrunyue)
				m_nongmonth.SetCurSel(m_nong.month);
			else
				m_nongmonth.SetCurSel(m_nong.month-1);
		}
		else
		{
			if(m_run==0)
				m_nongmonth.SetCurSel(m_nong.month-1);
			else
				m_nongmonth.SetCurSel(m_nong.month);
		}
	}
}

void CMyPropertyPage4::GongToNong()
{
	CALENDAR m_nongli=m_cal.ConvertToNongLi(m_gong);
	m_nong.year=m_nongli.year;
	m_nong.month=m_nongli.month;
	m_nong.day=m_nongli.day;
	m_nong.isrunyue=m_nongli.isrunyue;
}
void CMyPropertyPage4::NongToGong()
{
	CALENDAR m_gongli=m_cal.ConvertToGongLi(m_nong);
	m_gong.year=m_gongli.year;
	m_gong.month=m_gongli.month;
	m_gong.day=m_gongli.day;
}

void CMyPropertyPage4::OnSelchangeGongmonth() 
{
	m_gong.month=m_gongmonth.GetCurSel()+1;
	GongMonthChanged();
}

void CMyPropertyPage4::OnSelchangeNongmonth()
{
	int month=m_nongmonth.GetCurSel();
	int m_run=m_cal.GetNongRunYue(m_nong.year);
	if(m_run==0)			 //本年度没有闰月
	{
		m_nong.month=month+1;
		m_nong.isrunyue=FALSE;
	}
	else					 //本年度有闰月
	{
		if(month==m_run)	 //选中闰月
		{
			m_nong.month=month;
			m_nong.isrunyue=TRUE;
		}
		else				 //没有选中闰月
		{
			m_nong.isrunyue=FALSE;
			if(month<m_run)
				m_nong.month=month+1;
			else
				m_nong.month=month;
		}
	}
	NongMonthChanged();
}




void CMyPropertyPage2::OnBrowse() 
{
	CFileDialog dlg(TRUE,"*.dcq",m_filename,OFN_FILEMUSTEXIST|OFN_HIDEREADONLY,"数据文件 (*.dcq)|*.dcq||");
	if(dlg.DoModal()==IDOK)
	{
		m_filename=dlg.GetPathName();
		UpdateData(FALSE);
		ReadFromFile(m_filename);
	}
}

void CMyPropertyPage2::OnAdditem()
{
	if(m_filename==_T(""))
	{
		CFileDialog dlg(FALSE,"*.dcq",m_filename,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,"数据文件 (*.dcq)|*.dcq||");
		if(dlg.DoModal()==IDOK)
		{
			m_filename=dlg.GetPathName();
			UpdateData(FALSE);
			CreateDataFile(m_filename);
			ReadFromFile(m_filename);
			OnAdditem();
			return;
		}
		else
			return;
	}

	if(m_filehead.m_totalitems>0)
	{
		if(!m_passright)
		{
			MessageBox("1.输入正确的文件名后;\n2.输入正确的口令后;\n3.再操作。");
			return;
		}
		else
		{
			SaveCurData(m_index);
			m_filehead.m_totalitems++;
			m_title=_T("请在此处输入注释");
			m_content=_T("请在此处输入数据");
			m_index=m_filehead.m_totalitems;
			m_changed=TRUE;
			UpdateData(FALSE);
			m_indexspin.SetRange(1,m_filehead.m_totalitems);
			EnablePanel();
		}
	}
	else
	{
		m_filehead.m_totalitems=1;
		m_title=_T("请在此处输入注释");
		m_content=_T("请在此处输入数据");
		m_index=m_filehead.m_totalitems;
		m_changed=TRUE;
		UpdateData(FALSE);
		m_indexspin.SetRange(1,m_filehead.m_totalitems);
		EnablePanel();
	}
}

void CMyPropertyPage2::OnLast() 
{
	SaveCurData(m_index);
	m_index--;
	GetCurData();
	EnablePanel();
}
void CMyPropertyPage2::OnNext() 
{
	SaveCurData(m_index);
	m_index++;
	GetCurData();
	EnablePanel();
}

void CMyPropertyPage2::OnSearch() 
{
	SaveCurData(m_index);

	CString m_info,m_thiscon;
	m_pitchitems=0;
	for(int i=0;i<m_filehead.m_totalitems;i++)
	{
		m_info=GetNTitle(i+1);
		m_thiscon=GetNContent(i+1);
		if((m_info.Find(m_searchtitle)!=-1) || (m_thiscon.Find(m_searchtitle)!=-1))
			m_pitchitems++;
	}
	if(m_pitchitems>0)
	{
		m_sindexspin.SetRange(1,m_pitchitems);
		if(m_sindex>m_pitchitems)
			m_sindex=m_pitchitems;
		if(m_sindex<1)
			m_sindex=1;
		SetSearchItem(m_sindex);
	}
	m_error.Format("找到%d条记录",m_pitchitems);
	UpdateData(FALSE);
	EnablePanel();
}

void CMyPropertyPage2::SetSearchItem(int index)
{
	CString m_info,m_thiscon;
	int m_num=0;
	for(int i=0;i<m_filehead.m_totalitems;i++)
	{
		m_info=GetNTitle(i+1);
		m_thiscon=GetNContent(i+1);
		if((m_info.Find(m_searchtitle)!=-1) || (m_thiscon.Find(m_searchtitle)!=-1))
		{
			m_num++;
			if(m_num==index)
			{
				m_index=i+1;
				GetCurData();
			}
		}
	}
}

void CMyPropertyPage2::DeleteNItem(int index)
{
	m_title=_T("");
	m_content=_T("");
	char m_buffer[6001];

	DWORD m_start=0;
	for(int i=index;i<m_filehead.m_totalitems;i++)

⌨️ 快捷键说明

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