R.Wieser a écrit :
It works fine for me (Windows 10) :
https://i.ibb.co/tKNzgJV/GDi-Plus-Flat.gif
Global variable :
GpImage* img;
Main window :
//...
static hWndStatic = NULL;
//...
case WM_CREATE:
{
hWndStatic = CreateWindowEx(0, TEXT("Static"), TEXT(""), WS_CHILD |
WS_VISIBLE | SS_BITMAP, 10, 10, 500, 500, hWnd, (HMENU)IDC_STATIC,
hInst, NULL);
//hWndButton = CreateWindowEx(0, L"Button", L"Click", WS_CHILD |
WS_VISIBLE | BS_PUSHLIKE, 100, 60, 60, 32, hWnd, (HMENU)IDC_BUTTON,
hInst, NULL);
GpStatus nStatus = GdipLoadImageFromFile(L"E:\\Hulk.png", &img);
BOOL bRet = SetWindowSubclass(hWndStatic, StaticSubclassProc, 0, 0);
return 0;
}
break;
Subclass proc for Static to display image :
LRESULT CALLBACK StaticSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam,
LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
{
switch (uMsg)
{
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hDC = BeginPaint(hWnd, &ps);
GpGraphics *g;
GdipCreateFromHDC(hDC, &g);
GdipDrawImage(g, img, 0, 0);
GdipDeleteGraphics(g);
EndPaint(hWnd, &ps);
}
break;
}
return DefSubclassProc(hWnd, uMsg, wParam, lParam);
}