mfc_binary_view_1 - 8BitsCoding/RobotMentor GitHub Wiki
// Dlg.h
CFont m_font;
BOOL CMFCApplication1Dlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// μ΄ λν μμμ μμ΄μ½μ μ€μ ν©λλ€. μμ© νλ‘κ·Έλ¨μ μ£Ό μ°½μ΄ λν μμκ° μλ κ²½μ°μλ
// νλ μμν¬κ° μ΄ μμ
μ μλμΌλ‘ μνν©λλ€.
SetIcon(m_hIcon, TRUE); // ν° μμ΄μ½μ μ€μ ν©λλ€.
SetIcon(m_hIcon, FALSE); // μμ μμ΄μ½μ μ€μ ν©λλ€.
// TODO: μ¬κΈ°μ μΆκ° μ΄κΈ°ν μμ
μ μΆκ°ν©λλ€.
m_font.CreatePointFont(128, L"꡴림체");
m_bin_data_list.SetFont(&m_font);
return TRUE; // ν¬μ»€μ€λ₯Ό 컨νΈλ‘€μ μ€μ νμ§ μμΌλ©΄ TRUEλ₯Ό λ°νν©λλ€.
}
void CMFCApplication1Dlg::OnBnClickedSelectBtn()
{
CFileDialog ins_dlg(TRUE);
// TRUE : νμΌμ΄κΈ°
// FALSE : λ€λ₯Έμ΄λ¦μΌλ‘ μ μ₯
if (IDOK == ins_dlg.DoModal()) {
SetDlgItemText(IDC_PATH_STATIC, ins_dlg.GetPathName());
m_bin_data_list.ResetContent();
FILE * p_file = NULL;
if (_wfopen_s(&p_file, ins_dlg.GetPathName(), L"rb") == 0) {
unsigned char temp[24];
//CString total_str, str;
wchar_t str[128];
int len = 24, line = 0, str_len;
while (len == 24) {
len = fread(temp, 1, 24, p_file); // freadλ μ€μ λ‘ μ½μ λ°μ΄νΈλ§νΌ 리ν΄λ¨
if (len > 0) {
//total_str.Empty();
str_len = swprintf_s(str, 128, L"%06d : ", line++);
//total_str.Format(L"%06d : ", line++);
for (int i = 0; i < 24; i++) {
str_len += swprintf_s(str + str_len, 128 - str_len, L"%02X ", temp[i]);
}
m_bin_data_list.InsertString(-1, str);
}
}
/*
// CString Style
unsigned char temp[24];
CString total_str, str;
int len = 24, line = 0;
while (len == 24) {
len = fread(temp, 1, 24, p_file); // freadλ μ€μ λ‘ μ½μ λ°μ΄νΈλ§νΌ 리ν΄λ¨
if (len > 0) {
//total_str.Empty();
total_str.Format(L"%06d : ", line++);
for (int i = 0; i < 24; i++) {
str.Format(L"%02X ", temp[i]);
total_str += str;
}
m_bin_data_list.InsertString(-1, total_str);
}
}
*/
fclose(p_file);
}
}
}