Beiträge von moelski

    Hi Support,

    today I got an example how to integrate a normal RichEdit into a Tchart. They use this code to draw the richedit to the Tchart Canvas:

    Code
    unit RichText_Drawing;{$I TeeDefs.inc}interfaceuses  {$IFNDEF LINUX}  Windows, Messages,  {$ENDIF}  SysUtils, Classes,  {$IFDEF CLX}  QGraphics, QControls, QForms, QDialogs, QExtCtrls, QComCtrls, QStdCtrls,  {$ELSE}  Graphics, Controls, Forms, Dialogs, ExtCtrls, ComCtrls, StdCtrls, RichEdit,  {$ENDIF}  {$IFDEF CLR}  Types,  {$ENDIF}  Base, TeeProcs, TeEngine, Chart;type  TRichTextDrawing = class(TBaseForm)    procedure Chart1AfterDraw(Sender: TObject);  private    { Private declarations }  public    { Public declarations }  end;Procedure DrawRichText(Chart:TCustomTeePanel; RichEdit:TRichEdit; R:TRect); overload;Procedure DrawRichText(Chart:TCustomTeePanel; const RichText:String; R:TRect); overload;implementation{$IFNDEF CLX}{$R *.dfm}{$ELSE}{$R *.xfm}{$ENDIF}procedure TRichTextDrawing.Chart1AfterDraw(Sender: TObject);var RichText : String;begin  RichText:= '{\rtf1\ansi\ansicpg1252\deff0\deflang1033'+             '{\fonttbl{\f0\fswiss\fcharset0 Arial;}'+             '{\f1\fmodern\fprq1\fcharset0 Courier New;}'+             '{\f2\fnil\fcharset2 Symbol;}}'+             '{SuperScript}{\super 2} {+ SubScript}{\sub 2}  =  a^2 + a2}';  DrawRichText(Chart1,RichText,Rect(60,60,360,90));  RichText:= '{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss'+      '\fcharset0 Arial;}{\f1\fmodern\fprq1\fcharset0 Courier New;}{\f2' +      '\fnil\fcharset2 Symbol;}}'+      '\viewkind4\uc1\pard\f0\fs20 Normal\par'+      '\b Bold  \ul\b0 Underline\ulnone   \i Itallic\par'+      '}';  DrawRichText(Chart1,RichText,Rect(60,100,360,140));end;{$IFDEF CLR}{$IF Defined(UnsafeCode)}{$DEFINE ACCEPTDRAW}{$IFEND}{$ELSE}{$DEFINE ACCEPTDRAW}{$ENDIF}Procedure DrawRichText(Chart:TCustomTeePanel; RichEdit:TRichEdit; R:TRect); overload; {$IFDEF CLR}{$IFDEF ACCEPTDRAW}unsafe;{$ENDIF}{$ENDIF}{$IFDEF ACCEPTDRAW}const TwipsPerPixel=1440.0/96.0;var fr : FORMATRANGE;{$ENDIF}begin  {$IFDEF ACCEPTDRAW}  fr.hdc := Chart.Canvas.Handle;  fr.hdcTarget := fr.hdc;  r.left :=Round(r.Left*twipsPerPixel);  r.top :=Round(r.Top*twipsPerPixel);  r.right :=Round(r.Right*twipsPerPixel);  r.bottom := Round(r.Bottom*twipsPerPixel);  fr.rc := r;  fr.rcPage := r;  fr.chrg.cpMin :=0;  fr.chrg.cpMax :=-1;  RichEdit.Perform(EM_FORMATRANGE,1,{$IFNDEF CLR}Integer{$ENDIF}(@fr));  {$ENDIF}end;Procedure DrawRichText(Chart:TCustomTeePanel; const RichText:String; R:TRect); overload;var RichEdit : TRichEdit;begin  RichEdit:=TRichEdit.Create(nil);  try    RichEdit.Parent:=Chart.Parent; // set Parent before text and color    RichEdit.Text:=RichText;    RichEdit.Color:=Chart.Color;    DrawRichText(Chart,RichEdit,R);  finally    RichEdit.Free;  end;end;initialization  RegisterClass(TRichTextDrawing);end.

    I can translate this to work with TWPRichText instead of RichEdit, but it wont work fpr me and I think it is a problem within this routine:

    Code
    Procedure DrawRichText(Chart:TCustomTeePanel; RichEdit:TRichEdit; R:TRect); overload; {$IFDEF CLR}{$IFDEF ACCEPTDRAW}unsafe;{$ENDIF}{$ENDIF}{$IFDEF ACCEPTDRAW}const TwipsPerPixel=1440.0/96.0;var fr : FORMATRANGE;{$ENDIF}begin  {$IFDEF ACCEPTDRAW}  fr.hdc := Chart.Canvas.Handle;  fr.hdcTarget := fr.hdc;  r.left :=Round(r.Left*twipsPerPixel);  r.top :=Round(r.Top*twipsPerPixel);  r.right :=Round(r.Right*twipsPerPixel);  r.bottom := Round(r.Bottom*twipsPerPixel);  fr.rc := r;  fr.rcPage := r;  fr.chrg.cpMin :=0;  fr.chrg.cpMax :=-1;  RichEdit.Perform(EM_FORMATRANGE,1,{$IFNDEF CLR}Integer{$ENDIF}(@fr));  {$ENDIF}end;

    I changed it to this:

    Code
    Procedure DrawRichText(Chart:TCustomTeePanel; RichEdit:TWPRichText; R:TRect); overload;   //    RichEdit:TRichEdit; R:TRect); overload;{$IFDEF CLR}{$IFDEF ACCEPTDRAW}unsafe;{$ENDIF}{$ENDIF}{$IFDEF ACCEPTDRAW}const TwipsPerPixel=1440.0/96.0;var fr : FORMATRANGE;{$ENDIF}begin  {$IFDEF ACCEPTDRAW}  fr.hdc := Chart.Canvas.Handle;  fr.hdcTarget := fr.hdc;  r.left :=Round(r.Left*twipsPerPixel);  r.top :=Round(r.Top*twipsPerPixel);  r.right :=Round(r.Right*twipsPerPixel);  r.bottom := Round(r.Bottom*twipsPerPixel);  fr.rc := r;  fr.rcPage := r;  fr.chrg.cpMin :=0;  fr.chrg.cpMax :=-1;  RichEdit.Perform(EM_FORMATRANGE,1,{$IFNDEF CLR}Integer{$ENDIF}(@fr));  {$ENDIF}end;

    I can compile it, but I see nothing. Could you please help me to get it working? I think there are two main problems:
    1) var fr : FORMATRANGE;
    This is defined in the unit RichEdit:

    Code
    {$EXTERNALSYM _formatrange}  _formatrange = record    hdc: HDC;    hdcTarget: HDC;    rc: TRect;    rcPage: TRect;    chrg: TCharRange;  end;  TFormatRange = _formatrange;  {$EXTERNALSYM FORMATRANGE}  FORMATRANGE = _formatrange;
    Code
    type  _charrange = record    cpMin: Longint;    cpMax: LongInt;  end;  {$EXTERNALSYM _charrange}  TCharRange = _charrange;

    2) RichEdit.Perform(EM_FORMATRANGE,1,{$IFNDEF CLR}Integer{$ENDIF}(@fr));
    I really don´t know if ths could work with WpRichText.

    So can you give me some tips what I have to change in addition?

    This is the code I tested ...

    Hi !

    We currrently use only TWPRichText. We save ans load RTF text from a stream. This works perfect for us.

    Recently I put a TWPRichTextLabel onto our MainForm. And in some cases our software reports an exception : EClassNotFound : Class TWPRichTextLabel not found.
    We don´t have done anything with the TWPRichTextLabel! Only the label was on our form - nothing else was done with it.

    Do you have any idea what causes this problem?

    Hallo !

    Wir würden gerne den Inhalt eines RTFs (TWPRichText) als Stream in unsere Datei einbetten. Dazu haben wir diese Funktion genutzt:

    Code
    WPRichText1.SaveToStream(FileStream, 'WPTOOLS');

    Zum Laden haben wir dann das hier benutzt:

    Code
    WPRichText1.LoadFromStream(FileStream, 'WPTOOLS', True);

    Die Datei in der das RTF einbebettet wird ist ein FileStream der eine Vielzahl von Informationen speichert, unter anderem eben das RTF.
    Beim Einlesen wird aber zu viel aus dem Stream eingelesen. Oder anders ausgedrückt, das LoadFromStream läd mehr als SaveToStream weggespeichert hat.
    Danach ist auch unser FileStream nicht mehr zu gebrauchen, da die Korrekte Positionierung auf das nächste Element im Stream nicht mehr sauber funktioniert.

    Es wäre gut wenn ich eine Info / kurzes Codeschnipsel bekommen könnte, wo das Laaden und Speichern in und von einem Stream gezeigt wird.

    Hi !

    If I use a slow machine with only about 200MHz and Windows 98 I got an access violation during close the application.

    I use Eurekalog for detailed error reporting and it tells me that the problem is in line 2600 of unit WPXMLInt.pas.

    I use V5.211 of wptools in delphi 7 pro.

    Did you have any hints what happens there?

    Hallo!

    Gibt es ein Event was nach dem Selektieren von Text bzw. einem Bild aufgerufen wird?

    Ich würde gerne folgendes machen. Wenn der User in einem TWPRichText etwas markiert, soll ein anderes Formular aufgerufen werden, in dem dann Buttons für Fett, Kursiv, etc enthalten sind. Wenn der User dort etwas selektiert soll der Text entsprechend angepasst werden und das extra Formular soll geschlossen werden.

    Das ganze soll dann in etwa so funktionieren wie in Word / Excel 2007.

    Greetz Dominik Schmidt

    Hi !

    I resently got the TMS VCL subscription. Nice components and a very nice looking office 2007 like menu.
    The problem that I have is the missing action property for the combo boxes within the TMS menu.

    Could you give me a little piece of code showing the following, please?
    - show font name from cursorposition in fontcombo
    - change font if text is selected and fontcombo is changed
    - same for fontsize

    Thx a lot!

    Moins !

    Wenn ich einen selektierten Text habe und setze die Grösse z.B. neu mit ...

    Code
    procedure TForm1.AdvGlowButton8Click(Sender: TObject);begin  if RTF.CurrAttr.Size >= 150  then exit;  RTF.SelectedTextAttr.SetFontSize(RTF.CurrAttr.Size + 1);end;

    Und ich dann die Font Attribute wieder retour setzen will mit ...

    Code
    RTF.SelectedTextAttr.ClearAttr(False, True);

    Dann tut er das zwar. Aber der Abstand der Zeichen zueinander wird nicht neu gesetzt. Bedeutet, nach dem ClearAttr sind alle Zeichen zusammengeschoben oder stark auseinandergezogen.

    Hi !

    I wrote some little procedures to get a simple way adding text und horizontal line by code.

    If I want to add text / line / text:

    Zitat

    AddText(False,'Verdana',14,True,True,False,clBlue,'Some little Tests ...');
    AddHorizLine;
    AddText(False,'Verdana',10,False,False,False,clBlack,
    'Dies ist dann einfach nur ein schnöder Text!');

    The result is:
    Some little Tests
    ... *)
    -------------------------------
    Dies ist dann einfach nur ein schnöder Text!

    *) What is the reason for this new line??
    Is here something missing in general?

    Hi !

    Today I did some tests with the Transparent property. If I set the property to true and want to sroll the text with the scrollbars I have a strange behavior.
    Sometimes the scrollbars are not displayed but the text scrolls if I click into the empty space where I find normaly the scrollbars ...
    Sometimes the scrollbars are shown. But that works not any time?

    How can I show the scrollbars the whole time? Or how is it possible that the scrollbars are shown if the mouse is over them? I think this is the normal way if I set Transparent property. But that doesn´t work very good.

    Any hints?

    Hi Julian,

    thx for your answer.

    I tried something like this:

    Code
    procedure TLabelDruckenForm.FormCreate(Sender: TObject);
    var .....
    begin
      if Printer.Printers.GetText = '' then exit;
      ....
    end;

    But this don´t seems to work. The error is still alive. Did you have a better solution?