mfc_calander - 8BitsCoding/RobotMentor GitHub Wiki
Static Textλ μλμ κ°μ΄ μ€μ νλ€.
- Align Text : ν μ€νΈ μν μ λ ¬
- Center Image : ν μ€νΈ μμ§ μ λ ¬
- Sunken : Static Text μ΄μ§ λ€μ΄κ° ν¨κ³Ό
Calender Ctrl μ°ν΄λ¦ -> μ΄λ²€νΈ μ²λ¦¬κΈ° λ§λ²μ¬
MCN_SELCAHNGE μ ν : λ μ§λ₯Ό λ³κ²½
μλνΈ μ»¨νΈλ‘€μ μμ±μ μλμ κ°μ΄ λλ€.
void CMFCApplication1Dlg::OnMcnSelchangeMyCalendar(NMHDR *pNMHDR, LRESULT *pResult)
{
// LPNMSELCHANGE pSelChange = reinterpret_cast<LPNMSELCHANGE>(pNMHDR);
SYSTEMTIME cur_time;
m_my_calendar.GetCurSel(&cur_time); // λ¬λ ₯μ νμ¬ λ μ§μ 보λ₯Ό λκΈ΄λ€.
wchar_t * p_week_str[7] = { L"μΌ",L"μ", L"ν", L"μ", L"λͺ©", L"κΈ", L"ν " };
CString str;
str.Format(L"%dλ
%dμ %dμΌ [%sμμΌ]", cur_time.wYear, cur_time.wMonth, cur_time.wDay, p_week_str[cur_time.wDayOfWeek]);
// cur_time.wDayOfWeek = μμΌμ 보
SetDlgItemText(IDC_DATE_STATIC, str);
str.Format(L"%04d%02d%02d.dat", cur_time.wYear, cur_time.wMonth, cur_time.wDay);
FILE * p_file;
if (0 == _wfopen_s(&p_file, str, L"rt,ccs=UNICODE")) {
wchar_t temp_str[1024];
str.Empty();
while (fgetws(temp_str, 1024, p_file) != NULL) {
str += temp_str;
}
str.Replace(L"\n", L"\r\n");
fclose(p_file);
SetDlgItemText(IDC_NOTE_EDIT, str);
}
else
{
SetDlgItemText(IDC_NOTE_EDIT, L"");
}
if(*pResult !=NULL) *pResult = 0;
}
void CMFCApplication1Dlg::OnBnClickedSetBtn()
{
SYSTEMTIME cur_time;
m_my_calendar.GetCurSel(&cur_time);
CString str;
str.Format(L"%04d%02d%02d.dat", cur_time.wYear, cur_time.wMonth, cur_time.wDay);
FILE * p_file;
if (0 == _wfopen_s(&p_file, str, L"wt,ccs=UNICODE")) {
GetDlgItemText(IDC_NOTE_EDIT, str);
str.Replace(L"\r\n", L"\n");
fwrite((const wchar_t*)str, (str.GetLength() + 1)*2, 1, p_file);
fclose(p_file);
}
}
BOOL CMFCApplication1Dlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// μ΄ λν μμμ μμ΄μ½μ μ€μ ν©λλ€. μμ© νλ‘κ·Έλ¨μ μ£Ό μ°½μ΄ λν μμκ° μλ κ²½μ°μλ
// νλ μμν¬κ° μ΄ μμ
μ μλμΌλ‘ μνν©λλ€.
SetIcon(m_hIcon, TRUE); // ν° μμ΄μ½μ μ€μ ν©λλ€.
SetIcon(m_hIcon, FALSE); // μμ μμ΄μ½μ μ€μ ν©λλ€.
// TODO: μ¬κΈ°μ μΆκ° μ΄κΈ°ν μμ
μ μΆκ°ν©λλ€.
m_font.CreatePointFont(160, L"κ΅΄λ¦Ό");
m_my_calendar.SetFont(&m_font);
m_date_static.SetFont(&m_font);
// μμνλ©΄μ λ°λ‘ λ μ§ λμ€κ² νκΈ°
OnMcnSelchangeMyCalendar(NULL, NULL);
return TRUE; // ν¬μ»€μ€λ₯Ό 컨νΈλ‘€μ μ€μ νμ§ μμΌλ©΄ TRUEλ₯Ό λ°νν©λλ€.
}