Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

HiliteMenuItem does not work

87 views
Skip to first unread message

Thomas Jaeger

unread,
Aug 17, 1998, 3:00:00 AM8/17/98
to
When using the following code in the popMonthsPopup event, the
January1Click event does not get fired. If I manually highlight a popup
menu item, the January1Click event does get fired.

I'm using D3.02. What's wrong?

procedure TfrmLedger.January1Click(Sender: TObject);
begin
if Sender is TMenuItem then
case TMenuItem(Sender).MenuIndex of
0: SelectedMonth:='January';
1: SelectedMonth:='February';
2: SelectedMonth:='March';
3: SelectedMonth:='April';
4: SelectedMonth:='May';
5: SelectedMonth:='June';
6: SelectedMonth:='July';
7: SelectedMonth:='August';
8: SelectedMonth:='September';
9: SelectedMonth:='October';
10: SelectedMonth:='November';
11: SelectedMonth:='December';
end;
end;

procedure TfrmLedger.popMonthsPopup(Sender: TObject);
var
Present: TDateTime;
Year,Month,Day: Word;
begin
Present:=Now;
DecodeDate(Present,Year,Month,Day);
popMonths.Items[Month-1].Default:=true;

HiliteMenuItem(frmLedger.Handle,popMonths.Handle,Month-1,MF_BYPOSITION+MF_HILITE);
end;

--
Best Regards,
Thomas Jaeger

Bernd Ua

unread,
Aug 17, 1998, 3:00:00 AM8/17/98
to
> If I manually highlight a popup
> menu item, the January1Click event does get fired.

No, OnClick only get's fired if you Click an Item with mouse
or
press <Enter> on an already highlighted menu item.
It never gets fired if you're just highlighting it with
arrow keys.
There is no OnHighlite-Event in Delphi TMenuItem , i'm
afraid.

But if you want to invoke the OnClick Event , why do't you
just call it directly or call the
apropriate MenuItems Click Method ?

Bernd

Thomas Jaeger

unread,
Aug 17, 1998, 3:00:00 AM8/17/98
to

I would like to have a popup menu item already highlighted so that the
user just has to press the Enter key. The HiliteMenuItem visually
highlights it just fine but Delphi does not actually move the active
menu item to the highlighted position. So, when a user presses the Enter
key, nothing happens since nothing was actually codewise highlighted so
that the OnClick can execute.

--
Best Regards,

President
Thomas Jaeger

Frederick C. Wilt

unread,
Aug 17, 1998, 3:00:00 AM8/17/98
to
Hi

I believe MS intends you to use the space bar to simulate a button click in
this situation.

Regards, Frederick C. Wilt


Bernd Ua

unread,
Aug 18, 1998, 3:00:00 AM8/18/98
to
I tested a bit around - and didn't get it work, at the end i
did a search in msdn
and found the following about HighLiteMenuItem

> snippet from Msdn Library CD 3 :
mk:@ivt:pdui/live/pdui/newmenus_2p0z.htm

> Highlighted Menu Items
> The system automatically highlights menu items on menus as
the user selects them. However, highlighting can
> be explicitly added or removed from a menu name on the
menu bar by using the HiliteMenuItem function. This
> function has no effect on menu items on menus. When
HiliteMenuItem is used to highlight a menu name,
> though, the name only appears to be selected. If the user
presses the enter key, the highlighted item is not
> chosen. This feature might be useful in, for example, a
training application that demonstrates the use of
> menus.


As you can see you can't get it to work with Delphi cause
you can't get it to work with Windows API.

Bernd

phil.b...@gmail.com

unread,
Feb 7, 2013, 8:34:04 AM2/7/13
to
Thomas,

Add this:

HiliteMenuItem(frmLedger.Handle,popMonths.Handle,Month-1,MF_BYPOSITION+MF_HILITE);
Application.ProcessMessages.
0 new messages