I've looked over the code available on the forums and the example over at msdn (they're all pretty much the same), though nothing I found actually covered multiple owner drawn cntls. The code snipet below works, though my question are;
- is it correct?
- can I use the same image (depressed state) for several controls, or should each individual control have its own set of bmps (nothing shared).
Code:
case WM_DRAWITEM:
{
DRAWITEMSTRUCT* lpDrawItem=(DRAWITEMSTRUCT*)lParam;
HBITMAP hBmp;
if (lpDrawItem->itemState&ODS_SELECTED)
{
if (LOWORD(wParam)==IDC_BUTTONA){
hBmp=reinterpret_cast<HBITMAP>(LoadImage(GetModuleHandle(0),
MAKEINTRESOURCE(IDI_NUMONE),
IMAGE_BITMAP,0,0,
LR_CREATEDIBSECTION));
}
if (LOWORD(wParam)==IDC_BUTTONB){
hBmp=reinterpret_cast<HBITMAP>(LoadImage(GetModuleHandle(0),
MAKEINTRESOURCE(IDI_NUMONE),
IMAGE_BITMAP,0,0,
LR_CREATEDIBSECTION));
}
}
else
{
if (LOWORD(wParam)==IDC_BUTTONA){
hBmp=reinterpret_cast<HBITMAP>(LoadImage(GetModuleHandle(0),
MAKEINTRESOURCE(IDI_NUMONEB),
IMAGE_BITMAP,0,0,
LR_CREATEDIBSECTION));
}
if (LOWORD(wParam)==IDC_BUTTONB){
hBmp=reinterpret_cast<HBITMAP>(LoadImage(GetModuleHandle(0),
MAKEINTRESOURCE(IDI_NUMTWOB),
IMAGE_BITMAP,0,0,
LR_CREATEDIBSECTION));
}
}