王秃秃 2019-07-27 11:56 采纳率: 0%
浏览 264

c如何在桌面显示位图??

为什么显示不出图片呢 桌面上啥也没有


```int main(int argc, char *argv[])
{

    HDC hdc = CreateCompatibleDC(NULL);
    HBITMAP cross = (HBITMAP)LoadImage(NULL, L"C:\\Users\\Administrator\\Desktop\\1.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
    SelectObject(hdc, cross);
    while (1)
    {
        HDC hdc_x = GetDC(HWND_DESKTOP);
        BitBlt(hdc_x, 60, 60, 900, 900, hdc, 60, 60, SRCCOPY);
        ReleaseDC(HWND_DESKTOP, hdc_x);
    }

    return 0;
}
  • 写回答

1条回答 默认 最新

  • qtchen_1988 2019-07-27 12:39
    关注
    先检查图片是否能找到;
    #include <unistd.h>
    #include <fcntl.h>
    
    char img_file[] = "C:\\Users\\Administrator\\Desktop\\1.bmp";
    if((access(img_file,F_OK)) == -1)
    {
        printf("file: %s inexistent!\n",img_file);
    }
    
    评论

报告相同问题?