Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > OOP
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 01-08-2015
joseprad joseprad is offline
Miembro
 
Registrado: oct 2006
Posts: 36
Poder: 0
joseprad Va por buen camino
Creacion de componente

Hola amigos:

Estoy intentando crear un componente TRichEdit con un corrector ortografico basado en Hunspell. De momento funciona correctamente y me marca en rojo las palabras incorrectas.
Al hacer clic sobre la palabra desearía crear un panel para poder, mediante un memo visulizar las palabras correctas.
Pero no se como hacerlo, he conseguido crear un panel pero dentro del RichEdit y claro yo necesito que se cree fuera.
Adjunto el código del componente por si alguien puede ayudarme.
Código Delphi [-]
type
  TRichDic = class(TRichEdit)
  private
    FOldBackColor: TColor;
    FColorOnEnter: TColor;
    FHunspell: TNHunspell;
    FDic: TStringList;
    Paraula: string;
    property OldBackColor: TColor read FOldBackColor write FOldBackColor;
    procedure UpdateDics;
    procedure ComprovarParaula(ValorLl, ValorIn, ValorOut: integer);
  protected
    procedure DoEnter; override;
    procedure DoExit; override;
    procedure KeyPress(var Key: Char); override;
    procedure Click; override;
  public
    constructor Create(AOwner: TComponent); override;
    destructor destroy; override;
    { Public declarations }
  published
    property ColorOnEnter: TColor read FColorOnEnter write FColorOnEnter;
    { Published declarations }
  end;
procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('jrComponents', [TRichDic]);
end;

{ TRichDic }

procedure TRichDic.ComprovarParaula(ValorLl, ValorIn, ValorOut: integer);
var
  tmpStr: TUnicodeStringList;
  POsi: integer;
begin
  if TNHSpellDictionary(FDic.Objects[0]).Spell(Paraula) then
    SelAttributes.Color := clBlack
  else begin
    selStart := ValorIn;
    SelLength := ValorLl;
    SelAttributes.Color := clRed;
    SelText := Paraula;
    SelAttributes.Color := clBlack;
  end;
end;

constructor TRichDic.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FColorOnEnter := Color;
  UpdateDics;
end;

destructor TRichDic.destroy;
begin
  inherited;
end;

procedure TRichDic.DoEnter;
begin
  OldBackColor := Color;
  Color := ColorOnEnter;
  inherited;
end;

procedure TRichDic.DoExit;
begin
  Color := OldBackColor;
  inherited;
end;

procedure TRichDic.KeyPress(var Key: Char);
var
  inici, Fi: integer;
  PosIni, Llarc: integer;
begin
  inici := 0;
  // Polsat la barra espaiadora
  if Key = #32 then begin
    if Length(Paraula) > 0 then begin
      Fi := selStart;
      Llarc := Length(Paraula);
      inici := Fi - Llarc;
      ComprovarParaula(Llarc, inici, Fi);
      Paraula := '';
      Llarc := 0;
    end;
  end
  else begin
    // Controlem que les tecles siguin lletres o numeros
    if (Key > #64) and (Key < #142) then begin
      Paraula := Paraula + Key;
      Inc(Llarc);
    end;
    // si s'ha polsat tecla backspace'
    if (Key = #8) then begin
      Paraula := '';
      // with FRichEdit do begin
      PosIni := selStart;
      while text[selStart] <> ' ' do begin
        Paraula := text[selStart] + Paraula;
        selStart := selStart - 1;
      end;
      selStart := PosIni;
    end;
    // end;
  end;
end;

procedure TRichDic.Click;
begin
  inherited;

Aqui deberia crear el Panel
end;

procedure TRichDic.UpdateDics;
begin
  with Hunspell do begin
    ReadFolder(ExtractFilePath
        ('E:\RAD Studio\Projects\PRESSUPOSTOS\catalan.oxt'));
    FDic := TStringList.Create;
    FDic.AddObject('Diccionari', SpellDictionaries[0]);
    SpellDictionaries[0].Active := True;
    UpdateAndLoadDictionaries;
  end;
end;
Muchas gracias
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Creación de componente Migmam2 Varios 4 01-12-2008 13:44:08
Creación de componente, con una x class mrnovice OOP 3 03-02-2008 17:03:40
Creacion de componente xerkan OOP 1 29-05-2007 14:20:36
Creacion componente CHiCoLiTa Varios 8 05-09-2005 20:24:48
Duda en la creacion de un Componente Holderhek OOP 3 23-03-2005 03:55:17


La franja horaria es GMT +2. Ahora son las 03:05:19.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi