Re: SetTabCaptionList during OnInitialize

Started by honkinberry, December 16, 2014, 02:57:17 PM

Previous topic - Next topic

honkinberry

This does not work -- at least not for tabs beyond the first 3.
See attached example.

--J

owenwengerd

Your code shows that you're replacing the existing tabs during OnInitialize. This is a different problem than the thread you posted in, so I've split your post into a new thread. I will investigate.
Owen Wengerd (Outside The Box) / ManuSoft

owenwengerd

I checked your sample under the debugger to verify what I suspected. The basic issue is that your form has only three tab pages. The TabCaptionList property nevertheless accepts a 5-member list of tab captions, even though there are no tab pages defined for the last two. The TabIndex argument of SetCurSel is based on defined tabs (i.e. tab pages), not visible tabs. Therefore, your call to SetCurSel fails because 4 is not a valid tab index.

The reason for the somewhat counterintuitive behavior is that you can hide and unhide tab pages, so the number of tab strips displayed in the tab strip control is somewhat dynamic at runtime and not necessarily the same as the number of tab pages. To allow for this, the two are maintained as separate lists with a mapping between them. This is why you can have more (or fewer) tabs than tab pages.
Owen Wengerd (Outside The Box) / ManuSoft

honkinberry

Ah, of course!
I had even set the Tab Captions at Design to have 6 captions.  But I should have instead been using the Wizard to create 6 tabs.
You are fantastic, thank you sir.

--J