1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
|
unit competances;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Forms, Dialogs, Controls, StdCtrls,
Buttons, ComCtrls;
P1lireSub1: TListBox;
IncludeBtn: TSpeedButton;
IncAllBtn: TSpeedButton;
ExcludeBtn: TSpeedButton;
ExAllBtn: TSpeedButton;
P1LireSub2: TListBox;
Listcomp: TListBox;
SpeedButton1: TSpeedButton;
P1LireSub3: TListBox;
P1LireSub4: TListBox;
P1LireSub5: TListBox;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
procedure IncludeBtnClick(Sender: TObject);
procedure ExcludeBtnClick(Sender: TObject);
procedure IncAllBtnClick(Sender: TObject);
procedure ExcAllBtnClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
procedure P1LireSub3DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
private
{ Déclarations privées }
public
{ Déclarations publiques }
procedure MoveSelected(List: TCustomListBox; Items: TStrings);
procedure SetItem(List: TListBox; Index: Integer);
function GetFirstSelection(List: TCustomListBox): Integer;
procedure SetButtons;
end;
var
DualListDlg: TDualListDlg;
implementation
{$R *.dfm}
procedure TDualListDlg.IncludeBtnClick(Sender: TObject);
var
Index: Integer;
begin
Index := GetFirstSelection(P1LireSub1);
MoveSelected(P1LireSub1, ListComp.Items);
SetItem(P1LireSub1, Index);
end;
procedure TDualListDlg.ExcludeBtnClick(Sender: TObject);
var
Index: Integer;
begin
Index := GetFirstSelection(ListComp);
MoveSelected(ListComp, P1LireSub1.Items);
SetItem(ListComp, Index);
end;
procedure TDualListDlg.FormCreate(Sender: TObject);
begin
P1LireSub1.Items.LoadFromFile ('c:\logival\compétances\P1LireSub1.ini');
P1LireSub2.Items.LoadFromFile('c:\logival\compétances\P1LireSub2.ini') ;
P1LireSub3.Items.LoadFromFile('c:\logival\compétances\P1LireSub3.ini') ;
P1LireSub4.Items.LoadFromFile('c:\logival\compétances\P1LireSub4.ini') ;
P1LireSub5.Items.LoadFromFile('c:\logival\compétances\P1LireSub5.ini') ;
end;
procedure TDualListDlg.IncAllBtnClick(Sender: TObject);
var
I: Integer;
begin
for I := 0 to P1LireSub1.Items.Count - 1 do
ListComp.Items.AddObject(P1LireSub1.Items[I],
P1LireSub1.Items.Objects[I]);
P1LireSub1.Items.Clear;
SetItem(P1LireSub1, 0);
end;
procedure TDualListDlg.ExcAllBtnClick(Sender: TObject);
var
I: Integer;
begin
for I := 0 to ListComp.Items.Count - 1 do
P1LireSub1.Items.AddObject(ListComp.Items[I], ListComp.Items.Objects[I]);
ListComp.Items.Clear;
SetItem(P1LireSub1, 0);
end;
procedure TDualListDlg.MoveSelected(List: TCustomListBox; Items: TStrings);
var
I: Integer;
begin
for I := List.Items.Count - 1 downto 0 do
if List.Selected[I] then
begin
Items.AddObject(List.Items[I], List.Items.Objects[I]);
List.Items.Delete(I);
end;
end;
procedure TDualListDlg.P1LireSub3DrawItem( Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
begin
{ Dessin du texte en utilisant la fonction API }
DrawText(Canvas.Handle, PChar(P1LireSUB3.Items), -1, Rect ,DT_NOPREFIX or DT_WORDBREAK );
end;
procedure TDualListDlg.SpeedButton1Click(Sender: TObject);
var
Index: Integer;
begin
Index := GetFirstSelection(P1LireSub2);
MoveSelected(P1LireSub2, ListComp.Items);
SetItem(P1LireSub2, 0);
end;
procedure TDualListDlg.SpeedButton2Click(Sender: TObject);
var
I: Integer;
begin
for I := 0 to P1LireSub2.Items.Count - 1 do
ListComp.Items.AddObject(P1LireSub2.Items[I],
P1LireSub2.Items.Objects[I]);
P1LireSub2.Items.Clear;
SetItem(P1LireSub2, 0);
end;
procedure TDualListDlg.SpeedButton3Click(Sender: TObject);
var
Index: Integer;
begin
Index := GetFirstSelection(ListComp);
MoveSelected(ListComp, P1LireSub2.Items);
SetItem(ListComp, Index);
end;
procedure TDualListDlg.SpeedButton4Click(Sender: TObject);
var
I: Integer;
begin
for I := 0 to ListComp.Items.Count - 1 do
P1LireSub2.Items.AddObject(ListComp.Items[I], ListComp.Items.Objects[I]);
ListComp.Items.Clear;
SetItem(P1LireSub2, 0);
end;
procedure TDualListDlg.SetButtons;
var
P1LireSub1Empty, DstEmpty, P1LireSub2Empty: Boolean;
begin
P1LireSub1Empty := P1LireSub1.Items.Count = 0;
DstEmpty := ListComp.Items.Count = 0;
P1LireSub1Empty := P1LireSub2.Items.Count = 0;
Speedbutton1.Enabled := not P1LireSub1empty;
Speedbutton3.Enabled := not P1LireSub1empty;
IncludeBtn.Enabled := not P1LireSub1Empty;
IncAllBtn.Enabled := not P1LireSub1Empty;
ExcludeBtn.Enabled := not DstEmpty;
ExAllBtn.Enabled := not DstEmpty;
end;
{function TDualListDlg.GetFirstSelection0(List: TCustomListBox): Integer;
begin
for Result := 0 to List.Items.Count -1 do
if List.Selected[Result] then Exit;
Result := LB_ERR;
end; }
function TDualListDlg.GetFirstSelection(List: TCustomListBox): Integer;
begin
for Result := 0 to List.Items.Count-1 do
if List.Selected[Result] then Exit;
Result := LB_ERR;
end;
procedure TDualListDlg.SetItem(List: TListBox; Index: Integer);
var
MaxIndex: Integer;
begin
with List do
begin
SetFocus;
MaxIndex := List.Items.Count - 1;
if Index = LB_ERR then Index := 0
else if Index > MaxIndex then Index := MaxIndex;
Selected[Index] := True;
end;
SetButtons;
end;
end. |
Partager