Problem with Option control.

Started by Elias Montoya, November 20, 2006, 02:18:04 AM

Previous topic - Next topic

Elias Montoya

Hello, Im having a problem with Option control.

I have 2 groups on my form, one is called OptionGroup0, and the
other one is called OptionGroup01.

OptionGroup0 has 6 members; Option1, Option2, Option3, Option4, Option5 and Option6.

OptionGroup01 only has 2 members; Option7 and Option8.

Bold ones are Checked by default. Each Option control has the Index
Corresponding to the number on the name, For example Option1's Index is 1.

I am setting the checked state at run time in WM_CREATE like this:

  Select Case Int(Items(Index).Rango)
   Case 1: FF_Control_SetOption(HWND_REGISTRO, IDC_REGISTRO_OPTION1, IDC_REGISTRO_OPTION6, IDC_REGISTRO_OPTION1)
   Case 2: FF_Control_SetOption(HWND_REGISTRO, IDC_REGISTRO_OPTION1, IDC_REGISTRO_OPTION6, IDC_REGISTRO_OPTION2)
   Case 3: FF_Control_SetOption(HWND_REGISTRO, IDC_REGISTRO_OPTION1, IDC_REGISTRO_OPTION6, IDC_REGISTRO_OPTION3)
   Case 4: FF_Control_SetOption(HWND_REGISTRO, IDC_REGISTRO_OPTION1, IDC_REGISTRO_OPTION6, IDC_REGISTRO_OPTION4)
   Case 5: FF_Control_SetOption(HWND_REGISTRO, IDC_REGISTRO_OPTION1, IDC_REGISTRO_OPTION6, IDC_REGISTRO_OPTION5)
   Case 6: FF_Control_SetOption(HWND_REGISTRO, IDC_REGISTRO_OPTION1, IDC_REGISTRO_OPTION6, IDC_REGISTRO_OPTION6)
  End Select
         
  If ((Items(Index).Flags And %AGEL_EJECUTIVO) = %AGEL_EJECUTIVO) Then    
   FF_Control_SetOption(HWND_REGISTRO, IDC_REGISTRO_OPTION7, IDC_REGISTRO_OPTION8, IDC_REGISTRO_OPTION8)
  End If


I have no problems with OptionGroup01, but OptionGroup0 only checks
the option controls 1, 2 and 6. but if Int(Items(Index).Rango) is
3, 4 or 5, no options are checked in OptionGroup0.

All the option controls can be clicked and they work correctly, but
those ones (3 to 5) dont get checked initially if they need to.

Am i doing something wrong?

Roger Garstang


TechSupport

Hi Elias,

I created a simple test program but it does not show any problems like you described. Try to run the following test program to see if it works for you.


%AGEL_EJECUTIVO = 2

Type Items_Type
  Rango As Long    
  Flags As Long
End Type      

Global Items() As Items_Type


'------------------------------------------------------------------------------------------------------------------------
Function REGISTRO_WM_CREATE ( _
                           hWndForm As Dword, _  ' handle of Form
                           ByVal UserData As Long _  'optional user defined Long value
                           ) As Long

Dim Index As Long
Dim Items(100) As Items_Type

Index = 0            

' Test the Rango values of 3, 4, 5 to see if the option control gets checked
Items(Index).Rango = 3

Select Case Int(Items(Index).Rango)
   Case 1: FF_Control_SetOption(HWND_REGISTRO, IDC_REGISTRO_OPTION1, IDC_REGISTRO_OPTION6, IDC_REGISTRO_OPTION1)
   Case 2: FF_Control_SetOption(HWND_REGISTRO, IDC_REGISTRO_OPTION1, IDC_REGISTRO_OPTION6, IDC_REGISTRO_OPTION2)
   Case 3: FF_Control_SetOption(HWND_REGISTRO, IDC_REGISTRO_OPTION1, IDC_REGISTRO_OPTION6, IDC_REGISTRO_OPTION3)
   Case 4: FF_Control_SetOption(HWND_REGISTRO, IDC_REGISTRO_OPTION1, IDC_REGISTRO_OPTION6, IDC_REGISTRO_OPTION4)
   Case 5: FF_Control_SetOption(HWND_REGISTRO, IDC_REGISTRO_OPTION1, IDC_REGISTRO_OPTION6, IDC_REGISTRO_OPTION5)
   Case 6: FF_Control_SetOption(HWND_REGISTRO, IDC_REGISTRO_OPTION1, IDC_REGISTRO_OPTION6, IDC_REGISTRO_OPTION6)
End Select
         
' UnREM the next line to test if the "And" flag works
'Items(Index).Flags = %AGEL_EJECUTIVO

If ((Items(Index).Flags And %AGEL_EJECUTIVO) = %AGEL_EJECUTIVO) Then    
   FF_Control_SetOption(HWND_REGISTRO, IDC_REGISTRO_OPTION7, IDC_REGISTRO_OPTION8, IDC_REGISTRO_OPTION8)
End If
 
End Function

Elias Montoya

I tried Roger, but one cant set the tab order of Option controls.

Paul, i made the example, using the code you provided and the controls
i added to the form. And everything works fine. The problem only appears to happen in my compiled program.

But no code is executed before setting the check of options, and no code
is executed after either.

I will create a video showing this behaviour... just a moment....

Elias Montoya

Here is the video:
http://www.sweetheartgames.com/FIREFLY.avi
it uses XVID MPEG-4  codec.

As you can see in the video, i click on al option buttons so you can see quickly the properties, use pause if you need, i made the video very fast to be able to upload faster.

After i click them all, i open the code editor, and show the code that gets
executed. i save several ranges (rangos), and only 1, 2 and 6 are updated in the option buttons.  ("Guardar" means "Save")

Im clueless. :?:

TechSupport

hmmmm..... not sure what the trouble could be. One thing that I did notice on your video is that Option7 and Option8 should have Index=1 and Index=2 rather than Index=7 and Index=8.

You could try testing the return value from each FF_Control_SetOption call. If any of them returns zero then the function failed.

Is there any other code that may be getting executed that is resetting the options - possibly in the BN_CLICKED message of the OptionButton?

If you would like, I could take a look at your code for you. BTW, your program looks very cool!  :)

Elias Montoya


TechSupport

Hi Elias,

The problem seems to be related to the values that FireFly is outputting for the IDC_ constants. I am now looking into the code generation module to see where the exact problem lies. I will post an updated FireFly engine as soon as possible.

TechSupport

Hi Elias,

I have reworked the code generation and now it appears to correctly generate consecutive IDC_ values for each OptionButton group.

Download and use the new FFEngine:
http://www.planetsquires.com/files/FFengine.zip

Please let me know if it works.

Elias Montoya

Helo Paul, i just downloaded it, it certainly now saves the state of the
option buttons, but for some reason some of them are not considered
part of the group.

Try clicking the Option3 one, and click Guardar. Then colse that window,
next time you open that window that option button is certainly checked,
but clicking other option buttons doesnt make then get unchecked...

?

Elias Montoya

I tried removing all the option buttons in OptionGroup0 and adding them
fresh, as i guessed something went wrong with them.

Now they ALL get checked if one of them is checked, for example, using

FF_Control_SetOption(HWND_REGISTRO, IDC_REGISTRO_OPTION1, IDC_REGISTRO_OPTION6, IDC_REGISTRO_OPTION1)

Causes them all to be checked. :(

Elias Montoya

Wow... Changed OptionGroup0 to OptionGroup12 and everything now works as expected! :P

However, if there is still something wrong, please let me know.

:)

Roger Garstang

Ok, so it was Tab Order, just not Tab Order we can set...so, is this fixed now with a fresh project?

TechSupport

It was not really 100% the tab order because the tab order is/was correctly set to the defined Option group and you could arrow though each option after that. The problem was that the IDC_ values for the individual option buttons were not consecutive. What would happen is that when you used the FireFly Function to set the option checkmark, it would fail in situations where FireFly generated that OptionButton's IDC_ value to be either less than the first OptionButton's value or greater than the last OptionButton's value. Basically, you would be trying to set the checkmark for an optionbutton where that button's control ID fell outside the range of the first and last button in the option group (as defined by that group's "Index" property).

I expect that the problem should now be resolved. In current projects all that you should have to do is perform a complete compile (rather than an incremental compile).

Franck Stegli

The problem still exist in version 2.80.

In some cases the function Formxxx_OPTGRPNAME_BN_CLICKED() of an option button group is fired before the Formxxx_WM_CREATE(). That way some wrong actions are taken due to the ControlIndex (always 0 in this case). Strange early firing !

If OptionGroup## is changed to an never used name the Internal ID's are rebuild in adjacent way and the problem is temporary solved (until some design modifications are done) .

Maybe a check command in FF could verify and rebuild (on demand) the ID's order ?