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
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
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
I believe MS intends you to use the space bar to simulate a button click in
this situation.
Regards, Frederick C. Wilt
> 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