thienfu Posted June 16, 2010 Share Posted June 16, 2010 Helo All, i newbie here, can anyone help for complete below script, i dunno why the script can work for checkbox1 only. can anyone help for make this script work for all func ( checkbox1, checkbox2 & Slidebar ) sorry my english no so good, hope u all can understand. expandcollapse popup#RequireAdmin #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include <WinAPI.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Process.au3> #NoTrayIcon Global $slider1 GUICreate("Test Checkbox and Slider Bar", 370, 400, 100, 100) ; will create a dialog box GUISetBkColor(0xFFFBF0) ; will change background color GUISetState(@SW_SHOW) $hTab = GUICtrlCreateTab(5, 10, 360, 380) $hTab0 = GUICtrlCreateTabItem("Tab 01") GUICtrlCreateGroup("", 15, 35, 120, 80) $cb1 = GUICtrlCreateCheckbox("CheckBox 1", 25, 50, 100, 20) $cb2 = GUICtrlCreateCheckbox("CheckBox 2", 25, 70, 100, 20) GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group GUICtrlCreateGroup("", 140, 35, 215, 80) GUICtrlCreateLabel("Test InputBox ", 150, 50) $InputBox = GUICtrlCreateInput("0", 220, 50, 100, 20) GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group GUICtrlCreateLabel("Test Sliderbar ", 150, 80) GUICtrlCreateLabel("Status of CheckBox : ", 20, 130) GUICtrlCreateLabel("CheckBox 1 : ", 30, 145) GUICtrlCreateLabel("CheckBox 2 : ", 30, 160) GUICtrlCreateTabItem("") Checkbox1() Checkbox2() Slidebar() Func Checkbox1() while 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $cb1 if BitAnd(GUICtrlRead($cb1), $GUI_CHECKED) == $GUI_CHECKED Then GUICtrlCreateLabel("Checked ", 100, 145) Else GUICtrlCreateLabel("Unchecked ", 100, 145) EndIf EndSwitch WEnd EndFunc Func Checkbox2() while 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $cb2 if BitAnd(GUICtrlRead($cb2), $GUI_CHECKED) == $GUI_CHECKED Then GUICtrlCreateLabel("Checked ", 100, 160) Else GUICtrlCreateLabel("Unchecked ", 100, 160) EndIf EndSwitch WEnd EndFunc Func Slidebar() $slider1 = GUICtrlCreateSlider(220, 80, 100, 20) GUICtrlSetLimit(-1, 500, 0) ; change min/max value GUISetState() GUICtrlSetData($slider1, 0) ; set cursor Do $msgslider = GUIGetMsg() If $msgslider = $slider1 Then GUICtrlCreateLabel(GUICtrlRead($slider1), 325, 80) EndIf Until $msgslider = $GUI_EVENT_CLOSE EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 16, 2010 Moderators Share Posted June 16, 2010 (edited) thienfu,Edit: Please do NOT double post in different forums - it is one of things that we really do not like. You need to put the check for both checkboxes into the one While...WEnd loop. You can check for the slider value constantly, not just when it sends a message. Your code then looks something like this: expandcollapse popup;#RequireAdmin #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include <WinAPI.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Process.au3> ;#NoTrayIcon Global $slider1 GUICreate("Test Checkbox and Slider Bar", 370, 400, 100, 100) ; will create a dialog box GUISetBkColor(0xFFFBF0) ; will change background color GUISetState(@SW_SHOW) $hTab = GUICtrlCreateTab(5, 10, 360, 380) $hTab0 = GUICtrlCreateTabItem("Tab 01") GUICtrlCreateGroup("", 15, 35, 120, 80) $cb1 = GUICtrlCreateCheckbox("CheckBox 1", 25, 50, 100, 20) $cb2 = GUICtrlCreateCheckbox("CheckBox 2", 25, 70, 100, 20) GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group $slider1 = GUICtrlCreateSlider(220, 80, 100, 20) GUICtrlSetLimit(-1, 500, 0) ; change min/max value $hLabel = GUICtrlCreateLabel(GUICtrlRead($slider1), 325, 80, 30, 20) GUICtrlCreateGroup("", 140, 35, 215, 80) GUICtrlCreateLabel("Test InputBox ", 150, 50) $InputBox = GUICtrlCreateInput("0", 220, 50, 100, 20) GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group GUICtrlCreateLabel("Test Sliderbar ", 150, 80) GUICtrlCreateLabel("Status of CheckBox : ", 20, 130) GUICtrlCreateLabel("CheckBox 1 : ", 30, 145) GUICtrlCreateLabel("CheckBox 2 : ", 30, 160) GUICtrlCreateTabItem("") $iLastSlider = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $cb1 If BitAnd(GUICtrlRead($cb1), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlCreateLabel("Checked ", 100, 145) Else GUICtrlCreateLabel("Unchecked ", 100, 145) EndIf Case $cb2 If BitAnd(GUICtrlRead($cb2), $GUI_CHECKED) == $GUI_CHECKED Then GUICtrlCreateLabel("Checked ", 100, 160) Else GUICtrlCreateLabel("Unchecked ", 100, 160) EndIf EndSwitch ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $iCurrSlider = GUICtrlRead($slider1) If $iCurrSlider <> $iLastSlider Then GUICtrlSetData($hLabel, $iCurrSlider) $iLastSlider = $iCurrSlider EndIf ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< WEndYou need the $iCurrSlider/$iLastSlider code or the label flashes as it is updated every pass through the loop. Try replacing the section between the <<<<<<<<<<<<< with a simple GUICtrlSetData($hLabel, $slider1) and see what happens. Ask if anything is unclear. M23 Edited June 16, 2010 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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