我这有个单击的 一样的
procedure Tform_GCZL.TreeView_mainClick(Sender: TObject);
var
mystr:string;
mystream:TMemoryStream;
begin
if TreeView_main.Selected=nil then Exit;
if TreeView_main.Selected.AbsoluteIndex=0 then Exit;
if (TreeView_main.Selected.ImageIndex=1) or (TreeView_main.Selected.ImageIndex=2) then
begin
if OleContainer_sys.State<>osEmpty then
begin
OleContainer_sys.DestroyObject;
Exit;
end;
end;
Screen.Cursor:=crHourGlass;
//saveole;
mystr:=getBG_ID(TreeView_main.Selected.AbsoluteIndex);
with myadoq do
begin
Close;
SQL.Clear;
SQL.Add('select * from mulu_file where BG_ID='''+mystr+''' and isfile=1');
Open;
if RecordCount>0 then
begin
mystream:=TMemoryStream.Create;
TBlobField(Fieldbyname('BG_FILE')).SaveToStream(mystream);
mystream.Position:=0;
OleContainer_sys.LoadFromStream(mystream);
Screen.Cursor:=crDefault;
end;
end;
Screen.Cursor:=crDefault;
end;
响应代码:
procedure TForm1.ListView4DblClick(Sender: TObject);
begin
if ListView4.Selected=nil then exit;
case ListView4.Items.IndexOf(ListView4.Selected) of
0:Label8.Caption:=ListView4.Selected.Caption;
1:Label8.Caption:=ListView4.Selected.Caption;
2:Label8.Caption:=ListView4.Selected.Caption;
3:Label8.Caption:=ListView4.Selected.Caption;
4:Label8.Caption:=ListView4.Selected.Caption;
end;
end;
做背景图代码:
unit ListViewMain;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics,
Controls, Forms, Dialogs,
ComCtrls, ImgList;
type
TForm1 = class(TForm)
ListView1: TListView;
ImageList1: TImageList;
procedure ListView1CustomDraw(Sender:
TCustomListView;
const ARect: TRect; var DefaultDraw:
Boolean);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Bitmap1: TBitmap;
implementation
{$R *.DFM}
procedure TForm1.ListView1CustomDraw(Sender:
TCustomListView;
const ARect: TRect; var DefaultDraw: Boolean);
var
x,y,w,h : LongInt;
begin
with Bitmap1 do begin
W := Width;
H := Height;
end;
Y := 0;
while Y < Height do begin
X := 0;
while X < Width do begin
ListView1.Canvas.Draw(X, Y, Bitmap1);
Inc(X, W);
end;
Inc(Y, H);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Bitmap1 := TBitmap.Create;
Bitmap1.LoadFromFile('backgray.bmp');
end;
procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Bitmap1.Free;
end;
end.