MFC, GDI

C++ 2012. 4. 6. 23:00


컨트롤 동적 생성

// 버튼 동적 생성

CButton* button = new CButton();

RECT rect;

rect.left = 0; rect.top = 0; // pos

rect.right = 100; rect.bottom = 100; // size

button->Create(m_hWnd, ATL::_U_RECT(rect), _T("dynamically created button"), WS_CHILD | WS_VISIBLE );


GDI 초기화

// GDI+

#include <objbase.h>

#include <gdiplus.h>

#pragma comment(lib, "gdiplus")

using namespace Gdiplus;


// init GDI+

ULONG_PTR m_gpToken; // gdi+

GdiplusStartupInput gpsi;

if (GdiplusStartup(&m_gpToken, &gpsi, NULL) != Ok)

{

AfxMessageBox(_T("can't initialize GDI+"));

return FALSE;

}

// release GDI+

GdiplusShutdown(m_gpToken);