SS_CENTERIMAGE | SS_BITMAP are for STATIC window.
Simplified example for owner draw button in WinCE:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#define IDM_EXIT 6001
#define IDM_TEST 6002
#define IDM_BTN1 6010
LRESULT WINAPI WndProc(HWND, UINT, WPARAM, LPARAM);
BOOL OnCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct);
void OnDestroy(HWND hwnd);
void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify);
void OnDrawItem(HWND hwnd, const DRAWITEMSTRUCT * lpDrawItem);
TCHAR szAppName[] = L"OwnerDrawCE";
TCHAR szFrameClass[] = L"cOwnerDrawCE";
HWND hFrame;
HANDLE hInst;
HWND hWndBtn1, hWndBtn2;
HBITMAP hBM;
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
WNDCLASS wc;
MSG msg;
//memset(&wc, 0, sizeof(wc));
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC)WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
// wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hIcon = 0;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
wc.lpszMenuName = NULL;
wc.lpszClassName = szFrameClass;
if (!RegisterClass(&wc)) {
MessageBox(NULL,L"Error with RegisterClass",0,0);
return 0;
}
hInst = hInstance;
hFrame = CreateWindowEx(WS_EX_CAPTIONOKBTN, szFrameClass, szAppName,
//WS_OVERLAPPEDWINDOW,
WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInst, NULL);
if(!hFrame) return 0;
ShowWindow(hFrame, nCmdShow);
UpdateWindow(hFrame);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT WINAPI WndProc(HWND hwnd, UINT wMsg, WPARAM wParam, LPARAM lParam)
{
switch(wMsg) {
case WM_COMMAND: return OnCommand(hwnd,(int)LOWORD(wParam),(HWND)lParam,(UINT)HIWORD(wParam)),0;
case WM_CREATE: return OnCreate(hwnd,(LPCREATESTRUCT)lParam),0;
case WM_DESTROY: return OnDestroy(hwnd),0;
case WM_DRAWITEM: return (OnDrawItem(hwnd,(const DRAWITEMSTRUCT*)lParam),0);
default:
return DefWindowProc(hwnd, wMsg, wParam, lParam);
}
}
BOOL OnCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct)
{
OutputDebugString(L"WM_CREATE");
hWndBtn1 = CreateWindow( L"BUTTON", L"Exit", WS_VISIBLE, 5, 5, 105, 45, hwnd, (HMENU)IDM_EXIT, hInst, NULL);
hWndBtn1 = CreateWindow( L"BUTTON", L"Button 1", WS_VISIBLE | BS_OWNERDRAW, 5, 50, 105, 45, hwnd, (HMENU)IDM_BTN1, hInst, NULL);
hBM = SHLoadDIBitmap(L"\\Storage Card\\Button1.bmp");
return 0;
}
void OnDestroy(HWND hwnd)
{
OutputDebugString(L"WM_DESTROY");
if (hBM) DeleteObject(hBM);
PostQuitMessage(0);
}
void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
switch(id) {
case IDM_EXIT:
PostMessage(hwnd, WM_CLOSE, 0, 0L);
return;
}
}
void OnDrawItem(HWND hwnd, const DRAWITEMSTRUCT * lpDrawItem)
{
RECT rc;
HDC hdc;
HDC hdcMem;
HBITMAP hbmOld;
BITMAP bm;
rc = lpDrawItem->rcItem;
hdc = lpDrawItem->hDC;
hdcMem = CreateCompatibleDC(hdc);
hbmOld = SelectObject(hdcMem, hBM);
GetObject(hBM, sizeof(bm), &bm);
//BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
//SelectObject(hdcMem, hbmOld);
if (lpDrawItem->itemState & ODS_SELECTED) {
BitBlt(hdc, 1, 1, bm.bmWidth-1, bm.bmHeight-1, hdcMem, 0, 0, SRCCOPY);
DrawEdge(lpDrawItem->hDC, &rc, EDGE_SUNKEN, BF_RECT);
//DrawEdge(lpDrawItem->hDC, (LPBORDERWIDTHS)&lpDrawItem->rcItem, EDGE_SUNKEN, BF_RECT);
} else {
BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
DrawEdge(lpDrawItem->hDC, &rc, EDGE_RAISED, BF_RECT);
}
SelectObject(hdcMem, hbmOld);
DeleteDC(hdcMem);
}