Quote:Original post by kingnosis
It looks to me like your problem is scope. You create hWndButton inside of the WM_CREATE case, so as soon as the windows procedure exits, your handle to the button is destroyed.
I believe that windows (such as buttons) get detroyed automatically, without you having to call a release function.
I'd say try making your button global, or static inside the WndProc.
kingnosis
Hi kingnosis.
These are only handles. Handles are not objects, therefore they don't have a destructor which is called when you go out of scope. A handle is 'destroyed' when
1) you DestroyWindow() it
2) you DestroyWindow() one of its ancestor.
@d1sc0rd:
a)the first BM_SETIMAGE was already working - the NULL return was correct, since it returns the previous associated bitmap handle. Since you just created the button, tyhere was no associated bitmap, hence the NULL return. You don't have to call it twice - just discard the NULL check. If you want to verify that your bitmap had been set by your SendMessage() call then you can issue another SendMessage() with BM_GETIMAGE. This will return you the handle of the current button bitmap.
Quote:Original post by d1sc0rd
I tried checking the return from the BM_GETSTATE as well. It should be returning 0 I think, which would be different from null, right?
b) #define NULL 0
So I guess that 0 and NULL should be the same :)
c) take care about your WM_CREATE handling. The MSDN states:
Quote:WM_CREATE return code
If an application processes this message, it should return zero to continue creation of the window. If the application returns –1, the window is destroyed and the CreateWindowEx or CreateWindow function returns a NULL handle.
d) I see nothing wrong with your code. Are you sure you see the button and no bitmap on it? Are you sure IDB_RIGHT_ARROW is correct? Can you try with a system bitmap (hBmp = LoadBitmap(NULL, MAKEINTRESOURCE(OBM_CHECK)); or hBmp = LoadBitmap(NULL, OBM_CHECK);, I don't remember which one is teh win).