Jump to content

ShowDialog improvement

Recommended Posts

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)

Link to post
Share on other sites
  • 4 weeks later...

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



procedure TW3CustomApplication.ShowDialog(aCaption: String;aText: String; aOptions: TW3AlertOptions);
  dx, dy: Integer;
  Temp: TW3TextMetric;
  if not GetDialogActive then
    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
      Temp := W3FontDetector.MeasureText(W3FontDetector.getFontInfo(FDialog.Handle), aText);
      FDialog.Width := Max(280, Temp.tmWidth);
      FDialog.Height := Max(200, Temp.tmHeight);

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

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

    (FDialog as IW3AlertDialog).SetupDialog(aCaption, aText, aOptions);
  end else
    raise EW3Application.Create('A dialog is already active error');
Link to post
Share on other sites
  • 1 year later...
  • 2 weeks later...
  • Administrators

Just as a notification: The overloaded ShowDialog() method has been implemented to the RTL and will be available with the next update. With it, you'll be able to define the dimensions of the dialog window. For additional customization like the font you'll however still need to stick to the OOP TW3AlertDialog way. ;)

Link to post
Share on other sites

The ShowDialog function could do with a bit more love. Currently it is not possible to entirely style the box and contents. Which limits the effectiveness of the dialog when it doesn't play nice with the form styling. In our case we all often have CSS applied to labels and form etc that are not suitable for a more business like dialog box.


For example I get the following result. The image shows that the title has the bottom cut off the letter "g"




Can you please open it up so that we can style the entire dialog using css. Cheers

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...