I'm creating a context menu for a window and I'd like to have in a submenu filled ellipses, each in a different colour, instead of texts - this submenu is responsible for choosing a colour. I don't know how to do it... Does anybody know any concrete example? I've read on MSDN pages about owner-drawn menu items, but there were no example concerning this specific task - so, I don't know how to do it. Later I tried to change checked icon for my menu item - but it turned out my Dev-C++ (under Windows 7) knows neither SetDCBrushColor nor DC_BRUSH, and I still don't know how to change checked icon without loading an image from a file. Then I added at the beginning of my program the following lines:
#define _WIN32_IE 0x0600
#define WINVER 0x0700
#define _WIN32_WINNT 0x0700
Then the compiler doesn't protest, however, the icon is always black, when I'm trying the following code and whatever colour I'm choosing:
HWND hwnd = GetDesktopWindow();
HDC hdc = GetDC( hwnd );
HDC hdcMem = CreateCompatibleDC( hdc );
SIZE size = { GetSystemMetrics( SM_CXMENUCHECK ), GetSystemMetrics( SM_CYMENUCHECK ) };
HBITMAP bitmap = CreateCompatibleBitmap( hdcMem, size.cx, size.cy );
HBITMAP bitmapOld = (HBITMAP) SelectObject( hdcMem, bitmap );
PatBlt( hdcMem, 0, 0, size.cx, size.cy, WHITENESS );
HBRUSH brushOld = (HBRUSH) SelectObject( hdcMem, GetStockObject( NULL_BRUSH ) );
Ellipse( hdcMem, 0, 0, size.cx, size.cy);
SetDCBrushColor( hdcMem, RGB(0,0,255) );
SelectObject( hdcMem, GetStockObject( DC_BRUSH ) );
Ellipse( hdcMem, 2, 2, size.cx-2, size.cy-2 );
SelectObject( hdcMem, brushOld );
SelectObject( hdcMem, bitmapOld );
DeleteDC( hdcMem );
ReleaseDC( hwnd, hdc );
SetMenuItemBitmaps( mnu_t, (30*M_MENU_T+25), MF_BYCOMMAND, bitmap, bitmap);// mnu_t and M_MENU_T are my variables
Can anyone help me?