Solved

System menu

Posted on 2000-03-18
6
162 Views
Last Modified: 2010-04-04
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
0
Comment
Question by:shtern
  • 5
6 Comments
 
LVL 17

Expert Comment

by:inthe
ID: 2631591
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
0
 
LVL 17

Expert Comment

by:inthe
ID: 2633102
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.
0
 

Author Comment

by:shtern
ID: 2652646
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.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Expert Comment

by:inthe
ID: 2655496
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 ;-).
0
 
LVL 17

Expert Comment

by:inthe
ID: 2655674
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.
0
 
LVL 17

Accepted Solution

by:
inthe earned 50 total points
ID: 2658735
or i can now re-propose new answer  :o)


   {how to make system menu}

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.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question