#1 2012-10-04 12:12:44

MC
Member
Registered: 2012-10-04
Posts: 21

Proposed two fix

I am a very satisfied user of your tools and congratulate you for your work!

I was faced with two problems I could fix.

SynTaskDialog version 1.17

On one computer the message was larger than the dialog form. Curiously the function AddLabel in TTaskDialog.Execute sets the correct width to the label but after setting the caption the width was larger. I realized that the message had a very very long word (web site adress).

Here are the changes I made:

function AddLabel(const Text: string; BigFont: boolean): TLabel;
var                         // <- NEW
   vRect: TRect;            // <- NEW
begin
  result := TLabel.Create(Form);
  result.Parent := Par;
  result.WordWrap := true;
  if BigFont then begin
    if aEmulateClassicStyle then begin
      result.Font.Height := FontHeight-2;
      result.Font.Style := [fsBold]
    end else begin
      result.Font.Height := FontHeight-4;
      result.Font.Color := $B00000;
    end;
  end else
    result.Font.Height := FontHeight;
  result.Left := X;
  result.Top := Y;

  result.AutoSize := False;  // <- NEW     
  vRect := Rect(0, 0, aWidth-X-8, result.Height); // <- NEW
  result.Height := DrawText(result.Canvas.Handle, PChar(CR(Text)), - 1, vRect, DT_CALCRECT or DT_WORDBREAK); // <- NEW
  

  result.Width := aWidth-X-8;
  result.Caption := CR(Text);
  inc(Y,result.Height+16);
end;

SynPDF 1.16

If I don't have outline in my report, I don't have zoom button enabled !

In the "else" part of the last "if" in the procedure TGDIPages.EndDoc, I replaced "M.Enabled := false;" to "M.Enabled := True;"

procedure TGDIPages.EndDoc;
 [...]
 if UseOutlines and (fOutline.Count>0) then begin
    Root.Enabled := true;
    M := Root;
    for i := 0 to fOutline.Count-1 do
    with TGDIPagereference(fOutline.Objects[i]) do begin
      while (M<>Root) and (cardinal(-2000-M.Tag)<cardinal(fOutline.Count)) and 
         (Rect.Bottom<=TGDIPagereference(fOutline.Objects[-2000-M.Tag]).Rect.Bottom) do
        M := M.Parent;
      M := NewPopupMenuItem(fOutline[i],-2000-i,M);
    end;
  end else
    //M.Enabled := False;  // <- COMMENT
    M.Enabled := True;     // <- NEW
end;

I hope this could help

Offline

#2 2012-10-04 13:19:34

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,206
Website

Re: Proposed two fix

SynTaskDialog has been modified to compute the height by hand, as you proposed.
See http://synopse.info/fossil/info/bd704264b5
Thanks!

I was not able to reproduce the issue with bookmarks.
I tried with the Report sample program: no problem with bookmarks.
So nothing changed yet here - M.Enabled should be left to false here until we are able to reproduce it.
Do you customize the menus?

Offline

#3 2012-10-08 07:56:24

MC
Member
Registered: 2012-10-04
Posts: 21

Re: Proposed two fix

In the "05 - Report created from code" project from the last mORMot, uncomment the 2 "DrawTitle" calls and run.

[...]
//DrawTitle(edt1.Text,true);
[...]
//DrawTitle('This is your text',false,0,'','bookmarkname');
[...]

The zoom button is not enabled because there is not a least one outline (DrawTitle add an outline when useoutline = true).
Have a nice day

Offline

#4 2012-10-08 08:28:53

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,206
Website

Re: Proposed two fix

There was indeed an issue.

But the fix was not exactly what you proposed.
See http://synopse.info/fossil/info/b4357cf338

Thanks a lot for the feedback.

Offline

#5 2012-10-10 09:09:06

MC
Member
Registered: 2012-10-04
Posts: 21

Re: Proposed two fix

I looked at your patch for SynTaskDialog http://synopse.info/fossil/info/bd704264b5.
Your code is not identical to the one I proposed but seems effectively correct.
So I tried it and... It did not work !
I reused my code and... It did work !
But... I don't know why ???!!!

This the test on a Windows XP where Calibri font is not installed so Tahoma font is used

[...]                  
var
  vDialogue : TTaskDialog;
begin
  vDialogue.Title   := 'My Title';
  vDialogue.Inst    := 'Lorem ipsum dolor sit amet consectetuer';
  vDialogue.Content := 'Libero interdum "' +
                       'necVestibulumidsedetwisinequetinciduntMorbiAliquampedetinciduntSedsempercursusorciipsumipsumegestasProinTortortempus' +
                       '" (' +
                       'neque libero Curabitur Donec non Morbi et odio ' +
                       'Praesent. Felis tincidunt vitae turpis malesuada fames\n\n'+
                       'sodales ac Suspendisse augue Aenean. Euismod Aenean non\n\n' +
                       'Morbi et vitae at hendrerit Quisque vitae accumsan. Tellus pretium adipiscing leo Curabitur\n\n' +
                       'Pellentesque turpis lacus Nulla.\n\n' +
                       'Curabitur faucibus risus eget nisl Lorem libero augue dui Nullam urna. Convallis';
  vDialogue.Buttons := 'Button1'#10'Button2';

  vDialogue.Verify        := 'Ne plus afficher ce message';
  vDialogue.VerifyChecked := False;

  vDialogue.Execute([], 100, [tdfUseCommandLinks], tiWarning);
  [...]

With your code below for AddLabel it does not work

function AddLabel(Text: string; BigFont: boolean): TLabel;
var R: TRect;
begin
  result := TLabel.Create(Form);
  result.Parent := Par;
  result.WordWrap := true;
  if BigFont then begin
    if aEmulateClassicStyle then begin
      result.Font.Height := FontHeight-2;
      result.Font.Style := [fsBold]
    end else begin
      result.Font.Height := FontHeight-4;
      result.Font.Color := $B00000;
    end;
  end else
    result.Font.Height := FontHeight;
  
  Text := CR(Text);
  result.AutoSize := false;
  R.Left := 0;
  R.Top := 0;
  R.Right := aWidth-X-8;
  R.Bottom := result.Height;
  R.Bottom := DrawText(result.Canvas.Handle,pointer(Text),-1,R,DT_CALCRECT or DT_WORDBREAK);
  result.SetBounds(X,Y,R.Right,R.Bottom);
  result.Caption := Text;
  inc(Y,R.Bottom+16);
end;

With my code below it does work

function AddLabel(const Text: string; BigFont: boolean): TLabel;
{NMD}
var
   vRect: TRect;
{NMD}
begin
  result := TLabel.Create(Form);
  result.Parent := Par;
  result.WordWrap := true;
  if BigFont then begin
    if aEmulateClassicStyle then begin
      result.Font.Height := FontHeight-2;
      result.Font.Style := [fsBold]
    end else begin
      result.Font.Height := FontHeight-4;
      result.Font.Color := $B00000;
    end;
  end else
    result.Font.Height := FontHeight;
  result.Left := X;
  result.Top := Y;

  {NMD}
  result.AutoSize := False;
  vRect := Rect(0, 0, aWidth-X-8, result.Height);
  result.Height := DrawText(result.Canvas.Handle, PChar(CR(Text)), - 1, vRect, DT_CALCRECT or DT_WORDBREAK);
  {NMD}

  result.Width := aWidth-X-8;
  result.Caption := CR(Text);
  inc(Y,result.Height+16);
end;

Did
Did I missed enormous something ?
Thanks for your help

Offline

#6 2012-10-10 10:04:29

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,206
Website

Re: Proposed two fix

In fact, after a call to DrawText() API, the R.Right content is changed!
I was not expecting this...

It should be fixed by http://synopse.info/fossil/info/df010b5e6b

Thanks for the feedback!

Offline

#7 2012-10-10 10:29:31

MC
Member
Registered: 2012-10-04
Posts: 21

Re: Proposed two fix

I tested successfully the last SynTaskDialog and SynPDF patches.
Thank you

Offline

Board footer

Powered by FluxBB