tlman12 Posted October 8, 2009 Posted October 8, 2009 Is there a way to have 1 default button per tabsheet? currently it just makes the last button with the $BS_DEFPUSHBUTTON style the default for the whole form. sorry if this has been asked before i did a quick search but wasn't sure of the wording to use and didn't find any results that answered my question. Thanks
Zedna Posted October 8, 2009 Posted October 8, 2009 (edited) I would change $BS_DEFPUSHBUTTON style of buttons according to active TabSheet selection.Look here how to catch $TCN_SELCHANGE notification - when Tab selection changeshttp://www.autoitscript.com/forum/index....owtopic=72894&st=0&p=531772&#entry531772 Edited October 8, 2009 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
tlman12 Posted November 6, 2009 Author Posted November 6, 2009 I would change $BS_DEFPUSHBUTTON style of buttons according to active TabSheet selection.Look here how to catch $TCN_SELCHANGE notification - when Tab selection changeshttp://www.autoitscript.com/forum/index....owtopic=72894&st=0&p=531772&#entry531772i tried something to that nature except i used _GUICtrlTab_GetCurFocus($tab) to determine the tab then a guictrlsetstyle depending on the tabit seemed to work like the button outlined like it was the default but when i hit enter nothing would happenhow would i build the guictrlsetstyle?
Moderators Melba23 Posted November 6, 2009 Moderators Posted November 6, 2009 timan12, I would do it this way: expandcollapse popup#include <GUIConstantsEx.au3> #Include <GuiTab.au3> $dll = DllOpen("user32.dll") Global $aTabButtons[3] $hGUI = GUICreate("Test", 500, 500) $tab = GUICtrlCreateTab(10, 10, 200, 100) $tabhandle = GUICtrlGetHandle($tab) $tab0 = GUICtrlCreateTabItem("tab 0") $aTabButtons[0] = GUICtrlCreateButton("Button 0", 20, 50, 50, 20) $tab1 = GUICtrlCreateTabItem("tab 1") $aTabButtons[1] = GUICtrlCreateButton("Button 1", 20, 50, 50, 20) $tab2 = GUICtrlCreateTabItem("tab 2") $aTabButtons[2] = GUICtrlCreateButton("Button 2", 20, 50, 50, 20) GUISetState() $iCurrIndex = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $aTabButtons[0] _Pressed(0) Case $aTabButtons[1] _Pressed(1) Case $aTabButtons[2] _Pressed(2) EndSwitch $iIndex = _GUICtrlTab_GetCurFocus($tabhandle) If $iIndex <> $iCurrIndex Then $iCurrIndex = $iIndex GUICtrlSetState($aTabButtons[$iIndex], $GUI_FOCUS) EndIf WEnd Func _Pressed($iIndex) ConsoleWrite("Hit" & @CRLF) MsgBox(0, "", "Button " & $iIndex & " pressed") EndFunc I hope this helps. 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
tlman12 Posted November 6, 2009 Author Posted November 6, 2009 timan12, I would do it this way: expandcollapse popup#include <GUIConstantsEx.au3> #Include <GuiTab.au3> $dll = DllOpen("user32.dll") Global $aTabButtons[3] $hGUI = GUICreate("Test", 500, 500) $tab = GUICtrlCreateTab(10, 10, 200, 100) $tabhandle = GUICtrlGetHandle($tab) $tab0 = GUICtrlCreateTabItem("tab 0") $aTabButtons[0] = GUICtrlCreateButton("Button 0", 20, 50, 50, 20) $tab1 = GUICtrlCreateTabItem("tab 1") $aTabButtons[1] = GUICtrlCreateButton("Button 1", 20, 50, 50, 20) $tab2 = GUICtrlCreateTabItem("tab 2") $aTabButtons[2] = GUICtrlCreateButton("Button 2", 20, 50, 50, 20) GUISetState() $iCurrIndex = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $aTabButtons[0] _Pressed(0) Case $aTabButtons[1] _Pressed(1) Case $aTabButtons[2] _Pressed(2) EndSwitch $iIndex = _GUICtrlTab_GetCurFocus($tabhandle) If $iIndex <> $iCurrIndex Then $iCurrIndex = $iIndex GUICtrlSetState($aTabButtons[$iIndex], $GUI_FOCUS) EndIf WEnd Func _Pressed($iIndex) ConsoleWrite("Hit" & @CRLF) MsgBox(0, "", "Button " & $iIndex & " pressed") EndFunc I hope this helps. M23 that is very close but the problem is when i got to type in the txt box the go becomes not the default button anymore and when i hit enter nothing happens
Yashied Posted November 6, 2009 Posted November 6, 2009 #Include <GUIConstantsEx.au3> $hForm = GUICreate('MyGUI', 400, 400) GUISetFont(8.5, 400, 0, 'MS Shell Dlg', $hForm) $Tab = GUICtrlCreateTab(10, 10, 380, 380) GUICtrlCreateTabItem('Tab1') GUICtrlCreateEdit('Test1', 28, 48, 342, 298) $Button1 = GUICtrlCreateButton('Button1', 165, 355, 70, 23) GUICtrlSetState(-1, BitOR($GUI_DEFBUTTON, $GUI_FOCUS)) GUICtrlCreateTabItem('Tab2') GUICtrlCreateEdit('Test2', 28, 48, 342, 298) $Button2 = GUICtrlCreateButton('Button1', 165, 355, 70, 23) GUICtrlCreateTabItem('') GUISetState() While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE ExitLoop Case $Tab Switch GUICtrlRead($Tab) Case 0 $CtrlID = $Button1 Case 1 $CtrlID = $Button2 EndSwitch GUICtrlSetState($CtrlID, $GUI_DEFBUTTON) GUICtrlSetState($Tab, $GUI_FOCUS) EndSwitch WEnd My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
Moderators Melba23 Posted November 6, 2009 Moderators Posted November 6, 2009 tlman12, If you do not ask the right question, you will not get the right answer. You had not mentioned input boxes! Try this: expandcollapse popup#include <GUIConstantsEx.au3> #Include <GuiTab.au3> #include <Misc.au3> $dll = DllOpen("user32.dll") Global $aTabButtons[3] $hGUI = GUICreate("Test", 500, 500) $tab = GUICtrlCreateTab(10, 10, 200, 100) $tabhandle = GUICtrlGetHandle($tab) $tab0 = GUICtrlCreateTabItem("tab 0") $aTabButtons[0] = GUICtrlCreateButton("Button 0", 20, 50, 50, 20) $hInput_0 = GUICtrlCreateInput("", 20, 80, 150, 20) $tab1 = GUICtrlCreateTabItem("tab 1") $aTabButtons[1] = GUICtrlCreateButton("Button 1", 20, 50, 50, 20) $hInput_1 = GUICtrlCreateInput("", 50, 80, 150, 20) $tab2 = GUICtrlCreateTabItem("tab 2") $aTabButtons[2] = GUICtrlCreateButton("Button 2", 20, 50, 50, 20) $hInput_2 = GUICtrlCreateInput("", 20, 80, 150, 20) GUISetState() $iCurrIndex = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $aTabButtons[0] _Pressed(0) Case $aTabButtons[1] _Pressed(1) Case $aTabButtons[2] _Pressed(2) EndSwitch $iIndex = _GUICtrlTab_GetCurFocus($tabhandle) If $iIndex <> $iCurrIndex Then $iCurrIndex = $iIndex GUICtrlSetState($aTabButtons[$iIndex], $GUI_FOCUS) EndIf If _IsPressed("0D", $dll) Then _Pressed($iCurrIndex) WEnd Func _Pressed($iIndex) ConsoleWrite("Hit" & @CRLF) MsgBox(0, "", "Button " & $iIndex & " pressed") EndFunc 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
tlman12 Posted November 6, 2009 Author Posted November 6, 2009 tlman12, If you do not ask the right question, you will not get the right answer. You had not mentioned input boxes! Try this: expandcollapse popup#include <GUIConstantsEx.au3> #Include <GuiTab.au3> #include <Misc.au3> $dll = DllOpen("user32.dll") Global $aTabButtons[3] $hGUI = GUICreate("Test", 500, 500) $tab = GUICtrlCreateTab(10, 10, 200, 100) $tabhandle = GUICtrlGetHandle($tab) $tab0 = GUICtrlCreateTabItem("tab 0") $aTabButtons[0] = GUICtrlCreateButton("Button 0", 20, 50, 50, 20) $hInput_0 = GUICtrlCreateInput("", 20, 80, 150, 20) $tab1 = GUICtrlCreateTabItem("tab 1") $aTabButtons[1] = GUICtrlCreateButton("Button 1", 20, 50, 50, 20) $hInput_1 = GUICtrlCreateInput("", 50, 80, 150, 20) $tab2 = GUICtrlCreateTabItem("tab 2") $aTabButtons[2] = GUICtrlCreateButton("Button 2", 20, 50, 50, 20) $hInput_2 = GUICtrlCreateInput("", 20, 80, 150, 20) GUISetState() $iCurrIndex = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $aTabButtons[0] _Pressed(0) Case $aTabButtons[1] _Pressed(1) Case $aTabButtons[2] _Pressed(2) EndSwitch $iIndex = _GUICtrlTab_GetCurFocus($tabhandle) If $iIndex <> $iCurrIndex Then $iCurrIndex = $iIndex GUICtrlSetState($aTabButtons[$iIndex], $GUI_FOCUS) EndIf If _IsPressed("0D", $dll) Then _Pressed($iCurrIndex) WEnd Func _Pressed($iIndex) ConsoleWrite("Hit" & @CRLF) MsgBox(0, "", "Button " & $iIndex & " pressed") EndFunc M23 i tried using something along those lines but what would happen is if you click on another button then type something in the input box and hit enter it would hit both buttons (the one you wanted to be default, and the last button uses) i know this is confusing and i'm thinking about dumping the default button altogeather and just make you have to click ok lol
Moderators Melba23 Posted November 6, 2009 Moderators Posted November 6, 2009 tlman12, what would happen is if you click on another button then type something in the input box and hit enter it would hit both buttons (the one you wanted to be default, and the last button uses)Have you tried? Once you click in the input, the focus passes to the input - the last button pressed looses focus at this point. Then when you press Enter, it is as if you pressed the button you want as default. Try this and see: expandcollapse popup#include <GUIConstantsEx.au3> #Include <GuiTab.au3> #include <Misc.au3> $dll = DllOpen("user32.dll") Global $aTabButtons[3] $hGUI = GUICreate("Test", 500, 500) $tab = GUICtrlCreateTab(10, 10, 200, 100) $tabhandle = GUICtrlGetHandle($tab) $tab0 = GUICtrlCreateTabItem("tab 0") $aTabButtons[0] = GUICtrlCreateButton("Button 0", 20, 50, 50, 20) $hInput_0 = GUICtrlCreateInput("", 20, 80, 150, 20) GUICtrlCreateButton("Dummy", 100, 50, 50, 20) $tab1 = GUICtrlCreateTabItem("tab 1") $aTabButtons[1] = GUICtrlCreateButton("Button 1", 20, 50, 50, 20) $hInput_1 = GUICtrlCreateInput("", 50, 80, 150, 20) GUICtrlCreateButton("Dummy", 100, 50, 50, 20) $tab2 = GUICtrlCreateTabItem("tab 2") $aTabButtons[2] = GUICtrlCreateButton("Button 2", 20, 50, 50, 20) $hInput_2 = GUICtrlCreateInput("", 20, 80, 150, 20) GUICtrlCreateButton("Dummy", 100, 50, 50, 20) GUISetState() $iCurrIndex = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $aTabButtons[0] _Pressed(0) Case $aTabButtons[1] _Pressed(1) Case $aTabButtons[2] _Pressed(2) EndSwitch $iIndex = _GUICtrlTab_GetCurFocus($tabhandle) If $iIndex <> $iCurrIndex Then $iCurrIndex = $iIndex GUICtrlSetState($aTabButtons[$iIndex], $GUI_FOCUS) EndIf If _IsPressed("0D", $dll) Then _Pressed($iCurrIndex) WEnd Func _Pressed($iIndex) ConsoleWrite("Hit" & @CRLF) MsgBox(0, "", "Button " & $iIndex & " pressed") EndFunc 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
ProgAndy Posted November 6, 2009 Posted November 6, 2009 I would do this: expandcollapse popup#include <GUIConstantsEx.au3> #include <ButtonConstants.au3> $hGUI = GUICreate("Test", 500, 500) $_DEFPUSHBUTTON = GUICtrlCreateButton("", -100, -100, 1,1, $BS_DEFPUSHBUTTON) $tab = GUICtrlCreateTab(10, 10, 200, 100) $tabhandle = GUICtrlGetHandle($tab) $tab0 = GUICtrlCreateTabItem("tab 0") $iTabButton0 = GUICtrlCreateButton("Button 0", 20, 50, 50, 20) $hInput_0 = GUICtrlCreateInput("", 20, 80, 150, 20) GUICtrlCreateButton("Dummy", 100, 50, 50, 20) $tab1 = GUICtrlCreateTabItem("tab 1") $iTabButton1 = GUICtrlCreateButton("Button 1", 20, 50, 50, 20) $hInput_1 = GUICtrlCreateInput("", 50, 80, 150, 20) GUICtrlCreateButton("Dummy", 100, 50, 50, 20) $tab2 = GUICtrlCreateTabItem("tab 2") $iTabButton2 = GUICtrlCreateButton("Button 2", 20, 50, 50, 20) $hInput_2 = GUICtrlCreateInput("", 20, 80, 150, 20) GUICtrlCreateButton("Dummy", 100, 50, 50, 20) GUISetState() $iCurrIndex = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $iTabButton0, $iTabButton1, $iTabButton2 _Pressed($nMsg) Case $_DEFPUSHBUTTON Switch GUICtrlRead($tab, 1) Case $tab0 _Pressed($iTabButton0) Case $tab1 _Pressed($iTabButton1) Case $tab2 _Pressed($iTabButton2) EndSwitch EndSwitch WEnd Func _Pressed($iButton) ConsoleWrite("Hit" & @CRLF) MsgBox(0, "", "Button '" & GUICtrlRead($iButton) & "' pressed") EndFunc *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
tlman12 Posted November 9, 2009 Author Posted November 9, 2009 I would do this: expandcollapse popup#include <GUIConstantsEx.au3> #include <ButtonConstants.au3> $hGUI = GUICreate("Test", 500, 500) $_DEFPUSHBUTTON = GUICtrlCreateButton("", -100, -100, 1,1, $BS_DEFPUSHBUTTON) $tab = GUICtrlCreateTab(10, 10, 200, 100) $tabhandle = GUICtrlGetHandle($tab) $tab0 = GUICtrlCreateTabItem("tab 0") $iTabButton0 = GUICtrlCreateButton("Button 0", 20, 50, 50, 20) $hInput_0 = GUICtrlCreateInput("", 20, 80, 150, 20) GUICtrlCreateButton("Dummy", 100, 50, 50, 20) $tab1 = GUICtrlCreateTabItem("tab 1") $iTabButton1 = GUICtrlCreateButton("Button 1", 20, 50, 50, 20) $hInput_1 = GUICtrlCreateInput("", 50, 80, 150, 20) GUICtrlCreateButton("Dummy", 100, 50, 50, 20) $tab2 = GUICtrlCreateTabItem("tab 2") $iTabButton2 = GUICtrlCreateButton("Button 2", 20, 50, 50, 20) $hInput_2 = GUICtrlCreateInput("", 20, 80, 150, 20) GUICtrlCreateButton("Dummy", 100, 50, 50, 20) GUISetState() $iCurrIndex = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $iTabButton0, $iTabButton1, $iTabButton2 _Pressed($nMsg) Case $_DEFPUSHBUTTON Switch GUICtrlRead($tab, 1) Case $tab0 _Pressed($iTabButton0) Case $tab1 _Pressed($iTabButton1) Case $tab2 _Pressed($iTabButton2) EndSwitch EndSwitch WEnd Func _Pressed($iButton) ConsoleWrite("Hit" & @CRLF) MsgBox(0, "", "Button '" & GUICtrlRead($iButton) & "' pressed") EndFunc that worked perfectly thank you
tlman12 Posted November 9, 2009 Author Posted November 9, 2009 Alright that was working perfectly but then i tried to set the colors and it's causing the issue i'm useing this to set the colors of the whole gui GUICtrlSetDefColor($fcolor) GUISetBkColor($mcolor) GUICtrlSetDefBkColor($mcolor) expandcollapse popup#include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <GUITab.au3> $fcolor = 0xffffff $color = 0x000000 $hGUI = GUICreate("Test", 500, 500) GUICtrlSetDefColor($fcolor) GUISetBkColor($color) GUICtrlSetDefBkColor($color) $_DEFPUSHBUTTON = GUICtrlCreateButton("", -100, -100, 1,1, $BS_DEFPUSHBUTTON) $tab = GUICtrlCreateTab(10, 10, 200, 100) _GUICtrlTab_SetBkColor($hGUI, $tab, $color) $tabhandle = GUICtrlGetHandle($tab) $tab0 = GUICtrlCreateTabItem("tab 0") $iTabButton0 = GUICtrlCreateButton("Button 0", 20, 50, 50, 20) $hInput_0 = GUICtrlCreateInput("", 20, 80, 150, 20) $bdummy1 = GUICtrlCreateButton("Dummy1", 100, 50, 50, 20) $tab1 = GUICtrlCreateTabItem("tab 1") $iTabButton1 = GUICtrlCreateButton("Button 1", 20, 50, 50, 20) $hInput_1 = GUICtrlCreateInput("", 50, 80, 150, 20) $bdummy2 = GUICtrlCreateButton("Dummy2", 100, 50, 50, 20) $tab2 = GUICtrlCreateTabItem("tab 2") $iTabButton2 = GUICtrlCreateButton("Button 2", 20, 50, 50, 20) $hInput_2 = GUICtrlCreateInput("", 20, 80, 150, 20) $bdummy3 = GUICtrlCreateButton("Dummy3", 100, 50, 50, 20) GUISetState() $iCurrIndex = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $iTabButton0, $iTabButton1, $iTabButton2 _Pressed($nMsg) Case $_DEFPUSHBUTTON Switch GUICtrlRead($tab, 1) Case $tab0 _Pressed($iTabButton0) Case $tab1 _Pressed($iTabButton1) Case $tab2 _Pressed($iTabButton2) EndSwitch Case $bdummy1 _Dummy($bdummy1) Case $bdummy2 _Dummy($bdummy1) Case $bdummy3 _Dummy($bdummy1) EndSwitch WEnd Func _Pressed($iButton) ConsoleWrite("Hit" & @CRLF) MsgBox(0, "", "Button '" & GUICtrlRead($iButton) & "' pressed") EndFunc Func _Dummy($ibutton) ConsoleWrite("Dummy" & @CRLF) MsgBox(0, "", "Dummy Button '" & GUICtrlRead($iButton) & "' pressed") EndFunc Func _GUICtrlTab_SetBkColor($hWnd, $hSysTab32, $sBkColor) Local $aTabPos = ControlGetPos($hWnd, "", $hSysTab32) Local $aTab_Rect = _GUICtrlTab_GetItemRect($hSysTab32, -1) GUICtrlCreateLabel("", $aTabPos[0], $aTabPos[1]+$aTab_Rect[3]+4, $aTabPos[2], $aTabPos[3]-$aTab_Rect[3] -4) GUICtrlSetBkColor(-1, $sBkColor) GUICtrlSetState(-1, $GUI_DISABLE) EndFunc if you click on one of the dummy buttons it'll always be that button when you hit enter unless you click another button or switch tabs i know i'm probably makeing this more complicated then it should be but thank you all for your help
picea892 Posted November 9, 2009 Posted November 9, 2009 Give focus back to the default button and you will be fine. expandcollapse popup#include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <GUITab.au3> $fcolor = 0xffffff $color = 0x000000 $hGUI = GUICreate("Test", 500, 500) GUICtrlSetDefColor($fcolor) GUISetBkColor($color) GUICtrlSetDefBkColor($color) $_DEFPUSHBUTTON = GUICtrlCreateButton("", -100, -100, 1,1, $BS_DEFPUSHBUTTON) $tab = GUICtrlCreateTab(10, 10, 200, 100) _GUICtrlTab_SetBkColor($hGUI, $tab, $color) $tabhandle = GUICtrlGetHandle($tab) $tab0 = GUICtrlCreateTabItem("tab 0") $iTabButton0 = GUICtrlCreateButton("Button 0", 20, 50, 50, 20) $hInput_0 = GUICtrlCreateInput("", 20, 80, 150, 20) $bdummy1 = GUICtrlCreateButton("Dummy1", 100, 50, 50, 20) $tab1 = GUICtrlCreateTabItem("tab 1") $iTabButton1 = GUICtrlCreateButton("Button 1", 20, 50, 50, 20) $hInput_1 = GUICtrlCreateInput("", 50, 80, 150, 20) $bdummy2 = GUICtrlCreateButton("Dummy2", 100, 50, 50, 20) $tab2 = GUICtrlCreateTabItem("tab 2") $iTabButton2 = GUICtrlCreateButton("Button 2", 20, 50, 50, 20) $hInput_2 = GUICtrlCreateInput("", 20, 80, 150, 20) $bdummy3 = GUICtrlCreateButton("Dummy3", 100, 50, 50, 20) GUISetState() $iCurrIndex = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $iTabButton0, $iTabButton1, $iTabButton2 _Pressed($nMsg) Case $_DEFPUSHBUTTON Switch GUICtrlRead($tab, 1) Case $tab0 _Pressed($iTabButton0) Case $tab1 _Pressed($iTabButton1) Case $tab2 _Pressed($iTabButton2) EndSwitch Case $bdummy1 _Dummy($bdummy1) GUICtrlSetState($_DEFPUSHBUTTON,$GUI_FOCUS) Case $bdummy2 _Dummy($bdummy1) GUICtrlSetState($_DEFPUSHBUTTON,$GUI_FOCUS) Case $bdummy3 _Dummy($bdummy1) GUICtrlSetState($_DEFPUSHBUTTON,$GUI_FOCUS) EndSwitch WEnd Func _Pressed($iButton) ConsoleWrite("Hit" & @CRLF) MsgBox(0, "", "Button '" & GUICtrlRead($iButton) & "' pressed") EndFunc Func _Dummy($ibutton) ConsoleWrite("Dummy" & @CRLF) MsgBox(0, "", "Dummy Button '" & GUICtrlRead($iButton) & "' pressed") EndFunc Func _GUICtrlTab_SetBkColor($hWnd, $hSysTab32, $sBkColor) Local $aTabPos = ControlGetPos($hWnd, "", $hSysTab32) Local $aTab_Rect = _GUICtrlTab_GetItemRect($hSysTab32, -1) GUICtrlCreateLabel("", $aTabPos[0], $aTabPos[1]+$aTab_Rect[3]+4, $aTabPos[2], $aTabPos[3]-$aTab_Rect[3] -4) GUICtrlSetBkColor(-1, $sBkColor) GUICtrlSetState(-1, $GUI_DISABLE) EndFunc
tlman12 Posted November 9, 2009 Author Posted November 9, 2009 (edited) Give focus back to the default button and you will be fine. expandcollapse popup#include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <GUITab.au3> $fcolor = 0xffffff $color = 0x000000 $hGUI = GUICreate("Test", 500, 500) GUICtrlSetDefColor($fcolor) GUISetBkColor($color) GUICtrlSetDefBkColor($color) $_DEFPUSHBUTTON = GUICtrlCreateButton("", -100, -100, 1,1, $BS_DEFPUSHBUTTON) $tab = GUICtrlCreateTab(10, 10, 200, 100) _GUICtrlTab_SetBkColor($hGUI, $tab, $color) $tabhandle = GUICtrlGetHandle($tab) $tab0 = GUICtrlCreateTabItem("tab 0") $iTabButton0 = GUICtrlCreateButton("Button 0", 20, 50, 50, 20) $hInput_0 = GUICtrlCreateInput("", 20, 80, 150, 20) $bdummy1 = GUICtrlCreateButton("Dummy1", 100, 50, 50, 20) $tab1 = GUICtrlCreateTabItem("tab 1") $iTabButton1 = GUICtrlCreateButton("Button 1", 20, 50, 50, 20) $hInput_1 = GUICtrlCreateInput("", 50, 80, 150, 20) $bdummy2 = GUICtrlCreateButton("Dummy2", 100, 50, 50, 20) $tab2 = GUICtrlCreateTabItem("tab 2") $iTabButton2 = GUICtrlCreateButton("Button 2", 20, 50, 50, 20) $hInput_2 = GUICtrlCreateInput("", 20, 80, 150, 20) $bdummy3 = GUICtrlCreateButton("Dummy3", 100, 50, 50, 20) GUISetState() $iCurrIndex = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $iTabButton0, $iTabButton1, $iTabButton2 _Pressed($nMsg) Case $_DEFPUSHBUTTON Switch GUICtrlRead($tab, 1) Case $tab0 _Pressed($iTabButton0) Case $tab1 _Pressed($iTabButton1) Case $tab2 _Pressed($iTabButton2) EndSwitch Case $bdummy1 _Dummy($bdummy1) GUICtrlSetState($_DEFPUSHBUTTON,$GUI_FOCUS) Case $bdummy2 _Dummy($bdummy1) GUICtrlSetState($_DEFPUSHBUTTON,$GUI_FOCUS) Case $bdummy3 _Dummy($bdummy1) GUICtrlSetState($_DEFPUSHBUTTON,$GUI_FOCUS) EndSwitch WEnd Func _Pressed($iButton) ConsoleWrite("Hit" & @CRLF) MsgBox(0, "", "Button '" & GUICtrlRead($iButton) & "' pressed") EndFunc Func _Dummy($ibutton) ConsoleWrite("Dummy" & @CRLF) MsgBox(0, "", "Dummy Button '" & GUICtrlRead($iButton) & "' pressed") EndFunc Func _GUICtrlTab_SetBkColor($hWnd, $hSysTab32, $sBkColor) Local $aTabPos = ControlGetPos($hWnd, "", $hSysTab32) Local $aTab_Rect = _GUICtrlTab_GetItemRect($hSysTab32, -1) GUICtrlCreateLabel("", $aTabPos[0], $aTabPos[1]+$aTab_Rect[3]+4, $aTabPos[2], $aTabPos[3]-$aTab_Rect[3] -4) GUICtrlSetBkColor(-1, $sBkColor) GUICtrlSetState(-1, $GUI_DISABLE) EndFunc the only problem with that is that my gui currently has about 70 buttons would i have to add that to every button? Edit: alright i tried it on a few of the buttons and although it worked in the small script for some reason it's not working in my larger one unfortuanatly because of it's content i cant release the source it's composed of about 6 personaly written includes most the buttons run fuctions from these includes but its all pretty simple stuff Edited November 9, 2009 by tlman12
Moderators Melba23 Posted November 9, 2009 Moderators Posted November 9, 2009 timan12,There is known bug in Autoit which means that coloured buttons wiil always trap the 'Enter' key regardless of the DEFPUSHBUTTON setting. So I am afraid it is normal buttons or picea892's idea. 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
tlman12 Posted November 9, 2009 Author Posted November 9, 2009 timan12,There is known bug in Autoit which means that coloured buttons wiil always trap the 'Enter' key regardless of the DEFPUSHBUTTON setting. So I am afraid it is normal buttons or picea892's idea. M23dam lol.. the same reason i couldn't color my tabs lolyou think this'll ever be fixed?
Moderators Melba23 Posted November 9, 2009 Moderators Posted November 9, 2009 timan12,According to this, never.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
tlman12 Posted November 10, 2009 Author Posted November 10, 2009 timan12, According to this, never. M23 i think i may have figured out a possible solution (atleas it works for me) If WinActive("Test") Then If _IsPressed("0D") Then Sleep(250) $nMsg = GUIGetMsg() If $nMsg = $_DEFPUSHBUTTON Then $p = 1 Else $nMsg = $_DEFPUSHBUTTON $p = 1 EndIf Else $nMsg = GUIGetMsg() $p = 1 EndIf EndIf it's got a couple of kinks, it runs whatever the default function is twice the first time you push enter, on smaller gui's if you hit enter on a mesage box it returns back to the top of the loop faster then you can take your finger off the enter so it keeps looping but this isn't an issue for me cause my main loop is pretty large i put $p = # to control when it gets to go into the loop but it's not a surefire thing Full Example expandcollapse popupDim $fcolor = 0xffffff Dim $color = 0x000000 Dim $p = 1 $hGUI = GUICreate("Test", 500, 500) GUICtrlSetDefColor($fcolor) GUISetBkColor($color) GUICtrlSetDefBkColor($color) $_DEFPUSHBUTTON = GUICtrlCreateButton("", -100, -100, 1, 1, $BS_DEFPUSHBUTTON) $tab = GUICtrlCreateTab(10, 10, 200, 100) _GUICtrlTab_SetBkColor($hGUI, $tab, $color) $tabhandle = GUICtrlGetHandle($tab) $tab0 = GUICtrlCreateTabItem("tab 0") $iTabButton0 = GUICtrlCreateButton("Button 0", 20, 50, 50, 20) $hInput_0 = GUICtrlCreateInput("", 20, 80, 150, 20) $bdummy1 = GUICtrlCreateButton("Dummy1", 100, 50, 50, 20) $tab1 = GUICtrlCreateTabItem("tab 1") $iTabButton1 = GUICtrlCreateButton("Button 1", 20, 50, 50, 20) $hInput_1 = GUICtrlCreateInput("", 50, 80, 150, 20) $bdummy2 = GUICtrlCreateButton("Dummy2", 100, 50, 50, 20) $tab2 = GUICtrlCreateTabItem("tab 2") $iTabButton2 = GUICtrlCreateButton("Button 2", 20, 50, 50, 20) $hInput_2 = GUICtrlCreateInput("", 20, 80, 150, 20) $bdummy3 = GUICtrlCreateButton("Dummy3", 100, 50, 50, 20) GUISetState() $iCurrIndex = 0 While 1 If WinActive("Test") Then If _IsPressed("0D") Then Sleep(250) $nMsg = GUIGetMsg() If $nMsg = $_DEFPUSHBUTTON Then $p = 1 Else $nMsg = $_DEFPUSHBUTTON $p = 1 EndIf Else $nMsg = GUIGetMsg() $p = 1 EndIf EndIf If $p = 1 Then Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $iTabButton0, $iTabButton1, $iTabButton2 _Pressed($nMsg) Case $_DEFPUSHBUTTON Switch GUICtrlRead($tab, 1) Case $tab0 _Pressed($iTabButton0) Case $tab1 _Pressed($iTabButton1) Case $tab2 _Pressed($iTabButton2) EndSwitch Case $bdummy1 _Dummy($bdummy1) Case $bdummy2 _Dummy($bdummy1) Case $bdummy3 _Dummy($bdummy1) EndSwitch $p = 0 EndIf WEnd Func _Pressed($iButton) ConsoleWrite("Hit" & @CRLF) MsgBox(0, "", "Button '" & GUICtrlRead($iButton) & "' pressed") EndFunc ;==>_Pressed Func _Dummy($iButton) ConsoleWrite("Dummy" & @CRLF) MsgBox(0, "", "Dummy Button '" & GUICtrlRead($iButton) & "' pressed") EndFunc ;==>_Dummy Func _GUICtrlTab_SetBkColor($hWnd, $hSysTab32, $sBkColor) Local $aTabPos = ControlGetPos($hWnd, "", $hSysTab32) Local $aTab_Rect = _GUICtrlTab_GetItemRect($hSysTab32, -1) GUICtrlCreateLabel("", $aTabPos[0], $aTabPos[1] + $aTab_Rect[3] + 4, $aTabPos[2], $aTabPos[3] - $aTab_Rect[3] - 4) GUICtrlSetBkColor(-1, $sBkColor) GUICtrlSetState(-1, $GUI_DISABLE) EndFunc ;==>_GUICtrlTab_SetBkColor idk if this will help anyone else but it worked for me so i thought i'd post it
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