source: branches/simple/Forms/FormMessages.pas

Last change on this file was 42, checked in by chronos, 15 months ago
  • Modified: Improved simple virtual machine.
File size: 1.2 KB
Line 
1unit FormMessages;
2
3interface
4
5uses
6 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, Message;
7
8type
9 TSelectEvent = procedure (Position: TPoint) of object;
10
11 { TFormMessages }
12
13 TFormMessages = class(TForm)
14 ListView1: TListView;
15 procedure ListView1Data(Sender: TObject; Item: TListItem);
16 procedure ListView1DblClick(Sender: TObject);
17 private
18 FOnSelect: TSelectEvent;
19 public
20 Messages: TMessages;
21 procedure Reload;
22 property OnSelect: TSelectEvent read FOnSelect write FOnSelect;
23 end;
24
25
26implementation
27
28{$R *.lfm}
29
30{ TFormMessages }
31
32procedure TFormMessages.ListView1Data(Sender: TObject; Item: TListItem);
33begin
34 with Messages do
35 if (Item.Index >= 0) and (Item.Index < Count) then
36 with TMessage(Items[Item.Index]) do begin
37 Item.Caption := IntToStr(Position.X) + ', ' + IntToStr(Position.Y);
38 Item.Data := Items[Item.Index];
39 Item.SubItems.Add(Text);
40 end;
41end;
42
43procedure TFormMessages.ListView1DblClick(Sender: TObject);
44begin
45 if Assigned(ListView1.Selected) then begin
46 if Assigned(FOnSelect) then
47 FOnSelect(TMessage(ListView1.Selected.Data).Position);
48 end;
49end;
50
51procedure TFormMessages.Reload;
52begin
53 ListView1.Items.Count := Messages.Count;
54 ListView1.Refresh;
55end;
56
57end.
58
Note: See TracBrowser for help on using the repository browser.