How to get the owner Form of a TsTitleButton ?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #70039
    SzakiLaci
    Participant

    I’m trying to place a “pin” icon on all forms’ title bar, so users can save form-position.

    For that I’d like to use a universal procedure (and not 58 different).
    How to get the owner Form of a TsTitleButton at OnMouseUp procedure from “Sender: TObject” ?
    TsTitleButton has no “.Owner”

    procedure TFoForm.sSkinProvider1TitleButtons0MouseUp(Sender: TObject;
      Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    begin
      SaveMyFormsPosition( TForm(TsTitleButton( Sender ).???  ) );

    (This code is just a trial, not the “universal” one yet.)

    • This topic was modified 3 years, 5 months ago by SzakiLaci.
    • This topic was modified 3 years, 5 months ago by SzakiLaci.
    #70042
    SzakiLaci
    Participant

    AC version: 14.29

    #70043
    SzakiLaci
    Participant

    I think I have found a way:
    TForm(TsSkinProvider(tsTitleButtons(TsTitleButton(Sender).Collection).Owner).Owner )

    #70045
    Support
    Keymaster

    Hello!
    Maybe it’s enough to use “Self” there?
    I mean:

    procedure TFoForm.sSkinProvider1TitleButtons0MouseUp(Sender: TObject;
      Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    begin
      SaveMyFormsPosition(Self);
    #70049
    SzakiLaci
    Participant

    No.
    Self = 1 form only!
    That would “work” only, if I repeat that 58x on 58 different form.

    This:
    SaveMyFormsPosition( TForm(TsSkinProvider(tsTitleButtons(TsTitleButton(Sender).Collection).Owner).Owner ) );
    works universally. It was enough to do it once, and add sSkinProvider1TitleButtons0MouseUp on the fly to each runtime-created button.

    Tested.

    #70058
    Support
    Keymaster

    I understand, Ok. Your way is correct too ))

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.