Makaule Posted April 17, 2010 Share Posted April 17, 2010 (edited) I want to create GUI table which may be resized, add additional buttoms, while keeping the rest not moved. I have made almost everything what i want, i just stuck on detecting which buttom was pressed. At the moment i am just lacking some imagination to solve it, so i am open for suggestions. Here is my code: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) Global $PriesagaInput[1] Global $Buttom[1] Global $n = 0 $MAIN = GUICreate("Test Form", 300, 300, 190, 115) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $Label1 = GUICtrlCreateLabel("Label1", 16, 18, 49, 17) GUICtrlSetResizing(-1, BitOr($GUI_DOCKTOP, $GUI_DOCKSIZE)) $Label2 = GUICtrlCreateLabel("Label2", 16, 52, 40, 17) GUICtrlSetResizing(-1, BitOr($GUI_DOCKTOP, $GUI_DOCKSIZE)) $Buttom[0] = GUICtrlCreateButton("Buttom", 205, 15, 70, 25) GUICtrlSetResizing(-1, BitOr($GUI_DOCKTOP, $GUI_DOCKSIZE)) GUICtrlSetOnEvent($Buttom[0], "_Check") $AddMore = GUICtrlCreateButton("More>>>", 205, 268, 70, 25) GUICtrlSetResizing(-1, BitOr($GUI_DOCKBOTTOM, $GUI_DOCKSIZE)) GUICtrlSetOnEvent($AddMore, "_AddMoreButtom") While 1 GUISetState(@SW_SHOW) WEnd Func _Exit() Exit EndFunc Func _Check() ConsoleWrite(@CRLF & UBound($Buttom) & "...." & $n) EndFunc Func _AddMoreButtom() $WinPos = WinGetPos($MAIN) If UBound($Buttom) = 2 Then GuiCtrlSetState($AddMore, $GUI_DISABLE) ReDim $Buttom[UBound($Buttom) + 1] $Buttom[UBound($Buttom) - 1] = GUICtrlCreateButton("Buttom" & _ (UBound($Buttom) - 1), 205, 15 + _ (UBound($Buttom) - 1) * 30, 70, 25) GUICtrlSetResizing(-1, BitOr($GUI_DOCKTOP, $GUI_DOCKSIZE)) GUICtrlSetOnEvent($Buttom[UBound($Buttom) - 1], "_Check") WinMove($MAIN, "", Default, Default, Default, $WinPos[3] + 30) EndFunc Edited April 17, 2010 by Makaule Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 17, 2010 Moderators Share Posted April 17, 2010 Makaule,Use the @GUI_CTRLID macro. As it says in teh Help file, it returns the control ID of the control sending the message OR the system event ID: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) Global $PriesagaInput[1] Global $Button[1] Global $n = 0 $MAIN = GUICreate("Test Form", 300, 300, 190, 115) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $Label1 = GUICtrlCreateLabel("Label1", 16, 18, 49, 17) GUICtrlSetResizing(-1, BitOR($GUI_DOCKTOP, $GUI_DOCKSIZE)) $Label2 = GUICtrlCreateLabel("Label2", 16, 52, 40, 17) GUICtrlSetResizing(-1, BitOR($GUI_DOCKTOP, $GUI_DOCKSIZE)) $Button[0] = GUICtrlCreateButton("Button0", 205, 15, 70, 25) GUICtrlSetResizing(-1, BitOR($GUI_DOCKTOP, $GUI_DOCKSIZE)) GUICtrlSetOnEvent($Button[0], "_Check") $AddMore = GUICtrlCreateButton("More>>>", 205, 268, 70, 25) GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKSIZE)) GUICtrlSetOnEvent($AddMore, "_AddMoreButton") While 1 GUISetState(@SW_SHOW) WEnd Func _Exit() Exit EndFunc ;==>_Exit Func _Check() For $i = 0 To UBound($Button) - 1 If $Button[$i] = @GUI_CtrlId Then ConsoleWrite("You pressed Button " & $i & @CRLF) Next EndFunc ;==>_Check Func _AddMoreButton() $WinPos = WinGetPos($MAIN) If UBound($Button) = 2 Then GUICtrlSetState($AddMore, $GUI_DISABLE) ReDim $Button[UBound($Button) + 1] $Button[UBound($Button) - 1] = GUICtrlCreateButton("Button" & _ (UBound($Button) - 1), 205, 15 + _ (UBound($Button) - 1) * 30, 70, 25) GUICtrlSetResizing(-1, BitOR($GUI_DOCKTOP, $GUI_DOCKSIZE)) GUICtrlSetOnEvent($Button[UBound($Button) - 1], "_Check") WinMove($MAIN, "", Default, Default, Default, $WinPos[3] + 30) EndFunc ;==>_AddMoreButtonM23 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...
Makaule Posted April 17, 2010 Author Share Posted April 17, 2010 Thanks Melba, You are my Hero, i were suspecting to get answer from you when i were creating topic here 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