eracross Posted October 12, 2010 Author Share Posted October 12, 2010 Help file. Link to comment Share on other sites More sharing options...
eracross Posted October 13, 2010 Author Share Posted October 13, 2010 (edited) last how can i disable the button? i tried GUICtrlSetState($btn, $GUI_DISABLE) but doesnt work ------------ I got it! $btn = ($BN_DISABLE) thanks anyway Wahh now the problem is how to return it ENABLE Edited October 13, 2010 by eracross Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 13, 2010 Moderators Share Posted October 13, 2010 eracross,In this script, each button enables/disables the other - look for the <<<<<<<<<<<<<< lines:expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiButton.au3> #include <WindowsConstants.au3> #include <GuiMenu.au3> Global $hButton_1, $hButton_2, $hButton_1_Handle _Main() Func _Main() Local $hGUI $hGUI = GUICreate("Buttons", 400, 400) $hButton_1 = GUICtrlCreateButton("Initial 1", 10, 10, 120, 30, $BS_SPLITBUTTON) $hButton_1_Handle = GUICtrlGetHandle(-1) $hButton_2 = _GUICtrlButton_Create($hGUI, "Initial 1", 270, 10, 120, 30, $BS_SPLITBUTTON) _GUICtrlButton_SetSplitInfo($hButton_2) ; puts icon to left GUISetState() GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $hButton_1 ConsoleWrite("Button 1 Pressed - " & GUICtrlRead($hButton_1) & @CRLF) EndSwitch WEnd Exit EndFunc ;==>_Main Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) #forceref $hWnd, $Msg, $wParam Local $tNMBHOTITEM = DllStructCreate("hwnd hWndFrom;int IDFrom;int Code;dword dwFlags", $lParam) Local $nNotifyCode = DllStructGetData($tNMBHOTITEM, "Code") ;Local $nID = DllStructGetData($tNMBHOTITEM, "IDFrom") Local $hCtrl = DllStructGetData($tNMBHOTITEM, "hWndFrom") ;Local $dwFlags = DllStructGetData($tNMBHOTITEM, "dwFlags") Switch $nNotifyCode Case $BCN_DROPDOWN _Popup_Menu($hCtrl) EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _Popup_Menu($hCtrl) Local Enum $iOption_1 = 1000, $iOption_2 Local $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Disable", $iOption_1) _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Enable", $iOption_2) Switch _GUICtrlMenu_TrackPopupMenu($hMenu, $hCtrl, -1, -1, 1, 1, 2) Case $iOption_1 Switch $hCtrl Case $hButton_1_Handle ConsoleWrite("Button 1 - Option 1" & @CRLF) GUICtrlSetData($hButton_1, "Option 1") _GUICtrlButton_Enable($hButton_2, False) ; <<<<<<<<<<<<<<<<<<<<<<<< Case $hButton_2 ConsoleWrite("Button 2 - Option 1" & @CRLF) _GUICtrlButton_SetText($hButton_2, "Option 1") GUICtrlSetState($hButton_1, $GUI_DISABLE) ; <<<<<<<<<<<<<<<<<<<<<<<< EndSwitch Case $iOption_2 Switch $hCtrl Case $hButton_1_Handle ConsoleWrite("Button 1 - Option 2" & @CRLF) GUICtrlSetData($hButton_1, "Option 2") _GUICtrlButton_Enable($hButton_2, True) ; <<<<<<<<<<<<<<<<<<<<<<<< Case $hButton_2 ConsoleWrite("Button 2 - Option 2" & @CRLF) _GUICtrlButton_SetText($hButton_2, "Option 2") GUICtrlSetState($hButton_1, $GUI_ENABLE) ; <<<<<<<<<<<<<<<<<<<<<<<< EndSwitch EndSwitch _GUICtrlMenu_DestroyMenu($hMenu) EndFunc ;==>_Popup_Menu ; React on a button click Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam) #forceref $hWnd, $Msg Local $nNotifyCode = BitShift($wParam, 16) ;Local $nID = BitAND($wParam, 0x0000FFFF) Local $hCtrl = $lParam Local $sText = "" Switch $hCtrl Case $hButton_2 Switch $nNotifyCode Case $BN_CLICKED $sText = "Button 2 Clicked - " & _GUICtrlButton_GetText($hButton_2) EndSwitch EndSwitch If $sText <> "" Then ConsoleWrite($sText & @CRLF) Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMANDAll clear? M23 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...
eracross Posted October 13, 2010 Author Share Posted October 13, 2010 OMG all clear! Thanks melba23 u rock as always... 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