Autor Beitrag
motion
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 295

XP, Linux
D7 Prof
BeitragVerfasst: Mo 06.03.06 12:56 
Wie kann ich ein PopUpMenu anzeigen und gleichzeitig einen gewünschten Eintrag selektieren (so das ein Druck auf die Enter-Taste genügt, um diesen zu aktivieren)?
digi_c
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1905

W98, XP
D7 PE, Lazarus, WinAVR
BeitragVerfasst: Mo 06.03.06 14:33 
Für was für ein Verhalten soll das denn gut sein? Sowas habe ich noch nie gesehen, vielleicht wäre ja ein hotkey für eine so häufig benutzte Funktion eher das passende.
Hux
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 171



BeitragVerfasst: Mo 06.03.06 16:16 
Das mit dem Selektieren... keine Ahnung, du könntest versuchen die PopUpMenuposition der Mausposition anpassen und dann die Procedur starten...(PopUpFunktion1Click)..., oder so ähnlich, aber für was soll des gut sein???
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Mo 06.03.06 16:42 
Hallo,

die Selection eines MenuItem kannst Du damit andeuten:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure TForm1.PopupMenu1Popup(Sender: TObject);
var m : TMenuItemInfo;
    h : hMenu;
begin
  h := PopupMenu1.Handle;
  m.cbSize := SizeOf(TMenuItemInfo);
  m.fMask := MIIM_STATE;
  m.fState := MFS_HILITE;
  //das zweite Item, nicht 0-basierend, also PopupMenu1.Items[1]
  SetMenuItemInfo(h,2,false,m);
end;

:!: das Item ist aber dann noch nicht mit [Enter] ansprechbar, es ist nur eine grafische Markierung.

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
motion Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 295

XP, Linux
D7 Prof
BeitragVerfasst: Mo 06.03.06 19:00 
@Lannes,
das war es noch nicht ganz. Aber das brachte mich schon mal auf einer Fährte ...
Ich habe mal einen Versuch mit der Emulierung von Keyboard Events zu machen und das scheint erst einmal funktionsfähig zu sein.
Nicht so elegant wie gewünscht, aber geht ...
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
VAR I : integer;
begin
  inherited;
  For I:=0 to Pop_BestandsArt.Items.Count-1 do
    Begin
      keybd_event(VK_down, MapVirtualKey(VK_down, 0), 00);
      keybd_event(VK_down, MapVirtualKey(VK_down, 0), KEYEVENTF_KEYUP, 0);
      if Pop_BestandsArt.Items[i].Checked then break;
    end;
end;