PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Charles Dietz on November 09, 2004, 08:05:59 PM

Title: Tab control
Post by: Charles Dietz on November 09, 2004, 08:05:59 PM
I am trying to learn to use the tab control.  Setting a form as a tabControlChild is easy enough but sizing it to match one of the tab windows is more difficult... at least if I'm doing it right.

So far I have just manually changed the width and height of the form, trying to match the tab window.

tab control:
  left = 16
  top = 8
  width = 448
  height = 200
  tab height = 20

Associated form:
  left = 0
  top = 0
  width = 442  (I computed incorrectly 448 - 16 = 432)
  height = 172  (I computed correctly 200 - 20 - 8 = 172)

I don't know why the width isn't as I computed.  Also, why couldn't the form, once defined as a tabControlChild, be associated with a particular tab control and then be automatically sized?
Title: Tab control
Post by: TechSupport on November 09, 2004, 10:51:16 PM
The problem you describe seems to be a common problem that users of the tab control are struggling with. I will have to address this is a FireFly update.

In the meantime, here is a simple way to see how big your child forms are - just change the background color of the form to a different color than the tab control. You will then be able to quickly see the difference in size between the child form and the tab control. When you are ready to finalize your project, you can change the color to match.

Also, unless you need to use the entire space on the child form, there is no requirement that your child form fill the entire tab control exactly.
Title: Tab control
Post by: Charles Dietz on November 09, 2004, 11:51:04 PM
That is exactly what I did do and it did help.  But I am still wondering why my width calculation came up short by 10 units.
Title: Tab control
Post by: Roger Garstang on November 10, 2004, 01:17:23 AM
I have problems with my code sizing at times too.  I started making my controls where they size on WM_SIZE so they look better and had to make a couple lines that put the size in a message box to see what it returns which is usually off from what FF says because of borders, etc.

I had suggested a while back using something like AdjustWindowRect or AdjustWindowRectEx to allow FF to figure the size of window needed for the desired client area, etc.  It appears setting border width and font doesn't mess with the sizing of my controls, but it may with AdjustWindowRect...probably needs some testing, but it could help.  I imagine your Associated form is showing the size with borders and such throwing you off.
Title: Tab control
Post by: Anonymous on November 11, 2004, 04:31:22 AM
Here is how I find out the size a tab control should be:

For XP with Themes:

TabControlChild's Height = TabControl's Height + TabControl's TabHeight - 48
TabControlChild's Width = TabControl's Width - 6

For all non-themes:

TabControlChild's Height = TabControl's Height + TabControl's TabHeight - 47
TabControlChild's Width = TabControl's Width - 5

Then, when you are working on the TabControlChild, I set the height to height = height + 34.  Then, after you're done, return it to what it should be from above.

Hopefully this helps for now.

I'd be a big fan of auto-sizing for tabcontrol children.  Also, when the tab control child has controls at the bottom, when you change the size to the correct size they appear cut off at the bottom.  

There is also a similar problem when using toolwindows.

Thanks,

John
Title: Tab control
Post by: Charles Dietz on November 11, 2004, 02:46:13 PM
Thank you Roger and John.  I appreciate your responses.  Hopefully, there will be auto-sizing in the near future, but for now, the info John supplied will be most useful.  Thanks again.