CodePudding user response:
1, replace with THeadControl columnheader, OnDrawSection events inside can make the color you want, shape,
2, the ListView set HeaderDefaultDrawing:=False, painting in OnDrawHeader events,
Two methods are completely finished drawing the head, set the color is not alone
CodePudding user response:
reference 1st floor lianzhu520610 response: 1, replace with THeadControl columnheader, OnDrawSection events inside can make the color you want, shape, 2, the ListView set HeaderDefaultDrawing:=False, painting in OnDrawHeader events, Two methods are completely finished drawing the head, set the color alone is not enough Have a code? CodePudding user response:
HeaderDefaultDrawing this attribute is not OnDrawHeader this event didn't I am using delphi7 CodePudding user response:
procedure TForm1. RzListView1DrawHeader (Sender: TObject; Canvas: TCanvas; Index: Integer; The Rect: TRect); Var BMP: TBitmap; Str: string; ARect: TRect; The begin BMP:=TBitmap. Create; Try BMP. SetSize (1, the Rect. Bottom - the Rect. Top); BMP. Canvas. Brush. Color:=clBlue; BMP. Canvas. FillRect (BMP) Canvas) ClipRect); ARect:=the Rect; If the Index=RzListView1. Columns. Then Count - 1 The begin ARect. Right: =ARect. Rightend; Canvas. StretchDraw (ARect, BMP); Canvas. Pen. Color:=$00838383; Canvas. MoveTo (ARect. Right - 1, ARect. Top + 1); Canvas. LineTo (ARect. Right - 1, ARect Bottom - 1); If the Index=0 then The begin Canvas. Pen. Color:=$FF6E6E6E; Canvas. MoveTo (ARect. Left, ARect. Top + 1); Canvas. LineTo (ARect. Left, ARect. Bottom - 1); end; Str:=RzListView1 Columns [Index]. Caption; ADrawText (Canvas, Str, ARect); The finally BMP. Free; end; end; Can in BMP images, the effect will be better, THeadControl's about writing CodePudding user response:
The reference 4 floor lianzhu520610 reply: procedure TForm1. RzListView1DrawHeader (Sender: TObject; Canvas: TCanvas; Index: Integer; The Rect: TRect); Var BMP: TBitmap; Str: string; ARect: TRect; The begin BMP:=TBitmap. Create; Try BMP. SetSize (1, the Rect. Bottom - the Rect. Top); BMP. Canvas. Brush. Color:=clBlue; BMP. Canvas. FillRect (BMP) Canvas) ClipRect); ARect:=the Rect; If the Index=RzListView1. Columns. Then Count - 1 The begin ARect. Right: =ARect. Rightend; Canvas. StretchDraw (ARect, BMP); Canvas. Pen. Color:=$00838383; Canvas. MoveTo (ARect. Right - 1, ARect. Top + 1); Canvas. LineTo (ARect. Right - 1, ARect Bottom - 1); If the Index=0 then The begin Canvas. Pen. Color:=$FF6E6E6E; Canvas. MoveTo (ARect. Left, ARect. Top + 1); Canvas. LineTo (ARect. Left, ARect. Bottom - 1); end; Str:=RzListView1 Columns [Index]. Caption; ADrawText (Canvas, Str, ARect); The finally BMP. Free; end; end; Can pack inside the BMP image, the effect will be better, THeadControl is almost spelled You are using raize, Delphi's own listview can't? CodePudding user response:
Forget, I am using TRzListView, you can use THeadControl to replace CodePudding user response:
How and listview THeadControl associate? reference 1st floor lianzhu520610 response: 1, replace with THeadControl columnheader, OnDrawSection events inside can make the color you want, shape, 2, the ListView set HeaderDefaultDrawing:=False, painting in OnDrawHeader events, Two methods are completely finished drawing the head, only set colors are not enough CodePudding user response:
refer to 6th floor lianzhu520610 response: forget, what I use is TRzListView, you can replace with THeadControl Raize is which version of you, I don't have DrawHeader events CodePudding user response:
Can't seem to link, to pass the event to change the size of the TlistView, such as OnSectionResize OnSectionTrack etc. If there are no special requirements, recommend to do with TRzListView, more convenient CodePudding user response:
5.2, OnDrawHeader, should have CodePudding user response:
BMP. SetSize (1, the Rect. Bottom - the Rect. Top); BMP without this method ADrawText (Canvas, Str, ARect); This method is written by yourself? Which version is your Delphi? CodePudding user response:
procedure TForm1. ADrawText (Canvas: TCanvas; AText: string; ARect: TRect); Var H, W, X, Y: Integer; The begin Canvas. Brush. Style:=bsClear; H:=Canvas. TextHeight (' a '); W:=Canvas. TextWidth (AText); X:=ARect. Left + (ARect. Right - ARect. Left - W) div 2; Y:=ARect. Top + (ARect. Bottom - ARect. Top - H) div 2; If X & lt; ARect. Left then: X=ARect. Left; Canvas. TextOut (x, y, AText); end; Can use the Bmp weidth, Bmp. Height set its size, what I use is 2007 CodePudding user response:
1 for listview handle ListView_GetHeader (); 2 with its own window procedure to replace the default window procedure setwindowlong 3 in the window procedure of the WM_PAINT message, refer to the upstairs You can refer to the listview rz how to deal with it CodePudding user response:
nullnullnullnullnullnull