Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Owner Draw Menu and XP

Status
Not open for further replies.

jesterspirit101

Programmer
Apr 26, 2003
1
GB
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top