suggestion

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #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 6 posts - 1 through 6 (of 6 total)
              • You must be logged in to reply to this topic.