mafioso Posted April 13, 2008 Posted April 13, 2008 (edited) Is there any way to make ComboBox read-only, like Edit control ? I mean, so you can't type to the ComboBox, just select. Thanks in advance. EDIT (1 MINUTE LOL) : Fixed, I had to use $CBS_DROPDOWNLIST. EDIT 2 : Now _GUICtrlComboBox_GetEditText, _GUICtrlComboBox_SetEditText and _GUICtrlListBox_AddString don't work. I also tried ListBox, no succes though. EDIT 3 : Also tried GUICtrlRead (also tried _GetCurSel) instead of _GetEditText, but if I just move my mouse over the list, it does the next thing...Cur. piece of code : $procitaj = _GUICtrlComboBox_GetCurSel ($klasa0) If $procitaj <> "" Then $split = StringSplit ($procitaj, " ") _GUICtrlComboBox_SetEditText($klasa0, "") Sleep (100) $iznos = InputBox ($split[1] & " - " & $split[3], "Vrijednost : ") _GUICtrlListBox_AddString ($klasa0lista, $split[1] & " - " & $iznos) EndIf Edited April 14, 2008 by mafioso
Xenobiologist Posted April 13, 2008 Posted April 13, 2008 Hi, didn't you answer all your questions? Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
mafioso Posted April 13, 2008 Author Posted April 13, 2008 No. EDIT 3 : Also tried GUICtrlRead (also tried _GetCurSel) instead of _GetEditText, but if I just move my mouse over the list, it does the next thing...Cur. piece of code : If I just hover over the list, it will show the InputBox, even if I don't click on the option. How to fix it ? _GetEditText doesn't work.
Zedna Posted April 13, 2008 Posted April 13, 2008 If you need more help then post more related code. Ideally small working reproducing script. $klasa0 = ? Resources UDF ResourcesEx UDF AutoIt Forum Search
mafioso Posted April 14, 2008 Author Posted April 14, 2008 (edited) A working example of my problem (commented, so you know where and what is the problem ): #include <GUIConstants.au3> #include <GUIComboBox.au3> $Form1 = GUICreate("AForm1", 284, 58, 193, 115) $combo = GUICtrlCreateCombo("", 54, 14, 145, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) ;I want the combo read only, so you can't type anything to it GUICtrlSetData(-1, "one|two|three|four|five") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() ;======PROBLEM --- I only want to read if I press on the option, not if I just move my mouse over it... $procitaj = GuiCtrlRead ($combo) ;====PROBLEM If $procitaj <> "" Then MsgBox (64, "problem...", "when you just hover over the option, this appears. I want that this appears only if I click on the option") GUICtrlSetData ($combo, "") ;that is to stop msgbox (change the combobox to "" so it doesn't show the msgbox) Endif Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd And BTW, the $klasa0 of the example I posted before... $klasa0 = GUICtrlCreateCombo("", 18, 112, 100, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL,$CBS_DISABLENOSCROLL,$WS_HSCROLL,$WS_VSCROLL)) Edited April 14, 2008 by mafioso
GaryFrost Posted April 14, 2008 Posted April 14, 2008 expandcollapse popup#include <GUIConstantsEx.au3> #include <GUIComboBox.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("AForm1", 284, 58, 193, 115) $hCombo = GUICtrlCreateCombo("", 54, 14, 145, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) ;I want the combo read only, so you can't type anything to it GUICtrlSetData(-1, "one|two|three|four|five") GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _ComboBox_SelEndOK($hWnd) Local $sText _GUICtrlComboBox_GetLBText($hWnd, _GUICtrlComboBox_GetCurSel($hWnd), $sText) MsgBox(64, "Selected", $sText) EndFunc ;==>_ComboBox_SelEndOK Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $hTempCombo = GUICtrlGetHandle($hCombo) $hWndFrom = $ilParam $iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word $iCode = BitShift($iwParam, 16) ; Hi Word Switch $hWndFrom Case $hTempCombo Switch $iCode Case $CBN_SELENDOK ; Sent when the user selects a list item, or selects an item and then closes the list _ComboBox_SelEndOK($hTempCombo) ; no return value EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
Zedna Posted April 14, 2008 Posted April 14, 2008 Here is simpler method: #include <GUIConstants.au3> #include <GUIComboBox.au3> $Form1 = GUICreate("AForm1", 284, 58, 193, 115) $combo = GUICtrlCreateCombo("", 54, 14, 145, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) ;I want the combo read only, so you can't type anything to it GUICtrlSetData(-1, "one|two|three|four|five") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $combo $procitaj = GuiCtrlRead ($combo) If $procitaj <> "" Then MsgBox (64, "problem...", "when you just hover over the option, this appears. I want that this appears only if I click on the option") GUICtrlSetData ($combo, "") Endif EndSwitch WEnd Resources UDF ResourcesEx UDF AutoIt Forum Search
henry1 Posted April 14, 2008 Posted April 14, 2008 Hi Zedna, I tried yours and Gary. Your script is when I choose an option, it will open a MsgBox. But after I want to try second, third, etc, the option list was gone? Henry
ProgAndy Posted April 14, 2008 Posted April 14, 2008 (edited) There was a GUICtrlSetData ($combo, ""), so the Combo was clear afterwards. #include <GUIConstantsEx.au3> #include <GUIComboBox.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("AForm1", 284, 58, 193, 115) $hCombo = GUICtrlCreateCombo("", 54, 14, 145, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) ;I want the combo read only, so you can't type anything to it -> $CBS_DROPDOWNLIST GUICtrlSetData(-1, "one|two|three|four|five") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $hCombo ; Do, when ComboItem selected MsgBox(0, 'Selected', GUICtrlRead($hCombo)) EndSwitch WEnd Edited April 14, 2008 by ProgAndy *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
Zedna Posted April 14, 2008 Posted April 14, 2008 (edited) Hi Zedna,I tried yours and Gary. Your script is when I choose an option, it will open a MsgBox. But after I want to try second, third, etc, the option list was gone?Original poster have had this functionality there so I haven't changed that piece of code.I have just sticked all the code into the right places. So ask that question to original poster, why he wanted to delete ComboBox after select some option from it.As ProgAndy said: If you want to preserve ComboBox just comment one line GUICtrlSetData ($combo, ""). Edited April 14, 2008 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
mafioso Posted April 14, 2008 Author Posted April 14, 2008 (edited) Thanks to both for your help ! But Gary's script deletes all of the options...and I just wanted to delete the selected one. Ex. : You click on "three". MsgBox appears, list disappears. Delete the "three" which is NOW in the ComboBox, not to delete it as option. Thanks to both again, Gary's script is hard to understand and I'll also try to make Zedna's work. Thanks again ! EDIT : Fixed Zedna's script. #include <GUIConstants.au3> #include <GUIComboBox.au3> $Form1 = GUICreate("AForm1", 284, 58, 193, 115) $combo = GUICtrlCreateCombo("", 54, 14, 145, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) ;I want the combo read only, so you can't type anything to it GUICtrlSetData(-1, "one|two|three|four|five") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $combo $procitaj = GuiCtrlRead ($combo) If $procitaj <> "" Then MsgBox (64, "problem...", "when you just hover over the option, this appears. I want that this appears only if I click on the option") GUICtrlSetData ($combo, "") GUICtrlSetData($combo, "one|two|three|four|five") Endif EndSwitch WEnd Just added GuiCtrlSetData again And works perfectly =) Edited April 14, 2008 by mafioso
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