mdp716 Posted February 13, 2014 Share Posted February 13, 2014 (edited) Greetings all, I am having difficulty with a combo box's appearance in the GUI. When I create the combo box with this: $editApplication = GUICtrlCreateCombo("Select Application", 22, 412, 405, 22) it appears with a White background in the GUI. However, I desire this to be a non editable object so I use this to create it instead: $editApplication = GUICtrlCreateCombo("Select Application", 22, 412, 405, 22, $CBS_DROPDOWNLIST) ...and when I do that, the appearance of the object is with a Grey background which is undesirable. I have not been able to figure out how to make it both a non editable control and have a white background. Can someone show me what I need to do this? Your assistance is greatly appreciated. Here is the code, I have stripped out a lot of the code not necessary to demonstrate my problem. As well, you will see that I commented out the lines of code that use the $CBS_DROPDOWNLIST constant so I can easily switch back and forth to the lines with and without that constant. expandcollapse popup#include <File.au3> #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> #include <GuiEdit.au3> #include <GuiComboBoxEx.au3> Global $version = "1.0" Global $deviceName = "Enter APS Printer Device Name Here" Global $gUI, $btnAPSTest, $editDeviceName, $iMsg, $nMsg Global $editApplication, $Application, $editPrintJob, $PrintJob Global $aData CreateGUI() ;The following are place holders for code removed from this example ;to similate the downloading of the data from a web site GUICtrlSetData($editApplication, "Application 1") GUICtrlSetData($editApplication, "Application 2") GUICtrlSetData($editApplication, "Application 3") Sleep(500) GUICtrlSetState($editApplication, $GUI_ENABLE) GUICtrlSetData($editPrintJob, "Print Job 1") GUICtrlSetData($editPrintJob, "Print Job 2") GUICtrlSetData($editPrintJob, "Print Job 3") GUICtrlSetData($editPrintJob, "Print Job 4") Sleep(500) GUICtrlSetState($editPrintJob, $GUI_ENABLE) Sleep(500) GUICtrlSetState($editDeviceName, $GUI_ENABLE) ;end place holders Global $accEnter = GUICtrlCreateDummy() Global $a_AccelKeys[1][2] = [["{ENTER}", $accEnter]] GUISetAccelerators($a_AccelKeys) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $editApplication If _GUICtrlEdit_GetText($editApplication) = "Select Application" Then MsgBox(,0, "Error", "Invalid Selection") Else Sleep(2000) GUICtrlSetState($editPrintJob, $GUI_ENABLE) EndIf Case $accEnter Switch GuiCtrlGetFocus($gUI) Case $editDeviceName MsgBox(0, "TEST", GuiCtrlGetFocus($gUI)) GUICtrlSetState($editApplication, $GUI_ENABLE) GUICtrlSetState($editApplication, $GUI_FOCUS) Case $editApplication If _GUICtrlEdit_GetText($editApplication) = "Select Application" Then MsgBox(0, "Test 1", "Am Here") Else GUICtrlSetState($editClose, $GUI_FOCUS) _GUICtrlEdit_SetSel($editClose, 0, -1) EndIf Case $editPrintJob If NOT ValidateTimes() Then MsgBox(0, "Test 2", "Am Here") _GUICtrlEdit_SetSel($editClose, 0, -1) Else GUICtrlSetState($btnConfig, $GUI_FOCUS) EndIf Case Else GUISetAccelerators("") ControlSend($gUI, "", GuiCtrlGetFocus($gUI), "{ENTER}") GUISetAccelerators($a_AccelKeys) EndSwitch Case $btnAPSTest MsgBox(0, "Pressed", "Button Pressed") EndSwitch WEnd CleanUp() Exit #cs ================================================================= ===================================================================== Function: CreateGUI() Arguments: N/A Requires: Purpose: Creates the User Interface ===================================================================== ===================================================================== #ce Func CreateGUI() $gUI = GUICreate("APS Print Test", 450, 550, -1, -1) GUISetIcon("C:\UAL\LPR\APSPT.ico", -1) GUISetBkColor(0xC0C0C0) GUICtrlCreatePic(@TempDir & "\" & "UA_BG_450X328.jpg", 0, 0, 450, 328) GUICtrlCreateGroup("", 8, 330, 435, 215) GUICtrlCreateGroup("Enter Printer DeviceName:", 15, 340, 420, 50) GUICtrlCreateGroup("Select Application:", 15, 395, 420, 50) GUICtrlCreateGroup("Select Print Job:", 15, 450, 420, 50) ;Banner Text GUISetFont(16, 400, 0, "Verdana") GUICtrlCreateLabel("APS Printer Test", 0, 10, 440, 30, $SS_CENTER) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) ; White Text GUISetFont(10, 400, 0, "Verdana") GUICtrlCreateLabel("Version " & $version, 5, 310, 90, 14) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) ; White Text GUISetFont(10, 400, 0, "Verdana") GUICtrlCreateLabel("Company Name Here", 250, 310, 250, 14) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) ; White Text GUISetFont (10, 400, 0, "Verdana") ;LABELS GUISetFont(14, 400, 0, "Verdana") Global $iMsg = GUICtrlCreateLabel("", 0, 50, 450, 23, $SS_CENTER) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) ; White Text ;INPUTS $editDeviceName = GUICtrlCreateEdit($deviceName, 22, 355, 405, 30, BitOR($GUI_SS_DEFAULT_INPUT,$WS_BORDER)) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x000000) GUICtrlSetState($editDeviceName, $GUI_DISABLE) $editApplication = GUICtrlCreateCombo("Select Application", 22, 412, 405, 22) ; $editApplication = GUICtrlCreateCombo("Select Application", 22, 412, 405, 22, $CBS_DROPDOWNLIST) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x000000) GUICtrlSetState($editApplication, $GUI_DISABLE) $editPrintJob = GUICtrlCreateCombo("Select Print Job", 22, 467, 405, 22) ; $editPrintJob = GUICtrlCreateCombo("Select Print Job", 22, 467, 405, 22, $CBS_DROPDOWNLIST) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x000000) GUICtrlSetState($editPrintJob, $GUI_DISABLE) ;Buttons $BtnAPSTest = GUICtrlCreateButton("Send Test Print", 15, 508, 420, 30) GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) EndFunc Edited February 13, 2014 by Melba23 Added code tags Link to comment Share on other sites More sharing options...
Danyfirex Posted February 13, 2014 Share Posted February 13, 2014 (edited) hi, only use de flag $CBS_DROPDOWNLIST and don't use $GUI_DISABLE for the control. Saludos Edited February 13, 2014 by Danyfirex Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
mdp716 Posted February 13, 2014 Author Share Posted February 13, 2014 hi, only use de flag $CBS_DROPDOWNLIST and don't use $GUI_DISABLE for the control. Saludos I use disable because there is a process that downloads information that is used to populate the ComboBox that has to happen before the ComboBox can be used. Once that process completes the control is enabled. Even so, when the control is enabled, it still shows a different face color when $CBS_DROPDOWNLIST is used than when that flag/constant is NOT used. Thus, this answer does not address the issue. But thanks for the effort ;-) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 13, 2014 Moderators Share Posted February 13, 2014 (edited) mdp716,The difference in appearance is a Windows "feature" to distinguish between "editable" and "read-only" inputs. Changing this would involve changes to all such controls within Windows - even if it were possible, do you really want to go that far? M23Edit:How about this as an alternative? expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <ListBoxConstants.au3> $hGUI = GUICreate("Example", 500, 500) GUICtrlCreateLabel("", 10, 10, 200, 20) GUICtrlSetBkColor(-1, 0) $cFalseInput = GUICtrlCreateLabel("", 11, 11, 198, 18, $SS_CENTERIMAGE) ; You can colour this label as you wish $cButton_Drop = GUICtrlCreateButton("v", 209, 9, 22, 22) GUISetState(@SW_SHOW, $hGUI) ; Create child GUI to hold list $hGUI_Child = GUICreate("Child", 200, 200, 10, 30, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) $cList = GUICtrlCreateList("", 0, 00, 200, 200) GUICtrlSetResizing(-1, $GUI_DOCKAUTO) ; List resizes with GUI GUISetState(@SW_HIDE, $hGUI_Child) $cList_Dummy = GUICtrlCreateDummy() _Fill_Combo() GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton_Drop GUISetState(@SW_SHOW, $hGUI_Child) Case $cList_Dummy GUICtrlSetData($cFalseInput, GUICtrlRead($cList)) GUISetState(@SW_HIDE, $hGUI_Child) EndSwitch WEnd Func _Fill_Combo() For $i = 0 To 99 $sData &= Chr(Random(65, 90, 1)) & Chr(Random(65, 90, 1)) & Chr(Random(65, 90, 1)) & Chr(Random(65, 90, 1)) & Chr(Random(65, 90, 1)) & "|" Next GUICtrlSetData($cList, $sData) EndFunc ;==>Keywords Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg If $lParam = GUICtrlGetHandle($cList) Then ; If item selected If BitShift($wParam, 16) = $LBN_SELCHANGE Then GUICtrlSendToDummy($cList_Dummy) ConsoleWrite("Click Detected" & @CRLF) EndIf EndIf EndFunc ;==>_WM_COMMAND Edited February 13, 2014 by Melba23 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...
mdp716 Posted February 13, 2014 Author Share Posted February 13, 2014 OK, so I am understanding that it is not as easy as I hoped it would be due to it being default windows behavior. As for setting the colors on labels, I do not have a problem with that - this appears to be specific to the Combo control as near as I can tell as I have never had an issue with providing colors for labels or most other controls that I have used up to this point. Thanks for your help. Guess I will just live with having to choose either being able to pick the color or pick it being non-editable. mdp716, The difference in appearance is a Windows "feature" to distinguish between "editable" and "read-only" inputs. Changing this would involve changes to all such controls within Windows - even if it were possible, do you really want to go that far? M23 Edit: How about this as an alternative? expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <ListBoxConstants.au3> $hGUI = GUICreate("Example", 500, 500) GUICtrlCreateLabel("", 10, 10, 200, 20) GUICtrlSetBkColor(-1, 0) $cFalseInput = GUICtrlCreateLabel("", 11, 11, 198, 18, $SS_CENTERIMAGE) ; You can colour this label as you wish $cButton_Drop = GUICtrlCreateButton("v", 209, 9, 22, 22) GUISetState(@SW_SHOW, $hGUI) ; Create child GUI to hold list $hGUI_Child = GUICreate("Child", 200, 200, 10, 30, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) $cList = GUICtrlCreateList("", 0, 00, 200, 200) GUICtrlSetResizing(-1, $GUI_DOCKAUTO) ; List resizes with GUI GUISetState(@SW_HIDE, $hGUI_Child) $cList_Dummy = GUICtrlCreateDummy() _Fill_Combo() GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton_Drop GUISetState(@SW_SHOW, $hGUI_Child) Case $cList_Dummy GUICtrlSetData($cFalseInput, GUICtrlRead($cList)) GUISetState(@SW_HIDE, $hGUI_Child) EndSwitch WEnd Func _Fill_Combo() For $i = 0 To 99 $sData &= Chr(Random(65, 90, 1)) & Chr(Random(65, 90, 1)) & Chr(Random(65, 90, 1)) & Chr(Random(65, 90, 1)) & Chr(Random(65, 90, 1)) & "|" Next GUICtrlSetData($cList, $sData) EndFunc ;==>Keywords Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg If $lParam = GUICtrlGetHandle($cList) Then ; If item selected If BitShift($wParam, 16) = $LBN_SELCHANGE Then GUICtrlSendToDummy($cList_Dummy) ConsoleWrite("Click Detected" & @CRLF) EndIf EndIf EndFunc ;==>_WM_COMMAND 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