Einzelnen Beitrag anzeigen

Aviator

Registriert seit: 3. Jun 2010
1.610 Beiträge
 
Delphi 10.3 Rio
 
#3

AW: Is a TButton in the header of VirtualStringTree possible?

  Alt 12. Aug 2020, 09:49
Why don't you simply use the OnHeaderClick Event? There you have a HitInfo parameter which provides you the position where the user clicked on.

Delphi-Quellcode:
procedure TfrmMain.vstHeaderClick(Sender: TVTHeader; HitInfo: TVTHeaderHitInfo);
begin
  if (HitInfo.HitPosition = hhiOnIcon) then begin
    // Do something here
  end;
end;

Pro tip: Check out the VirtualTreeView source code. This is the best documentation you can get. Or simply ask here if you don't know how to do it.

Delphi-Quellcode:
  // Structure used when info about a certain position in the header is needed.
  TVTHeaderHitInfo = record
    X,
    Y: Integer;
    Button: TMouseButton;
    Shift: TShiftState;
    Column: TColumnIndex;
    HitPosition: TVTHeaderHitPositions;
  end;

  // These flags are used to indicate where a click in the header happened.
  TVTHeaderHitPosition = (
    hhiNoWhere, // No column is involved (possible only if the tree is smaller than the client area).
    hhiOnColumn, // On a column.
    hhiOnIcon, // On the bitmap associated with a column.
    hhiOnCheckbox // On the checkbox if enabled.
  );
  TVTHeaderHitPositions = set of TVTHeaderHitPosition;
  Mit Zitat antworten Zitat