Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detecting MouseMove on a TabStrip

Status
Not open for further replies.

AndyGroom

Programmer
May 23, 2001
972
0
0
GB
I need to detect when the mouse moves over the main body area of a TabStrip control. Although a TabStrip has a "MouseMove" event it only fires when the mouse moves over the tabs themselves rather than the area underneath.

Other than placing all the contents of the tab area in a container, is there any way to detect a MouseMove within the main TabStrip area?

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
<Other than placing all the contents of the tab area in a container...

No, there isn't, actually. The way to use tabstrips is to create an array of frames, each one corresponding to one of the tabs, and size and place each one of the frames so it will look like it's contained by the tabstrip control.

A simple example: create a tabstrip control and a control array of 3 frames. Make 3 tabs, red, green and blue. Set the backcolor of frame 0 to red, of frame 1 to green, and frame 2 to blue. In the tabstrip's click event, put the this line of code (assuming default names for all the controls):
Code:
Private Sub TabStrip1_Click()
Frame1(TabStrip1.SelectedItem.Index - 1).ZOrder 0
End Sub

Note that you have to subtract 1 from the tabs' indices, as they are a 1 based array and control arrays are 0 based. (Sigh)

You can use the frames' mousemove events to get the functionality you're asking for.

HTH

Bob
 
You could always subclass the control and respond to WM_NCIHITTEST messages
 
I had the feeling that the OP had already hit on the basics of the tabstrip control without quite being sure of it, since one has the feeling that there should be some sort of "true containership" built into the control that one is missing. It seems to me that being able to recognize mouse moves on the control itself, when the control is always behind the frames that correspond to the tabs, would be superfluous in most cases. However, I'm sure that there are situations when that's not the case, and when so one can no doubt do as strongm suggests.
 
Thanks for your replies.

I only use the TabStrip when the controls within it are the same for each tab and it's the tab itself that dictates the context of the controls (eg. 12 tabs, one for each month, and the controls beneath are relevant to the selected month). Otherwise I agree with BobRodes and you might as well use a Tab control.

I was just interested to see that the mousemove only applies to the tabs and not the whole control.

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top