Marco's Web Center

Menu for Development

Site Menu
Object Pascal Handbook
Delphi Handbooks Collection
Mastering Borland Delphi 2005
(Old) White Papers
(Old)Tools
(Old) Conferences

My Other Sites
Italian Site (www.marcocantu.it)
the delphi search

Spirit of delphi

Advertising
Home My Blog Books Object Pascal Marco

Home: Code Repository: Mastering Delphi 6

Chapter 11 - Project ListDialDemo

Project Structure

ListDialDemo.dpr
program ListDialDemo;

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

{$R *.RES}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.
LdDemoF.pas
unit LdDemoF;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    MdListDialog1: TMdListDialog;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
  // select the text of the edit,
  // if corresponding to one of the strings
  MdListDialog1.Selected :=
    MdListDialog1.Lines.IndexOf (Edit1.Text);
  // run the dialog and get the result
  if MdListDialog1.Execute then
    Edit1.Text := MdListDialog1.SelItem;
end;

end.
LdDemoF.dfm
object Form1: TForm1
  Left = 251
  Top = 147
  Width = 296
  Height = 146
  Caption = 'List Dialog Test'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clBlack
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  PixelsPerInch = 96
  TextHeight = 13
  object Button1: TButton
    Left = 104
    Top = 24
    Width = 89
    Height = 33
    Caption = 'Select...'
    TabOrder = 0
    OnClick = Button1Click
  end
  object Edit1: TEdit
    Left = 48
    Top = 72
    Width = 201
    Height = 21
    TabOrder = 1
    Text = 'Edit1'
  end
  object MdListDialog1: TMdListDialog
    Lines.Strings = (
      'one'
      'two'
      'three'
      'four'
      'five'
      'six'
      'seven'
      'eight'
      'nine'
      'ten')
    Selected = 6
    Title = 'Choose a string'
    Left = 32
    Top = 24
  end
end