ObjReader Community

Discussion => Post Your Questions & Comments Here => Topic started by: Michael Lobko-Lobanovsky on July 06, 2019, 10:34:45 pm

Title: Skinned Menu Question
Post by: Michael Lobko-Lobanovsky on July 06, 2019, 10:34:45 pm

Can your skinned menus display bitmaps in the left column where ticks/bullets appear in a regular menu?
Title: Re: Skinned Menu Question
Post by: Patrice Terrier on July 07, 2019, 09:42:29 am
Not directly, you have to use an owndrawn menu for that purpose.

There is an example on how to do it in gMap64

Search for:

and of course:
    case WM_DRAWITEM:
         lpdis = (DRAWITEMSTRUCT*) lParam;
         if (lpdis->CtlType == ODT_MENU) {
             img = GetMenuIcon(lpdis->itemID);
             wcscopy(zTxt, GetMenuText(lpdis->itemID));

             if (CheckStyle(lpdis->itemState, ODS_SELECTED)) {
                 SetTextColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
                 SetBkColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT));
             } else {
                 SetTextColor(lpdis->hDC, GetSysColor(COLOR_MENUTEXT));
                 SetBkColor(lpdis->hDC, GetSysColor(COLOR_MENU));

             if (CheckStyle(lpdis->itemState, ODS_GRAYED)) {
                 SetTextColor(lpdis->hDC, GetSysColor(COLOR_GRAYTEXT));
                 ImgAttr = ZI_SetImageAlpha(80);

             ExtTextOut(lpdis->hDC, 6 + 16 + lpdis->rcItem.left,
                        lpdis->rcItem.top + 1, ETO_OPAQUE, &lpdis->rcItem, zTxt, lstrlen(zTxt), NULL);

             if (GdipCreateFromHDC(lpdis->hDC, graphics) == 0) {
                 GdipGetImageWidth(img, imgW); GdipGetImageHeight(img, imgH);
                 GdipDrawImageRectRectI(graphics, img,
                                        lpdis->rcItem.left + 1, lpdis->rcItem.top + 1, imgW, imgH,
                                        0, 0, imgW, imgH, UnitPixel, ImgAttr, 0, 0);

             return 1;

The problem with the skinned one, is that it has no idea of the image to use, nor if the graphic chart of the icon will match the current theme.

The best solution is to create the specific ownerdrawn popup menu directly inside of OR, using the same scope than in WinLIFT.

Or to use a GDImage overlay menu like in BB64 (see attachment), but there is no embedded child menu.
That is the same concept that in the OR's help topic list.