Search the Community
Showing results for tags 'combobox'.
-
Not trying to re-invent the wheel here, but I found some examples that did A-L-O-T that I didn't think was necessary (like forcing owner-drawn), the sparse number of the web examples were failing miserably too. It looked like @argumentum was taking the path I was on, his is much more feature rich ( 😅 ) ... Anyway, I was going to add a font option using this subclass method (Thanks to @LarsJ for his subclass method, saved me some time) but I am out of time and if I don't post this now, I will probably forget to post it later (Yep, age is getting there). @LarsJ - GUIRegisterMsg20 - @argumentum ComboBox Set DROPDOWNLIST Colors/size UDF (Lots-O-Stuff) Here's my short and sweet (I don't think I ever code anything short.. or sweet) Edit 2024-04-10: Added the font change functions, pay attention to the fact that there are 3 different hwnds, the control hwnd, the edit hwnd as well as the listbox hwnd for the combo box. There are 4 functions, one changes all 3, the others change each of the other hwnds. Edit-2 2024-04-10: So I was going to use the forum members meticulous eyes to find issues, but I seemed to find a few that I didn't notice before myself. - Wrong array bounds in font au3 was fixed - Multi color (LB and Edit different colors) fixed (mistakenly used 1 brush ... oops) for color au3 - Missing edit color logic fixed for color au3 GUIComboBox.2024.04.10-002.zip
- 3 replies
-
- combobox
- combobox color
-
(and 3 more)
Tagged with:
-
Hello all, I am aware that most of you may have seen similar questions being asked a lot. I've spent some days know to go through many of the propesed answers but so far none of those answers were able to help me to resolve the issue, i.e. interacting with a standard ComboBox of a third party software. I am doing this on Windows 11 (22H2) using AutoIt v3.3.16.1. What I am trying to do is to select a language from a ComboBox when running an InstallShield setup launcher (setup.exe). The only thing I managed so far is to read out the currently selected value that is being displayed: Local Const $sWndTitle = "InstallShield Wizard" Local Const $sCtrlClass = "[CLASS:ComboBox; INSTANCE:1]" WinActivate($sWndTitle) Local $hWnd = WinWaitActive($sWndTitle, "", 5) Local $sCurrentLang = ControlGetText($hWnd, "", $sCtrlClass) ConsoleWrite("$sCurrentLang: " & $sCurrentLang & @CRLF) ; OK Considering this dialog this gives me "$sCurrentLang: Deutsch" on the console. So far, so good. Now the issue is that I can't figure out how to select a different value from that ComboBox. I've tried all kinds of things ranging from all sorts of Control Name variations to different methods I found here in this forum, on StackOverflow, the web, like: ControlSetText($hWnd, "", "[CLASS:ComboBox; INSTANCE:1]", "Englisch", 1) ControlSend($hWnd, "", "[CLASS:ComboBox; INSTANCE:1]", "E") ControlSend($hWnd, "", "[CLASS:ComboBox; INSTANCE:1]", "Englisch") ControlCommand($hWnd, "" , "[CLASS:ComboBox; INSTANCE:1]" , "SelectString" , "Englisch") ControlSend($hWnd, "", $hCtrl, "Englisch") _GUICtrlComboBox_SetCurSel(306, 1) ;ID from AutoIt Info Tool _GUICtrlComboBox_SetCurSel("ComboBox1", 1) ;... The AutoIt Info Tool gives the following information about the ComboBox: >>>> Window <<<< Title: ABC - InstallShield Wizard Class: #32770 Position: 1088, 617 Size: 384, 157 Style: 0x94C808C4 ExStyle: 0x00010101 Handle: 0x00000000000D0910 >>>> Control <<<< Class: ComboBox Instance: 1 ClassnameNN: ComboBox1 Name: Advanced (Class): [CLASS:ComboBox; INSTANCE:1] ID: 306 Text: Position: 51, 65 Size: 317, 21 ControlClick Coords: 120, 19 Style: 0x50010343 ExStyle: 0x00000004 Handle: 0x00000000003F10EC I also tried other CombBox related functions, for example: ControlCommand("InstallShield", "", "ComboBox1","ShowDropDown", "") but nothing worked, except ControlGetText(). I would be very thankful if anybody could give me a hint on how to interact with this ComboBox. If anything is unclear or missing please do not hesitate to ask. Best regards, Tacomas Edit: This might be a Windows 11 issue, since I just found that I also can't click a button on this dialog. Either this or I completely misunderstood how to use AutoIt to interact with UI controls. WinActivate($sWndTitle) If ControlClick($sWndTitle, "", "[CLASS:Button; INSTANCE:2]") = 0 Then ConsoleError("ERROR: ControlClick() failed!" & @CRLF) ;no click, no error
-
I am making some GUI with combobox for the Baudrates communications and I listed 9600, 57600, 115200. I wrote the code to be defaulted to 57600 like this: GUICtrlSetData($comboBox_opticalBaudRate, "9600|57600|115200", "57600") But I wanted the GUI to remember the last item the user picks so the baudrates will NOT be defaulted to 57600. Example, I pick 9600 as my baudrates, then I close the GUI, after opening it, it always prompt 57600 since that is what I did in my code. But I want that if I choose 9600 and close the GUI, opening it again will show 9600 now instead of 57600. Is there a way to do it in GUI setting? Thanks.
-
Hello, i would like to know why isnt anything displayed on the combo box. i used this example and added it to my code Autoit Example : #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> Dim $sRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" GUICreate("Test", 400, 100) $cCombo_Font = GUICtrlCreateCombo("", 10, 10, 170, 20, 2097474);HELPHERE GUICtrlSetData($cCombo_Font, _RegEnumVal($sRegKey)) $cLabel = GUICtrlCreateLabel("Font preview", 230, 10, 155, 20) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $cCombo_Font GUICtrlSetFont($cLabel, 10, Default, Default, GUICtrlRead($cCombo_Font)) EndSwitch WEnd Func _RegEnumVal($sKey) Local $i = 1, $sVal, $sResult While 1 $sVal = RegEnumVal($sKey, $i) If @error Then ExitLoop $i += 1 $sResult &= $sVal & "|" WEnd Return StringRegExpReplace($sResult, " \(.*?\)", "") EndFunc ;==>_RegEnumVal And my code: #NoTrayIcon #include <Misc.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <File.au3> #include <GuiEdit.au3> #include <String.au3> #include <GuiRichEdit.au3> #include <GuiToolbar.au3> #include <GuiImageList.au3> $WIDTH = 500 $HEIGHT = 380 $EXT1 = "|Rich Text File (*.rtf)" $EXT2 = "|ODF Text (*.odt)" $EXT3 = "|All Files(*.*)" $EXT = $EXT1 & $EXT2 $SETTINGS = "Settings.ini" Dim $FONTKEY = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" Global $FILESAVE, $FILEOPEN = "", $SAVES, $SAVE, $FILEOPENED = 0 Global Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idHelp $MAINGUI = GUICreate("Text Editor", $WIDTH, $HEIGHT, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE) $TOOLBAR = _GUICtrlToolbar_Create($MAINGUI) _GUIImageList_AddIcon($TOOLBAR, @SystemDir & "\shell.dll", -1) $IMAGES = _GUIImageList_Create(24,24) _GUICtrlToolbar_SetImageList($TOOLBAR, $IMAGES) _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, -1);AndHereIfYouCouldTHX _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, -2) _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, 3) _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, 4) _GUICtrlToolbar_AddButtonSep($TOOLBAR) _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, 5) _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, 6) $EDITBOX = _GUICtrlRichEdit_Create($MAINGUI, "This is a test.", 10, 35, $WIDTH - 20, $HEIGHT - 70, _ BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) $FONTCOMBOBOX = GUICtrlCreateCombo("", $WIDTH - 170, 10, 160, 20, 2097474);HELPMEHERE GUICtrlSetData($FONTCOMBOBOX, _RegEnumVal($FONTKEY));ALSOHERE $FONTSIZECOMBOBOX = GUICtrlCreateCombo("", $WIDTH - 200, 10, 20, 20, 2097474);FuncForPreviousLineAtTheEnd $FILE = GUICtrlCreateMenu("File") $NEW = GUICtrlCreateMenuItem("New", $FILE) $OPEN = GUICtrlCreateMenuItem("Open...", $FILE) $SAVE = GUICtrlCreateMenuItem("Save", $FILE) $SAVEAS = GUICtrlCreateMenuItem("Save As...", $FILE) $PRINT = GUICtrlCreateMenuItem("Print...", $FILE) GUICtrlCreateMenuItem("", $FILE) $EXIT = GUICtrlCreateMenuItem("Exit", $FILE) $EDIT = GUICtrlCreateMenu("Edit") $UNDO = GUICtrlCreateMenuItem("Undo", $EDIT) $REDO = GUICtrlCreateMenuItem("Redo", $EDIT) $SEPARATOR = GUICtrlCreateMenuItem("", $EDIT) $FONT = GUICtrlCreateMenuItem("Font test", $EDIT) $SEPARATOR1 = GUICtrlCreateMenuItem("", $EDIT) $CUT = GUICtrlCreateMenuItem("Cut", $EDIT) $COPY = GUICtrlCreateMenuItem("Copy", $EDIT) $PASTE = GUICtrlCreateMenuItem("Paste", $EDIT) GUISetState(@SW_SHOW & $GUI_ACCEPTFILES) While 1 $Msg = GUIGetMsg() Select Case $Msg = $GUI_EVENT_CLOSE If _GUICtrlEdit_CanUndo($EDITBOX) Then $SAVECHANGES = MsgBox(35, "Text Editor", "Your original file has been modified." & @CRLF & "Would you like to save changes to it?") If $SAVECHANGES = 6 And $FILEOPENED = 0 Then SaveAs() _GUICtrlRichEdit_Destroy($hRichEdit) Exit EndIf If $SAVECHANGES = 6 And $FILEOPENED = 1 Then FileDelete($FILEOPEN) FileWrite($FILEOPEN, GUICtrlRead($EDITBOX)) Exit EndIf If $SAVECHANGES = 7 Then ExitLoop Exit EndIf EndIf If Not _GUICtrlEdit_CanUndo($EDITBOX) Then Exit Case $Msg = $OPEN $FILEOPEN = FileOpenDialog("Open", $FILEOPEN, $EXT) $TEXT = _GUICtrlRichEdit_StreamFromFile($EDITBOX, $FILEOPEN) _GUICtrlRichEdit_ReplaceText($EDITBOX, $TEXT) $FILEOPENED = 1 Case $Msg = $NEW If _GUICtrlEdit_CanUndo($EDITBOX) Then $SAVECHANGES = MsgBox(35, "Text Editor", "Your original file has been modified." & @CRLF & "Would you like to save changes to it?") If $SAVECHANGES = 6 And $FILEOPENED = 0 Then SaveAs() EndIf If $SAVECHANGES = 6 And $FILEOPENED = 1 Then FileDelete($FILEOPEN) FileWrite($FILEOPEN, GUICtrlRead($EDITBOX)) EndIf If $SAVECHANGES = 7 Then GUICtrlSetData($EDITBOX, "") If $SAVECHANGES = 2 Then Sleep(1) EndIf If Not _GUICtrlEdit_CanUndo($EDITBOX) Then GUICtrlSetData($EDITBOX, "") $FILEOPENED = 0 Case $Msg = $EXIT If _GUICtrlEdit_CanUndo($EDITBOX) Then $SAVECHANGES = MsgBox(35, "Text Editor", "Your original file has been modified." & @CRLF & "Would you like to save changes to it?") If $SAVECHANGES = 6 And $FILEOPENED = 0 Then SaveAs() _GUICtrlRichEdit_Destroy($hRichEdit) Exit EndIf If $SAVECHANGES = 6 And $FILEOPENED = 1 Then FileDelete($FILEOPEN) FileWrite($FILEOPEN, GUICtrlRead($EDITBOX)) Exit EndIf If $SAVECHANGES = 7 Then ExitLoop If $SAVECHANGES = 2 Then Sleep(1) EndIf EndIf If Not _GUICtrlEdit_CanUndo($EDITBOX) Then Exit Case $Msg = $SAVEAS GUICtrlSetState($EDITBOX, $GUI_DISABLE) SaveAs() $FILEOPENED = 1 GUICtrlSetState($EDITBOX, $GUI_ENABLE) Case $Msg = $SAVE And $FILEOPENED = 1 FileDelete($FILEOPEN) FileWrite($FILEOPEN, GUICtrlRead($EDITBOX)) _GUICtrlEdit_EmptyUndoBuffer($EDITBOX) Case $Msg = $SAVE And $FILEOPENED = 0 GUICtrlSetState($EDITBOX, $GUI_DISABLE) SaveAs() $FILEOPENED = 1 GUICtrlSetState($EDITBOX, $GUI_ENABLE) Case $Msg = $SAVE And $FILEOPENED = 0 GUICtrlSetState($EDITBOX, $GUI_DISABLE) SaveAs() $FILEOPENED = 1 GUICtrlSetState($EDITBOX, $GUI_ENABLE) Case $Msg = $PRINT $PRINTMSGBOX = MsgBox(35, "Text Editor", "Are you sure you want to print this page?") Select Case $PRINTMSGBOX = 6 If FileExists("Print.txt") Then FileDelete("Print.txt") EndIf FileWrite("Print.txt", GUICtrlRead($EDITBOX)) $PRINTFILE = "Print.txt" _FilePrint($PRINTFILE) FileDelete($PRINTFILE) EndSelect Case $Msg = $UNDO _GUICtrlRichEdit_Undo($EDITBOX) Case $Msg = $REDO _GUICtrlRichEdit_Redo($EDITBOX) Case _GUICtrlEdit_CanUndo($EDITBOX) And $SAVES = 1 GUICtrlSetState($SAVE, $GUI_ENABLE) Case $Msg = $CUT _GUICtrlRichEdit_Cut ($EDITBOX) Case $Msg = $COPY _GUICtrlRichEdit_Copy ($EDITBOX) Case $Msg = $PASTE _GUICtrlRichEdit_Paste ($EDITBOX) Case Not _GUICtrlEdit_CanUndo($EDITBOX) And $SAVES = 0 GUICtrlSetState($SAVE, $GUI_DISABLE) $SAVES = 1 Case $Msg = $FONT _GUICtrlRichEdit_SetFont($EDITBOX, $FONTSIZECOMBOBOX, "Times New Roman") Case $FONTCOMBOBOX _GUICtrlRichEdit_SetFont($EDITBOX, $FONTSIZECOMBOBOX, GUICtrlRead($FONTCOMBOBOX)) EndSelect WEnd Exit Func SaveAs() $FILESAVEAS = FileSaveDialog("Save As", "", "Text Document (*.txt)|All Files (*.*)") If Not @error Then $STRING = StringSplit($FILESAVEAS, ".") If $STRING[0] = 1 Then FileDelete($FILESAVEAS) _GUICtrlRichEdit_StreamToFile($EDITBOX, $FILESAVEAS &".rtf") Else _GUICtrlRichEdit_StreamToFile($EDITBOX, $FILESAVEAS &".rtf") EndIf EndIf EndFunc Func _RegEnumVal($sKey) Local $i = 1, $sVal, $sResult While 1 $sVal = RegEnumVal($sKey, $i) If @error Then ExitLoop $i += 1 $sResult &= $sVal & "|" WEnd Return StringRegExpReplace($sResult, " \(.*?\)", "") EndFunc ;==>_RegEnumVal So the problem is that The second combo box is blank Icons in taskbar are not appearing (don't really care for now, .dll file for icon in attachement) problem with $FONTCOMBOBOX = GUICtrlCreateCombo("", 10, 10, 200, 20, Bitor($CBS_SORT,$CBS_DROPDOWN,$CBS_AUTOHSCROLL,$WS_VSCROLL) (BitOR gave me a weird error) Thanks ! Autoit newbie ico.dll
-
As the title implies, trying to mimic Microsoft Word (Older version) using RichEdit. Not an easy task, it's not even 1/10th of what word really is but I wanted to make a small text editor (That supported changing an individual word/letters properties). Some of the functions I wanted to use didn't have a whole lot of information/topics about them so I spent many many hours trying to figure out how to do some things... (Like getting the text from a ExComboBox or changing the color of the rich edit text without changing ALL of the rich edit text (Turns out I just needed to update my AutoIt version....)) Some of the things I struggled with was reading the Font Size from the ComboBoxEx (GUICtrlRead and ControlGetText do not work, by themselves, but if you use _GUICtrlComboBoxEx_GetEditControl to get the GUICtrlID of the ComboBoxEx you can use ControlGetText), trying to track a Popup menu for the font size (I didn't want to use a dropdown menu, trying to use the scroll wheel to increment/decrement the text in the ComboBoxEx, making sure the correct attribute buttons are Checked depending on the location of the caret (This isn't 100% perfect, I got it to pretty much work though... I originally had it checking the letter 1 left of the caret all the time, except when the caret is at the 0,0 mark, but if the caret is at the very end and the user presses one of the attribute buttons, it won't keep the button checked correctly). There are a few other things but I can't think of them. I don't know enough about the WinAPI in order to make a truly amazing wordpad but maybe this will help some others out there trying to use some of the controls I used. Also, this was actually made to be attached (_WinAPI_SetParent($frmEditor, WinGetHandle("[Class:LWJGL]")) to a game I play (PokeMMO), so there may be some remnants of the game stuff in here. I don't think so, but there might be... It still functions properly. (There is no gameplay automation, it's just supposed to be a child of the game and work as a simple text editor. I've currently submitted it to one of mods of the game so I can release it to the community) Beginnings of a Wordpad.rar
-
Hi Forum, I am struggling to select an IP address from "Server Interface" dropdown (ComboBox2) of tftpd32 client. tftpd32 is a TFTP server - TFTPD32 : an opensource IPv6 ready TFTP server/service for windows : TFTP server (pagesperso-orange.fr) The IP addresses (and the associated interfaces) are dynamic in ComboBox2. What I want to do is to select an item from ComboBox2 which contains a given IP address (eg. 192.168.2.1) - (which is hidden in the picture as it is at the bottom of the list) and fill the edit field with the selection. (Note : the ComboBox items contain the IP address and the Interface name, therefore IP address is just a part of the item) I am not sure whether functions such as _GUICtrlComboBox_SelectString() are only to be used with Autoit generated ComboBoxes. Please help !!!! My code below, it does not select the ComboBox2 item with my IP address 192.168.2.1. Local $hWnd=ControlGetHandle("Tftpd32 by Ph. Jounin", "", 4008) Sleep(100) ControlFocus("Tftpd32 by Ph. Jounin", "", $hWnd) Sleep(100) Local $IP = "192.168.2.1" _GUICtrlComboBox_SelectString($HWnd, $IP) ComboBox2 ID = 4008
- 21 replies
-
Hi, i have a source code of "Danny35d" and i have 2 main question that are: How to extract this function's results (Datas are as Array) to combo-box without set number of datas? When i type 1, 2 in _SystemUsers($AccountType = 0) to get only Local or Domain users, it just give me both of them, it's old problem of this function, please share us debugged code :)❤ #include <Array.au3> $Users = _ArrayToString(_SystemUsers(), "|", 1) ConsoleWrite($Users & @CRLF) #cs =============================================================================== Function: _SystemUsers($AccountType = 0) Description: Return an array with the local or domain username Parameter(s): $AccountType: Local, domain or both username 0 = Local and Domain usernames 1 = Local usernames only 2 = Domain usernames only Returns: An array with the list of usernames - Succeeded @error 1 - Didn't query any username @error 2 - Failed to create Win32_SystemUsers object @error 3 - Invalid $AccountType Author(s): Danny35d #ce =============================================================================== Func _SystemUsers($AccountType = 0) Local $aSystemUsers Local $wbemFlagReturnImmediately = 0x10, $wbemFlagForwardOnly = 0x20 Local $colItems = "", $strComputer = "localhost" If Not StringRegExp($AccountType, '[012]') Then Return SetError(3, 3, '') $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_SystemUsers", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $Output = StringSplit($objItem.PartComponent, ',') If IsArray($Output) Then $Temp = StringReplace(StringTrimLeft($Output[2], StringInStr($Output[2], '=', 0, -1)), '"', '') If $AccountType = 0 Or ($AccountType = 1 And @ComputerName = $Temp) Then $aSystemUsers &= StringReplace(StringTrimLeft($Output[1], StringInStr($Output[1], '=', 0, -1)), '"', '') & '|' ElseIf $AccountType = 2 And @ComputerName <> $Temp Then $aSystemUsers &= StringReplace(StringTrimLeft($Output[1], StringInStr($Output[1], '=', 0, -1)), '"', '') & '|' EndIf EndIf Next $aSystemUsers = StringTrimRight($aSystemUsers, 1) If $aSystemUsers = '' Then Return(SetError(1, 1, $aSystemUsers)) Return(SetError(0, 0, StringSplit($aSystemUsers, '|'))) Else $aSystemUsers = '' Return(SetError(2, 2, $aSystemUsers)) EndIf EndFunc ;==>_SystemUsers Thanks to your best Team.
-
Hello Forum, I have one special Combo-box [with BitOR($CBS_DROPDOWNLIST, $GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE) ] and if I press one button I want to change the Combo-box's background color, and after I press Button B I want to change it to the basic settings and it not works. I wanna do this with one combo-box. I have already tried several methods and I tried GUICtrlComboSetColors that I have found on this forum. (But this methods works perfectly with Cobo boxes that don't have BitOR($CBS_DROPDOWNLIST, $GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE). Here is the example code #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= ;$CBS_DROPDOWNLIST ;$GUI_SS_DEFAULT_COMBO $Form1 = GUICreate("Form1", 504, 249, 252, 227) $Combo1 = GUICtrlCreateCombo("", 136, 24, 193, 25,BitOR($CBS_DROPDOWNLIST, $GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE)) ; I want to change this special combo's background color if I press button 1 $Button1 = GUICtrlCreateButton("Button1", 112, 96, 75, 25) $Button2 = GUICtrlCreateButton("Button2", 264, 96, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUICtrlSetData($Combo1," " & "|" & "apple" & "|" & "banana" & "|" & "cherry" ," ") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 GUICtrlSetBkColor($Combo1,0x0078D7) Case $Button2 ;Makes the original bc color GUICtrlSetBkColor($Combo1,0xFFFFFF) EndSwitch WEnd Thanks you in advance your help
-
Hi so i ran into a Problem i didn't expect to get stuck on. It sounds simple (and probably is) but i can't seem to get it to work So i created a Combobox and filled it with some things from an array which worked fine. $combobox = GUICtrlCreateCombo($list[0], 160, 200, 265, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GuiCtrlSetData($list, "|" & _ArrayToString($list,Default,1),$list[2]) GUICtrlSetFont(-1, 9, 400, 0, "Arial") Now i want to change the style of the combobox from $CBS_DROPDOWN to $CBS_DROPDOWNLIST via a checkbox. $Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 160, 96, 105, 25) Case $Checkbox1 If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then Call ("Read_only") Else Call ("Edit") Endif Func Read_only() GUICtrlSetStyle ($Combobox1,something to change it to $CBS_DROPDOWNLIST) EndFunc Func Edit() GUICtrlSetStyle ($Combobox1,something to change it to $CBS_DROPDOW) EndFunc I tried using $CBS_DROPDOWN and $CBS_DROPDOWNLIST but it simply does nothing. I also tried $ES_READONLY which kinda worked, it changed the combobox so i couldn't change the input via dropdown anymore but i could still type in it via keyboard (which i dont want). It's essential that its Editable but once the checkbox is checked the combobox becomes readonly so you can't type in it anymore but you can still choose between the items in the list. (It does not have to save your current input if you write something in it and then check the Checkbox it would be best if it would simpy jump back to the first item in the list) Im sure this is a simple thing but after long google search im tired of my stupidity can someone give me a push in the right direction?
-
Hello everyone , Text translated from Portuguese by google - please apologize for any errors Once again I need a light from the gurus of this wonderful website I am fanatic by combobox for its usability but I am not able to uncertain images within lists ... I know uncertain icons, and cursors but I am not able to insert gif or jpg images. 1) How to solve this ... 2) will the path is to convert gif into bmp and then uncertain ... how to do that? #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> ;dados de mouse #include <WinAPIRes.au3> ;COMBO #include <GuiComboBoxEx.au3> ;Fonts #include <FontConstants.au3> ;obter imagem de arquivo #include <GDIPlus.au3> #include <WinAPIGdi.au3> Example() Func Example() Local $hGUI, $hImage, $hCombo, $hFont Local $idListview, $hImage Local $sWow64 = "" Local $Pasta = "C:\WINDOWS\Cursors\3dgarro.cur" Local $PastaROMs = @MyDocumentsDir & "\Stella\ROMs\" ;com barra no final $hGUI = GUICreate("ImageList", 500, 310) GUISetFont(14, 400, 0, "Arial") ;<<<<<<<<<<this does not work for _GUICtrlComboBoxEx_Create $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 494, 200) ;GUICtrlSetFont($hCombo, 14, 400, 0, "Arial");<<<<<<<<<<It does not work ; ;Create a handle to a font object $hFont = _WinAPI_CreateFont(30, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial') ;Pass the handle to _WinAPI_SetFont _WinAPI_SetFont($hCombo, $hFont) $idListview = GUICtrlCreateListView("", 2, 50, 494, 250, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)) GUISetState(@SW_SHOW) ; Initialize GDI+ library _GDIPlus_Startup() ; Load images $hImage = _GUIImageList_Create(120, 70, 6, 2) ;32,32,5,5) ; $DadosCombo = "Escolha|" & _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 120, 70)) ;Local $aCursors[] = [32650, 32512, 32515, 32649, 32651, 32513, 32648, 32646, 32643, 32645, 32642, 32644, 32516, 32514] For $i = 1 To 10 $sFile = FileOpenDialog("Please select an image", $PastaROMs, "Image (*.jpg;*.png;*.bmp;*.gif;*.tif)", BitOR($FD_PATHMUSTEXIST, $FD_FILEMUSTEXIST)) If @error Then Exit MsgBox(BitOR($MB_TOPMOST, $MB_ICONERROR), "Error", "No image file has been selected", 30) $a = _GDIPlus_BitmapCreateFromFile ($sFile);<<<<< ok If @error Or Not $hImage Then MsgBox(BitOR($MB_TOPMOST, $MB_ICONERROR), "Error", "This file isn't supported by GDIPlus!") Else $b=_GUIImageList_Add($hImage, $a);<<<<<< Return -1 $DadosCombo &= "|" & $i & "_img_princ.gif""|" & $b EndIf Next _GUICtrlListView_SetImageList($idListview, $hImage, 1) _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage) ; Add columns _GUICtrlListView_AddColumn($idListview, "Icons - Mouses", 350) ; Add items $a = StringSplit($DadosCombo, "|") For $i = 1 To $a[0] Step 2 _GUICtrlListView_AddItem($idListview, $a[$i], $a[$i + 1]) _GUICtrlComboBoxEx_AddString($hCombo, $a[$i], $a[$i + 1], $a[$i + 1]) Next ;AutoIt_Debugger_Command:Disable_Debug ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() ;AutoIt_Debugger_Command:Enable_Debug EndFunc ;==>Example tks
-
I possibly misunderstood the value of combo boxes, but I thought you could type a value, press enter and the combo box would store that value. The reason for wanting this is to store a history of typed commands into the combo box (accepted by pressing enter). After hours of trying to trap enter on a combobox I realized that the enter event was not registering. I had code like this (which used to work on a input box), but it does not for a combobox (because it does not accept enter) unc WM_COMMAND($hWnd, $Msg, $wParam, $lParam) Local $nNotifyCode = BitShift($wParam, 16) Local $nID = BitAND($wParam, 0x0000FFFF) If $hWnd = $CmdForm Then If $nID = $ComboInput Then ; useed to work on a normal input box If _IsPressed('0D') Then ; enter was pressed, respond DoCmd() Anyone able to help?
-
Getting Combobox value after Manual change
Grasoft posted a topic in AutoIt General Help and Support
Greetings everyone, I'm writing a software that edit an ini file section by section with adding/renaming abilities but whenever I manually change the combobox to value other than constducted previously, I cannot get this value. THIS is a clean version of the code: #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiStatusBar.au3> #include <GuiEdit.au3> #include <MsgBoxConstants.au3> #Region ### START Koda GUI section ### Form=C:\Program Files (x86)\AutoIt3\SciTE\Koda\Forms\QuickRepEditList7.kxf $SecMgr = GUICreate("Sections Manager", 1159, 690) GUISetFont(12, 800, 0, "MS Sans Serif") $EditSec = GUICtrlCreateEdit("", 45, 45, 1090, 644, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN, $WS_HSCROLL, $ES_NOHIDESEL)) $Edit2 = GUICtrlCreateEdit("", 11, 45, 33, 617, BitOR($ES_RIGHT, $ES_READONLY, $ES_WANTRETURN)) GUICtrlSetData(-1, StringFormat(" 1:\r\n 2:\r\n 3:\r\n 4:\r\n 5:\r\n 6:\r\n 7:\r\n 8:\r\n 9:\r\n10:\r\n11:\r\n12:\r\n13:\r\n14:\r\n15:\r\n16:\r\n17:\r\n18:\r\n19:\r\n20:\r\n21:\r\n22:\r\n23:\r\n24:\r\n25:\r\n26:\r\n27:\r\n28:\r\n29:\r\n30:")) $Label1 = GUICtrlCreateLabel("Select Section:", 7, 13, 126, 24) GUICtrlSetFont(-1, 11, 800, 0, "MS Sans Serif") $Savesec = GUICtrlCreateButton("Save Changes", 375, 7, 129, 33) $NewSec = GUICtrlCreateButton("New Section", 700, 7, 121, 33) $SecDwn = GUICtrlCreateButton("Section Down", 830, 7, 137, 33) $SecUp = GUICtrlCreateButton("Section Up", 980, 7, 129, 33) $copystrs = GUICtrlCreateButton("*******", 507, 7, 73, 33) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $HeavySep = GUICtrlCreateButton("====", 581, 7, 73, 33) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") Global $SecSel Global $secno Global $secn = "NULLz" Global $sFilePathtemp Global $aArray Global $SecNames Global $secnnew Global $ssecn $SecSel = GUICtrlCreateCombo("", 110, 10, 257, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) queysecs() Filledit() GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $secno=GUICtrlRead($SecSel) $changed=0 While 1 $secn = GUICtrlRead($SecSel) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE saveeditedmsg() Exit Case $SecSel $secno=GUICtrlRead($SecSel) queysecs() Filledit() Case $Savesec saveeditedmsg() queysecs() Case $NewSec Case $SecDwn Case $SecUp Case $copystrs ClipPut("**************************************************************************************************************************************************************") Case $HeavySep ClipPut("==============================================================================================================================================================") EndSwitch WEnd Func queysecs();query section names $sFilePath = @ScriptDir & "\" & "Txt_Reps.ini" $aArray = IniReadSectionNames($sFilePath) $SecNames = $aArray[1] If $secn = "NULLz" Then $secn = $aArray[1] EndIf If Not @error Then For $i = 2 To $aArray[0] $SecNames = $SecNames & "|" & $aArray[$i] Next GUICtrlSetData($SecSel, "", "") GUICtrlSetData($SecSel, $SecNames, $secn) $secno = $secn EndIf EndFunc ;==>queysecs Func Filledit(); transfer section values on the edit box GUICtrlSetData($EditSec, "") $sFilePath = @ScriptDir & "\" & "Txt_Reps.ini" For $i = 1 To 30 $sRead = IniRead($sFilePath, $secn, $i, "") GUICtrlSetData($EditSec, $sRead & @CRLF, 1) Next GUISetState(@SW_SHOW) EndFunc ;==>Filledit Func saveeditedmsg(); save or rename modified section If $secn <> $secno Then $iMsgBoxAnswer = MsgBox(3, "NEW/RENAME", "Press YES to Add this as NEW section" & @CRLF & "Press NO to rename and save this section from " & $secno & "To" & $secn) Select Case $iMsgBoxAnswer = 6 ;YES $secn = $secno save($secn) $secn = GUICtrlRead($SecSel) $secno = $secn Case 7 ;NO $sFilePath = @ScriptDir & "\" & "Txt_Reps.ini" IniRenameSection($sFilePath, $secno, $secn) save($secn) $secn = GUICtrlRead($SecSel) $secno = $secn EndSelect Else $iMsgBoxAnswer = MsgBox(4, "Do you want to save changes to this section", "Save Section: " & $secn) Select Case $iMsgBoxAnswer = 6 ;yes save($secn) EndSelect EndIf EndFunc ;==>saveeditedmsg ;MsgBox(4, "Do you want to add this to Database?",$secn) Func save($ssecn); save edit control to a file and then rewrite modified values by line order. $sFilePathtemp = FileOpen(@ScriptDir & "\" & "tempo.quickrep", $FO_READ + $FO_OVERWRITE + $FO_CREATEPATH + $FO_UTF8) $sFilePath = @ScriptDir & "\" & "Txt_Reps.ini" FileWrite($sFilePathtemp, GUICtrlRead($EditSec)) $sFilePathtemp = FileOpen(@ScriptDir & "\" & "tempo.quickrep", $FO_READ + $FO_UTF8) For $i = 1 To 30 $sRead = FileReadLine($sFilePathtemp, $i) IniWrite($sFilePath, $ssecn, $i, $sRead) Next GUISetState(@SW_SHOW) EndFunc ;==>save And this is with som test msg boxes to know how to get it #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiStatusBar.au3> #include <GuiEdit.au3> #include <MsgBoxConstants.au3> #Region ### START Koda GUI section ### Form=C:\Program Files (x86)\AutoIt3\SciTE\Koda\Forms\QuickRepEditList7.kxf $SecMgr = GUICreate("Sections Manager", 1159, 690) GUISetFont(12, 800, 0, "MS Sans Serif") $EditSec = GUICtrlCreateEdit("", 45, 45, 1090, 644, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN, $WS_HSCROLL, $ES_NOHIDESEL)) $Edit2 = GUICtrlCreateEdit("", 11, 45, 33, 617, BitOR($ES_RIGHT, $ES_READONLY, $ES_WANTRETURN)) GUICtrlSetData(-1, StringFormat(" 1:\r\n 2:\r\n 3:\r\n 4:\r\n 5:\r\n 6:\r\n 7:\r\n 8:\r\n 9:\r\n10:\r\n11:\r\n12:\r\n13:\r\n14:\r\n15:\r\n16:\r\n17:\r\n18:\r\n19:\r\n20:\r\n21:\r\n22:\r\n23:\r\n24:\r\n25:\r\n26:\r\n27:\r\n28:\r\n29:\r\n30:")) $Label1 = GUICtrlCreateLabel("Select Section:", 7, 13, 126, 24) GUICtrlSetFont(-1, 11, 800, 0, "MS Sans Serif") $Savesec = GUICtrlCreateButton("Save Changes", 375, 7, 129, 33) $NewSec = GUICtrlCreateButton("New Section", 700, 7, 121, 33) $SecDwn = GUICtrlCreateButton("Section Down", 830, 7, 137, 33) $SecUp = GUICtrlCreateButton("Section Up", 980, 7, 129, 33) ;$LineNo = GUICtrlCreateInput("LineNo", 664, 7, 65, 28) $copystrs = GUICtrlCreateButton("*******", 507, 7, 73, 33) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $HeavySep = GUICtrlCreateButton("====", 581, 7, 73, 33) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") Global $SecSel Global $secno Global $secn = "NULLz" Global $sFilePathtemp Global $aArray Global $SecNames Global $secnnew Global $ssecn $SecSel = GUICtrlCreateCombo("", 110, 10, 257, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) queysecs() Filledit() GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $secno=GUICtrlRead($SecSel) $changed=0 While 1 $secn = GUICtrlRead($SecSel) ;If $secn <> $secno and $changed=0 Then ; $secns = $secn ; $changed=1 ;EndIf $nMsg = GUIGetMsg() ;MsgBox(4, "TEST1?", $secn) Switch $nMsg Case $GUI_EVENT_CLOSE saveeditedmsg() Exit Case $SecSel ;MsgBox(4, "TEST?", GUICtrlRead($SecSel)) ;MsgBox(4, "TEST1?", $secns) ;MsgBox(4, "TEST2?", $secn) $secno=GUICtrlRead($SecSel) ;saveeditedmsg() queysecs() Filledit() ;$changed=0 Case $Savesec saveeditedmsg() queysecs() Case $NewSec Case $SecDwn Case $SecUp Case $copystrs ClipPut("**************************************************************************************************************************************************************") Case $HeavySep ClipPut("==============================================================================================================================================================") EndSwitch ; MsgBox(4, "TEST2?", $secn) WEnd Func queysecs();query section names $sFilePath = @ScriptDir & "\" & "Txt_Reps.ini" $aArray = IniReadSectionNames($sFilePath) $SecNames = $aArray[1] ; MsgBox(4, "test3?", $secn) If $secn = "NULLz" Then $secn = $aArray[1] EndIf If Not @error Then For $i = 2 To $aArray[0] $SecNames = $SecNames & "|" & $aArray[$i] Next GUICtrlSetData($SecSel, "", "") GUICtrlSetData($SecSel, $SecNames, $secn) $secno = $secn ;MsgBox(4, "test4?", $secn) EndIf EndFunc ;==>queysecs Func Filledit(); transfer section values on the edit box GUICtrlSetData($EditSec, "") $sFilePath = @ScriptDir & "\" & "Txt_Reps.ini" For $i = 1 To 30 $sRead = IniRead($sFilePath, $secn, $i, "") GUICtrlSetData($EditSec, $sRead & @CRLF, 1) Next GUISetState(@SW_SHOW) EndFunc ;==>Filledit Func saveeditedmsg(); save or rename modified section If $secn <> $secno Then $iMsgBoxAnswer = MsgBox(3, "NEW/RENAME", "Press YES to Add this as NEW section" & @CRLF & "Press NO to rename and save this section from " & $secno & "To" & $secn) Select Case $iMsgBoxAnswer = 6 ;YES $secn = $secno save($secn) $secn = GUICtrlRead($SecSel) $secno = $secn Case 7 ;NO $sFilePath = @ScriptDir & "\" & "Txt_Reps.ini" IniRenameSection($sFilePath, $secno, $secn) save($secn) $secn = GUICtrlRead($SecSel) $secno = $secn EndSelect Else $iMsgBoxAnswer = MsgBox(4, "Do you want to save changes to this section", "Save Section: " & $secn) Select Case $iMsgBoxAnswer = 6 ;yes save($secn) EndSelect EndIf EndFunc ;==>saveeditedmsg ;MsgBox(4, "Do you want to add this to Database?",$secn) Func save($ssecn); save edit control to a file and then rewrite modified values by line order. $sFilePathtemp = FileOpen(@ScriptDir & "\" & "tempo.quickrep", $FO_READ + $FO_OVERWRITE + $FO_CREATEPATH + $FO_UTF8) $sFilePath = @ScriptDir & "\" & "Txt_Reps.ini" FileWrite($sFilePathtemp, GUICtrlRead($EditSec)) $sFilePathtemp = FileOpen(@ScriptDir & "\" & "tempo.quickrep", $FO_READ + $FO_UTF8) For $i = 1 To 30 $sRead = FileReadLine($sFilePathtemp, $i) IniWrite($sFilePath, $ssecn, $i, $sRead) Next GUISetState(@SW_SHOW) EndFunc ;==>save The ini file withthe au3 attached This is how I want: when the user changes the combo, the script will check the text combo. In case of changed text it will ask user if I should rename or add it as a new section and then save. If not changed the text of combo it will ask to save only. IF NOT possible, Will it possible with _GUICtrlComboBox__GUICtrlComboBoxEx_Create or _GUICtrlComboBoxEx_Create or not THANK you very much in advance QuickSecEdit.zip -
#include <GuiComboBox.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <Array.au3> #include <WinAPITheme.au3> #include <GDIPlus.au3> #Region GUICtrlComboSetColors UDF Global $g__aWM_CTLCOLORLISTBOX[1][16] = [[0, 0, 0]] ; init. the Global array ; #FUNCTION# ==================================================================================================================== ; Name...........: GUICtrlComboSetColors ; Description ...: Change the colors and position/size of a ComboBox ; Syntax.........: GUICtrlComboSetColors ( $idCombo [, $iBgColor = Default] [, $iFgColor = Default] [, $iExtendLeft = Default] ) ; Parameters ....: $idCombo - GUICtrlCreateCombo() ControlID / [ ArrayIndex ] ; $iBgColor - Background RGB color ; - or "-1" to use prior color declared ; - or to remove a control by ControlID, "-2" ; - or to remove a control by ArrayIndex, "-3" ; $iFgColor - Foreground RGB color ; - or "-1" to use prior color declared ; - or "-2" to use sytem color and leave theme default ; $iExtendLeft - pixels to extend the dropdown list ; - or "-1" to use prior width declared ; - or "1" auto size, extending left ( see Remarks/AutoSize ) ; - or "2" auto size, extending right ( see Remarks/AutoSize ) ; Return values .: Success - index position in the array ; Failure - 0 ; @error - 1 : Control handle = 0 ; - 2 : GetComboBoxInfo failed ; - 3 : Control for removal not found ; @extended - 2 : Success on Control removal ; Author ........: argumentum ; Modified.......: v0.0.0.5 ; Remarks .......: this UDF is in its a work in progress, will expand if needed. ; AutoSize...: use the pertinent parameters from GUICtrlComboSetColors_SetAutoSize() ; minus the CtrlID as semicolon separated to initialize. Ex: "2;Arial;8.5;0" ; Related .......: ; Link ..........: https://www.autoitscript.com/forum/topic/191035-combobox-set-dropdownlist-bgcolor/ ; Example .......: Yes, at the end of the file ; =============================================================================================================================== Func GUICtrlComboSetColors($idCombo = 0, $iBgColor = Default, $iFgColor = Default, $iExtendLeft = Default) If Not $idCombo Then Return SetError(1, 0, 0) Local $n, $tInfo, $i = 0 If $iBgColor = -2 Or $iBgColor = -3 Then Local $m For $n = 1 To $g__aWM_CTLCOLORLISTBOX[0][0] If ($g__aWM_CTLCOLORLISTBOX[$n][0] = $idCombo And $iBgColor = -2) Or ($g__aWM_CTLCOLORLISTBOX[$n][9] = $idCombo And $iBgColor = -3) Then _ArrayDelete($g__aWM_CTLCOLORLISTBOX, $n) $g__aWM_CTLCOLORLISTBOX[0][0] -= 1 Return SetError(0, 2, $n) EndIf Next Return SetError(3, 0, 0) EndIf For $n = 1 To $g__aWM_CTLCOLORLISTBOX[0][0] If $g__aWM_CTLCOLORLISTBOX[$n][0] = $idCombo Then $i = $n ExitLoop EndIf Next If Not $i Then $g__aWM_CTLCOLORLISTBOX[0][0] += 1 $i = $g__aWM_CTLCOLORLISTBOX[0][0] ; If $i >= UBound($g__aWM_CTLCOLORLISTBOX) Then ReDim $g__aWM_CTLCOLORLISTBOX[$i + 1][16] ; add extra "slots" EndIf EndIf Local $sStr = GUICtrlRead($idCombo) Local $iSetWindowTheme = 1 If $iBgColor = Default And $iFgColor = Default Then $iSetWindowTheme = 0 If $iBgColor = Default Then $iBgColor = _WinAPI_GetSysColor($COLOR_WINDOW) If $iFgColor = Default Then $iFgColor = _WinAPI_GetSysColor($COLOR_WINDOWTEXT) If $iBgColor = -1 Then $iBgColor = $g__aWM_CTLCOLORLISTBOX[$i][10] If $iFgColor = -1 Then $iFgColor = $g__aWM_CTLCOLORLISTBOX[$i][11] $g__aWM_CTLCOLORLISTBOX[$i][11] = $iFgColor $g__aWM_CTLCOLORLISTBOX[$i][10] = $iBgColor If $iExtendLeft = Default Then $iExtendLeft = 0 $g__aWM_CTLCOLORLISTBOX[$i][12] = 0 EndIf If $iExtendLeft = -1 Then $iExtendLeft = $g__aWM_CTLCOLORLISTBOX[$i][8] ElseIf Int($iExtendLeft) = 1 Then $g__aWM_CTLCOLORLISTBOX[$i][12] = 1 ElseIf Int($iExtendLeft) = 2 Then $g__aWM_CTLCOLORLISTBOX[$i][12] = 2 Else $g__aWM_CTLCOLORLISTBOX[$i][12] = 0 EndIf $g__aWM_CTLCOLORLISTBOX[$i][8] = Int($iExtendLeft) $g__aWM_CTLCOLORLISTBOX[$i][0] = $idCombo $g__aWM_CTLCOLORLISTBOX[$i][1] = GUICtrlGetHandle($idCombo) $g__aWM_CTLCOLORLISTBOX[$i][13] = "Arial" ; default $sFont $g__aWM_CTLCOLORLISTBOX[$i][14] = 8.5 ; default $fSize $g__aWM_CTLCOLORLISTBOX[$i][15] = 0 ; default $iStyle If $g__aWM_CTLCOLORLISTBOX[$i][12] Then $f = StringSplit($iExtendLeft, ";") If UBound($f) > 1 Then $g__aWM_CTLCOLORLISTBOX[$i][8] = Int($f[1]) If UBound($f) > 2 Then $g__aWM_CTLCOLORLISTBOX[$i][13] = $f[2] If UBound($f) > 3 Then $g__aWM_CTLCOLORLISTBOX[$i][14] = Int($f[3]) If UBound($f) > 4 Then $g__aWM_CTLCOLORLISTBOX[$i][15] = Int($f[4]) $t = TimerInit() GUICtrlComboSetColors_SetAutoSize(Int("-" & $i), $g__aWM_CTLCOLORLISTBOX[$i][12], $g__aWM_CTLCOLORLISTBOX[$i][13], $g__aWM_CTLCOLORLISTBOX[$i][14], $g__aWM_CTLCOLORLISTBOX[$i][15]) ConsoleWrite(TimerDiff($t) & @CRLF) EndIf If _GUICtrlComboBox_GetComboBoxInfo($idCombo, $tInfo) Then If $iSetWindowTheme Then If $g__aWM_CTLCOLORLISTBOX[$i][11] <> -2 Then _WinAPI_SetWindowTheme($g__aWM_CTLCOLORLISTBOX[$i][1], "", "") If $g__aWM_CTLCOLORLISTBOX[$i][11] <> -2 Then GUICtrlSetColor($g__aWM_CTLCOLORLISTBOX[$i][0], $iFgColor) GUICtrlSetBkColor($g__aWM_CTLCOLORLISTBOX[$i][0], $iBgColor) Else GUICtrlSetBkColor($g__aWM_CTLCOLORLISTBOX[$i][0], _WinAPI_GetSysColor($COLOR_HOTLIGHT)) _WinAPI_SetWindowTheme($g__aWM_CTLCOLORLISTBOX[$i][1], 0, 0) EndIf $g__aWM_CTLCOLORLISTBOX[$i][2] = DllStructGetData($tInfo, "hCombo") $g__aWM_CTLCOLORLISTBOX[$i][3] = DllStructGetData($tInfo, "hEdit") $g__aWM_CTLCOLORLISTBOX[$i][4] = DllStructGetData($tInfo, "hList") ; this is what is colored Else $g__aWM_CTLCOLORLISTBOX[0][0] -= 1 Return SetError(2, 0, 0) EndIf If Int($g__aWM_CTLCOLORLISTBOX[$i][5]) Then _WinAPI_DeleteObject($g__aWM_CTLCOLORLISTBOX[$i][5]) $g__aWM_CTLCOLORLISTBOX[$i][5] = 0 ; holder for "_WinAPI_CreateSolidBrush()" return value $g__aWM_CTLCOLORLISTBOX[$i][6] = BitOR(BitAND($iBgColor, 0x00FF00), BitShift(BitAND($iBgColor, 0x0000FF), -16), BitShift(BitAND($iBgColor, 0xFF0000), 16)) If $g__aWM_CTLCOLORLISTBOX[$i][11] = -2 Then $iFgColor = _WinAPI_GetSysColor($COLOR_WINDOWTEXT) $g__aWM_CTLCOLORLISTBOX[$i][7] = BitOR(BitAND($iFgColor, 0x00FF00), BitShift(BitAND($iFgColor, 0x0000FF), -16), BitShift(BitAND($iFgColor, 0xFF0000), 16)) If Not $g__aWM_CTLCOLORLISTBOX[0][1] Then If $g__aWM_CTLCOLORLISTBOX[$i][4] Then $g__aWM_CTLCOLORLISTBOX[0][1] = GUIRegisterMsg($WM_CTLCOLORLISTBOX, "UDF_WM_CTLCOLORLISTBOX") If $g__aWM_CTLCOLORLISTBOX[0][1] Then OnAutoItExitRegister("OnAutoItExit_UDF_WM_CTLCOLORLISTBOX") EndIf EndIf $g__aWM_CTLCOLORLISTBOX[0][2] += 1 $g__aWM_CTLCOLORLISTBOX[$i][9] = $g__aWM_CTLCOLORLISTBOX[0][2] ; internal ID $g__aWM_CTLCOLORLISTBOX[0][3] = TimerInit() ; to use in UDF_WM_CTLCOLORLISTBOX() $g__aWM_CTLCOLORLISTBOX[0][4] = 0 ; to use in UDF_WM_CTLCOLORLISTBOX() If $sStr Then GUICtrlSetData($idCombo, $sStr) Return SetError(0, 0, $g__aWM_CTLCOLORLISTBOX[0][2]) EndFunc ;==>GUICtrlComboSetColors Func UDF_WM_CTLCOLORLISTBOX($hWnd, $Msg, $wParam, $lParam) ConsoleWrite('+ Func UDF_WM_CTLCOLORLISTBOX(' & $hWnd & ', ' & $Msg & ', ' & $wParam & ', ' & $lParam & ')' & @CRLF) For $i = 1 To $g__aWM_CTLCOLORLISTBOX[0][0] If $g__aWM_CTLCOLORLISTBOX[$i][4] = $lParam Then If TimerDiff($g__aWM_CTLCOLORLISTBOX[0][3]) > 500 Or $g__aWM_CTLCOLORLISTBOX[0][4] <> $lParam Then If $g__aWM_CTLCOLORLISTBOX[$i][12] Then GUICtrlComboSetColors_SetAutoSize("-" & $i) EndIf $g__aWM_CTLCOLORLISTBOX[0][3] = TimerInit() $g__aWM_CTLCOLORLISTBOX[0][4] = $lParam If $g__aWM_CTLCOLORLISTBOX[$i][8] > 0 Then Local $aWPos = WinGetPos($g__aWM_CTLCOLORLISTBOX[$i][2]) WinMove($lParam, "", $aWPos[0] - $g__aWM_CTLCOLORLISTBOX[$i][8], $aWPos[1] + $aWPos[3], $aWPos[2] + $g__aWM_CTLCOLORLISTBOX[$i][8]) ElseIf $g__aWM_CTLCOLORLISTBOX[$i][8] < 0 Then Local $aWPos = WinGetPos($g__aWM_CTLCOLORLISTBOX[$i][2]) WinMove($lParam, "", $aWPos[0], $aWPos[1] + $aWPos[3], $aWPos[2] - $g__aWM_CTLCOLORLISTBOX[$i][8]) EndIf If $g__aWM_CTLCOLORLISTBOX[$i][7] >= 0 Then _WinAPI_SetTextColor($wParam, $g__aWM_CTLCOLORLISTBOX[$i][7]) EndIf If $g__aWM_CTLCOLORLISTBOX[$i][6] >= 0 Then _WinAPI_SetBkColor($wParam, $g__aWM_CTLCOLORLISTBOX[$i][6]) If Not $g__aWM_CTLCOLORLISTBOX[$i][5] Then $g__aWM_CTLCOLORLISTBOX[$i][5] = _WinAPI_CreateSolidBrush($g__aWM_CTLCOLORLISTBOX[$i][6]) Return $g__aWM_CTLCOLORLISTBOX[$i][5] EndIf Return 0 EndIf Next EndFunc ;==>UDF_WM_CTLCOLORLISTBOX ; #FUNCTION# ==================================================================================================================== ; Name...........: GUICtrlComboSetColors_SetAutoSize ; Description ...: Set autosize for a ComboBox initialized in GUICtrlComboSetColors() ; Syntax.........: GUICtrlComboSetColors ( $idCombo [, $iExtendLeft = Default] [, $sFont = Default] [, $fSize = Default] [, $iStyle = Default] ) ; Parameters ....: $idCombo - GUICtrlCreateCombo() ControlID / [ ArrayIndex ] ; $iExtendLeft - 1 = Left, 2 = Right, 0 = disable auto-sizing ; $sFont - Font name ; $fSize - Font size ; $iStyle - Font style ; Return values .: Success - widthest string in pixels ; Failure - -1 ; @error - look at the comments in the function ; Author ........: argumentum ; Modified.......: v0.0.0.5 ; Remarks .......: this UDF is in its a work in progress, will expand if needed. ; Related .......: GUICtrlComboSetColors() ; Link ..........: https://www.autoitscript.com/forum/topic/191035-combobox-set-dropdownlist-bgcolor/ ; Example .......: Yes, at the end of the file ; =============================================================================================================================== Func GUICtrlComboSetColors_SetAutoSize($idCombo, $iExtendLeft = Default, $sFont = Default, $fSize = Default, $iStyle = Default) ConsoleWrite('+ Func GUICtrlComboSetColors_AutoSizeSet("' & $idCombo & '", "' & $iExtendLeft & '", "' & $sFont & '", "' & $fSize & '", "' & $iStyle & '")' & @CRLF) $idCombo = Int($idCombo) ; just in case the value is a string Local $n, $iArrayIndex = 0, $iCtrl = 0 If $idCombo > 0 Then For $n = 1 To $g__aWM_CTLCOLORLISTBOX[0][0] If $g__aWM_CTLCOLORLISTBOX[$n][0] = $idCombo Then ; the expected value, is the ControlID $iArrayIndex = $n ExitLoop EndIf Next Return SetError(4, 0, -1) ; $iArrayIndex not found ElseIf $idCombo < 0 Then ; the expected value, is a negative of array's index .. $iArrayIndex = Int(StringTrimLeft(StringStripWS($idCombo, 8), 1)) ; .. so now is a positive value .. If $iArrayIndex < 1 Then Return SetError(3, 0, -1) ; .. else, error .. If $iArrayIndex > $g__aWM_CTLCOLORLISTBOX[0][0] Then Return SetError(2, 0, -1) ; .. as long as is not greater than expected Else Return SetError(1, 0, -1) ; could not find a usable value EndIf Switch $iExtendLeft Case 0, 1, 2 $g__aWM_CTLCOLORLISTBOX[$iArrayIndex][12] = $iExtendLeft EndSwitch Local $aCtrlPos = WinGetPos($g__aWM_CTLCOLORLISTBOX[$iArrayIndex][1]) If UBound($aCtrlPos) <> 4 Then Return SetError(5, 0, -1) ; could not get a usable value Local $sString = StringReplace(_GUICtrlComboBox_GetList($g__aWM_CTLCOLORLISTBOX[$iArrayIndex][0]), "|", @CRLF) Local $aStrWidth = _GDIPlus_MeasureString($sString, $g__aWM_CTLCOLORLISTBOX[$iArrayIndex][13], $g__aWM_CTLCOLORLISTBOX[$iArrayIndex][14], $g__aWM_CTLCOLORLISTBOX[$iArrayIndex][15]) If UBound($aStrWidth) <> 2 Then Return SetError(6, 0, -1) ; could not get a usable value If $aStrWidth[0] < $aCtrlPos[2] Then $g__aWM_CTLCOLORLISTBOX[$iArrayIndex][8] = 0 Else $g__aWM_CTLCOLORLISTBOX[$iArrayIndex][8] = $aStrWidth[0] - $aCtrlPos[2] If $g__aWM_CTLCOLORLISTBOX[$iArrayIndex][12] = 2 Then $g__aWM_CTLCOLORLISTBOX[$iArrayIndex][8] = Int("-" & $aStrWidth[0] - $aCtrlPos[2]) EndIf Return $aStrWidth[0] EndFunc ;==>GUICtrlComboSetColors_SetAutoSize Func _GDIPlus_MeasureString($sString, $sFont = "Arial", $fSize = 12, $iStyle = 0, $bRound = True) ConsoleWrite('Func _GDIPlus_MeasureString("' & $sString & '", "' & $sFont & '", "' & $fSize & '", "' & $iStyle & '", "' & $bRound & '")' & @CRLF) ; original code @ https://www.autoitscript.com/forum/topic/150736-gdi-wrapping-text/?do=findComment&comment=1077210 If Not $__g_iGDIPRef Then _GDIPlus_Startup() ; added by argumentum for this UDF's implementation ( AutoIt v3.3.14 ) due to the way the function is written ;~ Func _GDIPlus_Startup($sGDIPDLL = Default, $bRetDllHandle = False) ;~ $__g_iGDIPRef += 1 <-- I believe this aspect should be coded differently in "GDIPlus.au3" ;~ If $__g_iGDIPRef > 1 Then Return True Local $aSize[2] Local Const $hFamily = _GDIPlus_FontFamilyCreate($sFont) If Not $hFamily Then Return SetError(1, 0, $aSize) Local Const $hFormat = _GDIPlus_StringFormatCreate() Local Const $hFont = _GDIPlus_FontCreate($hFamily, $fSize, $iStyle) Local Const $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0) Local Const $hGraphic = _GDIPlus_GraphicsCreateFromHWND(0) Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat) $aSize[0] = $bRound ? Round($aInfo[0].Width, 0) : $aInfo[0].Width $aSize[1] = $bRound ? Round($aInfo[0].Height, 0) : $aInfo[0].Height _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_GraphicsDispose($hGraphic) Return $aSize EndFunc ;==>_GDIPlus_MeasureString Func OnAutoItExit_UDF_WM_CTLCOLORLISTBOX() For $i = 1 To $g__aWM_CTLCOLORLISTBOX[0][0] If Int($g__aWM_CTLCOLORLISTBOX[$i][5]) Then _WinAPI_DeleteObject($g__aWM_CTLCOLORLISTBOX[$i][5]) Next If $__g_iGDIPRef Then _GDIPlus_Shutdown() EndFunc ;==>OnAutoItExit_UDF_WM_CTLCOLORLISTBOX #EndRegion GUICtrlComboSetColors UDF Example() Func Example() ; Create GUI GUICreate("ComboBox Set DROPDOWNLIST BgColor", 640, 300) Local $a_idCombo[7] = [6] $a_idCombo[1] = GUICtrlCreateCombo("", 2, 2, 390, 296, BitOR($CBS_DROPDOWNLIST, $WS_HSCROLL, $WS_VSCROLL)) GUICtrlComboSetColors($a_idCombo[1], 0xEEEEEE, -2, Default) Example_FillTheCombo($a_idCombo[1]) GUICtrlCreateLabel("<<< change BG color, default theme && size ", 400, 4, 396, 296) $a_idCombo[2] = GUICtrlCreateCombo("", 2, 32, 390, 296, BitOR($CBS_DROPDOWNLIST, $WS_HSCROLL, $WS_VSCROLL)) GUICtrlComboSetColors($a_idCombo[2], 0x0000FF, 0xFFFF00, 0) Example_FillTheCombo($a_idCombo[2]) GUICtrlCreateLabel("<<< change colors", 400, 34, 396, 296) $a_idCombo[3] = GUICtrlCreateCombo("", 2, 62, 390, 296, BitOR($CBS_DROPDOWNLIST, $WS_HSCROLL, $WS_VSCROLL)) GUICtrlComboSetColors($a_idCombo[3], 0xdddddd, Default, 100) Example_FillTheCombo($a_idCombo[3]) GUICtrlCreateLabel("<<< change BG color, resize 100px. left", 400, 64, 396, 296) $a_idCombo[4] = GUICtrlCreateCombo("", 2, 92, 390, 296, BitOR($CBS_DROPDOWNLIST, $WS_HSCROLL, $WS_VSCROLL)) GUICtrlComboSetColors($a_idCombo[4], Default, 0x0000FF, -100) Example_FillTheCombo($a_idCombo[4]) GUICtrlCreateLabel("<<< change FG color, resize 100px. right", 400, 94, 396, 296) $a_idCombo[5] = GUICtrlCreateCombo("", 2, 122, 390, 296, BitOR($CBS_DROPDOWNLIST, $WS_HSCROLL, $WS_VSCROLL)) GUICtrlComboSetColors($a_idCombo[5], 0x00FFFF, 0x0000FF, 1) Example_FillTheCombo($a_idCombo[5]) GUICtrlCreateLabel("<<< change colors, resize auto left", 400, 124, 396, 296) $a_idCombo[6] = GUICtrlCreateCombo("", 2, 152, 390, 296, BitOR($CBS_DROPDOWNLIST, $WS_HSCROLL, $WS_VSCROLL)) GUICtrlSetFont($a_idCombo[6], 10, 400, 0, "Courier New") GUICtrlComboSetColors($a_idCombo[6], Default, Default, "2;Courier New;10") Example_FillTheCombo($a_idCombo[6]) GUICtrlCreateLabel("<<< default colors, resize auto right", 400, 154, 396, 296) Local $bttnArrayShow = GUICtrlCreateButton("Show array", 2, 296 - 27, 75, 25) Local $bttnStrMore = GUICtrlCreateButton("Longer str.", 102, 296 - 27, 75, 25) Local $idLorem = GUICtrlCreateLabel("", 195, 296 - 27, 50, 25) Local $bttnStrLess = GUICtrlCreateButton("Shorter str.", 252, 296 - 27, 75, 25) GUISetState(@SW_SHOW) WinActivate("ComboBox Set DROPDOWNLIST BgColor") ;~ Sleep(3500) ; you can reassign colors, size, or restore default ;~ GUICtrlComboSetColors($idCombo5, Default, Default, 300) ; this resets the Control back to default and changes $iExtendLeft ;~ GUICtrlComboSetColors($idCombo5, 0x0000FF, 0x00FFFF, -1) ; this changes the colors and keeps $iExtendLeft as it was ;~ GUICtrlComboSetColors($idCombo5, -1, -1, 300) ; using "-1" will keep the existing colors ;~ ; so in this case, only the $iExtendLeft is declared ;~ Example_FillTheCombo($idCombo5) ;~ Sleep(500) ; after removal, it will not repaint "hList", but then again, you're deleteing the control ;~ GUICtrlComboSetColors($idColors, -3) ;~ GUICtrlDelete($idCombo2) Local $iLorem = 5, $sLorem = "" Example_LoremStr($iLorem, $sLorem, $a_idCombo, $idLorem) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete() Return Case $bttnArrayShow _ArrayDisplay($g__aWM_CTLCOLORLISTBOX, "$g__aWM_CTLCOLORLISTBOX") Case $bttnStrMore $iLorem += 5 Example_LoremStr($iLorem, $sLorem, $a_idCombo, $idLorem) Case $bttnStrLess $iLorem -= 5 Example_LoremStr($iLorem, $sLorem, $a_idCombo, $idLorem) EndSwitch WEnd EndFunc ;==>Example Func Example_FillTheCombo(ByRef $idComboCtrl) GUICtrlSetData($idComboCtrl, "") _GUICtrlComboBox_AddString($idComboCtrl, "something") _GUICtrlComboBox_AddString($idComboCtrl, "something else") _GUICtrlComboBox_AddString($idComboCtrl, "blah, blah, blah, blah") _GUICtrlComboBox_AddString($idComboCtrl, "Lorem will change") Local $a = _GUICtrlComboBox_GetListArray($idComboCtrl) GUICtrlSetData($idComboCtrl, $a[1]) EndFunc ;==>Example_FillTheCombo Func Example_LoremStr(ByRef $iLorem, ByRef $sLorem, ByRef $a_idCombo, ByRef $idLorem) Local Static $s = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat." $s &= " Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat." Local Static $i = 5, $a = StringSplit($s, " ") If $iLorem < 1 Then $iLorem = 1 If $iLorem > $a[0] Then $iLorem = $a[0] Local $x, $iLastEntry $sLorem = "" GUICtrlSetData($idLorem, $iLorem & ' words') For $x = 1 To $iLorem $sLorem &= $a[$x] & " " Next For $x = 1 To $a_idCombo[0] $iLastEntry = _GUICtrlComboBox_GetCount($a_idCombo[$x]) - 1 _GUICtrlComboBox_DeleteString($a_idCombo[$x], $iLastEntry) _GUICtrlComboBox_AddString($a_idCombo[$x], $sLorem) Next EndFunc ;==>Example_LoremStr new in v0.0.0.5: auto size the dropdown. You may also wanna take a look at ComboBox Color Background/Text subclass approach.
-
I have a bunch of SDL_Surfaces loaded into memory. I want to list them in a ComboBox. Using this code, I can load images to the combobox from file but not from existing SDL_Surface memory CODE ISN"T MEANT TO RUN ; Create combobox pic list example $aControl[$iControl_id][$eControl_data] = _GUICtrlComboBoxEx_Create($gui, $data_value, $data_x, $data_y, $data_w, $data_h, $CBS_DROPDOWNLIST) ; Image List for ComboboxEx Local $hImage = _GUIImageList_Create($gTile_w, $gTile_h, 6) ; Fill hImage with SDL_Surfaces stored in memory: aNPC_surf[scale][type][way][frame] For $i = 0 To 1 ; This works but only from file: ;_GUIImageList_AddBitmap($hImage, $gFolder_graphics & $gaWorld_info[$player.iWorld_cur][$eWi_filename] & "Tiles\" & $i & ".bmp") ; I've broken up a sprite sheet and want to insert into combobox from memory ;_GUIImageList_Add($hImage, $aNPC_surf[1][1][1][$i]) _GUIImageList_Add($hImage, _GDIPlus_BitmapCreateFromMemory($aNPC_surf[1][1][1][$i]), True) ;_GDIPlus_BitmapCreateFromMemory($aNPC_surf[1][1][1][$i]) ; Add the index number to combobox item _GUICtrlComboBoxEx_AddString($aControl[$eNPC_iPic_type][$eControl_data], $i, $i, $i) Next ; Set hImage list to combobox control _GUICtrlComboBoxEx_SetImageList($aControl[$eNPC_iPic_type][$eControl_data], $hImage) Anyone know if I can convert from SDL_Surface to hBitmap? Maybe I'm doing something else wrong. I've seen hBitmap converted to SDL_Surface but I don't really understand it yet: My full script can be found here:
-
- combobox
- comboboxex
-
(and 3 more)
Tagged with:
-
I even understand that the Handle generated by _WinAPI_LoadCursor is not an Icon but how to display the image in the Combobox Here is the listing and please tell me how to make the current user current cursor image uncertainty #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> ;dados de mouse #include <WinAPIRes.au3> ;COMBO #include <GuiComboBoxEx.au3> Example() Func Example() Local $hGUI, $hImage, $hCombo Local $idListview, $hImage Local $sWow64 = "" Local $Pasta="C:\WINDOWS\Cursors\3dgarro.cur" $hGUI = GUICreate("ImageList Mouse Icons", 400, 300) $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100) $idListview = GUICtrlCreateListView("", 2, 104, 394, 200, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)) GUISetState(@SW_SHOW) ; Load images $hImage = _GUIImageList_Create(16, 16) ;teste _GUIImageList_AddIcon($hImage, $Pasta) ;<<<<<<<<<<<<<<<<<<<<<this $hIcon= _WinAPI_CopyCursor(_WinAPI_LoadCursor(0,$IDC_HAND));32649 ; Hand cursor _GUIImageList_AddIcon($hImage, $hIcon);<<<<<<<<<<<<<<<<<< erro for $i=1 to 15 $hIcon= _WinAPI_CopyCursor(_WinAPI_LoadCursor(0, $i));<<<<<<<<<<<<<<<<< _GUIImageList_AddIcon($hImage, $hIcon);<<<<<<<<<<<< Next _GUIImageList_AddIcon($hImage, $Pasta) _GUICtrlListView_SetImageList($idListview, $hImage, 1) _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage) ; Add columns _GUICtrlListView_AddColumn($idListview, "Items", 120) ; Add items $a=StringSplit("testeIcone|HAND|APPSTARTING|ARROW|CROSS|HELP|IBEAM|ICON|NO|SIZE|SIZEALL|SIZENESW|SIZENS|SIZENWSE|SIZEWE|UPARROW|WAIT|testefim","|") For $i=1 to $a[0] _GUICtrlListView_AddItem($idListview, $a[$i], $i-1) _GUICtrlComboBoxEx_AddString($hCombo, $a[$i], $i-1) Next ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Note that only the initial image is uncertain because it comes from a file And the one that would be the last enters as the second And the background is black how to transform into transparent imagem de cursor.bmp
-
hello, i just wanted to ask if how........ I have a gui combo box with a list and i wanted it to remember the last item that i selected, that when i close the gui and then open the gui again, my last selected item will be automatically show in the combobox as selected item already. thank you in advance.
-
Hi all, How can i get notified when user clicks on a combo box's edit area ? This is my code so far. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <ComboConstants.au3> #include <ListBoxConstants.au3> Global $btn ; creates a window Global $Window_0 = GUICreate("My Window", 800, 500, -1, -1, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX)) $btn = GUICtrlCreateButton("Click Me", 50, 50, 120, 50) Global $cmb = GUICtrlCreateCombo("Sample", 50, 150, 300, 50) GUICtrlSetFont(-1,12,400) Global $lstbx = GUICtrlCreateList("FirstItem", 400,50, 200, 300) GUICtrlSetFont(-1,12,400) GUIRegisterMsg($WM_COMMAND, "MyEventCallback") GUIRegisterMsg($WM_SIZE, "MyEventCallback") GUIRegisterMsg($WM_NOTIFY, "NotifyManager") GUISetState(@SW_SHOW) GUICtrlSetData($cmb, "Item 2|Item 3", "Item 2") GUICtrlSetData($lstbx, "Apple|Orange|Pineapple|Grape|Lemon") Do $Event = GUIGetMsg( ) Until $Event = $GUI_EVENT_CLOSE Func MyEventCallback($hwnd, $message, $wParam, $lParam) Select Case $message = $WM_COMMAND ;---------------------------------------------------------------- If LoWord($wParam) = $cmb Then ; if control id is combox's Then Local $Notification = HiWord($wParam) Select Case $Notification = $CBN_DROPDOWN ; here we check the notification code. ConsoleWrite("$CBN_DROPDOWN Worked " & @MIN & ":" & @SEC & @CRLF) Case $Notification = $CBN_EDITCHANGE ; here we check the notification code. ConsoleWrite("$CBN_EDITCHANGE Worked " & @MIN & ":" & @SEC & @CRLF) ; **** Here i want add the code for combo box clicking. EndSelect ;--------------------------------------------------------------------- ElseIf LoWord($wParam) = $lstbx Then Local $Notification = HiWord($wParam) Select Case $Notification = $LBN_SELCHANGE ConsoleWrite("$LBN_SELCHANGE" & @CRLF) EndSelect EndIf ;------------------------------------------------------------------ Case $message = $WM_SIZE EndSelect Return $GUI_RUNDEFMSG EndFunc ;==>ProGUI_EventCallback Func NotifyManager($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam ;Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR Local $tagNMHDR, $event, $hwndFrom, $code $tagNMHDR = DllStructCreate("int;int;int", $lParam) If DllStructGetData($tagNMHDR, 3) = $NM_LDOWN Then ConsoleWrite("Notify Worked" & @CRLF) EndIf Return $GUI_RUNDEFMSG EndFunc Func LoWord($Variable) Return BitAND($Variable, 0xFFFF) EndFunc Func HiWord($Variable) Return BitShift($Variable, 16) EndFunc
-
Good morning I'm working on a little project, and I was wondering if there's a way ( sure there is ) to insert data to a ComboBox control everytime the user insert some text in the ComboBox which is not in the ComboBox data. I'll try to explain with an example: - Form with some data ( ComboBox is empty ); - User prompt something in the ComboBox: if what the user prompts is not in the ComboBox values ( at the moment empty ), then insert the value in the ComboBox values, in order to have, next time the user prompts the form, the value that he entered. More pratical example: - First call of the form, ComboBox empty; - I prompt "A" in the ComboBox; - Second call, in the ComboBox I should see "A"; - I prompt "B" in the ComboBox; - Third call, I should see "A" "B"; - And so on... Everytime the form is called, I re-create it, so I think I can't use _GUICtrlComboBox_AddStrings(). I tried with Global $strCboStrings = "" ; When the user prompt the form, the code below is executed. ; I.E. : User prompt "A", after the if I should have "A"; ; In the second call, If I write "B", I should see "A" ; "B"; ; If I write "A" again, in the combobox values should not be any changes. If Not StringInStr($strCboStrings, GUICtrlRead($cboVoiceCategory)) <> 0 Then $strCboStrings &= $strCboStrings & "|" & GUICtrlRead($cboVoiceCategory) EndIf Any suggestion? Thanks
-
hello Comunity i am new to autoit and i bump into a pitfall regarding the creation of objects in a dinamyc way but more especific creating combobox at runtime i need many comboboxes and sofar i createdthem manually like this $idCombo_1 = GUICtrlCreateCombo("", 500, 40, 130, 21) $idCombo_2 = GUICtrlCreateCombo("", 500, 70, 130, 21) $idCombo_3 = GUICtrlCreateCombo("", 500, 100, 130, 21) $idCombo_4 = GUICtrlCreateCombo("", 500, 130, 130, 21) $idCombo_5 = GUICtrlCreateCombo("", 500, 160, 130, 21) $idCombo_6 = GUICtrlCreateCombo("", 500, 190, 130, 21) $idCombo_7 = GUICtrlCreateCombo("", 500, 220, 130, 21) $idCombo_8 = GUICtrlCreateCombo("", 500, 250, 130, 21) $idCombo_9 = GUICtrlCreateCombo("", 500, 280, 130, 21) GUICtrlSetData($idCombo_1, "Item1|Item2|Item3|Item4|Item5") GUICtrlSetData($idCombo_2, "Item1|Item2|Item3|Item4|Item5") GUICtrlSetData($idCombo_3, "Item1|Item2|Item3|Item4|Item5") GUICtrlSetData($idCombo_4, "Item1|Item2|Item3|Item4|Item5") GUICtrlSetData($idCombo_5, "Item1|Item2|Item3|Item4|Item5") GUICtrlSetData($idCombo_6, "Item1|Item2|Item3|Item4|Item5") GUICtrlSetData($idCombo_7, "Item1|Item2|Item3|Item4|Item5") GUICtrlSetData($idCombo_8, "Item1|Item2|Item3|Item4|Item5") GUICtrlSetData($idCombo_9, "Item1|Item2|Item3|Item4|Item5") now i need this example but create them at runtime as there are more than 9 combos what i need thanks in advance kind regards
-
Good evening guys I am working on a little project, in which I have to retrieve 8000+ rows of data from a table, from a SQLite database, to populate a combobox This is what I tried 'til now, but it still takes about 12 seconds to populate the combobox. _SQLite_Exec($objDatabase, "BEGIN TRANSACTION;") If _SQLite_GetTable($objDatabase, "SELECT DISTINCT Comune FROM LISTA_COMUNI;", $arrRisultatoQuery, $intRighe, $intColonne) = $SQLITE_OK Then For $i = 2 To UBound($arrRisultatoQuery) - 1 If $i < UBound($arrRisultatoQuery) - 1 Then GUICtrlSetData($cbo_ComuneNascita, $arrRisultatoQuery[$i] & "|") Else GUICtrlSetData($cbo_ComuneNascita, $arrRisultatoQuery[$i]) EndIf Next _SQLite_Exec($objDatabase, "COMMIT;") Are there any other solution to retrieve 8000+ records from a SQLite database? Thank you very much
-
Hi huys ! how are you ? family ? dog, cat ? well.. I've got a problem: _GUICtrlComboBox_GetCueBanner i can't get it to work. Simple: even the example from help does'nt work... I insist, it's excactly the example from the help, no modifications #include <GuiComboBox.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $g_idMemo Example() Func Example() Local $idCombo ; Create GUI GUICreate("ComboBox Get Count", 400, 296) $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296) _GUICtrlComboBox_SetCueBanner($idCombo, "Select an Item") $g_idMemo = GUICtrlCreateEdit("", 10, 50, 376, 234, $WS_VSCROLL) GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New") GUISetState(@SW_SHOW) ; Add files _GUICtrlComboBox_BeginUpdate($idCombo) _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe") _GUICtrlComboBox_EndUpdate($idCombo) MemoWrite("Cue Banner: " & _GUICtrlComboBox_GetCueBanner($idCombo)) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example ; Write a line to the memo control Func MemoWrite($sMessage) GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite I also added the display of the cuebanner in the loop. It never display what actually appears in the combo If you can show me any king of working example. Thanks Guys ! Nicolas. Actually autoit v3.3.14.2
-
Hello, I have searched everywhere but on the forum there isn't an example of a combobox with checkbox. I think is a very useful control but require subclassing. Several example in C++, one of this: CheckComboBox Control If somone has some time to check it out. If need i can provide the source code. Thanks
-
Let's say I have 10 combobox and 10 items in each. 1- If one item in a combobox is selected, I don't want it to be selectable in another combobox. (Or if it is, remove the duplicate one) 2- When I click on button, I want 10 msgboxes to show, and each item showing in each msgbox in order they are selected. (from combobox1 to combobox10) I'm confused whether to use select or switch or other loops.
-
Hello, I've writing this code and I'm a little stuck in what i want to do. When I select the combobox I want to get the ini information inside the multiline input field. I know that what I'm doing now is wrong but maybe this helps to clearify things in what I want to do. Does somebody knows how to do this , or can help me? #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <TabConstants.au3> #include <File.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <Array.au3> #include <Date.au3> check_file_exist() $Form1 = GUICreate("Form1", 320, 260, 192, 324);(b,h,,),30 $Tab1 = GUICtrlCreateTab(5, 5, 310, 250) ;(,,b,h) $TabSheet3 = GUICtrlCreateTabItem("Edit") $Label_tab_select = GUICtrlCreateLabel("select", 40, 50, 80, 25) $tab_select = GUICtrlCreateCombo(" tab 1", 40, 70, 80, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1, " tab 2") $Label_BtnSelect = GUICtrlCreateLabel("nr", 125, 50, 80, 25) $BtnSelect = GUICtrlCreateCombo(" 1", 125, 70, 60, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1, " 2 ") $Label_BtnName = GUICtrlCreateLabel("name", 190, 50, 80, 25) $BtName = GUICtrlCreateInput("", 190, 70, 80, 21) $multiline = GuiCtrlCreateEdit("this text needs to be changed at selection of combobox",15, 105, 290, 110) ;the next line is to clearify things :) ;$multiline = GuiCtrlCreateEdit(IniRead($ini_location_buttons, "btn00" & GUICtrlRead($BtnSelect), "text"),15, 105, 290, 110) $Btn301 = GUICtrlCreateButton("Cancel", 40, 220, 75, 25) $Btn302 = GUICtrlCreateButton("Save", 152, 220, 75, 25) GUICtrlCreateTabItem("") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Btn301 Exit Case $Btn302 Exit EndSwitch WEnd Func check_file_exist() If FileExists(@SCRIPTDIR & "\ini.ini") Then Global $ini_location_buttons = @SCRIPTDIR & "\ini.ini" Else If Not _FileCreate(@SCRIPTDIR & "\buttons.ini") Then MsgBox($MB_SYSTEMMODAL, "Error", " Error Creating/Resetting ini. error:" & @error) Else Global $ini_location_buttons = @SCRIPTDIR & "\ini.ini" create_new_ini() EndIf EndIf EndFunc Func create_new_ini() $file = FileOpen($ini_location_buttons, 1) Local $i = 1 local $j = 0 Do if $i = 10 then $j = "" FileWrite($file, "[btn0" & $j & $i & "]"& @CRLF) FileWrite($file, "button_name=Button " & $i & @CRLF) FileWrite($file, "text=lorum ipsum" & $i & @CRLF) $i = $i + 1 Until $i = 3 FileClose($file) EndFunc
-
Hi i try to read existing local Groups of remote computer and add to Combobox so i can select a Group to get members and add to $ListMembers. Does anyone have a solution how i can read existing local Groups of remote computer and add to Combobox? thanks. #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.1 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Add / Remove Members", 615, 432, 196, 128) GUISetBkColor(0xFFFFFF) $Group1 = GUICtrlCreateGroup("", 8, 8, 289, 185) GUICtrlSetFont(-1, 10, 800, 0, "Arial") $LabelCpname = GUICtrlCreateLabel("CP Name:", 16, 32, 81, 23) GUICtrlSetFont(-1, 12, 800, 0, "Arial") $InputCpname = GUICtrlCreateInput("", 16, 56, 129, 30) GUICtrlSetFont(-1, 14, 800, 0, "Arial") $LabelLocalGroups = GUICtrlCreateLabel("Local Groups", 16, 96, 107, 20) GUICtrlSetFont(-1, 12, 800, 0, "Arial") $ComboGroups = GUICtrlCreateCombo("", 16, 152, 273, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetFont(-1, 14, 800, 0, "Arial") GUICtrlSetBkColor(-1, 0xFFFF00) $ButtonReadGroups = GUICtrlCreateButton("read local Groups", 160, 56, 130, 25) $ButtonReadmembers = GUICtrlCreateButton("read Members", 16, 120, 130, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("User", 8, 200, 289, 89) GUICtrlSetFont(-1, 10, 800, 0, "Arial") $LabelUserID = GUICtrlCreateLabel("User ID:", 16, 224, 66, 23) GUICtrlSetFont(-1, 12, 800, 0, "Arial") $InputComputer = GUICtrlCreateInput("", 88, 216, 89, 30) GUICtrlSetFont(-1, 14, 800, 0, "Arial") $ButtonAdd = GUICtrlCreateButton("Add User", 184, 216, 100, 25) $ButtonRemove = GUICtrlCreateButton("Remove user", 184, 248, 100, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) $ListMembers = GUICtrlCreateList("", 304, 16, 305, 409) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select ;Case $GUI_EVENT_CLOSE Case $msg = $GUI_EVENT_CLOSE Exitloop Case $msg = $ButtonReadGroups MsgBox(0, "Note", "Button 'read Groups' not work !") Case $msg = $ButtonReadmembers ;MsgBox(0, "Note", "Button 'Read Members' not work !") GUICtrlSetData($ListMembers, "") Local $readCombo = GuiCtrlRead($ComboGroups) GUICtrlSetData($ListMembers, $readCombo) Case $msg = $ButtonAdd MsgBox(0, "Note", "Button 'Add User' not working !") Case $msg = $ButtonRemove MsgBox(0, "Note", "Button 'Remove User' not working !") EndSelect WEnd func terminate() ;exit Exit 0 EndFunc