Jump to content

Edit selection issue on gaining focus


Recommended Posts

Does anyone know how to make an edit or input control that does NOT select all the text within it once the GUI that contains that control gains focus? Just like notepads edit control.

If you don't know what i mean or what i'm talking about, create a GUI with an edit control, then place some text in there.

Once you've done that, click on another window, then click somewhere outside the edit control of the GUI you've just created.

You should notice that all the text within your edit control has been selected.

That is what i want to stop happening once the window containing that edit control gains focus.

If anyone could shed some light on this issue it would be much appreciated! :D

Edited by SxyfrG

My scripts:AppLauncherTRAY - Awesome app launcher that runs from the system tray NEW VERSION! | Run Length Encoding - VERY simple compression in pure autoit | Simple Minesweeper Game - Fun little game :)My website

Link to comment
Share on other sites

Hi! Try this:

#include <GUIConstants.au3>

$hGUI = GUICreate("Test GUI", 300, 200)

$hEdit = GUICtrlCreateEdit("Hello world!", 10, 10, 280, 180)

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    Local $IdFrom = BitAND($wParam, 0xFFFF)
    Local $iCode  = BitShift($wParam, 16)
    
    Switch $IdFrom
        Case $hEdit
            Switch $iCode
                Case $EN_SETFOCUS
                    Return 1
            EndSwitch
    EndSwitch
    
    Return $GUI_RUNDEFMSG
EndFunc
:D Edited by rasim
Link to comment
Share on other sites

Wow! Perfect!

Thanks Rasim, EXACTLY what i was looking for!

*EDIT*

Just so i know, what exactly does the WM_COMMAND function do, intercept the normal function call to select all the text?

Edited by SxyfrG

My scripts:AppLauncherTRAY - Awesome app launcher that runs from the system tray NEW VERSION! | Run Length Encoding - VERY simple compression in pure autoit | Simple Minesweeper Game - Fun little game :)My website

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...