디시인사이드 갤러리

갤러리 이슈박스, 최근방문 갤러리

갤러리 본문 영역

이 소스 분석좀 부탁드릴께요.ㅠㅠ

공대생(121.164) 2011.06.17 22:54:47
조회 84 추천 0 댓글 5

분석좀 부탁드릴께요 ~
친구한테 부탁해서 소스 받아 내긴했는데 어떤식으로 진행되는지 감이 안잡혀서요
헤더파일은 다 있다고 치고 분석좀 부탁드려요ㅠㅠ
// Schedule M.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "Schedule M.h"
#include "Schedule MDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CScheduleMApp

BEGIN_MESSAGE_MAP(CScheduleMApp, CWinApp)
 //{{AFX_MSG_MAP(CScheduleMApp)
  // NOTE - the ClassWizard will add and remove mapping macros here.
  //    DO NOT EDIT what you see in these blocks of generated code!
 //}}AFX_MSG
 ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CScheduleMApp construction

CScheduleMApp::CScheduleMApp()
{
 // TODO: add construction code here,
 // Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CScheduleMApp object

CScheduleMApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CScheduleMApp initialization

BOOL CScheduleMApp::InitInstance()
{
 AfxEnableControlContainer();

 // Standard initialization
 // If you are not using these features and wish to reduce the size
 //  of your final executable, you should remove from the following
 //  the specific initialization routines you do not need.

#ifdef _AFXDLL
 Enable3dControls();   // Call this when using MFC in a shared DLL
#else
 Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif

 CScheduleMDlg dlg;
 m_pMainWnd = &dlg;
 int nResponse = dlg.DoModal();
 if (nResponse == IDOK)
 {
  // TODO: Place code here to handle when the dialog is
  //  dismissed with OK
 }
 else if (nResponse == IDCANCEL)
 {
  // TODO: Place code here to handle when the dialog is
  //  dismissed with Cancel
 }

 // Since the dialog has been closed, return FALSE so that we exit the
 //  application, rather than start the application\'s message pump.
 return FALSE;
}
// Schedule MDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Schedule M.h"
#include "Schedule MDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
 CAboutDlg();

// Dialog Data
 //{{AFX_DATA(CAboutDlg)
 enum { IDD = IDD_ABOUTBOX };
 //}}AFX_DATA

 // ClassWizard generated virtual function overrides
 //{{AFX_VIRTUAL(CAboutDlg)
 protected:
 virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
 //}}AFX_VIRTUAL

// Implementation
protected:
 //{{AFX_MSG(CAboutDlg)
 //}}AFX_MSG
 DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
 //{{AFX_DATA_INIT(CAboutDlg)
 //}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
 CDialog::DoDataExchange(pDX);
 //{{AFX_DATA_MAP(CAboutDlg)
 //}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
 //{{AFX_MSG_MAP(CAboutDlg)
  // No message handlers
 //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CScheduleMDlg dialog

CScheduleMDlg::CScheduleMDlg(CWnd* pParent /*=NULL*/)
 : CDialog(CScheduleMDlg::IDD, pParent)
{
 //{{AFX_DATA_INIT(CScheduleMDlg)
 m_strEdit = _T("");
 //}}AFX_DATA_INIT
 // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CScheduleMDlg::DoDataExchange(CDataExchange* pDX)
{
 CDialog::DoDataExchange(pDX);
 //{{AFX_DATA_MAP(CScheduleMDlg)
 DDX_Control(pDX, IDC_CTRL_MONTH, m_ctrlMonth);
 DDX_Text(pDX, IDC_EDIT_DISPLAY, m_strEdit);
 //}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CScheduleMDlg, CDialog)
 //{{AFX_MSG_MAP(CScheduleMDlg)
 ON_WM_SYSCOMMAND()
 ON_WM_PAINT()
 ON_WM_QUERYDRAGICON()
 ON_BN_CLICKED(IDC_BTN_INSERT, OnBtnInsert)
 ON_NOTIFY(MCN_SELCHANGE,IDC_CTRL_MONTH, OnSelChange)
 ON_BN_CLICKED(IDC_BTN_EDIT, OnBtnEdit)
 ON_BN_CLICKED(IDC_BTN_DELETE, OnBtnDelete)
 //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CScheduleMDlg message handlers

BOOL CScheduleMDlg::OnInitDialog()
{
 CDialog::OnInitDialog();

 // Add "About..." menu item to system menu.

 // IDM_ABOUTBOX must be in the system command range.
 ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
 ASSERT(IDM_ABOUTBOX < 0xF000);

 CMenu* pSysMenu = GetSystemMenu(FALSE);
 if (pSysMenu != NULL)
 {
  CString strAboutMenu;
  strAboutMenu.LoadString(IDS_ABOUTBOX);
  if (!strAboutMenu.IsEmpty())
  {
   pSysMenu->AppendMenu(MF_SEPARATOR);
   pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  }
 }

 // Set the icon for this dialog.  The framework does this automatically
 //  when the application\'s main window is not a dialog
 SetIcon(m_hIcon, TRUE);   // Set big icon
 SetIcon(m_hIcon, FALSE);  // Set small icon
 
 // TODO: Add extra initialization here
 
 return TRUE;  // return TRUE  unless you set the focus to a control
}

void CScheduleMDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
 if ((nID & 0xFFF0) == IDM_ABOUTBOX)
 {
  CAboutDlg dlgAbout;
  dlgAbout.DoModal();
 }
 else
 {
  CDialog::OnSysCommand(nID, lParam);
 }
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CScheduleMDlg::OnPaint()
{
 if (IsIconic())
 {
  CPaintDC dc(this); // device context for painting

  SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

  // Center icon in client rectangle
  int cxIcon = GetSystemMetrics(SM_CXICON);
  int cyIcon = GetSystemMetrics(SM_CYICON);
  CRect rect;
  GetClientRect(&rect);
  int x = (rect.Width() - cxIcon + 1) / 2;
  int y = (rect.Height() - cyIcon + 1) / 2;

  // Draw the icon
  dc.DrawIcon(x, y, m_hIcon);
 }
 else
 {
  CDialog::OnPaint();
 }
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CScheduleMDlg::OnQueryDragIcon()
{
 return (HCURSOR) m_hIcon;
}

void CScheduleMDlg::OnBtnInsert()
{
 // TODO: Add your control notification handler code here
 UpdateData(TRUE);
 Insert();
 UpdateData(FALSE);
 AfxMessageBox("스케줄 입력 완료!!");
}


void CScheduleMDlg::OnSelChange()
{
 // 선택한 날짜의 스케줄이 Display되어야 함.
 SelChangeDisplay();
}

void CScheduleMDlg::OnBtnEdit()
{
 // TODO: Add your control notification handler code here
 // 선택된 날짜의 수정된 스케줄로 파일에 다시 저장
 UpdateData(TRUE);
 Delete();
 Insert();
 UpdateData(FALSE);
 AfxMessageBox("스케줄 수정 완료!!");

}

void CScheduleMDlg::OnBtnDelete()
{
 // TODO: Add your control notification handler code here
 // 파일에 선택된 날짜의 스케줄을 삭제.
 UpdateData(TRUE);
 Delete();
 SelChangeDisplay();
 UpdateData(FALSE); 
 AfxMessageBox("스케줄 삭제 완료!!");

}

void CScheduleMDlg::GetPointDate()
{
   SYSTEMTIME DateTime;
   m_ctrlMonth.GetCurSel(&DateTime);
 
   m_nSelYear = DateTime.wYear;
   m_nSelMonth = DateTime.wMonth;
   m_nSelDay = DateTime.wDay;
  
//    유효성 검사가 있으면 더 좋겠다.
//   if(m_nSelYear > 2000 && m_nSelYear<2011 && m_nSelMonth > 0 && m_month<13 && m_day>0 && m_day<32)
}

void CScheduleMDlg::Delete()
{
 FILE *stream;
    char list[200];
    char cur_day[9],txt_day[9];
 char data_txt[3000][200];

 int sel_index,count;
 CString msg;
 CString str_msg;

 
 count=0;

  memset(cur_day,0x00,sizeof(cur_day));
  GetPointDate();
  sprintf(cur_day,"%04d%02d%02d",m_nSelYear,m_nSelMonth,m_nSelDay);

  if( (stream = fopen( "스케줄.txt", "r" )) != NULL )
   {
   memset(list,0x00,sizeof(list)); 
   while(fgets( list, 198, stream ) != NULL)
   {   
     memset(txt_day,0x00,sizeof(txt_day));
     sprintf(txt_day,"%.8s",list);


     if((strncmp(cur_day,txt_day,8) != 0) && (strlen(list) > 8))
     {
    strcpy(data_txt[count++],list);
    memset(list,0x00,sizeof(list));
     }
   } // end while
         fclose( stream );

   if( (stream = fopen( "스케줄.txt", "w+" )) != NULL )
    {
     for(int i=0; i<count; i++)
     {
      fwrite( data_txt[i], sizeof( char ), strlen(data_txt[i]), stream );
     }

     fclose( stream );
    }
  }
     else
  {
           str_msg.Format("File could not be opened" );
  } 


}

void CScheduleMDlg::SelChangeDisplay()
{
 FILE *stream;
    char list[200];
    char cur_day[9],txt_day[9];

 int i,count;
 CString str_month,str_msg;

 UpdateData(TRUE);

 GetPointDate(); // m_nSelYear, m_nSelMonth, m_nSelDay
 
 memset(cur_day,0x00,sizeof(cur_day));
 sprintf(cur_day,"%04d%02d%02d",m_nSelYear,m_nSelMonth,m_nSelDay);
 
 count=0;

 if( (stream = fopen( ".\\\\스케줄.txt", "r" )) != NULL )
  {
  memset(list,0x00,sizeof(list));  
  while(fgets( list, 198, stream ) != NULL)
  {   
    memset(txt_day,0x00,sizeof(txt_day));

    if(strlen(list) > 8)
     sprintf(txt_day,"%.8s",list);
    else continue;

    if(strncmp(cur_day,txt_day,8) == 0)
    {
   // 스케줄이 있는 경우
   for(i=0;i<200;i++)
   {
    if(i>=0 && i<=7) list[i] = \' \';
    if(list[i] == \'\\n\') list[i] = \' \';
   }
   str_msg.Format("%.199s", list );
       m_strEdit = str_msg;
      UpdateData(FALSE);
      memset(list,0x00,sizeof(list));
   break;
    } else {
     // 스케줄이 없는 경우
   str_msg.Format("스케줄이 없습니다.");
       m_strEdit = str_msg;
      UpdateData(FALSE);
      memset(list,0x00,sizeof(list));
    }
  }
     fclose( stream );
 } else {
  AfxMessageBox("데이타가 없습니다.");
 }

}

void CScheduleMDlg::Insert()
{
 FILE *stream;
    char list[200];

 GetPointDate();
 memset(list,0x00,sizeof(list));
 sprintf(list,"\\n%04d%02d%02d%s",m_nSelYear,m_nSelMonth,m_nSelDay,m_strEdit);

 stream = fopen( ".\\\\스케줄.txt", "a+" );  
 fwrite( list, sizeof( char ), 199, stream );
 fclose( stream );


}

추천 비추천

0

고정닉 0

0

댓글 영역

전체 댓글 0
등록순정렬 기준선택
본문 보기

하단 갤러리 리스트 영역

왼쪽 컨텐츠 영역

갤러리 리스트 영역

갤러리 리스트
번호 제목 글쓴이 작성일 조회 추천
설문 지금 결혼하면 스타 하객 많이 올 것 같은 '인맥왕' 스타는? 운영자 24/10/28 - -
277841 스탠포드 무료 기계학습 과정 좋다 진짜 [2] 멸자(130.126) 11.10.04 97 0
277836 그런데 궁금한게 있는데 말이지 [3] 좋은아버지갤로그로 이동합니다. 11.10.04 60 0
277835 형들 비베 코딩 for문 좀 알려줄수 잇어요? [2] ㅇㅂ(218.237) 11.10.04 88 0
277834 워그화 신었는데 [1] Adelposs갤로그로 이동합니다. 11.10.04 52 0
277833 안드로이드로 숫자야구 앱 만들었는데 [3] ?(124.199) 11.10.04 107 0
277832 혹시 소프트웨어 마에스트로 에 대해서 잘 아는 형 있어? [1] 좋은아버지갤로그로 이동합니다. 11.10.04 60 0
277831 횽들 한글로 된 언어는 외쿡인들이 안 써줘서 망했다고 그랬자낭.. [1] LazyGyu갤로그로 이동합니다. 11.10.04 93 0
277830 좋은아침입니다 다들출근은했지요 三didas갤로그로 이동합니다. 11.10.04 40 0
277829 ㅋㅋ 너무 졸려서 [5] Adelposs갤로그로 이동합니다. 11.10.04 75 0
277827 내일이 지나면 나는 이제 3개월 차 에 돌입해. [5] 좋은아버지갤로그로 이동합니다. 11.10.04 110 0
277826 클래스 다이어그램 그릴일이 있는데.. [4] 쿄스케갤로그로 이동합니다. 11.10.04 117 0
277825 개발자 동호회 같은거 하고 싶은데 [23] 좋은아버지갤로그로 이동합니다. 11.10.04 216 0
277824 닌자파워어쌔신.zip [3] 회전매니아갤로그로 이동합니다. 11.10.04 118 0
277823 샘숭이말하는 대항마라는게 ㅂㅈㄷ(210.178) 11.10.04 45 0
277822 출근 is 죽고 싶다. [6] 좋은아버지갤로그로 이동합니다. 11.10.04 100 0
277819 크하하하하 만들었다 ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ forhappiness갤로그로 이동합니다. 11.10.04 39 0
277818 아게이 도대체 어디감? Adelposs갤로그로 이동합니다. 11.10.04 28 0
277816 아니 시발 ktx 개객기 Adelposs갤로그로 이동합니다. 11.10.04 41 0
277815 프갤여러분들 안녕! AnonyMous갤로그로 이동합니다. 11.10.04 30 0
277813 강남비트 자바 고급반 정보좀 줘~~부탁해,., 밥팅이야(59.10) 11.10.04 100 0
277812 1000원짜리 버스 막장갤신학생갤로그로 이동합니다. 11.10.04 46 0
277811 형들살려줘 [3] Adelposs갤로그로 이동합니다. 11.10.04 67 0
277810 아 시발 진ㄴ짜 지려온다 Adelposs갤로그로 이동합니다. 11.10.04 30 0
277809 아 피곤해 시발 Adelposs갤로그로 이동합니다. 11.10.04 25 0
277808 아 진짜 졸렵다 Adelposs갤로그로 이동합니다. 11.10.04 29 0
277807 C++ 오류 질문좀 드릴게요 [3] 라마(71.82) 11.10.04 50 0
277806 (c/c++)이게 왜 오류야? ㄷㄷ; [3] forhappiness갤로그로 이동합니다. 11.10.04 77 0
277805 오브젝티브 ㅆ ㅣ 공부하다가 [1] 돌아이바갤로그로 이동합니다. 11.10.04 54 0
277804 자바하는데 객체가 너무어렵다... [6] ^0^갤로그로 이동합니다. 11.10.04 135 0
277803 Bodhi(보디,버디) 리눅스를 써봤다 [3] 로하로하알로하갤로그로 이동합니다. 11.10.04 180 0
277802 내일이 대망의 프레젠테이션 발표인데 [3] 일광면(119.198) 11.10.04 83 0
277801 그냥 인증서 좀 백업하겠다는데 로하로하알로하갤로그로 이동합니다. 11.10.04 35 0
277800 밑에 스택프레임 보세요 [1] 일광면(119.198) 11.10.04 51 0
277799 카이스트나 서울대 컴공/대학원 나오면.. 으아(121.145) 11.10.04 489 0
277798 뒤늦게 이제서야 크라이시스를 해봤는데 [1] ㅋㄱ(183.96) 11.10.04 63 0
277797 6! (팩토리얼) 스택프레임 으로 그려오라는데 좀 알려줘 뀨읭(124.28) 11.10.04 110 0
277796 형들 WINHTTP를통해서 헤더PHPSESSID적용하려면어떻게해야하나요? [3] uxp갤로그로 이동합니다. 11.10.04 68 0
277794 C++ 도 폼을 볼수있나요? [1] 박구갤로그로 이동합니다. 11.10.04 71 0
277792 고작한시반인데 정전인척하는거야??? [1] 김호도갤로그로 이동합니다. 11.10.04 27 0
277791 데이터마이닝에서 .. nearest neighbor 알고리즘말인데.... 김호도갤로그로 이동합니다. 11.10.04 39 0
277790 좋은 아버지 짤 정했어 [10] 좋은아버지갤로그로 이동합니다. 11.10.04 169 0
277789 내일 과제 제출이냨ㅋㅋㅋ 조공 존나 많네 로하로하알로하갤로그로 이동합니다. 11.10.04 59 0
277788 dll 같이 배포???? 꼭???????? 횽들(219.250) 11.10.04 50 0
277787 카카오톡 삭제된 대화 복구할 수 있는 살암 [3] 카톡카톡(110.15) 11.10.04 647 0
277786 온라인 게임 싱글플레이 하는 법 아는 사람있나? [4] 궁금하네(121.161) 11.10.04 157 0
277784 [조공]클래스 질문입니다 봐주세요 클래스(180.67) 11.10.04 144 0
277783 오랜간만에 와보니깐 ㅋㅋㅋ [1] C_Perl갤로그로 이동합니다. 11.10.04 40 0
277782 [조공] 컴구조 질문점 하겠소 [4] SODMaster갤로그로 이동합니다. 11.10.04 153 0
277781 회사 선임중에 대학원 나온 선임이 있는데 VIBE갤로그로 이동합니다. 11.10.04 94 0
277780 어떤 븅신같은 학교가 vim사용법 [1] 로하로하알로하갤로그로 이동합니다. 11.10.04 123 0
갤러리 내부 검색
제목+내용게시물 정렬 옵션

오른쪽 컨텐츠 영역

실시간 베스트

1/8

뉴스

디시미디어

디시이슈

1/2