Jump to content

highlighting text under fucus


Recommended Posts

i would like to put focus on an inputbox (GUI) and NOT have the text highlighted when there is text in the inputbox,

i tried this twice, hoping it would offset it

GUICtrlSetState($input[7],$GUI_FOCUS)
    GUICtrlSetState($input[7],$GUI_FOCUS)

see? twice.

nope, that didnt work.

other than clicking on it.. is there another way?

be back later to see any responses. AFK!!! woohoo!

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

requires beta

#include <GUIConstants.au3>

;***************************
; need these
;***************************
Global Const $EM_GETSEL = 0xB0
Global Const $EM_SETSEL = 0xB1
Global Const $EC_ERR = -1
;***************************

GUICreate(" My GUI input acceptfile", 320,120, @DesktopWidth/2-160, @DesktopHeight/2-45, -1, 0x00000018); WS_EX_ACCEPTFILES
$file = GUICtrlCreateInput ( "this is a test", 10,  5, 300, 20)
GUICtrlSetState(-1,$GUI_ACCEPTFILES)
$input = GUICtrlCreateInput ("this is a test", 10,  35, 300, 20); will not accept drag&drop files
$btn = GUICtrlCreateButton ("Ok", 40,  75, 60, 20)
GUISetState () 

;***************************
GUICtrlSetState($file,$GUI_FOCUS)
; put a sleep so you can see it happen
Sleep ( 2000 )
_UnSelInputText($file)
Sleep ( 2000 )

GUICtrlSetState($input,$GUI_FOCUS)
; put a sleep so you can see it happen
Sleep ( 2000 )
_UnSelInputText($input)
;***************************
$msg = 0
While $msg <> $GUI_EVENT_CLOSE
       $msg = GUIGetMsg()
       Select
           Case $msg = $btn
               exitloop
       EndSelect
Wend

MsgBox (4096, "drag drop file", GUICtrlRead($file))

;***************************
; function to get selected length
; returns array
; array[0] length of array
; array[1] beginning of selected text
; array[2] end of selected text
;***************************
Func _GUICtrlInputGetSel($h_input)
   Local $ptr1 = "int", $ptr2 = "int"
   Local $wparam = DllStructCreate ($ptr1)
    Local $a_sel
   If @error Then
    ;MsgBox(0, "", "Error in DllStructCreate " & @error);
      Return $EC_ERR
   EndIf
   Local $lparam = DllStructCreate ($ptr2)
   If @error Then
    ;MsgBox(0, "", "Error in DllStructCreate " & @error);
      DllStructDelete ($wparam)
      Return $EC_ERR
   EndIf
   Local $ret = GUICtrlSendMsg($h_input, $EM_GETSEL, DllStructGetPtr ($wparam), DllStructGetPtr ($lparam))
   If ($ret == -1) Then
      DllStructDelete ($wparam)
      DllStructDelete ($lparam)
      Return $EC_ERR
   EndIf
   $a_sel = StringSplit(DllStructGetData ($wparam, 1) & "," & DllStructGetData ($lparam, 1), ",")
   DllStructDelete ($wparam)
   DllStructDelete ($lparam)
   Return $a_sel
EndFunc 

Func _UnSelInputText($h_input)
    Dim $sel
    $sel = _GUICtrlInputGetSel($h_input)
    GUICtrlSendMsg($h_input, $EM_SETSEL, $sel[2], $sel[2])
EndFunc
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.

 

Link to comment
Share on other sites

thanks man.

now to dissect....

also, in case anyone was wondering, in the topic title, i typed "fucus"

i meant "focus" but now that i think about it more, fucus sounds nice.

hardee har har!

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

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