Link to home
Start Free TrialLog in
Avatar of hederglan
hederglan

asked on

Individual hints on TPageControl

Hi, experts!

I need to show individual hints on TPageControl. What I mean is that I need the TabSheet showing the same hint of its page.
How do I do this?
If possible, I would like to create a component descendant of TPageControl with this feature.

Thanks in advance,

Hederglan
Avatar of kretzschmar
kretzschmar
Flag of Germany image

??
What I mean is that I need the TabSheet showing
the same hint of its page.

ehem, what??
maybe this?

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls;

type
  TForm1 = class(TForm)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    TabSheet3: TTabSheet;
    procedure PageControl1Change(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.PageControl1Change(Sender: TObject);
begin
  pagecontrol1.hint := pagecontrol1.ActivePage.Hint;
end;

end.

btw. the hint of the pagecontrol should be init with the hint of th activepage at designtime, otherwise first hintshow fails.

meikl ;-)
Avatar of hederglan
hederglan

ASKER

Meikl,

My point is show the page's hint when the user pass the mouse over the pageControl...even if the page isn't the active page...

Hederglan
you mean the tabs?
well then you should derive the tpagecontrol,
or use the onhint-event of tapplication.

i could post tomorrow a derived class,
which could do this hintswapping.

meikl ;-)
ASKER CERTIFIED SOLUTION
Avatar of shaneholmes
shaneholmes

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
well, my version :-))

unit HintPageControl;

interface

uses
  SysUtils, Classes, Controls, ComCtrls, commctrl, messages;

type
  THintPageControl = class(TPageControl)
  private
    fHintDefault : string;
  protected
    procedure WMMouseMove(var Message : TWMMouseMove); message WM_MouseMove;
  public
    { Public declarations }
  published
    property HintDefault : string read fHintDefault write fHintDefault;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Samples', [THintPageControl]);
end;

procedure THintPageControl.WMMouseMove(var Message : TWMMouseMove);
var
  tabInfo : TC_HITTESTINFO;
  tabidx  : Integer;
begin
  tabInfo.pt := point(message.XPos,message.YPos);
  tabidx := perform(TCM_HITTEST,0,integer(@tabInfo));
  if tabidx = -1 then
    hint := hintdefault
  else
    hint := pages[tabidx].Hint;
  inherited;
end;

end.

meikl ;-)
I will accept Shane's answer because it allows the hint to change if the mouse passes over more than one page...

Meikl, thank you for your answers.

Regards,

Hederglan
>...because it allows the hint to change if
>the mouse passes over more than one page...

guessing you didn't try ma derived component :-))
but well, its ok

meikl ;-)