XGamerGuide Posted May 29, 2021 Posted May 29, 2021 I'm trying to assign a faint text in the background to an input field that disappears after the input has started. This should have a certain color such as gray.
TheXman Posted May 29, 2021 Posted May 29, 2021 Like _GUICtrlEdit_SetCueBanner()? FrancescoDiMuro and Musashi 2 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
Musashi Posted May 29, 2021 Posted May 29, 2021 (edited) 11 hours ago, XGamerGuide said: I'm trying to assign a faint text in the background to an input field that disappears after the input has started. _GUICtrlEdit_SetCueBanner is a good solution, as long as you don't want to set the focus to this 'special' input field already after starting the script (the fainted text would disappear immediately). In case another control gets the focus on start, then the function mentioned by @TheXman fits perfectly. EDIT : (Revision, according to @Melba23 's note) : The function mentioned by @TheXman fits perfectly ! (Slightly modified example from the help) #include <GUIConstantsEx.au3> #include <GuiEdit.au3> Example() Func Example() Local $hGUI = GUICreate('Example', 300, 150) GUISetFont(9, 400, 0, 'Segoe UI') Local $idUsername = GUICtrlCreateInput('', 10, 10, 200, 25) _GUICtrlEdit_SetCueBanner($idUsername, "Enter Username...", True) Local $idPassword = GUICtrlCreateInput('', 10, 40, 200, 25) _GUICtrlEdit_SetCueBanner($idPassword, "Enter Password...", True) Local $idButton_Close = GUICtrlCreateButton("Close", 210, 120, 85, 25) GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idButton_Close ExitLoop EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>Example Edited May 29, 2021 by Musashi "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
Moderators Melba23 Posted May 29, 2021 Moderators Posted May 29, 2021 Musashi, Quote as long as you don't want to set the focus to this 'special' input field already after starting the script (the fainted text would disappear immediately) No so - you can set the $bOnFocus flag to keep the cuebanner visible on focus: #include <GUIConstantsEx.au3> #include <GUIEdit.au3> $hGUI = GUICreate("Test", 500, 500) $cInput1 = GUICtrlCreateInput("", 10, 10, 200, 20) _GUICtrlEdit_SetCueBanner($cInput1, "Visible on focus", True) $cInput2 = GUICtrlCreateInput("", 10, 100, 200, 20) _GUICtrlEdit_SetCueBanner($cInput2, "Vanish on focus") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd M23 Musashi and Skysnake 1 1 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
Musashi Posted May 29, 2021 Posted May 29, 2021 3 hours ago, Melba23 said: No so - you can set the $bOnFocus flag to keep the cuebanner visible on focus: Yep , that's what it says in the help, almost impossible to overlook (except by me) . TheXman and JockoDundee 1 1 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
JockoDundee Posted May 29, 2021 Posted May 29, 2021 5 hours ago, Musashi said: almost impossible to overlook (except by me) Next time, $bOnFocus Musashi 1 Code hard, but don’t hard code...
XGamerGuide Posted May 30, 2021 Author Posted May 30, 2021 Quote Like _GUICtrlEdit_SetCueBanner()? Thanks that works
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