Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

RichEdit - FindDialog - Scroll-Down - Scroll-Across

Posted on 2006-05-23
6
Medium Priority
?
551 Views
Last Modified: 2010-04-05
Hello All;

   I found the following code that will make the TRichEdit [Scroll-Down] while doing a Search
[ RichEdit.Perform(EM_SCROLL,SB_LINEDOWN,0); ]

But now, I need to find something that will make the TRichEdit [Scroll-Across] while doing a Search?

Any idea's on this one?

Thanks All;

Carrzkiss
0
Comment
Question by:Wayne Barron
  • 4
  • 2
6 Comments
 
LVL 26

Expert Comment

by:Russell Libby
ID: 16744546

If the cursor (SelStart) is set to the desired position to be scrolled into view, you can perform the following:

  RichEdit.Perform(EM_SCROLLCARET, 0, 0);

Regards,
Russell
0
 
LVL 31

Author Comment

by:Wayne Barron
ID: 16744755
tried that.
This is what I am using:

FindDialog1.Position := Point(RichEdit1.Left + RichEdit1.Width, RichEdit1.Top);
FindDialog1.Execute;
FindDialog1.Perform(EM_SCROLL,SB_LINEDOWN,0);
FindDialog1.Perform(EM_SCROLLCARET,0,0);
RichEdit1.SelStart := RichEdit1.GetTextLen;


I have tried to put the: RichEdit.Perform(EM_SCROLLCARET, 0, 0);
At the bottom line, but still no go.

Can the    ,0,0
Be changed? if so, could you explain what each of them will do?
0
 
LVL 26

Expert Comment

by:Russell Libby
ID: 16745754

Why are you having the **dialog** perform the EM_SCROLL and EM_SCROLLCARET messages? The RichEdit needs to perform the messages. And why are you setting the SelStart to the full text text len of the control, vs the text that you are searching for?

Russell
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 26

Accepted Solution

by:
Russell Libby earned 1000 total points
ID: 16746198
Eg:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ComCtrls;

type
  TForm1 = class(TForm)
    RichEdit1: TRichEdit;
    Button1: TButton;
    FindDialog1: TFindDialog;
    procedure FindDialog1Find(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation
{$R *.DFM}

procedure TForm1.FindDialog1Find(Sender: TObject);
var  FoundAt:       LongInt;
     StartPos,
     ToEnd:         Integer;
begin
  with RichEdit1 do
  begin
     if SelLength <> 0 then
        StartPos := SelStart + SelLength
    else
        StartPos := 0;
     ToEnd := Length(Text) - StartPos;
     FoundAt := FindText(FindDialog1.FindText, StartPos, ToEnd, []);
     if FoundAt <> -1 then
     begin
        SetFocus;
        SelStart := FoundAt;
        SelLength := Length(FindDialog1.FindText);
        Perform(EM_SCROLLCARET, 0, 0);
     end;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  FindDialog1.Position := Point(RichEdit1.Left + RichEdit1.Width, RichEdit1.Top);
  FindDialog1.Execute;
end;

end.

-- form dfm ---
object Form1: TForm1
  Left = 284
  Top = 114
  Width = 513
  Height = 519
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object RichEdit1: TRichEdit
    Left = 12
    Top = 60
    Width = 421
    Height = 397
    Lines.Strings = (
      'RichEdit1')
    ScrollBars = ssBoth
    TabOrder = 0
    WordWrap = False
  end
  object Button1: TButton
    Left = 12
    Top = 28
    Width = 75
    Height = 25
    Caption = 'Button1'
    TabOrder = 1
    OnClick = Button1Click
  end
  object FindDialog1: TFindDialog
    Options = [frDown, frFindNext]
    OnFind = FindDialog1Find
    Left = 112
    Top = 24
  end
end

0
 
LVL 31

Author Comment

by:Wayne Barron
ID: 16746840
That works perfect.
I just have to find out "Why" it is not working in my project?
Very strang, there is nothing different about the the 2-RichEdits.
But your code with scroll to the right,
Mine will not?

Just going to have to do some checking and find out what is going on.

----
As for the code that I supplied that I was using.
That is how I found it.
Should have done some more research on the code before using it.

Thanks Russell. (Added another [125] to the total)
Wayne
0
 
LVL 26

Expert Comment

by:Russell Libby
ID: 16747236
Anytime Wayne, thanks much ;-)

Regards,
Russell
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Loops Section Overview
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question