Sign in to follow this  
Followers 0
kaiks

"Select all" for Edit control?

5 posts in this topic

Well... I've made an edit control. It works all good as I want except that I can't use CTRL+a hotkey to select all and it really annoys me sometimes.

Is there any way to "enable" this hotkey? Like control style or whatever... not by hotkeyset of course...

I know I could do this with richedit control but there's no such implemented yet

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Well... I've made an edit control. It works all good as I want except that I can't use CTRL+a hotkey to select all and it really annoys me sometimes.

Is there any way to "enable" this hotkey? Like control style or whatever... not by hotkeyset of course...

I know I could do this with richedit control but there's no such implemented yet

Here's more than you asked for, didn't feel like changing my scrap that much, just added the hotkey to it.

Edit: Far as I know, there is no magic built in HotKey to enable.

#include <GuiConstants.au3>
#include <GuiEdit.au3>

Global Const $WM_COMMAND = 0x0111
Global Const $EN_CHANGE = 0x300
Global Const $EN_SETFOCUS = 0x100
Global Const $EN_KILLFOCUS = 0x200
Global Const $DebugIt = 1
Global $changed = 0
HotKeySet("^a","_SelectAll")

GUICreate("My GUI combo")  ; will create a dialog box that when displayed is centered

$edit = GUICtrlCreateEdit("This is a test, this is only a test", 80, 50, 270, 170) ; create first item
$btn = GUICtrlCreateButton("Ok", 40, 230, 60, 20)
GUISetState()
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $changed = 1
            ;----------------------------------------------------------------------------------------------
            If $DebugIt Then _DebugPrint("Edit Changed:" & GUICtrlRead($edit))
            If $DebugIt Then _DebugPrint(StringLen(GUICtrlRead($edit)))
            ;----------------------------------------------------------------------------------------------
            $changed = 0
    EndSelect
WEnd

Func _SelectAll()
    _GUICtrlEditSetSel($edit, 0, -1)
EndFunc

Func _Edit_Changed()
    $changed = 1
EndFunc   ;==>_Edit_Changed

Func _Edit_GotFocus()
    ;----------------------------------------------------------------------------------------------
    If $DebugIt Then _DebugPrint("Edit Got Focus")
    ;----------------------------------------------------------------------------------------------
EndFunc   ;==>_Edit_GotFocus

Func _Edit_LostFocus()
    ;----------------------------------------------------------------------------------------------
    If $DebugIt Then _DebugPrint("Edit Lost Focus")
    ;----------------------------------------------------------------------------------------------
EndFunc   ;==>_Edit_LostFocus

Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
    Local $nNotifyCode = _HiWord($wParam)
    Local $nID = _LoWord($wParam)
    Local $hCtrl = $lParam
    
    Switch $nID
        Case $edit
            Switch $nNotifyCode
                Case $EN_CHANGE
                    _Edit_Changed()
                Case $EN_SETFOCUS
                    _Edit_GotFocus()
                Case $EN_KILLFOCUS
                    _Edit_LostFocus()
            EndSwitch
    EndSwitch
    ; Proceed the default Autoit3 internal message commands.
    ; You also can complete let the line out.
    ; !!! But only 'Return' (without any value) will not proceed
    ; the default Autoit3-message in the future !!!
    Return $GUI_RUNDEFMSG
EndFunc   ;==>MY_WM_COMMAND

Func _DebugPrint($s_text)
    $s_text = StringReplace($s_text, @LF, @LF & "-->")
    ConsoleWrite("!===========================================================" & @LF & _
            "+===========================================================" & @LF & _
            "-->" & $s_text & @LF & _
            "+===========================================================" & @LF)
EndFunc   ;==>_DebugPrint

Func _HiWord($x)
    Return BitShift($x, 16)
EndFunc   ;==>_HiWord

Func _LoWord($x)
    Return BitAND($x, 0xFFFF)
EndFunc   ;==>_LoWord
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

I figured every edit control handled things like Ctrl+A itself. Are they just accelerator keys?

Share this post


Link to post
Share on other sites

Uh...

Thanks for that post gafrost, however that's not what I'd like, as I mentioned

not by hotkeyset of course...

in my first post.

I don't like it because I'd like my program to be running in background and ^a set as hotkey captures ctrl+a from other window... so that doesn't solve my problems ;)

And perhaps I could do that with something like "if the gui window is active, select all from focused control, else send ctrl^a", but still, I'd prefer it as it works in richedit...

Well, I guess I'll wait for your richedit UDF :whistle:

Unless someone got other idea...

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