GetFocus event
Description
Occurs just before the control receives focus (before it is
selected and becomes active).
GetFocus applies to all controls
Event ID
Event ID |
Objects |
---|---|
pbm_bnsetfocus |
CheckBox, CommandButton, Graph, OLE, |
pbm_cbnsetfocus |
DropDownListBox, DropDownPictureListBox |
pbm_dwnsetfocus |
DataWindow |
pbm_ensetfocus |
SingleLineEdit, EditMask, MultiLineEdit, |
pbm_lbnsetfocus |
ListBox, PictureListBox |
pbm_lvnsetfocus |
ListView |
pbm_rensetfocus |
RichTextEdit |
pbm_sbnsetfocus |
HScrollBar, HTrackBar, VScrollBar, VTrackBar |
pbm_setfocus |
HProgressBar, VProgressBar, DatePicker, MonthCalendar, |
pbm_tcnsetfocus |
Tab |
pbm_tvnsetfocus |
TreeView |
Parameters
None
Return Values
Long. Return code choices (specified
in a RETURN statement):
-
0 Continue
processing
Examples
This example in a SingleLineEdit control’s GetFocus
event selects the text in the control when the user tabs to it:
1 |
This.SelectText(1, Len(This.Text)) |
In Example 1, when the user clicks the SingleLineEdit rather
than tabbing to it, the control gets focus and the text is highlighted,
but then the click deselects the text. If you define a user event
that selects the text and then post that event in the GetFocus event,
the highlighting works when the user both tabs and clicks. This
code is in the GetFocus event:
1 |
This. EVENT POST ue_select( ) |
This code is in the ue_select user event:
1 |
This.SelectText(1, Len(This.Text)) |