Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2005.08.21;
Скачать: CL | DM;

Вниз

Как сделать чтобы при загрузке текста в ричидит, текст не менялся   Найти похожие ветки 

 
Logan ©   (2005-07-26 20:13) [0]

Народ подскажите как сделать чтобы при загрузке текста в ричидит, форматирование текста не менялось???


 
Virgo_Style ©   (2005-07-26 20:26) [1]

(*включает телепатор*)
RichEdit.WordWrap = false; ?


 
Logan ©   (2005-07-26 20:42) [2]

Не работает???


 
}{eRsOn   (2005-07-26 20:54) [3]

Logan ©   (26.07.05 20:13)

Модернизируй его...
>>>>>>>
unit RichEditEx;

interface

uses

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

type
TLangChangeEvent=procedure(Sender:TObject;Lang:HKL) of object;

TRichEditEx = class(TRichEdit)
private
FOnLangChange:TLangChangeEvent;
procedure WMLangRequest(var M:TMessage);message WM_INPUTLANGCHANGEREQUEST;
procedure WMLangChange(var M:TMessage);message WM_INPUTLANGCHANGE;

{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
published
property OnLangChange:TLangChangeEvent read FOnLangChange write FOnLangChange;

{ Published declarations }
end;

procedure Register;

implementation

procedure tricheditex.WMLangRequest(var M:TMessage);
begin
if assigned(FOnLangChange) then FOnLangChange(self,m.LParam);
inherited;end;

procedure tricheditex.WMLangChange(var M:TMessage);
begin m.Result:=1;end;

procedure Register;
begin

RegisterComponents("Samples", [TRichEditEx]);
end;

end.
>>>>>>>>


 
Logan ©   (2005-07-26 22:38) [4]

Пойду попробую :)


 
ferr ©   (2005-07-27 00:12) [5]

}{eRsOn   (26.07.05 20:54) [3]
А при чём здесь форматирование?


 
Logan ©   (2005-08-01 19:56) [6]

А причём здесь RichEdit.WordWrap = false;
он у меня за перенос текста отвечает???


 
Virgo_Style ©   (2005-08-01 20:04) [7]

Logan ©   (01.08.05 19:56) [6]
он у меня за перенос текста отвечает???


У меня тоже %-) А что ты подразумеваешь под форматированием?


 
Logan ©   (2005-08-01 20:11) [8]

эээ как бы объяснить... у меня в richedit"e в свойствах шрифта стоит tahoma 12, и вот весь текст загружается именно tahoma 12, даже если он был до этого сохранён в arial. так вот надо чтобы он  загружался arial, а не  tahoma!!!


 
Logan ©   (2005-08-01 20:32) [9]

}{eRsOn   (26.07.05 20:54) [3]
не работает


 
Starcom   (2005-08-01 21:20) [10]

Logan ©   (01.08.05 20:32) [9]

По моему тема неплохая, а что вот Мастера молчат, Дык :(


 
Leonid Troyanovsky ©   (2005-08-01 21:53) [11]


> Logan ©   (01.08.05 20:11) [8]
> эээ как бы объяснить... у меня в richedit"e в свойствах
> шрифта стоит tahoma 12, и вот весь текст загружается именно
> tahoma 12, даже если он был до этого сохранён в arial. так
> вот надо чтобы он  загружался arial, а не  tahoma!!!


By Peter Below (TeamB):

To extract and insert formatted
text you need to work with EM_STREAMIN and EM_STREAMOUT since the available
interface of the Delphi controls can only do that for the complete content of
a rich edit control. Add richedit to your Uses clause and play with the
following functions:

Type
 TEditStreamCallBack = function (dwCookie: Longint; pbBuff: PByte;
   cb: Longint; var pcb: Longint): DWORD; stdcall;

 TEditStream = record
   dwCookie: Longint;
   dwError: Longint;
   pfnCallback: TEditStreamCallBack;
 end;

function EditStreamInCallback(dwCookie: Longint; pbBuff: PByte;
cb: Longint; var pcb: Longint): DWORD; Stdcall;
var
 theStream: TStream;
 dataAvail: LongInt;
begin
 theStream := TStream(dwCookie);
 with theStream do begin
   dataAvail := Size - Position;
   Result := 0; {assume everything is ok}
   if dataAvail <= cb then begin
     pcb := Read(pbBuff^, dataAvail);
     if pcb <> dataAvail then {couldn"t read req. amount of bytes}
       result := E_FAIL;
   end
   else begin
     pcb := Read(pbBuff^, cb);
     if pcb <> cb then
       result := E_FAIL;
   end;
 end;
end;

Function EditStreamOutCallback(dwCookie­: Longint; pbBuff: PByte;
   cb: Longint; var pcb: Longint): DWORD; stdcall;
var
  theStream: TStream;
begin
  theStream := TStream(dwCookie);

  with theStream do begin
    If cb > 0 Then
      pcb := Write(pbBuff^, cb);
    Result := 0;
  end;
end;

Procedure GetRTFSelection( aRichEdit: TRichEdit; intoStream: TStream );
Var
 editstream: TEditStream;
Begin
 With editstream Do Begin
   dwCookie:= Longint(intoStream);
   dwError:= 0;
   pfnCallback:= EditStreamOutCallBack;
 end;
 aRichedit.Perform( EM_STREAMOUT, SF_RTF or SFF_SELECTION,
longint(@editstream));
End;

Procedure PutRTFSelection( aRichEdit: TRichEdit; sourceStream: TStream );
Var
 editstream: TEditStream;
Begin
 With editstream Do Begin
   dwCookie:= Longint(sourceStream);
   dwError:= 0;
   pfnCallback:= EditStreamInCallBack;
 end;
 aRichedit.Perform( EM_STREAMIN, SF_RTF or SFF_SELECTION,
longint(@editstream));
End;

To copy the selection from one control to the other your do this:

Var
 aMemStream: TMemoryStream;
begin
 aMemStream := TMemoryStream.Create;
 try
   GetRTFSelection( richedit1, aMemStream );
   aMemStream.Position := 0;
   PutRTFSelection( richedit2, aMemStream );
 finally
   aMemStream.Free;
 end;
end;

В твоем случае, IMHO, должно хватить PutRTFSelection.

--
Regards, LVT.



Страницы: 1 вся ветка

Текущий архив: 2005.08.21;
Скачать: CL | DM;

Наверх




Память: 0.5 MB
Время: 0.045 c
1-1122754509
Michael5
2005-07-31 00:15
2005.08.21
Как передать фокус Edit у?


1-1122984669
mazepa
2005-08-02 16:11
2005.08.21
progress


1-1123137944
zorik
2005-08-04 10:45
2005.08.21
Поддерживает ли Win98 экспорт в MS Excel?


1-1122828349
Destroyer
2005-07-31 20:45
2005.08.21
Вопрос по try ... except


1-1123017490
iskatel
2005-08-03 01:18
2005.08.21
прокси, попытка 2 ))