Sign in to follow this  
Followers 0
momar33

UpDown Input with No Highlighting

7 posts in this topic

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.

Share this post


Link to post
Share on other sites



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). :huh2:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

momar33,

I looked into this a while ago and found that you needed to subclass the input control to block the $EM_SETSEL message. :alien:

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). :huh2:

M23

this would be great for me ;) if you can post it it will help me... i recently start using the windows messages to catch events...

Share this post


Link to post
Share on other sites

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. :ph34r:

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: ;)

#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   ;==>_WndProc

Now 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. :huh2:

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. :alien:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

@melba23

mmmh maybe you´re right

This is a bit more complicated than "catching events"

i will continue whit my "catching events" learning for now Edited by monoscout999

Share this post


Link to post
Share on other sites

monoscout999,

It is not that difficult - even I can do it! :huh2:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0