This topic is now archived and is closed to further replies.


This topic is 5152 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Okay guys, I''m stumped. I''ve followed the MSDN examples and docs to the letter, but so far no good. I''m trying to create a static picture box that I can display a picture in, but it''s not working. Here''s some of my code:

HWND texPicBox;
HBITMAP texImage;

    // Create a Static box
    texPicBox = CreateWindowEx(WS_EX_STATICEDGE, "STATIC", "", 
    0, 0, 50, 50, texManHwnd, NULL, GetModuleHandle(NULL), NULL);
    if(texPicBox == NULL)
        MessageBox(NULL, "Can''t create Texture Picture Box.", "Error", MB_OK | MB_ICONERROR);
    texImage = (HBITMAP)LoadImage(NULL, "c:\\img.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);

    if(texImage == NULL)
        MessageBox(NULL, "Can''t load texture image.", "Error", MB_OK | MB_ICONERROR);
    SendMessage(texManHwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)(HANDLE)texImage);

That all is correct, no? But it''s not showing my image in the box. Any ideas? Thanks! CD Jesus is Lord!!

Share this post

Link to post
Share on other sites
You might need to invalidate the rect around the image.
An easy test to see if this is the problem is to move your app window off the screen then back on, if the picture shows up then you just have to do an Invalidate() and it should work.

Share this post

Link to post
Share on other sites