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
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
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.Hi nt;
end;
end.
btw. the hint of the pagecontrol should be init with the hint of th activepage at designtime, otherwise first hintshow fails.
meikl ;-)
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:
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.PageControl1Change(
begin
pagecontrol1.hint := pagecontrol1.ActivePage.Hi
end;
end.
btw. the hint of the pagecontrol should be init with the hint of th activepage at designtime, otherwise first hintshow fails.
meikl ;-)
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
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 ;-)
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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('Sample s', [THintPageControl]);
end;
procedure THintPageControl.WMMouseMo ve(var Message : TWMMouseMove);
var
tabInfo : TC_HITTESTINFO;
tabidx : Integer;
begin
tabInfo.pt := point(message.XPos,message .YPos);
tabidx := perform(TCM_HITTEST,0,inte ger(@tabIn fo));
if tabidx = -1 then
hint := hintdefault
else
hint := pages[tabidx].Hint;
inherited;
end;
end.
meikl ;-)
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('Sample
end;
procedure THintPageControl.WMMouseMo
var
tabInfo : TC_HITTESTINFO;
tabidx : Integer;
begin
tabInfo.pt := point(message.XPos,message
tabidx := perform(TCM_HITTEST,0,inte
if tabidx = -1 then
hint := hintdefault
else
hint := pages[tabidx].Hint;
inherited;
end;
end.
meikl ;-)
ASKER
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
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 ;-)
>the mouse passes over more than one page...
guessing you didn't try ma derived component :-))
but well, its ok
meikl ;-)
What I mean is that I need the TabSheet showing
the same hint of its page.
ehem, what??