PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Elias Montoya on November 20, 2006, 02:18:04 AM

Title: Problem with Option control.
Post by: Elias Montoya on November 20, 2006, 02:18:04 AM
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?
Title: Problem with Option control.
Post by: Roger Garstang on November 20, 2006, 10:12:37 AM
Tab Order?
Title: Problem with Option control.
Post by: TechSupport on November 20, 2006, 10:13:41 AM
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
Title: Problem with Option control.
Post by: Elias Montoya on November 20, 2006, 03:16:11 PM
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....
Title: Problem with Option control.
Post by: Elias Montoya on November 20, 2006, 03:55:04 PM
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. :?:
Title: Problem with Option control.
Post by: TechSupport on November 20, 2006, 06:29:34 PM
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!  :)
Title: Problem with Option control.
Post by: Elias Montoya on November 20, 2006, 07:25:51 PM
Sent. Let me know paul. :)
Title: Problem with Option control.
Post by: TechSupport on November 20, 2006, 09:13:27 PM
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.
Title: Problem with Option control.
Post by: TechSupport on November 20, 2006, 10:56:19 PM
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.
Title: Problem with Option control.
Post by: Elias Montoya on November 20, 2006, 11:27:04 PM
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...

?
Title: Problem with Option control.
Post by: Elias Montoya on November 20, 2006, 11:39:49 PM
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. :(
Title: Problem with Option control.
Post by: Elias Montoya on November 20, 2006, 11:45:29 PM
Wow... Changed OptionGroup0 to OptionGroup12 and everything now works as expected! :P

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

:)
Title: Problem with Option control.
Post by: Roger Garstang on November 23, 2006, 12:36:05 PM
Ok, so it was Tab Order, just not Tab Order we can set...so, is this fixed now with a fresh project?
Title: Problem with Option control.
Post by: TechSupport on November 23, 2006, 01:03:02 PM
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).
Title: Re: Problem with Option control.
Post by: Franck Stegli on May 19, 2007, 09:50:27 AM
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 ?
Title: Re: Problem with Option control.
Post by: TechSupport on May 20, 2007, 08:11:04 AM
Hi Franck,

Right you are. The messages are getting fired during creation of the control. This problem is related to another long standing problem where the EN_CHANGE message for TextBoxes gets fired during control creation. I have built in a fix for this for FireFly 3. For FireFly 2 you need to do the following:

(1) Add a global variable to your Form/Project:

Global gFireMessages As Long

(2) In each of your Option Button BN_CLICKED message handlers put code such as the following to exit the function if the flag has not been set:

Function FORM1_OPTION1_BN_CLICKED ( _
                                  ControlIndex     As Long,  _  ' index in Control Array
                                  hWndForm         As Dword, _  ' handle of Form
                                  hWndControl      As Dword, _  ' handle of Control
                                  idButtonControl  As Long   _  ' identifier of button
                                  ) As Long

If gFireMessages = %FALSE Then Exit Function

MsgBox "fired Option 1"

End Function


(3) The last line in the WM_CREATE message handler for the Form should set the global flag to TRUE:

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

gFireMessages = %TRUE

End Function


I hope this little workaround will help you.
Title: Re: Problem with Option control.
Post by: Franck Stegli on May 20, 2007, 02:56:19 PM

Yes I prefer to use this type of workaround (while waiting for FF3 ;) ) instead of to take any risk that the result is being hazardous during dev time.
Also placing "gFireMessages = %FALSE" before any Form_SHOW is not too fastidious for a stable program  ;D

Merci .