Click here to Skip to main content
11,415,711 members (83,523 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ Win32
I would like to start by saying thanks to everyone who takes some time to view this thread and try to help.

I have a owner drawn popup menu, with submenu, which is also owner drawn.

When I run the code the following effect happens:

When I hover with mouse over submenu's item, his background becomes white , and the arrow ( the one that indicates that submenu has items ) turns into white arrow.

My question is:

How do I change the color of that marker ( let it be red for example ) ?

Some code example/ pseudo-code / instructions / tutorials / links ... would be welcome.

UPDATE #4:
***********************************************************************************************

Fixed the problem of white background appearing behind text by using
ExtTextOut()
with style
ETO_OPAQUE
.

Arrow is still white.

I can highlight item properly with following code in WM_DRAWITEM:

if( lpdis->itemAction & ODA_SELECT ) // if item is selected
            {
                if(lpdis->itemState & ODS_SELECTED) 
                {
 
                    // set the color of the highlight marker

                    SetBkColor( lpdis->hDC, RGB(117, 210, 255) );
                    
                    // draw desired text

                    ExtTextOut( lpdis->hDC, lpdis->rcItem.left,
                        lpdis->rcItem.top, ETO_OPAQUE, &lpdis->rcItem,
                        (LPCWSTR)lpdis->itemData,
                        wcslen((LPCWSTR)lpdis->itemData), NULL);
 
                    // draw edges of the marker

                    DrawEdge( lpdis->hDC, &lpdis->rcItem, EDGE_RAISED,
                        BF_FLAT );
 
                    // draw frame around menu item and color it so it matches the markers color

                    FrameRect( lpdis->hDC, &lpdis->rcItem,
                        CreateSolidBrush( RGB(117, 210, 255) ) );
                }
            }

***********************************************************************************************
I work in MS Visual Studio Express 2008, on Windows XP, in C++, using pure WIN32 API.

If any other information is required ( source code or something similar ), please ask for it, I will more than gladly supply it.
Posted 20-May-13 13:00pm
Edited 21-May-13 13:35pm
v6
Comments
enhzflep at 21-May-13 1:31am
   
Nenad Smiljkovic at 21-May-13 12:10pm
   
Thank you for suggestion, I will try it and report my results as soon as possible!
enhzflep at 21-May-13 12:19pm
   
[EDIT: You're welcome :) ]


Before you tear-off, I should mention that I did play with the code for a while, but didn't have any success with it. The example is incomplete :(
The microsoft examples don't deal with it.

I had hoped there would be something in the Validating/Invalidating of rects or regions that would stop windows trying to draw the arrow, leaving me free to draw it as I please. I couldn't work anything out. Also, unfortunately, the author of that article only has one at that site - no obvious chance for some of the rest of his frame-work.

But, I guess there are a couple of ideas in there. (I probably spent 2 hours. I didn't try awfully hard, but it's not a hole-in-one of a solution unfortunately)

Good luck! :-)

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The solution is owner draw the menu. It is some work like this to:

Owner Drawn Menu with Icons, Titles and Shading[^]
  Permalink  
Comments
Nenad Smiljkovic at 21-May-13 12:11pm
   
Thank you for your suggestion, I will try it and report my results as soon as possible!

EDIT:
--------------
I will accept solution, but that code is too much for a novice like me...
Hopefully I will be able to handle it.
Thank you.

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 9,270
1 OriginalGriff 7,512
2 Maciej Los 3,710
3 Abhinav S 3,325
4 Peter Leow 3,084


Advertise | Privacy | Mobile
Web04 | 2.8.150427.4 | Last Updated 21 May 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100