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 Check if the mouse is over a tab of a TTabControl 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
31-Oct-02
Category
VCL-General
Language
Delphi 2.x
Views
127
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

I try to determine if the mouse is just over a tab of a TTabControl using 
GetHitTestInfoAt(). This returns htOnItem if the mouse is over the tab and if it's 
not. How do I have to approach this issue?

Answer:

Probably, the problem is in the routine which calls GetHitTestInfoAt, since I've 
tried to check this method and all seemed to work fine. I was calling it in the 
form's and tabcontrols's OnMouseMove events:
1   
2   procedure TForm1.TabControl1MouseMove(Sender: TObject; Shift: TShiftState; X, Y:
3     Integer);
4   var
5     XHitTests: THitTests;
6   begin
7     XHitTests := TabControl1.GetHitTestInfoAt(X, Y);
8     if htOnItem in XHitTests then
9       ShowMessage('OnItem');
10  end;


Also, you can try to call Win API macro TabCtrl_HitTest directly, in order to 
determine which tab, if any, is over the cursor. Here's an example:
11  
12  procedure TForm1.TabControl1MouseMove(Sender: TObject; Shift: TShiftState; X, Y:
13    Integer);
14  var
15    XHitTestInfo: TTCHitTestInfo;
16    XIndex: integer;
17  begin
18    XHitTestInfo.pt := POINT(X, Y);
19    XIndex := TabCtrl_HitTest(TabControl1.Handle, @XHitTestInfo);
20    if XHitTestInfo.flags in [TCHT_ONITEM] then
21      ShowMessage('OnItem ' + TabControl1.Tabs[XIndex])
22    else if XHitTestInfo.flags in [TCHT_ONITEMICON] then
23      ShowMessage('OnIcon ' + TabControl1.Tabs[XIndex])
24    else if XHitTestInfo.flags in [TCHT_ONITEMLABEL] then
25      ShowMessage('OnLabel ' + TabControl1.Tabs[XIndex]);
26  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