newman     VBWeb     VBSource     Portfolio    

SelectActiveText

REPLACE

TOP TEN

SendEditMsg
Selects the contents of a text box if the left mouse button is not down. Intended to be called from the GetFocus event.
Syntax
SelectActiveText
Call SelectActiveText


Remarks
This instruction will not select the contents if the user clicks on the text box. It can also be used on ComboBoxes with a Style of zero - Dropdown Combo.

Example
	Sub Text1_GetFocus ()
	    Call SelectActiveText
	End Sub
	

Source
	Sub SelectActiveText()
	    Dim ctrl As Control
	    Const KEY_LBUTTON = &H1
	
	    On Error GoTo SelectActiveTextTrap
	    Set ctrl = Screen.ActiveControl
	    If IsLButtonDown() Then
	        ctrl.SelLength = 0
	    Else
	        ctrl.SelStart = 0
	        ctrl.SelLength = Len(ctrl.Text)
	    End If
	SelectActiveTextTrap:
	    Exit Sub
	End Sub
	


Feedback Comments
Return Address (if you want a reply)


Copyright 1997 NEWMAN Services Corp. All rights reserved.
973-228-5753 pres@newmanservices.com
DECONSTRUCT THIS PAGE