JohnMC Posted May 24, 2009 Share Posted May 24, 2009 hi all!, i cant seem find any thing about this and it would really save the day if its possible.ive see edit controls in MANY programs that have a gray italic text in the box when the box isnt in focus, usualy is some sort of title/description like "User Name" https://johnscs.com Link to comment Share on other sites More sharing options...
martin Posted May 24, 2009 Share Posted May 24, 2009 hi all!, i cant seem find any thing about this and it would really save the day if its possible.ive see edit controls in MANY programs that have a gray italic text in the box when the box isnt in focus, usualy is some sort of title/description like "User Name"You can set the font in an edit with GuiCtrlSetFont. You can set the font colour with GuiCtrlSetColor.You can apply the relevant changes when the edit looses or gains focus.When an edit looses focus it sends a $EN_KILLFOCUS notification message using $WM_COMMAND, and when it gains focus the notification is $EN_SETFOCUS, so you would need to register the $WM_COMMAND message.You can read about the notifications here.See if you can make something of it and if you get stuck ask again. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 24, 2009 Moderators Share Posted May 24, 2009 JohnMC, Another way to do it:#include <GUIConstantsEx.au3> #include <WinAPI.au3> Global $aFocus[2][2] = [["", False], ["", False]] $hGUI = GUICreate("Test", 500, 500) $hInput_1 = GUICtrlCreateInput("Username", 10, 10, 480, 100) GUICtrlSetColor(-1, 0xC4C4C4) $hInput_2 = GUICtrlCreateInput("Password", 10, 120, 480, 100) GUICtrlSetColor(-1, 0xC4C4C4) $hButton = GUICtrlCreateButton("Exit", 10, 250, 80, 30) GUISetState() ControlFocus("Test", "", $hButton) For $i = 0 To 1 $aFocus[$i][0] = _WinAPI_GetClassName(ControlGetHandle("Test", "", $hInput_1 + $i)) & ($i + 1) Next While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $hButton Exit EndSwitch $sFocussed = ControlGetFocus("Test", "") For $i = 0 To 1 If $sFocussed = $aFocus[$i][0] And $aFocus[$i][1] = False Then $sControlID = $hInput_1 + $i GUICtrlSetData($sControlID, "") GUICtrlSetColor($sControlID, 0x000000) $aFocus[$i][1] = True EndIf Next WEnd Though martin's method would be more elegant. ;-) M23 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...
JohnMC Posted May 24, 2009 Author Share Posted May 24, 2009 Boths great answers, im about to use the second way right now just because it works for what i need, but knowing about the other get focus way is good to know and ill probably use it in the future, im surprised its not built in to get the focus state.. thank you both! https://johnscs.com Link to comment Share on other sites More sharing options...
martin Posted May 24, 2009 Share Posted May 24, 2009 Boths great answers, im about to use the second way right now just because it works for what i need, but knowing about the other get focus way is good to know and ill probably use it in the future, im surprised its not built in to get the focus state.. thank you both! For the record here's what I was thinking of. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> Global $oMyError Local $myedit, $myedit2, $msg $gui = GUICreate("My GUI edit"); will create a dialog box that when displayed is centered GUISetFont(9) $myedit1 = GUICtrlCreateEdit("First line" & @CRLF, 176, 32, 121, 97, $ES_AUTOVSCROLL + $WS_VSCROLL) $myedit2 = GUICtrlCreateEdit("First line" & @CRLF, 176, 150, 121, 97, $ES_AUTOVSCROLL + $WS_VSCROLL) GUICtrlSetFont($myedit2, 9, 400, 2) GUICtrlSetColor($myedit2, 0x222222) GUISetState() Send("{END}") GUIRegisterMsg($WM_COMMAND, "_MY_WM_COMMANDs") GUICtrlSetData($myedit1, "Second line", 1) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete() Func _MY_WM_COMMANDs($hWnd, $iMsg, $wParam, $lParam) Local $notif = BitAND($wParam, 0xFFFF0000) / 0x10000 Local $ID = BitAnd($wParam,0xFFFF) Switch $ID;lParam Case $myedit1;ControlGetHandle($gui, "", $myedit1) If $notif = $EN_SETFOCUS Then GUICtrlSetFont($myedit1, 9, 400, 0) GUICtrlSetColor($myedit1, 0) EndIf If $notif = $EN_KILLFOCUS Then GUICtrlSetFont($myedit1, 9, 400, 2) GUICtrlSetColor($myedit1, 0x222222) EndIf Case $myedit2;ControlGetHandle($gui, "", $myedit2) If $notif = $EN_SETFOCUS Then GUICtrlSetFont($myedit2, 9, 400, 0) GUICtrlSetColor($myedit2, 0) EndIf If $notif = $EN_KILLFOCUS Then GUICtrlSetFont($myedit2, 9, 400, 2) GUICtrlSetColor($myedit2, 0x222222) EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_MY_WM_COMMANDs Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. 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