DECLARE FUNCTION SetFocus LIB "USER32" ALIAS "SetFocus" (HWnd AS LONG) AS LONG
DECLARE SUB Search
CREATE Form AS QFORM
CAPTION = "Form"
Width = 320
Height = 200
Center
CREATE Rich AS QRICHEDIT
Left = 60
Top = 31
Height = 50
AddStrings "noise one noise"
AddStrings "noise two noise"
AddStrings "noise three noise"
SelStart = 0
Scrollbars = 3
HideSelection = 1
END CREATE
CREATE Poor AS QEDIT
Left = 90
Top = 90
Text = "Type word then ENTER"
END CREATE
CREATE Invisible AS QBUTTON
Top = 120
Left = 110
CAPTION = "Search"
Default = 1
OnClick = Search
END CREATE
SHOWMODAL
END CREATE
SUB Search
DEFLNG start
where = INSTR(start,Rich.Text,Poor.Text)
IF where <> 0 THEN
SetFocus(Rich.Handle)
Rich.SelStart = where - 1
Rich.SelLength = LEN(Poor.Text)
start = where + LEN(Poor.Text)
ELSE
SHOWMESSAGE "No more instances of " + Poor.Text
start = 0
END IF
END SUB
|