momar33 Posted May 27, 2011 Posted May 27, 2011 When you create a simple UpDown down input the number in the input field is always highlighted as you press the up or down buttons. Is there a way to remove this highlighting? $ES_NOHIDESEL keeps the highlighting there when you click away from the input box. I want the opposite, never show the highlighting.
Moderators Melba23 Posted May 27, 2011 Moderators Posted May 27, 2011 momar33,I looked into this a while ago and found that you needed to subclass the input control to block the $EM_SETSEL message. This is not a trivial thing to do - but if you really want it I can try and reproduce the code I produced (it was never posted on the forum). 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
monoscout999 Posted May 27, 2011 Posted May 27, 2011 momar33,I looked into this a while ago and found that you needed to subclass the input control to block the $EM_SETSEL message. This is not a trivial thing to do - but if you really want it I can try and reproduce the code I produced (it was never posted on the forum). M23this would be great for me if you can post it it will help me... i recently start using the windows messages to catch events...
Moderators Melba23 Posted May 27, 2011 Moderators Posted May 27, 2011 monoscout999,This is a bit more complicated than "catching events" with GUIRegisterMsg. We are actually replacing the internal procedure that Windows uses to action the events. That is what subclassing means and it is not something to undertake lightly - if you do not do it right you can crash your system very easily. Believe me I did it often enough to my machine when I was learning how to subclass controls! Here is how to subclass input controls to prevent them being highlighted when focused: expandcollapse popup#include <GUIConstantsEx.au3> #include <Constants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <EditConstants.au3> ;Global subclass vars Global Const $GCL_WNDPROC = -24 Global $hNew_ControlProc = 0, $pOriginal_EditProc ; Must be run before any input controls are created _ControlGlobalSubclass() ; All subsequently created inputs will be subclassed - individual controls original wndproc cannot be restored ; Create GUI $hGUI = GUICreate("Subclassed Input Control without Highlight", 500, 210) $hInput = GUICtrlCreateInput("Example text", 10, 10, 80, 20) $hButton = GUICtrlCreateButton("Dummy", 10, 50, 80, 30) GUISetState() Sleep(2000) ; Remove initial HighLight from input GUICtrlSendMsg($hInput, 0xB1, 0, 0) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ; Must delete subclassed controls before freeing DLLCallbacks GUIDelete($hGUI) ; Now free DLLCallbacks - not strictly necessary, but "good idea" according to Help file DllCallbackFree($hNew_ControlProc) Exit EndSwitch WEnd Func _ControlGlobalSubclass() ; Check we have not done it already If $hNew_ControlProc <> 0 Then Return SetError(1, 0, 0) ; Create temp GUI Local $hGUITemp = GUICreate("", 1, 1, -10, -10) ; Create temporary edit Local $hEditTemp = GUICtrlGetHandle(GUICtrlCreateEdit("", -10, -10, 1, 1)) ; Create callback $hNew_ControlProc = DllCallbackRegister("_WndProc", "int", "hwnd;uint;wparam;lparam") Local $pCallbackPtr = DllCallbackGetPtr($hNew_ControlProc) ; Subclass Edit class - which means replace the original wndproc with our own $pOriginal_EditProc = DllCall("User32.dll", "dword", "SetClassLongW", "hwnd", $hEditTemp, "int", $GCL_WNDPROC, "ptr", $pCallbackPtr) $pOriginal_EditProc = $pOriginal_EditProc[0] ; Destroy temporary GUI GUIDelete($hGUITemp) Return SetError(0, 0, 1) EndFunc ;==>_ControlGlobalSubclass ; And this is the new wndproc which we set when we subclass Func _WndProc($hWnd, $iMsg, $wParam, $lParam) Switch _WinAPI_GetClassName($hWnd) Case "Edit" ; Intercept the SETSEL message If $iMsg = $EM_SETSEL And $lParam <> -1 Then ConsoleWrite("SETSEL msg intercepted" & @CRLF) Return 0 EndIf ; Pass other messages to original wndproc Return _WinAPI_CallWindowProc($pOriginal_EditProc, $hWnd, $iMsg, $wParam, $lParam) Case Else Return 0 EndSwitch EndFunc ;==>_WndProcNow if you use the TAB key to switch between the controls, you will see that the input content is no longer highlighted when it gets focus. If you want to see some more examples of subclassing, look at my NoFocusLines and GUIFrame UDFs. And if you have any questions, please ask and I will try to explain within teh limits of my own hobbyist knowledge. 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
monoscout999 Posted May 27, 2011 Posted May 27, 2011 (edited) @melba23mmmh maybe you´re right This is a bit more complicated than "catching events" i will continue whit my "catching events" learning for now Edited May 27, 2011 by monoscout999
Moderators Melba23 Posted May 27, 2011 Moderators Posted May 27, 2011 monoscout999,It is not that difficult - even I can do it! 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
momar33 Posted May 27, 2011 Author Posted May 27, 2011 Thanks for the Reply. I may deal with the highlighting for the sake of keeping the code simple, but this will definitely help should I choose to picky. Thanks again!
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