Changeset 27 for branches/topdown


Ignore:
Timestamp:
Aug 22, 2019, 11:32:31 AM (5 years ago)
Author:
chronos
Message:
  • Modified: Menu shutdown button with drop down menu and reboot action.
  • Fixed: Correct left positioning of main menu.
Location:
branches/topdown
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/topdown/UFormMain.lfm

    r26 r27  
    11object FormMain: TFormMain
    2   Left = 441
     2  Left = 689
    33  Height = 300
    4   Top = 290
     4  Top = 331
    55  Width = 400
    66  BorderStyle = bsNone
  • branches/topdown/UFormMain.pas

    r26 r27  
    8282  P: TPoint;
    8383begin
    84   P := ClientToScreen(Point(0, PanelTaskBar.Top - PanelTaskBar.Height));
    85   FormMenu.BoundsRect := Bounds(0, P.Y - FormMenu.Height,
     84  P := PanelTaskBar.ClientToScreen(Point(ButtonMenu.Left, ButtonMenu.Top - PanelTaskBar.Height));
     85  FormMenu.BoundsRect := Bounds(P.X, P.Y - FormMenu.Height,
    8686    FormMenu.Width, FormMenu.Height);
    8787  FormMenu.Show;
  • branches/topdown/UFormMenu.lfm

    r26 r27  
    1212  OnShow = FormShow
    1313  LCLVersion = '2.0.2.0'
    14   object ButtonShutDown: TButton
    15     Left = 7
    16     Height = 31
    17     Top = 362
    18     Width = 94
    19     Anchors = [akLeft, akBottom]
    20     Caption = 'Shut down'
    21     OnClick = ButtonShutDownClick
    22     TabOrder = 0
    23   end
    2414  object ListBoxApps: TListBox
    2515    Left = 10
     
    3424    ItemHeight = 20
    3525    OnClick = ListBoxAppsClick
     26    TabOrder = 0
     27  end
     28  object ToolBar1: TToolBar
     29    Left = 164
     30    Height = 30
     31    Top = 362
     32    Width = 90
     33    Align = alCustom
     34    Anchors = [akTop, akRight]
     35    AutoSize = True
     36    Caption = 'ToolBar1'
     37    EdgeBorders = []
     38    Flat = False
     39    ShowCaptions = True
    3640    TabOrder = 1
     41    object ToolButton1: TToolButton
     42      Left = 1
     43      Top = 2
     44      Caption = 'Shutdown'
     45      DropdownMenu = PopupMenu1
     46      OnClick = ToolButton1Click
     47      Style = tbsDropDown
     48    end
    3749  end
    38   object ButtonReboot: TButton
    39     Left = 112
    40     Height = 31
    41     Top = 362
    42     Width = 94
    43     Anchors = [akLeft, akBottom]
    44     Caption = 'Reboot'
    45     OnClick = ButtonRebootClick
    46     TabOrder = 2
     50  object PopupMenu1: TPopupMenu
     51    left = 111
     52    top = 278
     53    object MenuItemReboot: TMenuItem
     54      Caption = 'Reboot'
     55      OnClick = MenuItemRebootClick
     56    end
    4757  end
    4858end
  • branches/topdown/UFormMenu.pas

    r26 r27  
    66
    77uses
    8   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls;
     8  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Menus,
     9  Buttons, ComCtrls;
    910
    1011type
     
    1314
    1415  TFormMenu = class(TForm)
    15     ButtonShutDown: TButton;
    16     ButtonReboot: TButton;
    1716    ListBoxApps: TListBox;
    18     procedure ButtonRebootClick(Sender: TObject);
    19     procedure ButtonShutDownClick(Sender: TObject);
     17    MenuItemReboot: TMenuItem;
     18    PopupMenu1: TPopupMenu;
     19    ToolBar1: TToolBar;
     20    ToolButton1: TToolButton;
    2021    procedure FormDeactivate(Sender: TObject);
    2122    procedure FormShow(Sender: TObject);
    2223    procedure ListBoxAppsClick(Sender: TObject);
     24    procedure MenuItemRebootClick(Sender: TObject);
     25    procedure ToolButton1Click(Sender: TObject);
    2326  private
    2427
     
    5457  FormClass: TFormTaskClass;
    5558begin
    56   FormClass := TFormTaskClass(ListBoxApps.Items.Objects[ListBoxApps.ItemIndex]);
    57   BaseSystem.Tasks.StartTask(FormClass);
     59  if ListBoxApps.ItemIndex <> -1 then begin
     60    FormClass := TFormTaskClass(ListBoxApps.Items.Objects[ListBoxApps.ItemIndex]);
     61    BaseSystem.Tasks.StartTask(FormClass);
     62  end;
     63end;
     64
     65procedure TFormMenu.MenuItemRebootClick(Sender: TObject);
     66begin
     67  Hide;
     68  BaseSystem.Reboot;
     69end;
     70
     71procedure TFormMenu.ToolButton1Click(Sender: TObject);
     72begin
     73  Hide;
     74  BaseSystem.ShutDown;
    5875end;
    5976
     
    7188end;
    7289
    73 procedure TFormMenu.ButtonShutDownClick(Sender: TObject);
    74 begin
    75   Hide;
    76   BaseSystem.ShutDown;
    77 end;
    78 
    79 procedure TFormMenu.ButtonRebootClick(Sender: TObject);
    80 begin
    81   Hide;
    82   BaseSystem.Reboot;
    83 end;
    84 
    8590end.
    8691
Note: See TracChangeset for help on using the changeset viewer.