jesterspirit101
Programmer
I am fairly new at programming and have recently been studying ownerdraw menus.
This code in DrawItem(LPDRAWITEMSTRUCT lpDIS) works fine in 98 or NT
but wont work with XP.
//////////
CDC *pDC = CDC::FromHandle(lpDIS->hDC);
CBrush redBrush(RGB(255, 0, 0));
CBrush blueBrush(RGB(0, 0, 255));
CBrush yellowBrush(RGB(255, 255, 0));
CBrush greenBrush(RGB(0, 255, 0));
CRect rect(lpDIS->rcItem);
rect.DeflateRect(1, 1, 1, 1);
if (lpDIS->itemState == ODS_SELECTED)// it doesnt pick this up
{
pDC->FillRect(&rect, &yellowBrush);
rect.DeflateRect(2, 2, 2, 2);
}
switch (lpDIS->itemID)
{
case ID_COLORS_RED:
pDC->FillRect(&rect, &redBrush);
break;
case ID_COLORS_BLUE:
pDC->FillRect(&rect, &blueBrush);
break;
case ID_COLORS_GREEN:
pDC->FillRect(&rect, &greenBrush);
break;
}
/////////////////
However the part code below works ok when used instead
///////////////////////
if ((lpDIS->itemState & ODS_SELECTED) &&
(lpDIS->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)))
{
// item has been selected - hilite frame
COLORREF crHilite = RGB(0,0,0);
CBrush br(crHilite);
pDC->FrameRect(&lpDIS->rcItem, &br);
}
i sort of understand what is happening but i have never come across the use of the single & except to meen "address of", however in this context i dont think it means this.
This code in DrawItem(LPDRAWITEMSTRUCT lpDIS) works fine in 98 or NT
but wont work with XP.
//////////
CDC *pDC = CDC::FromHandle(lpDIS->hDC);
CBrush redBrush(RGB(255, 0, 0));
CBrush blueBrush(RGB(0, 0, 255));
CBrush yellowBrush(RGB(255, 255, 0));
CBrush greenBrush(RGB(0, 255, 0));
CRect rect(lpDIS->rcItem);
rect.DeflateRect(1, 1, 1, 1);
if (lpDIS->itemState == ODS_SELECTED)// it doesnt pick this up
{
pDC->FillRect(&rect, &yellowBrush);
rect.DeflateRect(2, 2, 2, 2);
}
switch (lpDIS->itemID)
{
case ID_COLORS_RED:
pDC->FillRect(&rect, &redBrush);
break;
case ID_COLORS_BLUE:
pDC->FillRect(&rect, &blueBrush);
break;
case ID_COLORS_GREEN:
pDC->FillRect(&rect, &greenBrush);
break;
}
/////////////////
However the part code below works ok when used instead
///////////////////////
if ((lpDIS->itemState & ODS_SELECTED) &&
(lpDIS->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)))
{
// item has been selected - hilite frame
COLORREF crHilite = RGB(0,0,0);
CBrush br(crHilite);
pDC->FrameRect(&lpDIS->rcItem, &br);
}
i sort of understand what is happening but i have never come across the use of the single & except to meen "address of", however in this context i dont think it means this.