Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to catch the TPageControl.HotTrack event Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
09-Oct-02
Category
VCL-General
Language
Delphi 2.x
Views
131
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

When the HotTrack property of a TPageControl is True the tabsheet captions light 
blue for example when the mouse hovers over them. How can I display the TabSheets 
hint when this event occurs (the TabSheet hint should be displayed only when the 
mouse hovers over the TabSheet caption)?

Answer:

Use the pagecontrol's OnMouseMove event:
1   
2   {tabindex may be <> pageindex if some pages have tabvisible = false!}
3   
4   function FindPageforTabIndex(pagecontrol: TPageControl; tabindex: Integer): 
5   TTabSheet;
6   var
7     i: Integer;
8   begin
9     Assert(Assigned(pagecontrol));
10    Assert((tabindex >= 0) and (tabindex < pagecontrol.pagecount));
11    Result := nil;
12    for i := 0 to pagecontrol.pagecount - 1 do
13      if pagecontrol.pages[i].tabVisible then
14      begin
15        Dec(tabindex);
16        if tabindex < 0 then
17        begin
18          result := pagecontrol.pages[i];
19          break;
20        end;
21      end;
22  end;
23  
24  function HintForTab(pc: TPageControl; tabindex: Integer): string;
25  var
26    tabsheet: TTabsheet;
27  begin
28    tabsheet := FindPageforTabIndex(pc, tabindex);
29    if assigned(tabsheet) then
30      result := tabsheet.hint
31    else
32      result := '';
33  end;
34  
35  procedure TForm1.PageControl1MouseMove(Sender: TObject; Shift: TShiftState; X, Y:
36    Integer);
37  var
38    tabindex: Integer;
39    pc: TPageControl;
40    newhint: string;
41  begin
42    pc := Sender as TPageControl;
43    tabindex := pc.IndexOfTabAt(X, Y);
44    if tabindex >= 0 then
45    begin
46      newhint := HintForTab(pc, tabindex);
47      if newhint <> pc.Hint then
48      begin
49        pc.Hint := newhint;
50        application.CancelHint;
51      end;
52    end
53    else
54      pc.Hint := '';
55  end;
56  
57  {Attach this to every tabsheets OnMouseMove event}
58  
59  procedure TForm1.TabSheetMouseMove(Sender: TObject; Shift: TShiftState; X, Y:
60    Integer);
61  begin
62    pagecontrol1.Hint := '';
63  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC