Fórum Como faço para inserir um jpg no fundo de uma treeview ? #326651
02/08/2006
0
Como faço para inserir um jpg no fundo de uma treeview ?
Já ouvi falar disso mais nunca vi..... como se fosse uma marca d´agua....
Valeu galera.....
Já ouvi falar disso mais nunca vi..... como se fosse uma marca d´agua....
Valeu galera.....
Cabal
Curtir tópico
+ 0
Responder
Posts
02/08/2006
Nightshade
eu so cnhc codigo pra listview
procedure TForm1.ListView1CustomDraw(Sender: TCustomListView;
const ARect: TRect; var DefaultDraw: Boolean);
function GetHeaderHeight: Integer;
var
Header: HWND; // header window handle
Pl: TWindowPlacement; // header window placement
begin
// Get header window
Header := SendMessage(ListView1.Handle, LVM_GETHEADER, 0, 0);
// Get header window placement
FillChar(Pl, SizeOf(Pl), 0);
Pl.length := SizeOf(Pl);
GetWindowPlacement(Header, @Pl);
// Calculate header window height
Result := Pl.rcNormalPosition.Bottom - Pl.rcNormalPosition.Top;
end;
var
BmpXPos, BmpYPos: Integer; // X and Y position for bitmap
Bmp: TBitmap; // Reference to bitmap
ItemRect: TRect; // List item bounds rectangle
TopOffset: Integer; // Y pos where bmp drawing starts
begin
// Get top offset where bitmap drawing starts
if ListView1.Items.Count > 0 then
begin
ListView_GetItemRect(ListView1.Handle, 0, ItemRect, LVIR_BOUNDS);
TopOffset := ListView_GetTopIndex(ListView1.Handle) *
(ItemRect.Bottom - ItemRect.Top);
end
else
TopOffset := 0;
BmpYPos := ARect.Top - TopOffset + GetHeaderHeight;
// Draw the bitmap
// get reference to bitmap
Bmp := Image1.Picture.Bitmap;
// loop until bmp is past bottom of list view
while BmpYPos < ARect.Bottom do
begin
// draw bitmaps across width of display
BmpXPos := ARect.Left;
while BmpXPos < ARect.Right do
begin
ListView1.Canvas.Draw(BmpXPos, BmpYPos, Bmp);
Inc(BmpXPos, Bmp.Width);
end;
// move to next row
Inc(BmpYPos, Bmp.Height);
end;
end;
//aki dexa o fundo dos itens transparente
// Ensure that the items are drawn transparently
SetBkMode(ListView1.Canvas.Handle, TRANSPARENT);
ListView_SetTextBkColor(ListView1.Handle, CLR_NONE);
ListView_SetBKColor(ListView1.Handle, CLR_NONE);
exemplo http://www.delphidabbler.com/download?file=article-16-demo.zip
tente adaptar dai pra treeview, acredito q deva funcionar..
para por jpg declare nas uses JPEG
mas axo q eh ais facil pegar o exemplo dos componentes da VirtualTreeView no site da revista, saiu uma materia q ensinava fzr isso.
procedure TForm1.ListView1CustomDraw(Sender: TCustomListView;
const ARect: TRect; var DefaultDraw: Boolean);
function GetHeaderHeight: Integer;
var
Header: HWND; // header window handle
Pl: TWindowPlacement; // header window placement
begin
// Get header window
Header := SendMessage(ListView1.Handle, LVM_GETHEADER, 0, 0);
// Get header window placement
FillChar(Pl, SizeOf(Pl), 0);
Pl.length := SizeOf(Pl);
GetWindowPlacement(Header, @Pl);
// Calculate header window height
Result := Pl.rcNormalPosition.Bottom - Pl.rcNormalPosition.Top;
end;
var
BmpXPos, BmpYPos: Integer; // X and Y position for bitmap
Bmp: TBitmap; // Reference to bitmap
ItemRect: TRect; // List item bounds rectangle
TopOffset: Integer; // Y pos where bmp drawing starts
begin
// Get top offset where bitmap drawing starts
if ListView1.Items.Count > 0 then
begin
ListView_GetItemRect(ListView1.Handle, 0, ItemRect, LVIR_BOUNDS);
TopOffset := ListView_GetTopIndex(ListView1.Handle) *
(ItemRect.Bottom - ItemRect.Top);
end
else
TopOffset := 0;
BmpYPos := ARect.Top - TopOffset + GetHeaderHeight;
// Draw the bitmap
// get reference to bitmap
Bmp := Image1.Picture.Bitmap;
// loop until bmp is past bottom of list view
while BmpYPos < ARect.Bottom do
begin
// draw bitmaps across width of display
BmpXPos := ARect.Left;
while BmpXPos < ARect.Right do
begin
ListView1.Canvas.Draw(BmpXPos, BmpYPos, Bmp);
Inc(BmpXPos, Bmp.Width);
end;
// move to next row
Inc(BmpYPos, Bmp.Height);
end;
end;
//aki dexa o fundo dos itens transparente
// Ensure that the items are drawn transparently
SetBkMode(ListView1.Canvas.Handle, TRANSPARENT);
ListView_SetTextBkColor(ListView1.Handle, CLR_NONE);
ListView_SetBKColor(ListView1.Handle, CLR_NONE);
exemplo http://www.delphidabbler.com/download?file=article-16-demo.zip
tente adaptar dai pra treeview, acredito q deva funcionar..
para por jpg declare nas uses JPEG
mas axo q eh ais facil pegar o exemplo dos componentes da VirtualTreeView no site da revista, saiu uma materia q ensinava fzr isso.
Responder
Gostei + 0
08/03/2008
Seven
alo amigo?!
alguem conseguiu colocar o TREEVIEW transparente?
estou precisando muito implementar isto em um sistema.
se alguem conseguiu , please... da uma luz ae.
desde ja agradeço.
alguem conseguiu colocar o TREEVIEW transparente?
estou precisando muito implementar isto em um sistema.
se alguem conseguiu , please... da uma luz ae.
desde ja agradeço.
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)