Tab control client area?

SephirothSephiroth Fayetteville, NC, USA
I've got a problem with a tab control that I am using in my latest pet-project. I get the client area of a specified tab using "TCM_GETITEMRECT", but it is returning the area occupied by the tab itself, not the content area below the tabs. How do I get that client area?
//Try to get the client area of the third tab
::SendMessage(hHandle, TCM_GETITEMRECT, (WPARAM)2, (LPARAM)&rBounds);
That's my current method, which works in getting a client area, but not the correct one. So how do I get the client area of the tab control. The client area below the tabs that you click on, that is.


I added a few lines of code to see what the client area was, and it returned something that was WAY off. Here's the code.
wchar_t pBuffer[256];
::wsprintf(pBuffer, L"X: %d, Y: %d, W: %d, H: %d", rBounds.left,, rBounds.right, rBounds.bottom);
::MessageBox(this->Handle(), pBuffer, L"Debug", MB_OK);
Those lines of code are right below the "SendMessage" line. I get back "X: 110, Y: 2, W: 177, H: 23". That maps to the second and third tab area, not the tab control client area. What in the world is wrong here?


I figured out that if I call "GetClientRect()" on the main tab control and not one of the tabs, that I get the entire client area, including the area occupied by the tabs. This is no good since the tab size may vary depending on a user's font size. I can hard-code the program to add 24 units to the top and subtract 26 from the bottom, as well as adding 2 units to the left and subtracting 4 from the right. This makes it work, but when you change font sizes or even styles, this screws everything up again. I need to know how to get just the USABLE client are of the tab control. I don't need the area where the tabs themselves are.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!