使用Delphi XE2,您可以选择将自定义样式(皮肤)嵌入到VCL项目中。
一切正常。现在我将一些表单分成动态显示的分隔dll
当然那些没有剥皮。我该如何纠正?
我想我必须以某种方式打电话给TVisualStyle,但没有运气。
主持人:
procedure TForm1.Button1Click(Sender: TObject);
var
l: THandle;
p: procedure (const h: THandle); stdcall;
begin
l:= LoadLibrary('project1.dll');
if l > 0 then
begin
@p:= GetProcAddress(l,'ShowIt');
p(Application.Handle);
FreeLibrary(l);
end;
end;
dll:
procedure ShowIt(const h: THandle);stdcall;
var
form: TForm;
b: TButton;
han: THandle;
begin
han:= Application.Handle;
Application.Handle:= h;
form :=Tform.Create(Application);
b:= TButton.Create(form);
b.Parent:= form;
b.Caption:= 'ytes';
b.Left:= 2;
b.Top:= 2;
form.ShowModal;
form.Release;
Application.Handle:= han;
end;
exports ShowIt ;
begin
end.
非常标准的东西。现在,要使dll表单使用主机的样式主题,究竟必须做些什么?
答案 0 :(得分:14)
您有两个不同的VCL实例。您已在可执行文件所拥有的StyleServices
实例中设置了样式,但您的DLL并不知道它。您可以通过以下任一方式解决此问题:
StyleServices
实例。答案 1 :(得分:0)
我遇到了很多麻烦,因为我使用的是themes
而不是VCL.THEMES
和VCL.STYLES
。
Delphi引发customeStyleException
说“未找到风格”或EcustomStyleException
“此风格不支持此功能”