全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1830
推到 Plurk!
推到 Facebook!

TreeView 加入底圖的方法

答題得分者是:GGL
s8310306
一般會員


發表:2
回覆:1
積分:0
註冊:2009-03-04

發送簡訊給我
#1 引用回覆 回覆 發表時間:2009-05-08 17:53:11 IP:203.75.xxx.xxx 訂閱
請問大家知道如何在TreeView加入底圖嗎?
網站上ListView加入底圖的做法似乎不能用在TreeView上
感謝!
GGL
資深會員


發表:104
回覆:600
積分:335
註冊:2006-11-05

發送簡訊給我
#2 引用回覆 回覆 發表時間:2009-05-17 09:04:54 IP:165.123.xxx.xxx 未訂閱

我在google找到這篇
topic.csdn.net/t/20030125/22/1392531.html

試試看吧!!

[code cpp]
//---------------------------------------------------------------------------
#include
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
Graphics::TBitmap *bmp;
TWndMethod ms;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
bmp=new Graphics::TBitmap();
bmp->LoadFromFile("D:\\bcb is.bmp");
TreeView1->Canvas->Brush->Bitmap=bmp;
ms=TreeView1->WindowProc;
TreeView1->WindowProc=proc;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::proc(TMessage &msg)
{
if(msg.Msg==WM_ERASEBKGND)
return;
if(msg.Msg==WM_PAINT)
{
TRect ARect=TreeView1->ClientRect;
int W=ARect.Width();
int H=ARect.Height();

HDC memdc=CreateCompatibleDC(TreeView1->Canvas->Handle);
HBITMAP membmp=CreateCompatibleBitmap(TreeView1->Canvas->Handle,W,H);
SelectObject(memdc,membmp);
ms(msg);
BitBlt(memdc,0,0,W,H,TreeView1->Canvas->Handle,0,0,SRCCOPY);

HDC maskdc=CreateCompatibleDC(TreeView1->Canvas->Handle);
HBITMAP maskbmp=CreateBitmap(W,H,1,1,NULL);
SelectObject(maskdc,maskbmp);
BitBlt(maskdc,0,0,W,H,memdc,0,0,SRCCOPY);

TreeView1->Canvas->FillRect(ARect);
SetBkColor(memdc,RGB(0,0,0));
SetTextColor(memdc,RGB(255,255,255));
BitBlt(memdc,0,0,W,H,maskdc,0,0,SRCAND);

SetBkColor(TreeView1->Canvas->Handle,RGB(255,255,255));
SetTextColor(TreeView1->Canvas->Handle,RGB(0,0,0));

BitBlt(TreeView1->Canvas->Handle,0,0,W,H,maskdc,0,0,SRCAND);
BitBlt(TreeView1->Canvas->Handle,0,0,W,H,memdc,0,0,SRCPAINT);

DeleteObject(memdc);
DeleteObject(membmp);
DeleteObject(maskdc);
DeleteObject(maskbmp);
}
else
ms(msg);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::TreeView1Expanded(TObject *Sender, TTreeNode *Node)
{
TreeView1->Repaint();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormDestroy(TObject *Sender)
{
delete bmp;
}
//---------------------------------------------------------------------------

[/code]
系統時間:2024-04-19 15:45:06
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!