luis713 Posted October 3, 2012 Share Posted October 3, 2012 (edited) i want to choose from a combo box between NTFS and FAT, if i choose NTFS i want to limit the number of characters of an input to 32 and if i choose FAT i want to limit it to 11 characters, how is this possible? i want to do it without clicking a button, thanks here is my code expandcollapse popup#include GUICreate("", 200, 120) $input = GUICtrlCreateInput("", 10, 60, 180, 20) $checkBox = GUICtrlCreateCheckbox("Activate combo", 10, 10, 100, 20) $combo = GUICtrlCreateCombo("", 50, 30, 100, 100) GUISetState(@SW_SHOW) GUICtrlSetData($combo, "NTFS|FAT32|FAT", "NTFS") While 1 $msg = GUIGetMsg() ;Enable or disbable the combo when checked If GUICtrlRead($CheckBox) = $GUI_CHECKED Then If BitAND(GUICtrlGetState($Combo), $GUI_ENABLE) <> $GUI_ENABLE Then GUICtrlSetState($combo, $GUI_ENABLE) EndIf EndIf If GUICtrlRead($CheckBox) = $GUI_UNCHECKED Then If BitAND(GUICtrlGetState($combo), $GUI_disable) <> $GUI_disable Then GUICtrlSetState($combo, $GUI_disable) EndIf EndIf Select case $msg = $GUI_event_Close Exit EndSelect WEnd Edited October 8, 2012 by luis713 Link to comment Share on other sites More sharing options...
BrewManNH Posted October 3, 2012 Share Posted October 3, 2012 Here's one way of doing it. It enables and disables the combobox depending upon whether you check or uncheck the checkbox, then sets the limit for the inputbox depending upon what you select in the combo. It's initially set to a limit of 32 characters, because NTFS is the default, but will reset the limit if you change to FAT or FAT32. It also reads what you've put into the input box, if anything, and trims the excess characters if you select the lower limit. expandcollapse popup#include <GUIConstantsEx.au3> GUICreate("", 200, 120) $input = GUICtrlCreateInput("", 10, 60, 180, 20) $checkBox = GUICtrlCreateCheckbox("Activate combo", 10, 10, 100, 20) $combo = GUICtrlCreateCombo("", 50, 30, 100, 100) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState(@SW_SHOW) GUICtrlSetData($combo, "NTFS|FAT32|FAT", "NTFS") While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_event_Close Exit Case $msg = $checkBox If GUICtrlRead($checkBox) = $GUI_CHECKED Then GUICtrlSetState($combo, $GUI_ENABLE) GUICtrlSetLimit($input, 32) Else GUICtrlSetState($combo, $GUI_DISABLE) EndIf Case $msg = $combo If GUICtrlRead($combo) = "NTFS" Then GUICtrlSetLimit($input, 32) ; limits the input to 32 chars. Else GUICtrlSetLimit($input, 11) ; limits the input to 11 chars. GUICtrlSetData($input, StringLeft(GUICtrlRead($input), 11)) ; reads what's in the input and trims anything over 11 chars. EndIf EndSelect WEnd If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
luis713 Posted October 4, 2012 Author Share Posted October 4, 2012 thanks it works perfect for me 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