Autor Beitrag
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Fr 30.08.02 12:56 
Um einen neuen Menüpunkt in das Systemmenü einzufügen kann man folgenden Code benutzen:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
Type 
  tForm1 = Class (tForm)
    Procedure FormCreate (aSender: tObject);
  Private
    Procedure DoMessage (Var aMsg: tMsg; Var aHandled: Boolean);
    Procedure MenuClick;
  End;

Var
  Form1: TForm1;

Implementation

{$R *.DFM}

Const
  cMenuItemId = WM_USER + 1;

Procedure tForm1.DoMessage (Var aMsg: tMsg; Var aHandled: Boolean);
Begin
 If aMsg.Message = WM_SYSCOMMAND Then
   If aMsg.wParam = cMenuItemId Then
     MenuClick;
End;

Procedure TForm1.FormCreate (aSender: tObject);
Begin
  Application.OnMessage := DoMessage;

  { Trennlinie einfügen (Form) }
  AppendMenu (GetSystemMenu (Handle, False), MF_SEPARATOR, 0'');

  { Menüpunkt einfügen (Form) }
  AppendMenu (GetSystemMenu (Handle, False), MF_BYPOSITION, cMenuItemId, '&Neues Menü');

  { Trennlinie einfügen (System) }
  AppendMenu (GetSystemMenu (Application.Handle, False), MF_SEPARATOR, 0'');

  { Menüpunkt einfügen (System) }
  AppendMenu (GetSystemMenu (Application.Handle, False), MF_BYPOSITION, cMenuItemId, '&Neues Menü')
End;

Procedure TForm1.MenuClick;
Begin
  MessageDlg ('Hallo', mtInformation, mbOKCancel, 0);
End;