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

TreeView的著色問題?

 
jck1
一般會員


發表:53
回覆:67
積分:24
註冊:2002-05-23

發送簡訊給我
#1 引用回覆 回覆 發表時間:2002-05-29 22:50:43 IP:211.22.xxx.xxx 未訂閱
這個程式 為什在我點選level 為 1 的 node時 會出現一塊白色的方形 把我的node.text都給遮住了呢? 是不是下面的程式有誤??? (我的treeview長成這樣 aaaaaa a1 a2 a3 bbbbb b1 b2 b3 ) procedure TForm1.TreeView1CustomDrawItem(Sender: TCustomTreeView; Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean); var NodeRect: TRect; begin if((Node.Data <> nil)and(Node.Level > 0))then begin with TreeView1.Canvas do begin Brush.Color := clLime; Brush.Style := bsSolid; FillRect(NodeRect); end; end else if((Node.Data = nil)and(Node.Level > 0))then begin with TreeView1.Canvas do begin Brush.Color:= clWhite; Brush.Style:= bsSolid; FillRect(NodeRect); end; end; end;
ccchen
版主


發表:61
回覆:940
積分:1394
註冊:2002-04-15

發送簡訊給我
#2 引用回覆 回覆 發表時間:2002-05-30 08:49:12 IP:163.29.xxx.xxx 未訂閱
引言: 這個程式 為什在我點選level 為 1 的 node時 會出現一塊白色的方形 把我的node.text都給遮住了呢? 是不是下面的程式有誤???
你的程式自己用FillRect把整個區域填滿,當然就看不到文字了 加上這兩行寫出文字吧 TreeView1.Canvas.Font.Color:=clWindowText; TreeView1.Canvas.TextOut(NodeRect.Left, NodeRect.Top, Node.Text);
jck1
一般會員


發表:53
回覆:67
積分:24
註冊:2002-05-23

發送簡訊給我
#3 引用回覆 回覆 發表時間:2002-05-30 09:11:03 IP:211.22.xxx.xxx 未訂閱
引言:
引言: 這個程式 為什在我點選level 為 1 的 node時 會出現一塊白色的方形 把我的node.text都給遮住了呢? 是不是下面的程式有誤???
你的程式自己用FillRect把整個區域填滿,當然就看不到文字了 加上這兩行寫出文字吧 TreeView1.Canvas.Font.Color:=clWindowText; TreeView1.Canvas.TextOut(NodeRect.Left, NodeRect.Top, Node.Text);
謝謝大大 已經可以了 但還有一個問題 就是 當我在選某個node時 原本會出現藍色的底,黑色的字(會有反藍的效果) 但現在卻沒有了 不知要修改哪裡呢?
ccchen
版主


發表:61
回覆:940
積分:1394
註冊:2002-04-15

發送簡訊給我
#4 引用回覆 回覆 發表時間:2002-05-30 09:32:38 IP:163.29.xxx.xxx 未訂閱
引言: 謝謝大大 已經可以了 但還有一個問題 就是 當我在選某個node時 原本會出現藍色的底,黑色的字(會有反藍的效果) 但現在卻沒有了 不知要修改哪裡呢?
可能你加入的Textout位置有問題,例如Level0也呼叫到Textout 我把你的邏輯整理一下,你試試 with Treeview1.Canvas do begin if Node.level > 0 then begin Brush.Style := bsSolid; if Node.data <> nil then Brush.Color := clLime else Brush.Color:= clWhite; FillRect(NodeRect); Font.Color:=clWindowText; TextOut(NodeRect.Left, NodeRect.Top, Node.Text); end; end;
jck1
一般會員


發表:53
回覆:67
積分:24
註冊:2002-05-23

發送簡訊給我
#5 引用回覆 回覆 發表時間:2002-05-30 09:54:18 IP:211.22.xxx.xxx 未訂閱
引言: 可能你加入的Textout位置有問題,例如Level0也呼叫到Textout 我把你的邏輯整理一下,你試試 with Treeview1.Canvas do begin if Node.level > 0 then begin Brush.Style := bsSolid; if Node.data <> nil then Brush.Color := clLime else Brush.Color:= clWhite; FillRect(NodeRect); Font.Color:=clWindowText; TextOut(NodeRect.Left, NodeRect.Top, Node.Text); end; end;
謝謝大大 在你的提示下試出來了 要把TreeView1.selected到的node給判斷掉 with Treeview1.Canvas do begin if(Node.level > 0)then begin if(Node = TreeView1.Selected)then begin exit; end else if(Node.data <> nil)then begin Brush.Color := clLime end else begin Brush.Color:= clWhite; end; FillRect(NodeRect); Font.Color:=clWindowText; TextOut(NodeRect.Left, NodeRect.Top, Node.Text); end; end;
系統時間:2024-03-29 6:32:38
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!