Title: Get HeaderControl Section Index on Right Click
Question: How do I get the section index when the user right clicks?
Answer:
procedure TForm2.HeaderControl1MouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
Index: Integer;
Info: THDHitTestInfo;
begin
if Button=mbRight then begin
Info.Point.X := X;
Info.Point.Y := Y;
Index := SendMessage(HeaderControl1.Handle,HDM_HITTEST,0,Integer(@Info));
{ Index has the section index, or -1 if not }
if Index=0 then
// do something with it...
HeaderControl1.Sections[Index].text:=IntToStr(Info.Point.X);
end;
end;