Set BITMAP on a STATIC control

I am trying to display a BITMAP image on a STATIC control and it doesn't work. I don't know what am I doing wrong.

My code is this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//--RESOURCES.RC--
#define MYBITMAP "mybitmap.bmp"

//--RESOURCES.H--
#define MYBITMAP  101

#define CONTAINER 201
#define PICTURE   202

//--MAIN.CPP--

HWND container, picture;
BITMAP mybitmap;

//--I am trying to apply the bitmap inside the WM_CREATE message

case WM_CREATE:
     // This is a STATIC that contains the STATIC that displays the image
     container = CreateWindowEx(
                 0, 
                 "STATIC", 
                 NULL, 
                 WS_CHILD|WS_VISIBLE, 
                 5, 21, 190, 180, 
                 hWnd, 
                 (HMENU)CONTAINER, 
                 hInstance, 
                 NULL
                 );
     // This is the STATIC that contains the image
     picture = CreateWindowEx(
               0, 
               "STATIC", 
               NULL, 
               WS_CHILD|WS_VISIBLE|SS_BITMAP, 
               100, 30, 100, 100, 
               container, 
               (HMENU)PICTURE, 
               hInstance, 
               NULL
               );

     mybitmap = LoadBitmap(hInstance, MAKEINTRESOURCE(MYBITMAP));
     SendDlgItemMessage(container, PICTURE, STM_SETIMAGE, (WPARAM)MYBITMAP, (LPARAM)mybitmap);
break;


Again, I feel like something is missing. Any ideas, please? Thanks!
Last edited on
The wParam is incorrect. It has to be IMAGE_BITMAP. See http://msdn.microsoft.com/en-us/library/windows/desktop/bb760782(v=vs.85).aspx for details.
Second time I make the same mistake.
100 points for webJose. Thanks man!
Last edited on
Topic archived. No new replies allowed.