Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

C#
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
Updated 21-May-13 12:35pm
v6
Comments
enhzflep 21-May-13 1:31am    
MyOldAccount 21-May-13 12:10pm    
Thank you for suggestion, I will try it and report my results as soon as possible!
enhzflep 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

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

Owner Drawn Menu with Icons, Titles and Shading[^]
 
Share this answer
 
Comments
MyOldAccount 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)



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