if you want to use bitmaps for the buttons, don't know if that's the idea:
hbmp=the HBITMAP of the BMP file or resource for the button in normal state
hbmp_pressed=the HBITMAP of the BMP file for the button in pressed state
so for every button, you need at least two bitmaps
Code:
LPDRAWITEMSTRUCT lpdis;
HDC hdc,hdcMem;
...
WM_CREATE:
...
hbutton = CreateWindow("button",NULL,WS_CHILD|WS_VISIBLE|BS_OWNERDRAW,0,0,0,0,hwnd,(HMENU)MYBUTTON,hinstance,NULL);
//also load the bitmaps here
...
case WM_DRAWITEM :
lpdis = (LPDRAWITEMSTRUCT) lParam;
hdcMem = CreateCompatibleDC(lpdis->hDC);
switch(lpdis->CtlID)//if the button is not pressed
{
case MYBUTTON:
SelectObject(hdcMem, hbmp);
StretchBlt(lpdis->hDC, lpdis->rcItem.left,lpdis->rcItem.top, lpdis->rcItem.right - lpdis->rcItem.left, lpdis->rcItem.bottom - lpdis->rcItem.top, hdcMem,0,0,mybuttonwidth,mybuttonheight,SRCCOPY);
break;
}
if(lpdis->itemState & ODS_SELECTED)//if the button is pressed
{
switch(lpdis->CtlID)
{
case MYBUTTON:
SelectObject(hdcMem, hbmp_pressed);
StretchBlt(lpdis->hDC, lpdis->rcItem.left,lpdis->rcItem.top, lpdis->rcItem.right - lpdis->rcItem.left, lpdis->rcItem.bottom - lpdis->rcItem.top, hdcMem,0, 0,mybuttonwidth,mybuttonheight,SRCCOPY);
break;
}
DeleteDC(hdcMem);
return 0;