• Welcome to PlanetSquires Forums.
 

Tabbed Control with Pages Containing Option Controls

Started by RhodyRich, February 05, 2009, 04:56:17 PM

Previous topic - Next topic

RhodyRich

I have a dialog that uses a tabbed control with three tabs. The main form is Form0. The three tab forms are Form1, Form2 and Form3. There are option controls on the first tab and the third tab. To successfully initialize the options on tab one I have to use this statement to set the first option.

FF_CONTROL_SETOPTION HWND_FORM1, IDC_FORM1_OPTION1(0), IDC_FORM1_OPTION1(1), IDC_FORM1_OPTION1(0)

On the third tab I have to use the next statement to set the first option.

FF_CONTROL_SETOPTION HWND_FORM0, IDC_FORM3_OPTION1(0), IDC_FORM3_OPTION1(1), IDC_FORM3_OPTION1(0)

I have no idea why I need to use the handle for FORM0 in the second case instead of FORM3. Using FORM0 for the first case does not work.

I guess I can always work this out by trial and error but why is this so confusing?

UPDATE: I thought I had this working with trial and error but I am still having trouble initializing the options correctly. The options work fine once clicked but I am either getting all of the options being indicated as chosen for an initial condition or the wrong one being set. I'm still trying to puzzle this out. No problem using the Option control when Tabs are not used.

NEXT DAY UPDATE: Well I have tried just about everything I can think of and nothing seems to allow me to set the initial state of the option group properly.

1. Initializing during the creation of the main form which will display the individual tabs results in the options being displayed with all options showing as selected. If an option is clicked at this point, it behaves correctly in that the clicked option is selected and the others are cleared.

2. Initializing when a tab is clicked results in the same behavior as in (1)

3. The option group I have been experimenting with is on the third tab. If I use the handle of a form other than that of the third tab in initializing the group, the group will display correctly but the option selected is the one that I selected as a default in designing the form and not the one that is supposed to be set. The control will behave correctly at this point but is not initialized correctly.

4. I tried changing the control group name to a unique name. I changed it from OptionGroup0 to HcpGroup. I changed it on each option for the group. This was really strange. The control group would initialize with the unselected options visible and unselected but the selected option was hidden. I tried changing from HcpGroup to OptionGroup9. Same result with the selected option hidden.

5. I completely deleted each option and recreated them. I accepted the defaults of Option1 for the control name and OptionGroup0 for the group name. Same result as in (1).

6. I've tried redrawing the control when the tab is selected and other "brainstorms" but in the end, nothing has worked.

HELP!!! This is a showstopper for me since the form I am designing is a basic form where the user sets or changes a number of options and values for the program. I must be able to correctly display the current settings when the form loads. I have used option groups on other forms without the tabbed control and they work fine. I've used the tabbed control with other dialogs but without option groups and the tabbed control works fine. It could be me but this seems to be a bug and I hope you have a solution or a work around.

TechSupport

Hi Dick,

I am working on an example now to see if I experience the same problem as you.

I'll post back shortly.....

TechSupport

Okay, it struck me pretty quickly when I started to work on the demo that it appears in your post that you are creating "Control Arrays" for each option button group.

Delete you option button groups. Recreate then but do not say "Yes" to the prompt to create the control array. Once you have your option group created, change the "Index" property for each option button so that they are consecutive. So, for example, if you have three option buttons on the first Form then number the Index as 1, 2, 3 for the three buttons.

Once you get that working then we can deal with "Control Arrays" (which I don't think you are needing in this case).

As an aside, you can have duplicate OptionButton GroupNames as long as the option button groups are on different Forms.

TechSupport

I have attached the sample project to this post. You can see the FF_OptionButton_SetOption functions in action in the WM_CREATE handler for each Form with and option button group.


RhodyRich

Tried your example and yes I see how it works. I will try this on my project and let you know if I run into a problem.

In my case I have four options. Each time the dialog is loaded any of the four options might need to be displayed as the current selection. Although I can surely change from using an option array to the set of separate options which you use to get this to work, it does not explain to me why the option array will not work correctly. Using your example I have to create a program with four separate statements to set each individual option as needed. With a properly functioning array, I should only need one statement.

The option array does work fine if a tabbed control is not used but not if it is used. Why is that?

TechSupport

I have attached another version of the Tab Control project that uses two control arrays (one for each set of option buttons). As you can see, it does work as expected.

I wonder it you are setting the "Index" properties for each Control Array group?

Take a look at the project and let me know if it works as you expect.

RhodyRich

You got me on the right track. For whatever reason, I did not notice that there were two indexes. A "ControlIndex", that starts at 0 and increases, and an "Index" that starts at 1 and increases. I was using and making sure the "ControlIndex" was setup correctly but I paid no attention to the "Index" which was set at 1 and remained at one until I manually changed it so that each option is a unique index number.

Okay. Now I understand it. Now I will have to "remember" this when using the Option control in the future. Why the need for two indexes?