Marco Cantù 1998, Mastering Delphi 4

Project: BICONS.DPR


Project Structure


BICONS.DPR

program Bicons;

uses
  Forms,
  BIconsF in 'BIconsF.pas' {Form1};

{$R *.RES}

begin
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

BICONSF.PAS

unit BIconsF;

interface

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

type
  TForm1 = class(TForm)
    MainMenu1: TMainMenu;
    BorderIcons1: TMenuItem;
    SystemMenu1: TMenuItem;
    MinimizeBox1: TMenuItem;
    MaximizeBox1: TMenuItem;
    Help1: TMenuItem;
    procedure SetIcons(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.SetIcons(Sender: TObject);
var
  BorIco: TBorderIcons;
begin
  (Sender as TMenuItem).Checked :=
    not (Sender as TMenuItem).Checked;
  if SystemMenu1.Checked then
    BorIco := [biSystemMenu]
  else
    BorIco := [];
  if MaximizeBox1.Checked then
    Include (BorIco, biMaximize);
  if MinimizeBox1.Checked then
    Include (BorIco, biMinimize);
  if Help1.Checked then
    Include (BorIco, biHelp);
  BorderIcons := BorIco;
end;

end.

BICONSF.DFM

object Form1: TForm1
  Left = 209
  Top = 129
  Width = 435
  Height = 300
  BorderIcons = [biSystemMenu, biMinimize, biMaximize, biHelp]
  Caption = 'Toggle Border Icons'
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  Menu = MainMenu1
  PixelsPerInch = 96
  TextHeight = 13
  object MainMenu1: TMainMenu
    Left = 24
    Top = 8
    object BorderIcons1: TMenuItem
      Caption = '&Border Icons'
      object SystemMenu1: TMenuItem
        Caption = '&System Menu'
        Checked = True
        OnClick = SetIcons
      end
      object MinimizeBox1: TMenuItem
        Caption = '&Minimize Box'
        Checked = True
        OnClick = SetIcons
      end
      object MaximizeBox1: TMenuItem
        Caption = 'M&aximize Box'
        Checked = True
        OnClick = SetIcons
      end
      object Help1: TMenuItem
        Caption = '&Help'
        OnClick = SetIcons
      end
    end
  end
end


Copyright Marco Cantù 1998