suggestion

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #38135
    SpeedTI
    Participant

    Is it possible to add the FromPage and ToPage parameters in the OnChanging event of the TsPageControl component? That would make it a lot easier in some situations.

    Thank you.

    Regards
    Valdir Sola

    #58988
    Support
    Keymaster

    Hello

    Standard event can't be changed, but you can try the OnPageChanging event which exists already:

    Code:
    TacTabChangingEvent = procedure(Sender: TObject; NewPage: TsTabSheet; var AllowChange: Boolean) of object;
    #58998
    SpeedTI
    Participant
    'Support' wrote:

    Hello

    Standard event can't be changed, but you can try the OnPageChanging event which exists already:

    Code:
    TacTabChangingEvent = procedure(Sender: TObject; NewPage: TsTabSheet; var AllowChange: Boolean) of object;

    Thank you. It helps but not much. Is it possible to create an event that contains these parameters?

    Regards
    Valdir Sola

    #59010
    Support
    Keymaster
    'vsola' wrote:

    Thank you. It helps but not much. Is it possible to create an event that contains these parameters?

    Why not?

    FromPage is sPageControl1.ActivePage;

    ToPage is NewPage parameter in this event.

    #59017
    Stephane Senecal
    Participant

    The way I do it, is to get the coordinates of the cursor from the message by calling GetMessagePos() and get the tab under those coordinates.

    Note that GetMessagePos() return the cursor position relative to the display, not the PageControl.

    Code:
    procedure TForm1.sPageControl1Changing(Sender: TObject; var AllowChange: Boolean);
    var
    iCoord:Cardinal;
    pt:TPoint;
    iFromTab:Integer;
    iToTab:Integer;
    begin
    iCoord := GetMessagePos();
    pt := sPageControl1.ScreenToClient( Point( LoWord( iCoord ), HiWord( iCoord ) ) );

    iToTab := sPageControl1.GetTabUnderMouse( pt );
    iFromTab := sPageControl1.ActivePageIndex;
    end;

    Stephane Senecal
    CIS Group
    Delphi programmer since 2001

    #59026
    Support
    Keymaster

    Stephane, the OnPageChanging event exists in the TsPageControl with the “NewPage” parameter, there is no needs to search a tab under mouse.

    #59033
    Stephane Senecal
    Participant

    Oh, I didn't know that. Interesting.

    Thanks

    Stephane Senecal
    CIS Group
    Delphi programmer since 2001

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