Study/C, C++ (MFC, UE)

GDI+을 사용하려면 반드시 초기화 구문을 쓰자

BlueBright 2018. 6. 25. 09:55

GDI+가 경로가 맞음에도 불구하고, 이미지를 불러오지 못해서 찾아봤지만,

여러가지 시도를 해봤지만 실패


그러다가 GDI+를 사용하기 전에 초기화가 필요하다는 것을 뒤늦게 알고,

선언을 하니까 이미지를 잘 불러오게됨...


기초는 항상 중요하다....


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//StdAfx.h
#include <gdiplus.h>
#pragma comment(lib, "gdiplus")
using namespace Gdiplus;
 
 
//thaApp이 선언되어있는 클래스.h/cpp 파일 쪽
 
//전역변수 선언
ULONG_PTR    m_gdiplusToken;
 
 
BOOL (클래스 이름)::InitInstance(){
    GdiplusStartupInput gdiplusStartupInput;
 
    if (::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL!= Ok) {
        AfxMessageBox(_T("ERROR : Failed to initialize GDI+ library"));
        return FALSE;
    }
}
 
 
int (클래스 이름)::ExitInstance(){
    GdiplusShutdown(m_gdiplusToken);
}
cs



출처 : 열혈강의 Visual C++ 2008 MFC 윈도우 프로그래밍 (최호성 저)