Thema: Delphi Hauptmenü vertikal ?

Einzelnen Beitrag anzeigen

Benutzerbild von _frank_
_frank_

Registriert seit: 21. Feb 2003
Ort: Plauen / Bamberg
922 Beiträge
 
Delphi 3 Professional
 
#8

Re: Hauptmenü vertikal ?

  Alt 15. Nov 2006, 01:52
wie denkst du dir das mit Untermenüs (wie soll das aussehen)?

mal ein versuch sowas zu implementieren (vorerst links), wenn ich dich richtig verstanden habe...

Delphi-Quellcode:
//dfm:
object Form1: TForm1
  Left = 200
  Top = 108
  Width = 870
  Height = 640
  Caption = 'Form1'
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  PixelsPerInch = 96
  TextHeight = 13
  object ListBox1: TListBox
    Left = 0
    Top = 0
    Width = 45
    Height = 97
    Color = clBtnFace
    ItemHeight = 13
    Items.Strings = (
      '1'
      '2'
      '3')
    TabOrder = 0
    OnClick = ListBox1Click
  end
  object PopupMenu1: TPopupMenu
    Left = 48
    object menu11: TMenuItem
      Caption = 'menu1-1'
    end
    object menu121: TMenuItem
      Caption = 'menu1-2'
    end
  end
  object PopupMenu2: TPopupMenu
    Left = 48
    Top = 28
    object menu211: TMenuItem
      Caption = 'menu2-1'
    end
    object menu221: TMenuItem
      Caption = 'menu2-2'
    end
  end
  object PopupMenu3: TPopupMenu
    Left = 48
    Top = 56
    object menu311: TMenuItem
      Caption = 'menu3-1'
    end
    object menu321: TMenuItem
      Caption = 'menu3-2'
    end
  end
end
Delphi-Quellcode:
//pas
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Menus, StdCtrls;

type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    PopupMenu1: TPopupMenu;
    PopupMenu2: TPopupMenu;
    PopupMenu3: TPopupMenu;
    menu11: TMenuItem;
    menu121: TMenuItem;
    menu211: TMenuItem;
    menu221: TMenuItem;
    menu311: TMenuItem;
    menu321: TMenuItem;
    procedure ListBox1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.ListBox1Click(Sender: TObject);
var p:TPoint;
    pm:TPopupmenu;
begin
  p:=Point(Listbox1.left,listbox1.top);
  p:=ClientToScreen(p);
  pm:=(findcomponent('popupmenu'+IntToStr(Listbox1.Itemindex+1)) as TPopupmenu);
  if assigned(pm) then
    pm.popup(p.x+listbox1.width,p.y+Listbox1.Itemindex*Listbox1.Itemheight);
end;

end.
rechts sollte sich per TPopupmenu.Alignment und ohne "+listbox1.width" realisieren lassen.

HTH Frank
  Mit Zitat antworten Zitat