Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: Help with RichEdit Control

  1. #11
    Senior Member catventure's Avatar
    Join Date
    Oct 2005
    Blog Entries
    Rep Power
    Quote Originally Posted by Petr Schreiber View Post
    Hi Phil,
    I am really happy it works for you!,
    Hooray - it works!!! I was so close before but Petr's example has helped me a great deal to get it to work.
    It was even easier than I had thought
    Here is the video of it WORKING GREAT!!!


    'for editor script coding control find buttons
    Global laststr As String
    Global occurrence As Long Value=1 
    'findResp() is called when user presses [FindText] button
    '627 - editbox control for search text
    '620 - Richedit control
    'hDlg - window containing richedit control
    Function findResp() As Long
    Local x, linebreaks As Long
    'get text from find textbox
    Control Get Text hDlg, 627 To searchstr 
    'if no text typed by user
    If searchstr="" Then
    MsgBox hdlg, "Please type in a string to search for", %MB_ICONWARNING, "Information"
    Exit Function
    End If
    'check if text same as last time
    If laststr<>searchstr Then
    End If
    'copy searchstr into laststr
    'try and find position and occurrence of text 
    x=InStr(response, searchstr, occurrence)
    ' if string not found...
    If x=0 Then
    MsgBox hdlg, "Could Not Find"+$CRLF+$DQ+searchstr+$DQ, %MB_ICONASTERISK,"Information"
    Exit Function
    End If
    'count number of linebreaks from start to position
    linebreaks=ParseCount(Mid$(response,1,x), Any $LF)
    'subtract number of lnebreaks from position
    x =(x-linebreaks)
    'highlight occurence of found string
    If x=1 Then
    Control Send hdlg,620, %EM_SETSEL, x-1, x+Len(searchstr)-1
    Control Send hdlg,620, %EM_SETSEL, x, x+Len(searchstr)
    End If
    Control Set Focus hdlg, 620
    'In case user tries to find next occurrence of same string
    Incr occurrence
    End Function
    ' When exiting Window dialog following vars are reset:
    ' laststr=""
    ' occurrence=1
    Last edited by catventure; 17-12-2020 at 13:25. - Home Of The ThinBasic Adventure Builder Project. (Interactive Fiction/Text Adventure Maker)

  2. #12
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Brno - Czech Republic
    Blog Entries
    Rep Power
    Superb, I am really happy

    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

Page 2 of 2 FirstFirst 12

Similar Threads

  1. RichEdit
    By martin in forum thinBasic General
    Replies: 4
    Last Post: 17-10-2011, 17:57
  2. RichEdit background control color
    By ErosOlmi in forum Sources, Templates, Code Snippets, Tips and Tricks, Do you know ...
    Replies: 2
    Last Post: 21-09-2006, 08:31
  3. RichEdit - RTF. We need some testers
    By ErosOlmi in forum Announcements
    Replies: 2
    Last Post: 19-09-2006, 00:23
  4. RichEdit AutoScroll?
    By catventure in forum thinBasic General
    Replies: 13
    Last Post: 20-01-2006, 16:40

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts