TabStrip Client Area co-ordinates
Posted on 1998-10-12
I've got a simple TabStrip control on a basic form. It has 4 tabs. When the form is resized, the TabStrip control is resized to the Scale Width/Height of the form. Great so far. Now, I've got 4 Frames, in a collection. The idea is that I associate each Frame with a Tab, and hide/show it (and its contained controls) appropriately. This is all working wonderfully - the correct controls are getting displayed depending on the selected Tab.
My problem is that I can't properly size the Frame within the Tab. The Form itself has a ScaleMode of 1 (Twips), but when I watch the code execute, it appears that the sizes of the Frames (before I resize them and after) aren't getting set properly. For example, when the form is resized to (for example) 10000 x 10000 (twips, don't forget), the tab control ends up with sizes like 9885 x 9315, which is fair enough. But the tab control's client area shows a size of 201.75 x 181.45. Naturally, when I set the frames to this size, they look like crap. At first I thought that somehow the client area sizes were being reported in pixels, rather than twips (despite the fact that all controls are supposed to inherit the parent form's ScaleMode), but that's not right either. I put in the correction (* Screen.TwipsPerPixelX) and they were still to small - they looked about two thirds as big as they should have been. In case it helps, here's the entire subroutine on the form's resize:
Private Sub Form_Resize()
tabMain.Left = frmMain.ScaleLeft
tabMain.Top = frmMain.ScaleTop
tabMain.Width = frmMain.ScaleWidth
tabMain.Height = frmMain.ScaleHeight
fraTab(tabMain.SelectedItem.Index).Left = tabMain.ClientLeft
fraTab(tabMain.SelectedItem.Index).Top = tabMain.ClientTop
fraTab(tabMain.SelectedItem.Index).Width = tabMain.ClientWidth
fraTab(tabMain.SelectedItem.Index).Height = tabMain.ClientHeight
The main Form is frmMain, the TabStrip is tabMain, and the collection of Frames is fraTab.