奉献树形表格TreeView Grid 控件源代码(原创)(0)

  • 主题发起人 xuxiaohan
  • 开始时间
X

xuxiaohan

Unregistered / Unconfirmed
GUEST, unregistred user!
写了个 TreeView Grid控件,可以编辑,可以排序,源代码在我的博客里面,另外包括一个可以 ownerDraw 标题的 ListView由于论坛不能附图,发表在我的博客上 http://blog.sina.com.cn/fsr2009做了很大的修改,表现力超强
 
L

linghe

Unregistered / Unconfirmed
GUEST, unregistred user!
上班時間上不了外網,無條件支持!
 
A

arhaha

Unregistered / Unconfirmed
GUEST, unregistred user!
看了一下,没有看到myfunctions, mycontrols这两个单元,楼主能否一起公布?不然没法用了
 
X

xuxiaohan

Unregistered / Unconfirmed
GUEST, unregistred user!
之前用了一个 FlatEdit 是在mycongtrol里面的,后来采用 TmaskEdit,mycontrols 可以去掉,没有任何作用。用到 myfunctions 的几个函数,我整理一下贴出了
 
X

xuxiaohan

Unregistered / Unconfirmed
GUEST, unregistred user!
用到 myfunctions 的几个函数(大部分是绘图函数),代码如下,当然你可以用你的绘图函数代替它们-----------function percentToFloat(value: string): double;用料排序的var i: integer; s: string;begin s:=value; while Pos('%', S) > 0 do S[Pos('%', S)] := #0; result:=StrToFloat(s);end;procedure BlendBmp(bmp: TBitmap; clBlend: Tcolor; value: byte);半透明图片var Pixel: PRGBTriple; w, h: Integer; x, y: Integer; clR,clG,clB: TColor;begin Bmp.PixelFormat := pf24Bit; w := bmp.Width; h := bmp.Height; clR:=getRValue(clBlend); clG:=getGValue(clBlend); clB:=getBValue(clBlend); for y := 0 to h - 1 do begin Pixel := bmp.ScanLine[y]; for x := 0 to w - 1 do begin pixel^.rgbtRed:=(pixel^.rgbtRed*(255-value)+clR * value) div 255; pixel^.rgbtGreen:=(pixel^.rgbtGreen*(255-value)+clG * value) div 255; pixel^.rgbtBlue:=(pixel^.rgbtBlue*(255-value)+clB * value) div 255; Inc(Pixel); end; end;end;procedure FillTubeGradientRect(DC: HDC; const ARect: TRect; AColor1, AColor2: TColor; AHorizontal: Boolean);var FromR, FromG, FromB, ToR, ToG, ToB: Integer; ToR1, ToG1, ToB1, ToR2, ToG2, ToB2: Integer; SR: TRect; W, I, N, M: Integer; R, G, B: Byte; ABrush: HBRUSH; ALeft, ARight, ARectLeft, ARectRight: ^Integer;begin AColor1 := ColorToRGB(AColor1); AColor2 := ColorToRGB(AColor2); if AColor1 = AColor2 then begin ABrush := CreateSolidBrush(AColor1); FillRect(DC, ARect, ABrush); DeleteObject(ABrush); Exit; end; FromR := GetRValue(AColor1); FromG := GetGValue(AColor1); FromB := GetBValue(AColor1); ToR := GetRValue(AColor2); ToG := GetGValue(AColor2); ToB := GetBValue(AColor2); SR := ARect; if AHorizontal then begin ALeft := @SR.Left; ARight := @SR.Right; ARectLeft := @ARect.Left; ARectRight := @ARect.Right; end else begin ALeft := @SR.Top; ARight := @SR.Bottom; ARectLeft := @ARect.Top; ARectRight := @ARect.Bottom; end; W := ARight^ - ALeft^; M := W div 2; ToR1 := FromR - MulDiv(FromR - ToR, 80, 200); ToG1 := FromG - MulDiv(FromG - ToG, 80, 200); ToB1 := FromB - MulDiv(FromB - ToB, 80, 200); ToR2 := FromR - MulDiv(FromR - ToR1, W, M); ToG2 := FromG - MulDiv(FromG - ToG1, W, M); ToB2 := FromB - MulDiv(FromB - ToB1, W, M); N := 256; if W < N then N := W; for I := 0 to N - 1 do begin ARight^ := ARectLeft^ + MulDiv(I + 1, W, N); if I < M then begin R := FromR + MulDiv(I, ToR2 - FromR, N - 1); G := FromG + MulDiv(I, ToG2 - FromG, N - 1); B := FromB + MulDiv(I, ToB2 - FromB, N - 1); end else if I = M then begin R := ToR1; G := ToG1; B := ToB1; FromR := ToR + MulDiv(ToR1 - ToR, W, M); FromG := ToG + MulDiv(ToG1 - ToG, W, M); FromB := ToB + MulDiv(ToB1 - ToB, W, M); end else begin R := FromR + MulDiv(I, ToR - FromR, N - 1); G := FromG + MulDiv(I, ToG - FromG, N - 1); B := FromB + MulDiv(I, ToB - FromB, N - 1); end; if not IsRectEmpty(SR) then begin ABrush := CreateSolidBrush(RGB(R, G, B)); FillRect(DC, SR, ABrush); DeleteObject(ABrush); end; ALeft^ := ARight^; if ALeft^ >= ARectRight^ then Break; end;end;procedure DrawUpArraw(ACanvas: TCanvas;ARect: TRect; Size: byte; Color: Tcolor);var oldBsColor: TColor; PL, PR, PT: Tpoint; Rw, Rh: integer;begin oldBsColor:=ACanvas.Brush.Color; Rw:=ARect.Right-Arect.Left; Rh:=ARect.Bottom-ARect.Top; PT:=point(ARect.Left + Rw div 2, ARect.Top+(Rh-size) div 2); PL:=point(ARect.Left + Rw div 2 - Size, ARect.Top+(Rh+size) div 2); PR:=point(ARect.Left + Rw div 2 + Size, ARect.Top+(Rh+size) div 2); with ACanvas do begin pen.Color:=color; Brush.Color:=color; Polygon([PL,PR,PT]); Brush.Color:=OldBsColor; end;end;procedure DrawDownArraw(ACanvas: TCanvas;ARect: TRect; Size: byte; Color: Tcolor);var oldBsColor: TColor; PL, PR, PB: Tpoint; Rw, Rh: integer;begin oldBsColor:=ACanvas.Brush.Color; Rw:=ARect.Right-Arect.Left; Rh:=ARect.Bottom-ARect.Top; PL:=point(ARect.Left + Rw div 2 - Size, ARect.Top+(Rh-size) div 2); PR:=point(ARect.Left + Rw div 2 + Size, ARect.Top+(Rh-size) div 2); PB:=point(ARect.Left + Rw div 2, ARect.Top+(Rh-size) div 2 + Size); with ACanvas do begin pen.Color:=color; Brush.Color:=color; Polygon([PL,PR,PB]); Brush.Color:=OldBsColor; end;end;//混合颜色function getAlphaColor(BackColor,ForeColor: TColor; alpha: integer): TColor; var R,G,B: integer;begin backColor:=TColor(backColor); backColor:=colortoRGB(backColor); ForeColor:=colortoRGB(ForeColor); R:=(getRValue(backColor)*(255-alpha)+getRvalue(ForeColor)*alpha) div 255; G:=(getGValue(backColor)*(255-alpha)+getGvalue(ForeColor)*alpha) div 255; B:=(getBValue(backColor)*(255-alpha)+getBvalue(ForeColor)*alpha) div 255; if R>255 then R:=255; if R<0 then R:=0; if G>255 then G:=255; if G<0 then R:=0; if B>255 then B:=255; if B<0 then B:=0; result:=RGB(R,G,B);end;有需要的可以Email 给我,或者在我的博客留言
 
A

arhaha

Unregistered / Unconfirmed
GUEST, unregistred user!
非常感谢!!!
 
X

xuxiaohan

Unregistered / Unconfirmed
GUEST, unregistred user!
本人并非IT业内人士,都是一时兴趣写下的代码,对我没有任何作用,我还有很多自写的控件,将来也会一一发布出来。现在主攻外汇交易,对于delphi,大家可以一起交流。
 
A

arhaha

Unregistered / Unconfirmed
GUEST, unregistred user!
把delphi作为兴趣而不是吃饭的工具,这个境界也是我所向往的!!!
 
X

xuxiaohan

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure WMNCLButtonDown(var Message: TWMNCLButtonDown); message WM_NCLBUTTONDOWN;是多余的,原来想用WMNCLButtonDown 作为点击标题进行排序,后来改为 procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
 
0

007vivi

Unregistered / Unconfirmed
GUEST, unregistred user!
很好,还没达到这个境界。。
 
Z

zzf888

Unregistered / Unconfirmed
GUEST, unregistred user!
没有图片,看不到效果!
 
X

xuxiaohan

Unregistered / Unconfirmed
GUEST, unregistred user!
有图片哦
 
O

omvm

Unregistered / Unconfirmed
GUEST, unregistred user!
是没有图片,点属性地址是这个:file:///C:/DOCUME~1/pg001/LOCALS~1/Temp//Catch5.jpg也就是说,只有在你电脑上能看到
 
X

xuxiaohan

Unregistered / Unconfirmed
GUEST, unregistred user!
奇怪,为什么会这样?之前是用的,别人也看到是有的,真想不通, 现在重新放上图片。
 
D

delphi2011

Unregistered / Unconfirmed
GUEST, unregistred user!
我自己也搞了一个,不过只能显示,不能编辑类似dxdbtreelist
 
O

omvm

Unregistered / Unconfirmed
GUEST, unregistred user!
还是看不到图,不如给个demo,自己运行自己看
 
X

xuxiaohan

Unregistered / Unconfirmed
GUEST, unregistred user!
这次图片真的可以看了这里也可以看图片http://photo.blog.sina.com.cn/category/u/1114487833/s/175714
 
D

doll_paul

Unregistered / Unconfirmed
GUEST, unregistred user!
打个完整的DEMO包吧。呵呵~~
 
X

xuxiaohan

Unregistered / Unconfirmed
GUEST, unregistred user!
已经有Demo,简单的
 

Similar threads

D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
990
DelphiTeacher的专栏
D
D
回复
0
查看
840
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
S
回复
0
查看
1K
SUNSTONE的Delphi笔记
S
顶部