Beiträge von dirkil

    Thanks Julian, you put me on the right track.

    I looked at the output after the mail merge and there the margin was still correct. After assigning it to the editor to display it it went wrong.

    I used

    Code
    rtfAllPreview.SelectionAsString := ...

    because it could happen that rtfAllPreview has already some content. Now I check before assigning. If it is empty I assign with

    Code
    rtfAllPreview.AsString := ...


    otherwise

    Code
    rtfAllPreview.SelectionAsString := ...

    I am doing a mail merge by instantiating a TWPRichText in a class (not putting it on a form), assigning an RTF template, using a TWPMMDataProvider (also not on a form) and doing the usual mail merge routine as described in the manual.

    After the mail merge the output TWPRichText has different left and top margins than the input document.

    The mail merge template had \margl1788 and \margt773. The resulting document had \margl1882 and \margt1440.

    It seems to me that the resulting values are the default values which is not what I want.

    I tried assigning the header of the template

    but that didn't work either. Calling Loaded() after assigning AsString also didn't help.

    Do you have any idea what am I doing wrong?

    I would like to add a page footer that contains three elements: one is left-aligned, one is centered and one is right-aligned. I tried it like that:

    I don't know how to achieve that. I didn't even manage two elements. I tried it like that:

    rtfPreview.HeaderFooter.Get( wpIsFooter, wpraOnAllPages).RtfText.AsString :=
    '<<div>Links</div><div>Seite <pagenr></div>';

    That didn't work. Any ideas?

    I wrote my own editor using DevExpress components. In a toolbar I have a combo box where the user can select styles from all available styles.

    So he can write some text and then assign a style to that paragraph by selecting a style from the combo box. Then he carries on writing and selecting a different style for the next text he wrote.

    When he now places the cursor in the first text I would like to automaically select the style of that current paragraph from my style combo box. Is there an event or something I can use?

    Also if the user selects a single word and hits the bold button to make the selected text bold face. If he returns with the cursor to the bold text the bold button should be selected and deselected when it is in normal text.

    How do I do that?

    This is also interesting but actually not what I wanted since your solution has to be done at compile time. I need flexibility at run-time instead.

    For example, I would like the user of my program to be able to do the following: add a mail merge picture of size 100x100 somewhere in the document. Another user may want to have a picture of size 200x100.

    I think what's missing is that the user can define the size of a mail merge field at run-time.

    I hope now it's clearer.

    In my mail merge template I would like to have a picture of a certain size, say 200x200 pixels. But the images in my data source have varying size, e.g. 300x220, 600x400, etc

    Is it possible to have WPTools automatically scale the pictures proportionally when executing the mail merge?

    What I already achieved is to offer special mail merge fields e.g. PIC200_200, PIC300_300 and in the code I check which field is currently processed and scale it myself. This can be used for the time being but it has the disadvantage that I have to prepare a number of fields instead of only one and maybe the formats I prepare are not the formats my users want to have.

    I offer mail merge functionality in my application. When the user designs the mail merge template he can insert fields from a drop down menu. That works very well but there's a little catch. Suppose you use TABs to align a few things so that they look nice.

    If there are mail merge fields with long and short names it can be difficult for the user to determine how to align them perfectly. The long field names could move things to the right a lot although when the mail merge is executed it is not that far right.

    I hope I could get my point across. Is there a way to hide all field names so that only <<>> is displayed? This would solve the problem since then the user could switch between views.

    I think I found a bug in TWPMMDataProvider.DoMergeGetText. When you run the mail merge and your template contains a field and your data source doesn't contain this field then you get an access violation on line 1200 in unit wpdbrich.

    The original source is like that:

    Code
    if (dataset <> nil) and dataset.Active then  begin    field := dataset.FindField(fieldname);    if FShowFieldNames then    begin      if field <> nil then Contents.StringValue := field.DisplayName      else Contents.StringValue := fieldname;      if FAppendSpaceToNonEmpty and (Contents.StringValue <> '') then        Contents.StringValue := Contents.StringValue + #32;      Done := TRUE;    end    else      if field.isnull then // <- IT CRASHES HERE!      begin        Contents.StringValue := '';        done := true;      end

    The variable 'field' can be null and then calling field.isnull is not possible. The following change fixes the problem:

    Code
    if (field <> nil) AND field.isnull then // <- NOW IT CAN'T CRASH

    Julian, if you agree that this needs to be fixed I would be glad if you'll add that in the next update of WPTools.

    I have difficulty getting a jpeg stored in a database field into a mail merge field. You can download my sample from here: http://www.niftybits.de/downloads/MailMergeGraphic.zip

    Basically the code is like that:

    Code
    unit Unit1;interfaceuses  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  Dialogs, StdCtrls, WPRTEDefs, WPCTRMemo, WPCTRRich, FIBDatabase,  pFIBDatabase, DB, FIBDataSet, pFIBDataSet, Wpdbrich, WPOBJ_Image;type  TForm1 = class(TForm)    pFIBDatabase1: TpFIBDatabase;    pFIBTransaction1: TpFIBTransaction;    Button1: TButton;    Button2: TButton;    qry: TpFIBDataSet;    WPMMDataProvider1: TWPMMDataProvider;    DataSource1: TDataSource;    lAllRichText: TWPRichText;    lTemplate: TWPRichText;    procedure Button1Click(Sender: TObject);    procedure Button2Click(Sender: TObject);    procedure lTemplateMailMergeGetText(Sender: TObject;      const inspname: String; Contents: TWPMMInsertTextContents);  private    { Private-Deklarationen }  public    { Public-Deklarationen }  end;var  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);begin  lTemplate.InputMergeField( 'SIGNATURE_PIC','SIGNATURE_PIC' );end;procedure TForm1.Button2Click(Sender: TObject);var  i: Integer;  lSection: TWPRTFSectionProps;begin  lTemplate.BeginUpdate;  qry.Open;  qry.First;  try    i := 0;    lAllRichText.BeginUpdate;    while not qry.Eof do    begin      lTemplate.MergeText;      if i=0 then // FIRST RUN      begin         lAllRichText.AsString := lTemplate.AsString;         lAllRichText.CPPosition := MaxInt; // to end      end      else if i>0 then // SUBSEQUENT RUNS      begin         // Append a new paragraph if the last line is not empty         if lAllRichText.ActivePosInPar>0 then             lAllRichText.InputString(#13);         // Need page break         lAllRichText.FastSetPageBreak(true, true);         // and append the text         lSection        := lAllRichText.FastAppendText(lTemplate,true);         lSection.Select := [wpsec_ResetOutlineNums];      end;      qry.Next;      Inc(i);    end;  finally    lTemplate.EndUpdate;  end;end;procedure TForm1.lTemplateMailMergeGetText(Sender: TObject;  const inspname: String; Contents: TWPMMInsertTextContents);var  lWpObj: TWPOImage;  lStream: TMemoryStream;begin  if inspname = 'SIGNATURE_PIC' then  begin    if Contents.CurrentObject=nil then    begin      lWpObj := TWPOImage.Create( lTemplate );      lStream := TMemoryStream.Create;      try        TBlobField( qry.FN('SIGNATURE_PIC')).SaveToStream( lStream );        lStream.Position := 0;        lWpObj.FileExtension := 'JPG';        lWpObj.LoadFromStream(lStream);        lWPObj.WidthTW := lWpObj.ContentsWidth;        lWpObj.HeightTW := lWpObj.ContentsHeight;        Contents.Obj := lWpObj;      except        ;      end;      lStream.Free;      lWpObj.Free;    end;  end;end;end.

    What happens is that nothing is displayed just «».
    When I assign

    Code
    Contents.StringValue:='xxx';


    then the text is displayed correctly. What am I doing wrong?

    Regards,
    Dirk.

    I am trying to do a Master/Detail report with WPReporter but in OnMailMergeGetText the property Contents.DatasetnamePart is always blank and therefore I cannot find out from which dataset this callback was called.

    I am sure I forgot to set something since I haven't used WPReporter before. I added two entries to TWPReportBandsDialog.Databases, though.

    What else do I need to do in order to have DatasetnamePart filled?

    I am still having problems with localisation. I am now creating the object in code in the constructor of the form like that

    Code
    FWPLanguageControl := TWPLanguageControl.Create(self);
      FWPLanguageControl.Active := true;
      FWPLanguageControl.GlobalLanguage := 'DE';
      WPLangInterface := TWPLocalizationInterface.Create(FWPLanguageControl);
      WPLocalizeLoadForms := TRUE;
      WPTools_LoadVCLStrings;    // WPUtils
      WPTools_LoadActionStrings; // WPActnStr

    But I am still getting the english captions. Do I have to set the german strings somewhere? Where is the language control looking for the german strings?

    DevExpress assume that this is a problem in WPTools. Are you going to fix that? Here is what they wrote:

    ==>> Changed On: 4/30/2008 6:23 PM
    ==>> Issue type: BugReport
    ==>> Product Group: VCL
    ==>> Product: ExpressBars Suite
    ==>> State: Processed (Won't Fix) ("Won't Fix" indicates that this is not an bug and we are not going to fix it) ==>> Previous State: Reproduced


    ==>> Last comment:
    Hi Dirk,

    We found that this problem relates to the WPLanguageControl implementation. A simple query whether it supports the IDispatch interface results in an AV:

    <code>
    procedure TForm1.Button1Click(Sender: TObject); var
    ATemp: IDispatch;
    begin
    if not Supports(WPLanguageControl1, IDispatch, ATemp) then
    Caption := WPLanguageControl1.ClassName
    else
    Caption := 'supported';
    end;
    </code>

    We assume that this behavior is wrong.

    Thanks,
    Alex

    You can check the state of your issue at: https://www.devexpress.com/issue=Q102354
    If you need to you can modify your inquiry and add additional details.

    DevExpress was able to reproduce the error and filed my request under bug reports. So I suggest we'll wait for them to find a solution.

    Zitat


    Reproduced by Developer Express Team at 28.04.2008 08:47:05

    Hi Dirk,

    We're sorry that you encountered this issue. We managed to reproduce it using only a TdxBarManager on a form. Our developers will look into this issue.

    Thanks,
    Alex

    In my program I change the text color like that:
    rtfForm.CurrAttr.Color :=
    rtfForm.CurrAttr.ColorToNr(TdxBarColorCombo(Sender).Color, true);

    In the TWPRichText this change is displayed correctly but when I save and reload the RTF the colour information is lost. All other changes to parameters (e.g. bold, italic) are ok.

    What am I doing wrong?

    When I drop a WPLanguageControl on a form that has a DevExpress TdxRibbon on it I am getting an access violation in the Delphi IDE. When there is no ribbon or other DevExpress components on the form it works fine.

    Here is the stack trace:

    date/time : 2008-04-26, 01:06:51, 372ms
    computer name : PLUTO
    user name : Dirk <admin>
    operating system : Windows XP Service Pack 2 build 2600
    system language : German
    system up time : 2 days 8 hours
    program up time : 7 minutes 41 seconds
    processors : 2x AMD Athlon(tm) 64 X2 Dual Core Processor 3800+
    physical memory : 959/2014 MB (free/total)
    free disk space : (C:) 15,65 GB
    display mode : 1920x1200, 32 bit
    process id : $13d8
    allocated memory : 93,86 MB
    executable : delphi32.exe
    current module : madExcept_.bpl
    exec. date/time : 2004-04-23 16:01
    version : 7.0.8.1
    madExcept version : 3.0b
    callstack crc : $40005ecd, $9ac74717, $9ac74717
    exception number : 8
    exception class : EAccessViolation
    exception message : Zugriffsverletzung bei Adresse 40005ECD in Modul 'rtl70.bpl'. Lesen von Adresse 65767265.

    main thread ($1388):
    40005ecd +00d rtl70.bpl
    40005ef4 +004 rtl70.bpl System @CallDynaInst
    00634378 +034 coreide70.bpl Propinsp TPropertyInspector.RefreshPrimarySelection
    006342c9 +029 coreide70.bpl Propinsp TPropertyInspector.SetPrimarySelection
    00634742 +066 coreide70.bpl Propinsp TPropertyInspector.SelectionChanged
    0098d40a +1b2 designide70.bpl Componentdesigner TComponentDesigner.SetSelection
    0098d745 +0f5 designide70.bpl Componentdesigner TComponentDesigner.UpdateSelections
    00989693 +1e3 designide70.bpl Componentdesigner TComponentRoot.SelectionsChanged
    0098bf40 +020 designide70.bpl Componentdesigner TSelections.SelectionChanged
    0096b6eb +067 designide70.bpl Designer TSelectionListenerHelper.SelectionChanged
    0096b52b +027 designide70.bpl Designer TSimpleSelections.Modified
    0096b34e +022 designide70.bpl Designer TSimpleSelections.EndSelections
    0096985b +00f designide70.bpl Designer TDesigner.EndSelect
    009697a2 +0d6 designide70.bpl Designer TDesigner.DragEnd
    0096a83f +023 designide70.bpl Designer TDesigner.MouseUp
    00881951 +041 vcl70.bpl Controls TControl.WndProc
    00884c97 +157 vcl70.bpl Controls TWinControl.WndProc
    0089e87d +421 vcl70.bpl Forms TCustomForm.WndProc
    00884914 +02c vcl70.bpl Controls TWinControl.MainWndProc
    7e3696c2 +00a user32.dll DispatchMessageA
    008a568b +083 vcl70.bpl Forms TApplication.ProcessMessage
    008a56c2 +00a vcl70.bpl Forms TApplication.HandleMessage
    008a58f2 +096 vcl70.bpl Forms TApplication.Run

    thread $36c: <priority>
    7c91eb94 +00 ntdll.dll KiFastSystemCallRet
    7c91d85a +0a ntdll.dll NtDelayExecution
    7c8023e7 +4b kernel32.dll SleepEx
    7c80244c +0a kernel32.dll Sleep

    thread $1484: <priority>
    7c91eb94 +00 ntdll.dll KiFastSystemCallRet
    7c91e9a9 +0a ntdll.dll NtWaitForMultipleObjects
    7c8094dc +00 kernel32.dll WaitForMultipleObjectsEx
    7c80a070 +13 kernel32.dll WaitForMultipleObjects
    598386e5 +0d madExcept_.bpl madExcept CallThreadProcSafe
    5983874f +37 madExcept_.bpl madExcept ThreadExceptFrame
    >> created by main thread ($1388) at:
    72c9328c +00 wdmaud.drv

    thread $170c: <priority>
    7c91eb94 +00 ntdll.dll KiFastSystemCallRet
    7e37e03d +3b user32.dll GetMessageA
    598386e5 +0d madExcept_.bpl madExcept CallThreadProcSafe
    5983874f +37 madExcept_.bpl madExcept ThreadExceptFrame
    >> created by main thread ($1388) at:
    76af5f4c +00 winmm.dll

    thread $770:
    7c91eb94 +0 ntdll.dll KiFastSystemCallRet
    7c91d85a +a ntdll.dll NtDelayExecution

    I can't decide whether this is a wpTools problem or a DevExpress problem. I will also inform the DevExpress support.

    Now I am getting an empty first page, on the second page I am getting two records (as before) and from the third page on it's correct.

    My current source is like that:

    So, it didn't really solve my problem. Or have I misunderstood you in how to incorporate your suggestion?

    Cheers,
    Dirk.