[*.h]に追加
// gdiplus.hはHの最後に読み込んでください
#include <gdiplus.h>
#pragma comment (lib, "Gdiplus.lib")
using namespace Gdiplus;
[.cpp]
Bitmap *pImage;
int APIENTRY _tWinMain(......)
{
// TODO: ここにコードを挿入してください。
// GDIの開始
Gdiplus::GdiplusStartupInput gSi;
ULONG_PTR gToken;
Gdiplus::GdiplusStartup(&gToken, &gSi, NULL);
.
.
.
.
.
.
// GDIの終了
Gdiplus::GdiplusShutdown(gToken);
return (int) msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
Graphics *gp;
switch (message)
{
case WM_CREATE:
// Bitmap作成
pImage = new Bitmap(L"フルパスのファイル名");
if(pImage==NULL || pImage->GetLastStatus()!=Ok){
MessageBox(NULL,"読み込みエラー","",MB_OK);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
gp = new Graphics(hdc);
gp->DrawImage(pImage, 0, 0);
// Graphicsオブジェクトを破棄
delete gp;
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
delete pImage;
break;
}
|