1{%MainUnit ../menus.pp}
2{******************************************************************************
3                                  TMainMenu
4 ******************************************************************************
5
6 *****************************************************************************
7  This file is part of the Lazarus Component Library (LCL)
8
9  See the file COPYING.modifiedLGPL.txt, included in this distribution,
10  for details about the license.
11 *****************************************************************************
12}
13
14procedure TMainMenu.SetWindowHandle(const AValue: HWND);
15begin
16  FWindowHandle := AValue;
17  if HandleAllocated then
18  begin
19    SetMenu(FWindowHandle, Handle);
20    BidiModeChanged;
21  end
22  else
23    SetMenu(FWindowHandle, 0);
24end;
25
26{------------------------------------------------------------------------------
27  Method: TMainMenu.ItemChanged
28  Params:  none
29  Returns: Nothing
30
31  Called whenever
32 ------------------------------------------------------------------------------}
33procedure TMainMenu.ItemChanged;
34begin
35  MenuChanged(nil, nil, False);
36end;
37
38class procedure TMainMenu.WSRegisterClass;
39begin
40  inherited WSRegisterClass;
41  RegisterMainMenu;
42  RegisterPropertyToSkip(TMainMenu, 'AutoMerge', 'VCL compatibility property', '');
43end;
44
45procedure TMainMenu.MenuChanged(Sender: TObject; Source: TMenuItem; Rebuild: Boolean);
46begin
47  // pass CM_MENUCANGED to the form which own the menu
48  if WindowHandle <> 0 then
49    SendMessage(WindowHandle, CM_MENUCHANGED, 0, 0);
50  inherited MenuChanged(Sender, Source, Rebuild);
51end;
52
53procedure TMainMenu.Merge(Menu: TMainMenu);
54begin
55  if Assigned(Menu) then
56    Items.MergeWith(Menu.Items)
57  else
58    Items.MergeWith(nil);
59end;
60
61procedure TMainMenu.Unmerge(Menu: TMainMenu);
62begin
63  if Assigned(Menu) and (Items.Merged = Menu.Items) then
64    Items.MergeWith(nil);
65end;
66
67{------------------------------------------------------------------------------
68  Method: TMainMenu.Create
69  Params:  AOwner: the owner of the class
70  Returns: Nothing
71
72  Constructor for the class.
73 ------------------------------------------------------------------------------}
74constructor TMainMenu.Create(AOwner : TComponent);
75begin
76  FCompStyle := csMainMenu;
77  FWindowHandle := 0;
78  inherited Create(AOwner);
79end;
80
81function TMainMenu.GetHeight: Integer;
82begin
83  Result := GetSystemMetrics(SM_CYMENU);
84end;
85
86// included by menus.pp
87
88