Link to home
Start Free TrialLog in
Avatar of shtern
shtern

asked on

System menu

How can I call system menu from the code (I have a form with no caption and need system menu to come after clicking my own button)?

Thanks
Avatar of inthe
inthe

hi,
the only way to do this is like:

procedure TForm1.Button1Click(Sender: TObject);
begin
//add the system menu to form
form1.bordericons := form1.bordericons + [bisystemmenu];
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
//delete the system menu from form
form1.bordericons := form1.bordericons - [bisystemmenu];
end;

Regards Barry
ps
when you say no caption ,if you mean you just have no title the above will be fine however if you mean no caption bar whatsoever you will have to make your own menu on a popup with the system menu,though you will still have the real system menu accessable on the taskbar icon of your program if you right click it.
Avatar of shtern

ASKER

Barry,

sorry for a long delay. I mean no caption bar. Is there any way to call the system menu? When no, maybe I should really make my own popup menu, but I'm not sure about all the items: I don't know how to realize some of the actions.

Regards,

Olga.
hi,
ok yes you will have to make your own popup menu for no caption..

i will make example with the actions to perform and post here tomorrow after some sleep ;-).
here is how (quite simple i found)
make your popup and add the items  and do:

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    PopupMenu1: TPopupMenu;
    Button1: TButton;
    Restore1: TMenuItem;
    Move1: TMenuItem;
    Size1: TMenuItem;
    Minimize1: TMenuItem;
    Maximize1: TMenuItem;
    Close1: TMenuItem;
    procedure Button1Click(Sender: TObject);
    procedure Close1Click(Sender: TObject);
    procedure Maximize1Click(Sender: TObject);
    procedure Minimize1Click(Sender: TObject);
    procedure Restore1Click(Sender: TObject);
    procedure Size1Click(Sender: TObject);
    procedure Move1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
popupmenu1.popup(form1.left,form1.top);
end;

procedure TForm1.Close1Click(Sender: TObject);
begin
Perform( WM_SYSCOMMAND, SC_CLOSE, 0 );
end;

procedure TForm1.Maximize1Click(Sender: TObject);
begin
Perform( WM_SYSCOMMAND, SC_MAXIMIZE, 0 );
end;

procedure TForm1.Minimize1Click(Sender: TObject);
begin
Perform( WM_SYSCOMMAND, SC_MINIMIZE, 0 );
end;

procedure TForm1.Restore1Click(Sender: TObject);
begin
Perform( WM_SYSCOMMAND, SC_RESTORE, 0 );
end;

procedure TForm1.Size1Click(Sender: TObject);
begin
Perform( WM_SYSCOMMAND, SC_SIZE, 0 );
end;

procedure TForm1.Move1Click(Sender: TObject);
begin
Perform( WM_SYSCOMMAND, SC_MOVE, 0 );
end;

end.
ASKER CERTIFIED SOLUTION
Avatar of inthe
inthe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial