Beiträge von acrbb

    Julian

    Thanks for your reply.

    I've both used the WPRichText1.InsertGraphicAsLinkDialog('Graphic Files|*.BMP;*.WMF') and the below code (both add the image with success).
    Anyway my problem persists: everytime I add, for example, a 1 Mbytes image, 1 Mbytes mem usage is added to my application total mem usage. At the end if I add 200x 1 Mbytes images, my application crashes because of too much RAM being used. Basically I want to add a link to the image without adding the image itself (I want it to be drawn only). What is wrong with the below code?

    Thanks, Andre

    with wprichtext1 do begin
    tablecolnumber:=1;
    obj:=TWPOImage.create(wpRichText1);
    obj.fileextension:='BMP';
    obj.streamname:='d:\ext.bmp';
    obj.WidthTW := round(obj.ContentsWidth/2);
    obj.HeightTW := round(obj.ContentsHeight/2);
    TextObjects.Insert(obj);
    end;

    Hello again Julian

    On your last email you wrote:

    "WPExtObj etc belong to WPTools Standard. See the directory \Dx"

    I cannot see any Dx folder inside my WpTools installation and after 3 emails I'm exactly on the same confition I was on the start of this thread.

    Wouldn't it be easier if you write here an example on how to add images to the WpRichText which are written in realtime from a file and not added to the component (to avoid spending memory)?

    Imagine I want to add an image that when drawn would look for file "d:\myimage.jpg" and draw it on the screen?

    Thanks. Andre

    Julian

    "Please see unit WPExtObj for examples about embedded objects. WPEmOBJ is also a good source."

    Where can I visit that? On the Help menu? On the Demos folder?

    "Insert hidden markers and find the first marker then delete the text including this marker. "

    Where can I find examples on how to do this?
    Tks, Andre

    Julian,

    But can you please let me know some code samples of how to do the two solutions you mentioned? Are they available on the demos that come with the product?

    Tks. Andre.

    Hello

    My application adds each 10 seconds a table to a wprichtext component which contains an image with aprox 100 Kb. The problm is that after several minutes and because of adding so many images the Memusage reaches more than 50 MBytes which is too much for my users.
    Ive two questions regarding this:

    1) Is there any way of adding an image without spending so much memory on my application? (maybe the image would be on a file and would be read when needed)?

    2) If not and supposing I have 1000 tables on my wprichtext how can I delete the first table added to the component? (anytime I would add a new table I would delete the first one).

    Thanks in advance.
    Andre

    Julian,

    Thanks again for your help.

    Unfortunately only the second code you sent me (the one that does the obj.loadfromfile) works. Anyway I need to load the bmp from memory and not from a file.

    The first code (that uses obj.loadfromstream) writes the bitmap in a very small size (being the bmp a big or small picture, the size it is written is always the same).

    The last code (obj.Picture.Graphic.assign) gives an error.
    Anyway correcting that error with a "obj.picture.graphic:=tbitmap.create", works, but the picture is again written with a default small size.

    Any help highly appreciated.

    PS: Try this code and see for yourself the problem of drawing a small image:

    procedure TForm1.Button1Click(Sender: TObject);
    var obj : TWPOImage;
    bmp:tbitmap;
    begin
    bmp:=tbitmap.create;
    bmp.loadfromfile('d:\a.bmp');
    obj:=TWPOImage.create(WPRichText1);
    obj.fileextension:='BMP';
    obj.picture.graphic:=tbitmap.create;
    obj.picture.graphic.assign(bmp);
    WPRichText1.readonly:=false;
    WPRichText1.TextObjects.Insert(obj);
    bmp.free;
    end;

    Julian

    Still no luck, but we are almost there.
    With the below code it writes the image but always with the same (small) size. How can I change the size of the image being written? No matter what the size of the bmp is, it always paints it very small...

    Any help appreciated.

    procedure TForm1.Button1Click(Sender: TObject);
    var obj : TWPOImage;
    bmp:tbitmap;
    begin
    with wprichtext1 do begin
    bmp:=tbitmap.create;
    bmp.loadfromfile('d:\d.bmp');
    obj:=TWPOImage.create(wpRichText1);
    obj.fileextension:='BMP';
    obj.assign(bmp);
    wpRichText1.TextObjects.Insert(obj);
    end;
    end;

    About #3 in the previous message, I still cannot add the bitmap to the wprichtext: I have the image in a tbitmap and want to draw it. What's wrong with the below code?

    bmpstream:=tmemorystream.create;
    bmp2.savetostream(bmpstream);
    bmp2.free;
    obj:=TWPObject.create(mainform.WPRichText1); //use TWPOImage
    bmpstream.position := 0; // Inserted
    obj.loadfromstream(bmpstream);
    obj.fileextension:='BMP'; //Not here, BEFORE LoadFromStream
    WPRichText1.readonly:=false;
    WPRichText1.TextObjects.Insert(obj);

    Nothing happens...any clues?
    Thanks alot again for the previous help.

    Hello again

    Thanks for your previous reply.

    I have 4 questions this time, which I cannot find an answer for.
    Thanks in advance for any possible reply.

    1- I want to add text in several different colors. I'm using the following code without result. Any help appreciated:

    CurrAttr.AddStyle([afsBold]);
    CurrAttr.fontname:='Courier New';
    CurrAttr.color:=clred;
    Currattr.size:=10;
    InputString('My Text');

    The text is written in red.

    2- About the TStream fileextension changing to BMP. Where can I change that?

    3- I want the component to bbe read-only The problem is that when I set it to read only it doesn't allow me to add images in the format:
    "WPRichText1.TextObjects.Insert(obj);"

    4- How can I add an hyperlink to the text so, when it is clicked, another window is opened inside the program? (the window to be opened depends on the text clicked).

    Thanks. Andre