0

Can you explain how I can get used colors of the TDialogService.MessageDialog window?

MessageDialog

Update: Which created using this command:

  TDialogService.MessageDialog('Test3: Confirmation', MsgDlgType.mtConfirmation,
    [TMsgDlgBtn.mbOK], TMsgDlgBtn.mbOK, 0,
    procedure(const AResult: TModalResult)
    begin
    end);

I need color of the bottom panel (Button parent) and background color of the message. I need this color to make my own dialog looks like FMX default dialog.

Currently I have my own highly customizable dialog which looks like this:

Custom MessageDialog

And also where I can get icons which used in TDialogService.MessageDialog window?

Alex Egorov
  • 907
  • 7
  • 26
  • 4
    The icons are the standard icons that you can load with `LoadIcon`. Read the documentation for that function. The top dialog isn't an FMX dialog, I dont't think, it looks like the system `MessageBox` or `TaskDialog`. As for the colors and the painting, I'd expect you to use the `TASKDIALOG` parts and states from the theme API: https://msdn.microsoft.com/en-us/library/windows/desktop/bb773210.aspx – David Heffernan Mar 21 '17 at 13:38
  • Thank you for information, top dialog created with delphi code (added to question) and this is not system dialog (contain bug with button theme) – Alex Egorov Mar 21 '17 at 13:43
  • Oh, so you've got the source code for the dialog then? Can you read it? I don't have the Berlin source to hand. – David Heffernan Mar 21 '17 at 13:46
  • You are right, this is uses MessageBoxIndirect internally – Alex Egorov Mar 21 '17 at 13:52
  • The button problem is due to a missing comctl32 v6 manifest I guess – David Heffernan Mar 21 '17 at 13:54
  • 3
    All in all, I expect my first comment contains the germs of what you need. – David Heffernan Mar 21 '17 at 13:55

1 Answers1

0

Thanks to the answer of David Heffernan and Triber:

procedure GetThemeBackgroud(AImage: TImage; ATheme: HTHEME; APartID: Integer);
var
  stream: TMemoryStream;
  bitmap: Vcl.Graphics.TBitmap;
begin
  bitmap := Vcl.Graphics.TBitmap.Create;
  try
    bitmap.Width := Round(AImage.Width);
    bitmap.Height := Round(AImage.Height);
    DrawThemeBackground(ATheme, bitmap.Canvas.Handle, APartID, 0,
                        Rect(0, 0, bitmap.Width, bitmap.Height), nil);
    stream := TMemoryStream.Create;
    try
      bitmap.SaveToStream(stream);
      AImage.Bitmap.LoadFromStream(stream);
    finally
      stream.Free;
    end;
  finally
    bitmap.Free;
  end;
end;

procedure GetThemeBackgroud;
var
  theme: HTHEME;
begin
  theme := OpenThemeData(0, 'TASKDIALOG');
  if theme <> 0 then
  try
    // Client color
    GetThemeBackgroud(imgClient, theme, TDLG_PRIMARYPANEL);
    // Bottom color
    GetThemeBackgroud(imgBottom, theme, TDLG_SECONDARYPANEL);
  finally
    CloseThemeData(theme);
  end;
end;

Here we should to add 2 TImages: client and buttons parents:

enter image description here

Now I should investigate of the system icons loading

Community
  • 1
  • 1
Alex Egorov
  • 907
  • 7
  • 26