Colors of the TDialogService.MessageDialog

孤街浪徒 提交于 2019-12-08 12:50:42

问题


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

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:

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


回答1:


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:

Now I should investigate of the system icons loading



来源:https://stackoverflow.com/questions/42928717/colors-of-the-tdialogservice-messagedialog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!