본문 바로가기

MFC

[스크랩] USB 시리얼 포트 자동 인식하기 출처: http://infoarts.tistory.com/22 요즘은 MCU에도 USB 기능이 원칩화 되면서 점점 UART를 RS232C로 사용하지 않고 USB로 사용할 수 있습니다. 그러다보니 별도의 추가 비용없이 USB Serial 기능을 사용할 수 있게 되었습니다. 그런데, Windows 어플리케이션에서 USB 시리얼을 연결하여 사용하다가 Windows 어플리케이션에서 연결을 끊지 않은 상태에서 USB 시리얼 케이블을 뽑았다가 다시 연결하거나 또는 타깃 보드가 리셋되어서 Windows 어플리케이션에서 연결을 끊고 다시 연결하려면 연결이 않되는 버그가 있습니다. 즉, Windows에서 타깃 보드와 시리얼 통신을 하고 있다가 보드를 리셋하면 다시 연결하려면 않되는 것이죠. 이 때는 USB 시리얼 포트를.. 더보기
ChartDirector 한글 입력 문제 (ChartDirector Encoding) 차트를 그릴때 유용하게 사용할 수 있는 라이브러리 CharDirector(http://www.advsofteng.com/index.html)다만.. 영어가 아닌 문자를 그래프에 사용할 경우, 유니코드로 변환 & 해당문자 사용가능 폰트로 변경해 주어야한다. 예제코드) wchar_t strUni[256] =L"유니코드"; char title[256] = {0x00,}; WideCharToMultiByte(CP_UTF8, 0, strUni, -1, title, sizeof(char)*255, 0, 0); double x[] = { 0, 1, 2 }; double y[] = { 50, 100, 150 }; // Create a XYChart object of size 250 x 250 pixels XYChart.. 더보기
System Error Code (GetLastError Code) 출처 : https://msdn.microsoft.com/en-us/library/windows/desktop/ms681381(v=vs.85).aspx System Error CodesNote The information on this page is intended to be used by programm s681383(v=vs.85).aspx ers so that the software they write can better deal with errors. If you are an end-user that is experiencing difficulty with an application you are installing or running, contact customer support for the .. 더보기
[MFC] ShellExecute function 출처: https://msdn.microsoft.com/en-us/library/windows/desktop/bb762153(v=vs.85).aspx Performs an operation on a specified file.SyntaxC++HINSTANCE ShellExecute( _In_opt_ HWND hwnd, _In_opt_ LPCTSTR lpOperation, _In_ LPCTSTR lpFile, _In_opt_ LPCTSTR lpParameters, _In_opt_ LPCTSTR lpDirectory, _In_ INT nShowCmd ); Parametershwnd [in, optional]Type: HWNDA handle to the parent window used for displayi.. 더보기
[MFC] 프로그램 중복실행 방지 1. App클래스에 멤버변수 추가HANDLEm_hDpMutex; 2. InitInstance()에 다음 코드 추가m_hDpMutex = CreateMutex(NULL, FALSE, "프로젝트명");if(ERROR_ALREADY_EXISTS == GetLastError()) return FALSE; 더보기
[MFC] 다양한 문자열 형식간 변환 출처: http://msdn.microsoft.com/ko-kr/library/ms235631.aspx 1) char * -> wchar_t*, _bstr_t, CComBSTR, CString, basic_string, System.String// convert_from_char.cpp // compile with: /clr /link comsuppw.lib #include #include #include #include "atlbase.h" #include "atlstr.h" #include "comutil.h" using namespace std; using namespace System; int main() { // Create and display a C style string, and then .. 더보기
[MFC] _RecordsetPtr RecordCount returns -1 출처: http://www.adopenstatic.com/faq/recordcounterror.asp RecordCount returns -1The use of the ADO Recordset's .RecordCount property requires either the use of:Static or Keyset server-side cursors orA client-side cursor (which returns a Static cursor)(Note: some OLEDB Providers will return the correct recordcount with an adOpenDynamic cursor, others will not).By default Recordsets are opened serv.. 더보기
[MFC] CListctrl, CTreectrl Drag And Drop 오류 (No Text Error) 리스트컨트롤이나, 트리컨트롤에서 드래그 앤 드랍을 사용할 경우 아래와같은 문제가 발생할 때가 있다.사진출처) 구글 검색 원인은 XP부터 생겨난 ClearType 글꼴의 안티앨러싱(?)설정 때문.. 해결방법은 드래그 이미지를 생성하는 CreateDragImage함수 호출전에 안티앨러싱을 제거한 폰트를 설정하고,호출이 종료되면 원설정의 폰트상태로 복구하는 것. 주의할 사항) Font는 지역변수가 아닌, 전역/멤버변수로 선언하여 프로그램이 실행되는 동안 객체가 유지되어야 한다.CFont설정 참조: http://ogoons.tistory.com/43 적용 코드) 현재 코드는 트리컨트롤일때를 가정했지만, 리스트컨트롤의 경우에도 몇몇 설정을 제외하고는 동일하다.//CFont 선언 CFont *m_pDragFont;.. 더보기
[MFC]기존 프로젝트에 WinSock(CSocket) 추가하기 초기화 함수에서 아래 코드 추가if(!AfxSocketInit()){AfxMessageBox("Socket Initialize Error");return false;} stdafx.h 파일에 아래 코드 추가#include 더보기
[MFC] DLL 만들기 Sample Code 위와 같이 MFC로 구현하는 DLL의 세가지 방식에 대한 Sample Code자세한 구현방법은 주석을 확인작성 툴 : Visual Studio 2010 구현방식 출처 :http://psh85a.tistory.com/entry/MFC-Dll-%EB%B0%B0%ED%8F%AC-%EB%B0%8F-%EC%82%AC%EC%9A%A9 http://blog.daum.net/cjp777/4 http://leekiho.tistory.com/12 더보기