본문 바로가기

MFC8

MFC - Drag and Drop 구현 DragAcceptFiles()함수와 WM_DROPFILES메세지를 이용해서 드래그앤드랍을 구현 할 수 있습니다. 다이얼로그 베이스 프로젝트에서 아래와 같이 헤더와 소스파일에서 구현하면 됩니다. CMFCDropFilesDlg.h protected: afx_msg void OnDropFiles(HDROP dropInfo); DECLARE_MESSAGE_MAP() CMFCDropFilesDlg.cpp BEGIN_MESSAGE_MAP(CMFCDropFilesDlg, CDialogEx) ON_WM_DROPFILES() END_MESSAGE_MAP() BOOL CMFCDropFilesDlg::OnInitDialog() { DragAcceptFiles(); // entire dialog list.DragAccept.. 2019. 4. 28.
MFC - CString GetBuffer(), ReleaseBuffer() 사용 아래와 같이 char배열 포인터를 받아서 전화번호 문자열을 복사해주는 함수가 있다고 가정했을 때, void GetPhoneNumber(char *buf) { strcpy(buf, "010-1234-5678"); } 받은 전화번호 데이터를 다시 CString으로 처리해야하는 경우, 보통 아래와 같이 처리를 합니다. CString str; char sz[20] = { 0, }; GetPhoneNumber(sz); str = sz; // str 사용... 이를 CString의 GetBuffer(), GetRelease()함수를 사용하여 아래와 같이 간단하게 처리할 수 있습니다. CString str; GetPhoneNumber(str.GetBuffer(20)); str.ReleaseBuffer(); // st.. 2019. 1. 25.
MFC - 예외(Exception) 처리 (try catch, CException) Exception 에러 메세지창으로 띄우기 try { // Exception 발생 구문 } catch (CException *ex) { ex->ReportError(); } Excption 에러 메세지 얻어오기 try { // Exception 발생 구문 } catch (CException *ex) { TCHAR szMsg[1024] = {0,}; ex->GetErrorMessage(szMsg, 1024); CString strMsg; strMsg.Format(/*적절한 메세지 만들기*/); ::AfxMessageBox(strMsg); } 위에 예문을 토대로 함수를 만들어 봤습니다. Made by 꾸션 헤더 CString GetErrorDescription(CException *ex); CString G.. 2015. 2. 9.
MFC - GetLastError()에 해당하는 메세지 출력 GetLastError에 해당하는 메세지 얻어오기 LPVOID lpMsgBuf = NULL; CString strMsg; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL); if (!lpMsgBuf) { strMsg = (LPCTSTR)lpMsgBuf; LocalFree(lpMsgBuf); } 이를 토대로 함수를 만들어 보았습니다. Made by 꾸션 헤더 CString GetErrorDescription(DWORD dwLastErrorCode); CStr.. 2015. 2. 9.
MFC - [추천도서] Visual C++ 6 완벽가이드 2nd Edition Visual C++ 혹은 MFC를 공부를 막 시작하시려는 분들께 아래의 책을 소개해드립니다. 흔히, "눈깔이책"으로 유명한 책이죠. 2nd Edition으로도 알 수 있듯이 책의 구성이나 내용이 꽤 괜찮게 짜여져 있습니다. 각 Chapter별 예제도 CD로 제공하고 있어서, 초입단계 분들에게는 아주 유용하다고 생각됩니다. 목차는 아래와 같습니다. Part 1 기본 프로그래밍 Chapter 1 사전학습 Chapter 2 프로그램의 뼈대 Chapter 3 GDI를 이용한 그래픽 Chapter 4 대화상자와 컨트롤 Chapter 5 사용자 인터페이스 Chapter 6 도큐먼트의 데이터 관리 Part 2 고급 프로그래밍 Chapter 7 분할 윈도우와 다중 뷰 Chapter 8 다중 도큐먼트 프로그램 Chapt.. 2015. 2. 4.
MFC - 리스트컨트롤(CListCtrl) 대용량 데이터 처리 리스트 컨트롤에서 대용량의 데이터를 업데이트 하는 방법에 대해서 알아보겠습니다. CListCtrl클래스의 SetItemCount(), SetItemCountEx()함수를 사용하면 되는데, 사용 방법은 업데이트 할 데이터의 양을 먼저 위 두개의 함수를 사용하여 알려주고, 데이터를 입력하기만 하면 됩니다. 아래는 각 각의 함수를 사용하는 방법이며, MSDN에서 발췌하였습니다. CListCtrl::SetItemCount() https://msdn.microsoft.com/en-us/library/88tba5s4.aspx CString str; // Add 1024 items to the list view control. m_myListCtrl.SetItemCount(1024); for (int i = 0; i.. 2015. 2. 3.
반응형