Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

display sorting triangle in ListView column header

Posted on 1998-08-16
4
574 Views
Last Modified: 2010-04-03
How can I display in a ListView column header a triangle that shows after which column are sorted the items, and in which direction (like in the Microsoft Internet Mail and News)?
0
Comment
Question by:biroadam
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
erajoj earned 50 total points
ID: 1336098
Hi,
You could do something like this:

uses
  ...ComCtrls, Commctrl;

var
  MyBMP : TBitmap;
  hditem: THDItem;

  MyBMP := TBitmap.Create;
  with MyBMP do begin
    Canvas.Brush.Color := clBtnFace;
    Width  := 10;
    Height := 10;
// down...
    Canvas.Polyline([Point(0,0),Point(4,8),Point(8,0),Point(0,0)]);
//  up...
//  Canvas.Polyline([Point(0,8),Point(4,0),Point(8,8),Point(0,8)]);
  end;

 ...

  hditem.Mask := HDI_FORMAT;
  Header_GetItem( GetDlgItem( ListView1.Handle, 0 ), 1, hditem );
  hditem.Mask := HDI_BITMAP or HDI_FORMAT;
  hditem.fmt  := hditem.fmt or HDF_BITMAP;
  hditem.hbm := MyBMP.Handle;
  Header_SetItem( GetDlgItem( ListView1.Handle, 0 ), 1, hditem );

/// John

0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1336099
Did you check it? It doesn't seem to work.
0
 

Author Comment

by:biroadam
ID: 1336100
 Thank you, it was a good answer.

  I have two further questions:

  1. How can I move the bitmap on the RIGHT side of the column header’s caption (the bitmap generated by your code is on the left side)?

  2. How can I resolve the transparency problem for this bitmap? I must have a triangle on a clButtonFace background, so I have two choises: A. making a procedure which calls the CreateGrayMappedBmp function every time the system colors changes, or B. I have a transparent color.

  I couldn’t use the solution B because setting my bitmap’s Transparency, TransparentColor and TransparentMode properties, the transparency didn’t work on the column header.
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1336101
Does it work on NT4?
Does it work when the listview is not on the main form?

If yes, can you please send me the sample code?  ronith@cmr.co.il

Thanks,
Ronit
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question