Ashalshaikh Posted October 14, 2010 Share Posted October 14, 2010 (edited) Hi I just wrote small function which can helps you to make small box easly._ChooseBoxShow box with choices and buttonPictures :-Function with two examples : -expandcollapse popup#include <GuiTreeView.au3> #include <GuiImageList.au3> ;--- Examples ------------------------- Global $ChooseList[4][3] $ChooseList[0][0] = 'Choose 1' $ChooseList[0][1] = 'shell32.dll' $ChooseList[0][2] = '5' $ChooseList[1][0] = 'Choose 2' $ChooseList[1][1] = 'shell32.dll' $ChooseList[1][2] = '8' $ChooseList[2][0] = 'Choose 3' $ChooseList[2][1] = 'shell32.dll' $ChooseList[2][2] = '200' $ChooseList[3][0] = 'Choose 4' $ChooseList[3][1] = 'shell32.dll' $ChooseList[3][2] = '150' $result = _ChooseBox($ChooseList) If @error Then MsgBox(16, '', 'You Click X Button') Else MsgBox(64, '', 'Selected : ' & $result & @CRLF & _ ' Array Index = ' & @extended) EndIf $result = _ChooseBox($ChooseList, 'Example', 300, 100, 50, 150) If @error Then MsgBox(16, '', 'You Click X Button') Else MsgBox(64, '', 'Selected : ' & $result & @CRLF & _ ' Array Index = ' & @extended) EndIf ;--- End - Examples --------------------- ;-------------- _ChoosBox ---------------------- ; Name...........: _ChooseBox ; Description ...: Show box with choices and button ; Tested On .....: AutoIt Version : 3.3.6.1 ; Syntax.........: _ChooseBox($ChooseList[, $Title = 'ChooseBox'[, $Width = 100[, $Height = 200[, $Left = -1[, $Top = -1[, $Parent = '']]]]]]) ; Parameters ....: $ChooseList - The array of choices and icons ; The array must be two dimensions .Like This: ; $Array[X][0] = Choice Text ; $Array[X][1] = Choice Icon File ; $Array[X][2] = Choice Icon Index ; X = Number of choice ; $Title - Title of ChooseBox GUI [Default = ChooseBox] ; $Width - Width of ChooseBox GUI [Default = 100] ; $Height - Height of ChooseBox GUI [Default = 200] ; $Left - Left postion of ChooseBox GUI [Default = -1] ; $Top - Top postion of ChooseBox GUI [Default = -1] ; $Parent - Parent of ChooseBox GUI [Default = ''] ; Return values .: Success - The Choosen Text ; @Extended = Index of choosen choice at the array ; Failure - 0 ; Remarks .......: If User click X button (Close) , @Error will be 1 ; Author ........: Ahmad Alshaikh (Ashalshaikh) ; Link ..........: http://www.autoitscript.com/forum/index.php?showtopic=120920 ; ====================================================================================================== Func _ChooseBox($ChooseList, $Title = 'ChooseBox', $Width = 100, $Height = 200, $Left = -1, $Top = -1, $Parent = '') Local $GUI = GUICreate($Title, $Width, $Height, $Left, $Top, Default, Default, $Parent) Local $ChooseBtn = GUICtrlCreateButton('Choose', 5, $Height - 40 + 10, $Width - 10, 25) Local $TreeView = _GUICtrlTreeView_Create($GUI, 5, 5, $Width - 10, $Height - 40) Local $IList = _GUIImageList_Create(16, 16, 5), $ILtmp _GUICtrlTreeView_SetNormalImageList($TreeView, $IList) GUISetState() For $i = 0 To UBound($ChooseList) - 1 $ILtmp = _GUIImageList_AddIcon($IList, $ChooseList[$i][1], $ChooseList[$i][2]) _GUICtrlTreeView_Add($TreeView, 0, $ChooseList[$i][0], $ILtmp, $ILtmp) Next _GUICtrlTreeView_SelectItem($TreeView, _GUICtrlTreeView_GetFirstItem($TreeView), 0) While 1 Switch GUIGetMsg() Case -3 _GUIImageList_Destroy($IList) GUIDelete($GUI) Return SetError(1, 0, 0) ExitLoop Case $ChooseBtn Local $tmp = _GUICtrlTreeView_GetText($TreeView, _GUICtrlTreeView_GetSelection($TreeView)) For $t = 0 To UBound($ChooseList) - 1 If $tmp = $ChooseList[$t][0] Then _GUIImageList_Destroy($IList) GUIDelete($GUI) Return SetExtended($t, $tmp) ExitLoop EndIf Next EndSwitch WEnd EndFunc ;==>_ChooseBoxNote : It needs include (GuiTreeView.au3 | GuiImageList.au3) to work.I hope to be useful to someone. Edited October 14, 2010 by Ashalshaikh Link to comment Share on other sites More sharing options...
Zibit Posted October 15, 2010 Share Posted October 15, 2010 looks good. Creator Of Xtreme DevelopersPixel Pattern UDFTray GUI UDFMathssend & recive register scriptMouse Control via Webcam 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