有什么方法可以排除VCL样式的样式,避免其样式对话框的边框。
通过调用MessageDlg或ShowMessage分别显示一个对话框。
我读了一些有关“通往Delphi的道路”(这是一个很棒的网站)的文章,但找不到答案。
这是我想要实现的目标:
现在(带有样式边框的碳风格):
目标(具有标准窗户边框的碳风格):
我仍然想要样式控件,但没有样式边框。
从父窗体StyleElements中删除seBorder
并不能解决问题。
谢谢!
最佳答案
MessageDlg()
和ShowMessage()
是Delphi VCL函数。他们动态创建了一个Delphi TForm
并显示它,因此您没有机会对其进行自定义。但是,可以改用CreateMessageDialog()
创建相同的TForm
,然后根据需要修改其样式元素,然后显示它。例如:
function DoMessageDlgPosHelp(MessageDialog: TForm; X, Y: Integer): Integer;
begin
with MessageDialog do
try
if X >= 0 then Left := X;
if Y >= 0 then Top := Y;
if (Y < 0) and (X < 0) then Position := poScreenCenter;
Result := ShowModal;
finally
Free;
end;
end;
procedure ShowStyledMessage(const Msg: string; const StyleElements: TStyleElements);
var
Form: TForm;
begin
Form := CreateMessageDialog(Msg, mtCustom, [mbOK]);
Form.StyleElements := StyleElements;
DoMessageDlgPosHelp(Form, -1, -1);
end;
这样称呼它:
ShowStyledMessage('Some text', [seFont, seClient]);
对话框如下所示:
关于delphi - 从样式Dialog/ShowMessage边框中排除VCL样式,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29046468/