Indy 9 and IdNotify, is it working with RichEdit ?

Giganews Newsgroups
Subject: Indy 9 and IdNotify, is it working with RichEdit ?
Posted by:  Jouko Puustinen (jouko.puustin…@pp.inet.fi)
Date: Wed, 10 Mar 2004

Hello

Can you help me ...

I think that IdNotify messages does not function correctly if I use Delphi's
TRichEdit component.
If I use only TMemo component everything is fine.

But I need some function what are not in TMemo but in TRichEdit they are...

In procedure KirjoitaInfo there is actual writing to memo or RichEdit. If I
use only memo and not RichEdit
IdNotify message function OK but if I use RichEdit then there happens
infinite loop ...

This call is made in separate thread actually ClientThread (this is done
manually)
TOmaInfoMsg.InfoMsg('Some info ...', '', 1);

With memo I get one text to memo -> Some info ...

With RichEdit I get same text as above but it will come again and again
as long as program is running ...

Is my IdNotify type made some how wrong ? I have looked IdNotify demo
and I think that this is made excactly the same way.

My code is like this:

unit MainForm;

interface

uses
  Windows, Messages, Graphics, Controls, Forms, ComCtrls, StdCtrls,
  ExtCtrls, ToolWin, ImgList, Spin, Menus, SysUtils, Classes, IdGlobal,
  IdBaseComponent, IdComponent, IdTCPServer, IdTCPClient, IdThread,
IdThreadMgr,
  IdThreadMgrDefault, IniFiles, IdTCPConnection, SyncObjs, Dialogs,
  ClientThread, ServersThread, LokiThread, IdUDPBase, IdUDPServer,
  IdUDPClient, IdSocketHandle, IdSync;

type
  TOmaInfoMsg = class(TIdNotify)
  private
    FInfoNro : Integer;
    FMsg,
    FMsg2    : string;
    procedure DoNotify; override;
  public
    class procedure InfoMsg(const AMsg, AMsg2 : string; const iMemo :
Integer);
  end;

  TServerMainForm = class(TForm)
    Label19: TLabel;
    Label23: TLabel;
    Memo2: TMemo;
    RichEdit1: TRichEdit;
    Memo1: TMemo;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    procedure KirjoitaInfo(sRivi, sRivi2 : string; iMemo: Byte);
  public
    { Public declarations }
  end;

{ TOmaInfoMsg }

class procedure TOmaInfoMsg.InfoMsg(const AMsg, AMsg2 : string; const iMemo
: Integer);
begin
  with Create do begin
    FInfoNro := iMemo;
    FMsg := AMsg;
    FMsg2 := AMsg2;
    Notify;
  end;
end;

procedure TOmaInfoMsg.DoNotify;
begin
  ServerMainForm.KirjoitaInfo(FMsg, FMsg2, FInfoNro);
end;

procedure TServerMainForm.KirjoitaInfo(sRivi, sRivi2 : string; iMemo :
Byte);
begin
  case iMemo of
    1 : Begin      // Info debuggi ikkunaan
          if (Memo1.Lines.Count > iMaxLineCount) then
            Memo1.Lines.Clear;
          Memo1.Lines.Add(sRivi);
          Label19.Caption := 'Debug=' + IntToStr(Memo1.Lines.Count);
{          if (RichEdit1.Lines.Count > iMaxLineCount) then
            RichEdit1.Lines.Clear;
          RichEdit1.Lines.Add(sRivi);
          Label19.Caption := 'Debug=' + IntToStr(RichEdit1.Lines.Count);  }
        end;
    2 : Begin      // Info hälytysikkunaan
          if (Memo2.Lines.Count > iMaxLineCount) then
            Memo2.Lines.Clear;
          Memo2.Lines.Add(sRivi);
          Label23.Caption := 'Hälytys debug=' + IntToStr(Memo2.Lines.Count);
{          if (RichEdit2.Lines.Count > iMaxLineCount) then
            RichEdit2.Lines.Clear;
          RichEdit2.Lines.Add(sRivi);
          Label23.Caption := 'Hälytys debug=' +
IntToStr(RichEdit2.Lines.Count); }
        end;
  end;
end;

Replies