Click here to Skip to main content
15,850,298 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am building Windows CE 6.0 R3 image for VIA board.I have added Start Menu Banner(.bmp) displaying Windows CE to the Start Menu.

When i am scrolling the mouse or keyboard over the start menu, The banner gets erased.Its not refreshed.
I have tried the functions like RedrawWindow(),Invalidate(). but i can't be able to solve the problem. Here is the code related to draw start menu, can any one help me to redraw the start menu banner,


C++
int StartMenu_DrawMenuItem(DRAWITEMSTRUCT *lpdis)
 { 
  LPSTMENUDATA lpst; 
  RECT rc; //HWND hwnd; 
  HICON hicon; 
  CStringRes szMenu(g_hInstance);
 
 if (!lpdis)
 {
  ASSERT(lpdis);
  return FALSE;
 }
 
 lpst = (LPSTMENUDATA)lpdis->itemData;
 if (!lpst)
{
 ASSERT(lpst);
 return FALSE;
}
// ASSERT(lpst->szDisplay);
CopyRect(&rc, &lpdis->rcItem);
if (lpst->idMenuCmd <= IDM_START_LAST_BANNER)
{
 rc.left += sizeSTPegasus.cx; // This is for the start menu banner.
}
 //This following lines are added by SGP for startmenu banner problem
 if (lpst->idMenuCmd == IDM_START_LOGOFF || lpst->idMenuCmd == IDM_START_SHUTDOWN)
 {
  rc.left += sizeSTPegasus.cx;
 }
// added upto this by SGP for startmenu banner problem

 switch (lpdis->itemAction)
 {
   case ODA_DRAWENTIRE:
   if (idFirstMenu == lpst->idMenuCmd)
   {
    CopyRect(&rcMenu, &lpdis->rcItem);
    rcMenu.right = rcMenu.left + sizeSTPegasus.cx; // sizeSTPegasus.cx --> bitmap image width
   }
  else if  (idLastMenu == lpst->idMenuCmd)
  {
    rcMenu.bottom = lpdis->rcItem.bottom;
 
    if (hbmSTPegasus) // hdmSTPegasus --> Bitmap image 
    {
        HDC hdcmem = CreateCompatibleDC(lpdis->hDC);
        if (hdcmem)
        {
            SelectObject(hdcmem, hbmSTPegasus);
 

            FillRect(lpdis->hDC, &rcMenu,
                     GetSysColorBrush(COLOR_ACTIVECAPTION));
 
            BitBlt(lpdis->hDC, 0, rcMenu.bottom - sizeSTPegasus.cy,
                   sizeSTPegasus.cx, sizeSTPegasus.cy, hdcmem, 0, 0,
                   SRCCOPY);
            //RedrawWindow(lpdis->hwndItem,NULL,NULL,RDW_INVALIDATE|RDW_UPDATENOW);
            DeleteDC(hdcmem);
        }
    }
}
// drop into color selects...
case ODA_SELECT: // Problem occurs here. when i am selecting menu's the bitmap image in the left side of the menu(start menu Banner) gets erased
if ((lpdis->itemState & ODS_SELECTED) && lpst->idMenuCmd)
{   
 HBRUSH hbrush = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT));
 SetTextColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
 FillRect(lpdis->hDC, &rc, hbrush);
//RedrawWindow(lpdis->hwndItem,NULL,NULL,RDW_INVALIDATE|RDW_UPDATENOW);                             DeleteObject((HGDIOBJ)hbrush);                   
}
else
{
    HBRUSH hbrush = CreateSolidBrush(GetSysColor(COLOR_MENU));
    SetTextColor(lpdis->hDC, GetSysColor(COLOR_MENUTEXT));
    FillRect(lpdis->hDC, &rc, hbrush);
    DeleteObject((HGDIOBJ)hbrush);
}
break;
 
default:
  break;
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900