我可以在窗口上成功显示单个图像,我不确定如何在窗口上显示两个图像。我为不同的图像重复了相同的代码,但它不起作用。这是显示单个图像的代码。
static HBITMAP bmpSource = NULL;
static HDC hdcSource = NULL;
PAINTSTRUCT ps;
HDC hdcDestination;
//* inside the WndProc()
case WM_PAINT:
bmpSource = (HBITMAP)LoadImage(NULL,file_path,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
hdcSource = CreateCompatibleDC(GetDC(0));
SelectObject(hdcSource, bmpSource);
hdcDestination = BeginPaint(hwnd, &ps);
BitBlt(hdcDestination,img_x, img_y, 300, 300, hdcSource, 0, 0, SRCCOPY);
EndPaint(hwnd, &ps);
breaks;
//**
这就是我正在做的事情,我有窗口 gui 的经验。
static HBITMAP bmpSource = NULL,bmpSource2 = NULL;
static HDC hdcSource = NULL,hdcSource2 = NULL;
PAINTSTRUCT ps;
HDC hdcDestination;
//* inside the WndProc()
case WM_PAINT:
bmpSource = (HBITMAP)LoadImage(NULL,file_path,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
hdcSource = CreateCompatibleDC(GetDC(0));
SelectObject(hdcSource, bmpSource);
bmpSource2 = (HBITMAP)LoadImage(NULL,file2_path,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
hdcSource2 = CreateCompatibleDC(GetDC(0));
SelectObject(hdcSource2, bmpSource2);
hdcDestination = BeginPaint(hwnd, &ps);
BitBlt(hdcDestination,img_x, img_y, 300, 300, hdcSource, 0, 0, SRCCOPY);
BitBlt(hdcDestination,img2_x, img2_y, 300, 300, hdcSource2, 0, 0, SRCCOPY);
EndPaint(hwnd, &ps);
breaks;
//**