Beiträge von rRowlands

    Hello.

    The WPRichtext has styles loaded at form creation like this.

    frmMain.WPStyleCollection1.Clear;
    frmMain.WPStyleCollection1.LoadFromFile(sStylesPath + 'Notes.ini');
    frmMain.WPStyleCollection1.Update(frmMain.WPRichTextJobNotes.HeaderFooter.RTFProps);

    I want to make sure these are the only styles available, even if the loaded text has additional styles attached in the header.

    I would like the styles in the loaded text to remain attached to paragraphs but I do not want the styles added to the RTFProps.

    Also, when I paste in text from word I seem to get a load of styles added. Is it possible to protect against this?

    I've tried
    frmMain.WPRichTextJobNotes.HeaderFooter.RTFProps.Locked := True;

    but when I paste in something from Word I still get a load of new styles added.

    In summary I want to load the styles into the RichText and ensure those are the only ones available.

    Thanks.

    I am using a WPRichText for general notes relating to projects.

    The notes are loaded when the user moves to a different record.

    I would like to save any changes that are made immediately the user leaves the WPRichText to try and avoid the record being changed by another user.

    I appreciate the need to keep focus on the component when clicking menu items.

    Is there any way to detect the user clicking away from the WPRichText other than for having code in every menu items OnClick event?

    Julian

    I've tried the fix but I still have the problem. Have done a Build having loaded the dpk and then installing.

    I rightclick on a misspelt word and select a correction.

    The cursor is now at the start of the word.

    I click at the end of the line and the cursor moves there.

    I start typing and the characters appear at the beginning of the corrected word.

    Thank you Julian.

    I have modified the code in WPtoPDFDlg to see if the file can be exclusively opened when the user clicks 'CreatePDF'.

    Code
    Try
        if FileExists(fileName.text) Then
          begin
            chkStream := TFileStream.Create(fileName.text, fmOpenReadWrite OR fmShareExclusive);
          end;
      except
        on EFOpenError do
        .....

    I will look at your suggestion but the I'm sure error being returned was an IO error.

    Rob.

    I use DevEx components for the font name and size combos.

    This is my code in the OnSelectionChanged event.

    Code
    frmReport.dxBarFontNameCombo1.Text :=  WPRichText1.CurrAttr.FontName;  frmReport.dxBarComboFontSize.CurText := inttostr(Trunc(WPRichText1.CurrAttr.Size));

    For setting the font from the font combo I have the following in the combo OnCloseUp event.

    Code
    RichText.CurrAttr.FontName := dxBarFontNameCombo1.CurText;

    HTH.

    Rob

    Stef

    I've resigned myself to having to click on a correctly spelt word to get my popup to appear.

    A little messy and not expected by the user but that is the only way to get it to work.

    I make sure that there is always text in the RichText or else the popup will not appear. I am using the RichText for a notes field in a database and new records have a default entry of 'Notes' to achieve this.

    Julian

    I have tried your suggestion and scoured the NGs for further assistance.

    I cannot get the correct output.

    The graphic I want as the printed background is created at exactly A4. It is a JpegImage. There is sufficient white around it to cater for all printer margins.

    I do not want the graphic cropped or anything like that. I want it to sit exactly over the A4 printer page.

    Whatever I do I get a large margin at the right and bottom of the printed page. The image is being cropped but as I say, the resulting white space is two to three times the size of the print margins.

    Is it possible to line an A4 Jpeg exactly over the A4 page?

    Thanks.

    Rob.

    Julian

    I am trying to use the printer.canvas option.

    In the OnPaintWatermarkEvent I have the following code

    Code
    if printer.Printing then
      begin
        PageRect.Left := 6;
        PageRect.Top := -42;
        PageRect.Right  := PageRect.Left + MulDiv(11630, Xres, 1440);
        PageRect.Bottom := PageRect.Top + MulDiv(16900, Yres, 1440);
        Printer.canvas.StretchDraw(PageRect,BackgroundImage);
        exit;
      end;

    The above prints correctly. It is an A4 image and the paper is A4

    Why do I have to 'fiddle' with the twips as opposed to using RichText.Header.PageWidth and PageHeight?

    This works on one printer bu on the other the graphic is 30mm or so too far to the right.

    What is the correct weay to get this to work?

    Thanks.

    Rob.


    (Edited 02 May 2006 08:55 BST)

    I am using a high quality jpeg for our letterheads.

    This is loaded in the RichText.OnPaintWatermarkEvent using the following code

    if wppInPaintDesktop in PaintMode then //Want to paint on the Canvas and not the Background (can't print if on BackGround)
    PaintMode := PaintMode - [wppInPaintDeskTop];
    if not Assigned(BackGroundImage) then //i.e. not already loaded
    begin
    if FileExists(WPRichText1.RTFVariables.Find('BackGround').Text) then
    begin
    BackgroundImage := TJpegImage.Create;
    BackgroundImage.LoadFromFile(WPRichText1.RTFVariables.Find('BackGround').Text);
    end;
    end;
    toCanvas.StretchDraw(PageRect,BackgroundImage);


    This looks great on screen and the graphic is correctly positioned for the A4 page.

    When I print the letter the graphic shrinks by about 10mm vertically and proportionally horizontally.

    How can I get it to print the full size?

    Thanks.

    Rob.