How do you hi-light a menu(TrackPopupMenuEx) item?

Note: HiliteMenuItem(...) works...sortof. It hi-lights the item but then
when you use the arrow keys you see two hilights(yours and the real one).

Re: How do I hi-light menu item? by Alex

Alex
Sun Oct 22 07:09:39 CDT 2006

mr.sir bossman wrote:
> How do you hi-light a menu(TrackPopupMenuEx) item?
>
> Note: HiliteMenuItem(...) works...sortof. It hi-lights the item but then
> when you use the arrow keys you see two hilights(yours and the real one).

Usually, you don't do anything at all. Menu itself cares
about highlighting of its items. When the item is clicked
(or Enter is pressed) menu returns item's ID to you. That's all.

Re: How do I hi-light menu item? by John

John
Sun Oct 22 07:31:08 CDT 2006

"mr.sir bossman" <mrsirbossman@discussions.microsoft.com> wrote in
message news:8FA8FDCF-D54F-49A6-A93F-F561A23A5143@microsoft.com
> How do you hi-light a menu(TrackPopupMenuEx) item?
>
> Note: HiliteMenuItem(...) works...sortof. It hi-lights the item but
> then when you use the arrow keys you see two hilights(yours and the
> real one).

It is not clear why you want to do this. However, WM_MENUSELECT gives you
notifications of selections made with the arrow keys or by moving the mouse
cursor. Untested, but presumably you can use HiLiteMenuItem to cancel the
highlighting resulting from user action. Of course the other possibility is
a fully owner drawn menu.

--
John Carson



Re: How do I hi-light menu item? by mrsirbossman

mrsirbossman
Sun Oct 22 07:54:01 CDT 2006

"John Carson" wrote:
> > How do you hi-light a menu(TrackPopupMenuEx) item?
> >
> > Note: HiliteMenuItem(...) works...sortof. It hi-lights the item but
> > then when you use the arrow keys you see two hilights(yours and the
> > real one).
>
> It is not clear why you want to do this.
IE style Menubar. When the user presses Alt and then the down arrow I want
the first item to be selected.
>
> However, WM_MENUSELECT gives you
> notifications of selections made with the arrow keys or by moving the mouse
> cursor. Untested, but presumably you can use HiLiteMenuItem to cancel the
> highlighting resulting from user action.
That is what I was thinking of doing if I couldn't find a better way....
>
> Of course the other possibility is a fully owner drawn menu.
That would be last ditch.

Re: How do I hi-light menu item? by John

John
Sun Oct 22 08:15:37 CDT 2006

"mr.sir bossman" <mrsirbossman@discussions.microsoft.com> wrote in
message news:A578A48B-C986-4C32-A31C-3D193D9E4325@microsoft.com
> "John Carson" wrote:
>>> How do you hi-light a menu(TrackPopupMenuEx) item?
>>>
>>> Note: HiliteMenuItem(...) works...sortof. It hi-lights the item but
>>> then when you use the arrow keys you see two hilights(yours and the
>>> real one).
>>
>> It is not clear why you want to do this.
>
> IE style Menubar. When the user presses Alt and then the down arrow I
> want the first item to be selected.

Have you seen this?

http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/faq/iemenubar.asp?frame=true


--
John Carson



Re: How do I hi-light menu item? by mrsirbossman

mrsirbossman
Sun Oct 22 20:51:01 CDT 2006

"John Carson" wrote:
> "mr.sir bossman" <mrsirbossman@discussions.microsoft.com> wrote in
> message news:A578A48B-C986-4C32-A31C-3D193D9E4325@microsoft.com
> > "John Carson" wrote:
> >>> How do you hi-light a menu(TrackPopupMenuEx) item?
> >>>
> >>> Note: HiliteMenuItem(...) works...sortof. It hi-lights the item but
> >>> then when you use the arrow keys you see two hilights(yours and the
> >>> real one).
> >>
> >> It is not clear why you want to do this.
> >
> > IE style Menubar. When the user presses Alt and then the down arrow I
> > want the first item to be selected.
>
> Have you seen this?
>
> http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/faq/iemenubar.asp?frame=true
Sadly it is a generalization and offers no solution to my problem.

Re: How do I hi-light menu item? by John

John
Sun Oct 22 22:01:41 CDT 2006

"mr.sir bossman" <mrsirbossman@discussions.microsoft.com> wrote in
message news:C06ABCF1-A5BB-4B64-9D2E-D7AA311010D6@microsoft.com
> "John Carson" wrote:
>> "mr.sir bossman" <mrsirbossman@discussions.microsoft.com> wrote in
>> message news:A578A48B-C986-4C32-A31C-3D193D9E4325@microsoft.com
>>> "John Carson" wrote:
>>>>> How do you hi-light a menu(TrackPopupMenuEx) item?
>>>>>
>>>>> Note: HiliteMenuItem(...) works...sortof. It hi-lights the item
>>>>> but then when you use the arrow keys you see two hilights(yours
>>>>> and the real one).
>>>>
>>>> It is not clear why you want to do this.
>>>
>>> IE style Menubar. When the user presses Alt and then the down arrow
>>> I want the first item to be selected.
>>
>> Have you seen this?
>>
>> http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/faq/iemenubar.asp?frame=true
> Sadly it is a generalization and offers no solution to my problem.

There may be more elegant ways, but to select the first item in a popup
menu, you can do the following. Add

PostMessage(hwnd, WM_APP, wParam, 0);

to WM_INITMENUPOPUP processing and then process WM_APP as follows:

RECT rect;
GetMenuItemRect(0, (HMENU)wParam, 0, &rect);
SetCursorPos(rect.left+10, rect.top+10);

Note that it doesn't seem to work on XP unless you have a 0 for the HWND as
the first argument of GetMenuItemRect. Experimentation on other Windows
versions may be advisable.

--
John Carson



Re: How do I hi-light menu item? by mrsirbossman

mrsirbossman
Sun Oct 22 23:48:02 CDT 2006

> "mr.sir bossman" <mrsirbossman@discussions.microsoft.com> wrote in
> message news:C06ABCF1-A5BB-4B64-9D2E-D7AA311010D6@microsoft.com
> > "John Carson" wrote:
> >> "mr.sir bossman" <mrsirbossman@discussions.microsoft.com> wrote in
> >> message news:A578A48B-C986-4C32-A31C-3D193D9E4325@microsoft.com
> >>> "John Carson" wrote:
> >>>>> How do you hi-light a menu(TrackPopupMenuEx) item?
> >>>>>
> >>>>> Note: HiliteMenuItem(...) works...sortof. It hi-lights the item
> >>>>> but then when you use the arrow keys you see two hilights(yours
> >>>>> and the real one).
> >>>>
> >>>> It is not clear why you want to do this.
> >>>
> >>> IE style Menubar. When the user presses Alt and then the down arrow
> >>> I want the first item to be selected.
> >>
> >> Have you seen this?
> >>
> >> http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/faq/iemenubar.asp?frame=true
> > Sadly it is a generalization and offers no solution to my problem.
>
> There may be more elegant ways, but to select the first item in a popup
> menu, you can do the following. Add
>
> PostMessage(hwnd, WM_APP, wParam, 0);
>
> to WM_INITMENUPOPUP processing and then process WM_APP as follows:
>
> RECT rect;
> GetMenuItemRect(0, (HMENU)wParam, 0, &rect);
> SetCursorPos(rect.left+10, rect.top+10);
>
> Note that it doesn't seem to work on XP unless you have a 0 for the HWND as
> the first argument of GetMenuItemRect. Experimentation on other Windows
> versions may be advisable.
I decided to go with
PostMessage(WM_KEYDOWN, VK_DOWN);
in a timer(just before TrackPopupMenuEx). It seems to work.
>
Thx for help.