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

Thread: Help with RichEdit Control

  1. #11
    Quote Originally Posted by Petr Schreiber View Post
    Hi Phil,
    I am really happy it works for you!,
    Petr
    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!!!



    YES

    '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
    laststr=""
    occurrence=1
    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
    occurrence=1
    End If
    
    
    'copy searchstr into laststr
    laststr=searchstr
    
    
    '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"
    laststr=""
    occurrence=1
    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
    Else
    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
    
    catventure/Phil.
    Last edited by catventure; 17-12-2020 at 13:25.
    http://tab.thinbasic.com - Home Of The ThinBasic Adventure Builder Project. (Interactive Fiction/Text Adventure Maker)

  2. #12
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Superb, I am really happy


    P
    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

Members who have read this thread: 0

There are no members to list at the moment.

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
  •