Athfar Posted December 10, 2007 Share Posted December 10, 2007 (edited) Does anyone have an example of saving and then repopulating a GUI with an INI file? I am getting stuck on a simple radio button: expandcollapse popupFunc read_settings() GUICtrlSetState($gui_send_to_window_radio, BitAND(IniRead($CB_SETTINGS_INI, "Target", "send_to_window", 1), $GUI_CHECKED)) GUICtrlSetState($gui_send_to_window_radio, BitAND(IniRead($CB_SETTINGS_INI, "Target", "send_to_csv", 0), $GUI_CHECKED)) EndFunc Func write_settings() IniWrite($CB_SETTINGS_INI, "Target", "send_to_window", BitAND(GUICtrlRead($gui_send_to_window_radio), $GUI_CHECKED)) IniWrite($CB_SETTINGS_INI, "Target", "send_to_csv", BitAND(GUICtrlRead($gui_send_to_csv_radio), $GUI_CHECKED)) EndFunc read_settings() While 1 $gui_message = GUIGetMsg() Switch $gui_message Case $gui_send_to_window_radio If GUICtrlRead($gui_send_to_window_radio) = 1 Then GUICtrlSetState($gui_target_window_group, $GUI_ENABLE) GUICtrlSetState($gui_target_window_label, $GUI_ENABLE) GUICtrlSetState($gui_target_window_combo, $GUI_ENABLE) GUICtrlSetState($gui_csv_target_label, $GUI_DISABLE) GUICtrlSetState($gui_csv_target_group, $GUI_DISABLE) GUICtrlSetState($gui_csv_target_combo, $GUI_DISABLE) GUICtrlSetState($gui_csv_target_view_btn, $GUI_DISABLE) GUICtrlSetState($gui_csv_target_browse_btn, $GUI_DISABLE) Else GUICtrlSetState($gui_target_window_group, $GUI_DISABLE) GUICtrlSetState($gui_target_window_label, $GUI_DISABLE) GUICtrlSetState($gui_target_window_combo, $GUI_DISABLE) GUICtrlSetState($gui_csv_target_label, $GUI_ENABLE) GUICtrlSetState($gui_csv_target_group, $GUI_ENABLE) GUICtrlSetState($gui_csv_target_combo, $GUI_ENABLE) GUICtrlSetState($gui_csv_target_view_btn, $GUI_ENABLE) GUICtrlSetState($gui_csv_target_browse_btn, $GUI_ENABLE) EndIf Case $gui_send_to_csv_radio If GUICtrlRead($gui_send_to_csv_radio) = 1 Then GUICtrlSetState($gui_target_window_group, $GUI_DISABLE) GUICtrlSetState($gui_target_window_label, $GUI_DISABLE) GUICtrlSetState($gui_target_window_combo, $GUI_DISABLE) GUICtrlSetState($gui_csv_target_label, $GUI_ENABLE) GUICtrlSetState($gui_csv_target_group, $GUI_ENABLE) GUICtrlSetState($gui_csv_target_combo, $GUI_ENABLE) GUICtrlSetState($gui_csv_target_view_btn, $GUI_ENABLE) GUICtrlSetState($gui_csv_target_browse_btn, $GUI_ENABLE) Else GUICtrlSetState($gui_target_window_group, $GUI_ENABLE) GUICtrlSetState($gui_target_window_label, $GUI_ENABLE) GUICtrlSetState($gui_target_window_combo, $GUI_ENABLE) GUICtrlSetState($gui_csv_target_label, $GUI_DISABLE) GUICtrlSetState($gui_csv_target_group, $GUI_DISABLE) GUICtrlSetState($gui_csv_target_combo, $GUI_DISABLE) GUICtrlSetState($gui_csv_target_view_btn, $GUI_DISABLE) GUICtrlSetState($gui_csv_target_browse_btn, $GUI_DISABLE) EndIf Case $GUI_EVENT_CLOSE write_settings() Exit EndSwitch WEnd How it should work: There are two radio buttons. If one radio is checked it enables one group and disables the other and vice versa. If I close the GUI it saves the state of the radio(s). If I reopen the GUI it reads the INI for the state of each radio to return it to it's previous state as well as enabling/disabling the group. Edited December 10, 2007 by Athfar Link to comment Share on other sites More sharing options...
Athfar Posted December 10, 2007 Author Share Posted December 10, 2007 (edited) I have it working with an IF statement but I am still interested to see if anyone has a better way of doing this. Just seems like alot of Spaghetti MAMAMEA! Is there a way to disable a group AND all of the controls within it? Edited December 10, 2007 by Athfar Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now