Poon Sloth
Poon Sloth

Reputation: 9

I cannot load image from folder using win32

I am new to win32. I placed the bitmap image 'logo2.bmp' into the directory which .vcxproj is there. However, when I used the LoadImage() function, it seems that nothing is loaded.

I have checked my questions online, but the image still cannot be loaded after the modification.

void AddControls(HWND hwnd)
{
//some code
    hLogo = CreateWindowW(L"Static", NULL, WS_VISIBLE | WS_CHILD | SS_BITMAP,
                                 350, 60, 100, 100, hwnd, NULL, NULL, NULL);
    if (hLogoImage != NULL)
    {
        SendMessage(hLogo, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hLogoImage);
    }
    else
    {
        MessageBox(0, L"Could not load image", L"Error", MB_OK);
    }
}

void loadImages()
{
    hLogoImage = (HBITMAP)LoadImage(NULL, L"logo2.bmp", IMAGE_BITMAP,
                                      0,0,LR_LOADFROMFILE | LR_DEFAULTSIZE);
}

I expect the output is a bitmap image successfully displayed on the windows, but the 'Error' text box was displayed and no picture displayed instead.

Upvotes: -1

Views: 1707

Answers (1)

Poon Sloth
Poon Sloth

Reputation: 9

Edit: Okay, I understand that this is a problem of file format. I better study more.

Upvotes: -1

Related Questions