기본 콘텐츠로 건너뛰기

라벨이 MFC인 게시물 표시

Mixed C++/CLI TypeLoadException Internal limitation: too many fields

원문보기 Mixed C++/CLI TypeLoadException Internal limitation: too many fields up vote 3 down vote favorite On a quest to migrate some new UI into Managed/C# land, I have recently turned on Common Language Runtime Support (/clr) on a large legacy project, which uses MFC in a Shared DLL and relies on about a dozen other projects within our overall solution. This project is the core of our application, and would drive any managed UI code that is produced (hence the need to turn on clr support for interop). After fixing a ton of little niggly errors and warnings, I finally managed to get the application to compile.. However, running the application causes an EETypeLoadException and leaves me unable to debug... Doing some digging, I found the cause to be "System.TypeLoadException: Internal limitation: too many fields." which occurs right at the end of compilation. I then found  this link  which suggests to break the assembly down into two or more dlls. However...

Python 배포하기

MFC로 만든 프로그램에 python을 embedding하여 사용중인데 배포에 문제가 발생했습니다. 즉 python이 설치된 컴퓨터에는 제대로 작동하나 그렇지 않은 컴퓨터에는 python 코드가 실행되지 않는다는 겁니다.(py2exe로 python dll과 library.zip 파일을 생성) 그렇다고 모든 사용자들에게 python을 설치하고 프로그램을 실행하라고 할 수도 없는 일이구요... 그래서 구글링을 하여 찾아보니 python에 있는 DLLs와 Lib 폴더를 프로그램 폴더에 복사하여 배포를 하면 된다고하여 그렇게 해보았더니... 성공!!! 프로그램 폴더 구조 + 응용 프로그램 pythonxx.dll  -- + python    -- + DLLs : python에 있는 DLLs 폴더에 있는 모든 파일을 복사합니다.    -- + Lib : python에 있는 Lib 폴더에 있는 모든 파일을 복사합니다. 이렇게 하니 단점은 프로그램 배포 파일의 크기가 커진다는거~~ DLLs,Lib 폴더를 압축하여 배포 파일을 생성하였는데도 기존보다 약 10M 정도가 큽니다.

프린터 속성 설정하기

아래는 프린터 속성을 설정하는 함수입니다. 원문보기 #include <WinSpool.h> /** @brief set printer property @author humkyung @date 2013.11.06 @param pPrinterName @param dmType @param dmValue **/ STDMETHODIMP CISODwgLib4IDCS::SetPrinterProperty(BSTR pPrinterName , SHORT dmType, SHORT dmValue, VARIANT_BOOL* ret) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); CString sPrinterName(pPrinterName); (*ret) = VARIANT_TRUE; ////////////////////////////////////////////////////////////////////////// HANDLE hPrinter = NULL; DWORD dwNeeded = 0; PRINTER_INFO_2 *pi2 = NULL; DEVMODE *pDevMode = NULL; PRINTER_DEFAULTS pd; BOOL bFlag; LONG lFlag; // Open printer handle (on Windows NT, you need full-access because you // will eventually use SetPrinter)... ZeroMemory(&pd, sizeof(pd)); pd.DesiredAccess = PRINTER_ALL_ACCESS; bFlag = OpenPrinter(LPSTR(sPrinterName.operator LPCSTR()) , &hPrinter, &pd); if (!bFlag || (hPrinter == NULL)) return FALSE; // The first GetPrinter tells ...

MessageBox with custom icon

MSGBOXPARAMS msgbox = { 0 } ; msgbox . cbSize = sizeof ( msgbox ) ; msgbox . dwStyle = MB_USERICON | MB_OK ; // MB_USERICON - flag for "lpszIcon" msgbox . hInstance = GetModuleHandle ( 0 ) ; // handle of file with icon msgbox . hwndOwner = hWnd ; // parent window msgbox . lpszIcon = ( LPTSTR ) IDI_ICOID ; // ID of icon msgbox . lpszCaption = " Caption " ; msgbox . lpszText = " MessageBox with user icon " ; MessageBoxIndirect ( & msgbox ) ;

리스트 뷰의 응용

원문보기 1. 콜백항목 리스트 뷰는 컨트롤이 자체적으로 데이터를 관리한다. 그러나 메모리의 낭비가 생기고 데이터를 따로 관리해야 함으로 대량의 데이터를 관리할 경우에는 콜백 항목으로 데이터를 관리하는게 좋다. 콜백항목은  응용프로그램이 직접 리스트 뷰의 데이터를 소유 하고 있다가 리스트 뷰가 출력 또는 정렬을 위해 데이터가  필요할 경우에만 데이터를 제공 해 주는 형식을 말한다. 일괄적으로 데이터를 관리할 수 있다는 점과 메모리가 이중으로 낭비되지 않는다는 장점이 있다. 1-1 콜백항목의 추가 콜백항목을 사용하기 위해서는 일단 항목(아이템)을 추가 할 때 문자열은  LPSTR_TEXTCALLBACK  형식으로, 이미지는  I_IMAGECALLBACK  형식으로 추가를 하게 되면 콜백항목으로 등록이 된다. ex) LVITEM lvi ; lvi . mask = LVIF_TEXT ; lvi . state = 0 ; lvi . stateMask = 0 ; lvi . iSubItem = 0 ; for ( int i = 0 ; i < 5 ; i + + ) { lvi . iItem = i ; lvi . pszText = LPSTR_TEXTCALLBACK ; ListView_InsertItem ( hListView , & lvi ) ; ListView_SetItemText ( hListView , i , 1 , LPSTR_TEXTCALLBACK ) ; ListView_SetItemText ( hListView , i , 2 , LPSTR_TEXTCALLBACK ) ; ListView_SetItemText ( hListView , i , 3 , LPSTR_TEXTCALLBACK ) ; } 1-2 콜백항목의 데이터 처리 콜백항...

C++ 0x : 람다(Lambda)

원문:  http://scor7910.tistory.com/55 Visual C++ 팀블로그에 C++0x에 대한 소개 자료중 람다(Lambda)에 관한 내용을 번역했습니다. 차후에 나머지도 번역해서 올리겠습니다. 번역이 만만치 않은 작업이근영....  원본 :  http://blogs.msdn.com/vcblog/archive/2008/10/28/lambdas-auto-and-static-assert-c-0x-features-in-vc10-part-1.aspx Lambdas, auto, and static_assert: C++0x Features in VC10, Part 1 마이크로소프트   비절   스투디오  2010CTP(Community Technology Preview) 에서는  C++ 0x 에   포함된   lambdas ,  auto ,  static_assert , rvalue references   라는  4 가지의   개념을   제공합니다 .    여기서는   처음   세가지에   대해   이야기를   하겠습니다 . 첫번째로   ,  내용을   쓰기전 ..: 1.  이   포스트는  Visual C++  라이브러리   개발자인 Stephan T. Lavavej  님이 작성했습니다 .  그리고   Stephan T. Lavavej 님이   위의   네가지   기능에   대한   구현을   담당하지   않았음을   밝힘니다 . 2.  내용에서  VS 2010 에서  Visual C++  컴파일러를 ...