Jump to content


Photo

ShowDialog improvement


  • Please log in to reply
6 replies to this topic

#1 Igor Savkic

Igor Savkic
  • Members
  • 185 posts

Posted 13 April 2016 - 07:19 PM

Application.ShowDialog creates TW3AlertDialog and specifies fixed size (280x200), in lot of cases that size isn't good (text is clipped). It's necessary to have a mechanism to customize this dialog (change dialog size mostly, text size and font and buttons caption).

It would be also good that dialog dynamically change to accomodate text size (shrinks for small texts and grows for large)


  • ielite, markus_ja and recursiveElk like this

#2 Igor Savkic

Igor Savkic
  • Members
  • 185 posts

Posted 11 May 2016 - 12:26 PM

In case someone needs a auto adjust size solution, change TW3CustomApplication.ShowDialog to

 

procedure TW3CustomApplication.ShowDialog(aCaption: String;aText: String; aOptions: TW3AlertOptions);
var
  dx, dy: Integer;
  Temp: TW3TextMetric;
begin
  if not GetDialogActive then
  begin
    FBlockBox := TW3BlockBox.Create(Display);
    FBlockBox.SetBounds(0, 0, Display.Width, Display.Height);

    (* We want to center our dialog should the blockbox be
       resized. So we hook into the resize mechanism *)
    FBlockBox.OnResize := HandleDialogBlockerReSize;

    FDialog := TW3AlertDialog.Create(FBlockBox);
    FDialog.OnSelect := HandleDialogFeedBack;

    if Length(aText) > 0 then
    begin
      Temp := W3FontDetector.MeasureText(W3FontDetector.getFontInfo(FDialog.Handle), aText);
      FDialog.Width := Max(280, Temp.tmWidth);
      FDialog.Height := Max(200, Temp.tmHeight);
    end;

//    FDialog.Width := 280;
  //  FDialog.Height := 200;

    dx := (FBlockBox.Width - FDialog.Width) div 2;
    dy := (FBlockBox.Height - FDialog.Height) div 2;

    FDialog.SetBounds(dx,dy,FDialog.Width,FDialog.Height);
    (FDialog as IW3AlertDialog).SetupDialog(aCaption, aText, aOptions);
  end else
    raise EW3Application.Create('A dialog is already active error');
end;
 

  • ielite, Nico Wouterse and recursiveElk like this

#3 recursiveElk

recursiveElk
  • Members
  • 36 posts

Posted 25 August 2017 - 05:13 AM

+1 Would also appreciate a more dynamic box to use.

#4 Dennis07

Dennis07
  • Administrators
  • 24 posts
  • LocationBerlin, Germany
  • Enterprise Edition

Posted 07 September 2017 - 01:51 PM

+1 Would also appreciate a more dynamic box to use.


What do you mean? Do you mean that the RTL should include an overloaded version with specifyable dimensions?

#5 recursiveElk

recursiveElk
  • Members
  • 36 posts

Posted 15 September 2017 - 05:31 AM

I would find that useful, as well as basic font / size parameters like any of the SmartCL.Controls. Whether that be an adjustment to ShowDialog or something else, i attempted to use ShowModal instead but couldn't get it to work to well.

#6 Dennis07

Dennis07
  • Administrators
  • 24 posts
  • LocationBerlin, Germany
  • Enterprise Edition

Posted 18 September 2017 - 10:35 AM

Thank you for this, I will discuss this with the team and I'm sure it will find a way into the final 2.3 version!
  • recursiveElk likes this

#7 recursiveElk

recursiveElk
  • Members
  • 36 posts

Posted 19 September 2017 - 12:05 AM

Thanks! it's been a while since i last used it but i did recall wanting an easier way access the internal components of the dialog to do things like set the style-class for the components used in it too, (I believe they were called something like .TW3AlertDialog and .TW3AlertButton in the style sheet so i just replaced those instead).




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users