在另一个TForm中嵌入TForm时如何避免出现问题? [英] How to avoid issues when embedding a TForm in another TForm?

查看:209
本文介绍了在另一个TForm中嵌入TForm时如何避免出现问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常将 TForm descendant嵌入另一个 TForm 后裔:

  var 
Form1:TForm1;
Form2:TForm2;
begin
Form2.Parent:= Form1;
Form2.BorderStyle:= bsNone;
Form2.Align:= alClient;
Form2.Show;
结束通常这样做很好,但有时Form2中的控件没有正确对齐。有没有一般的解决方法,这种问题?



有人知道是什么导致这种不对齐?



我知道我可以使用 TFrame 进行这种工作,但是我有很多的库代码,我不得不重写,我没有看到任何理由 TForm 中的 TForm 不适用于



编辑:我已经将组件 TcxListView 确定为这里的罪魁祸首,我向组件供应商(DevExpress)提交了一个错误报告:



http://www.devexpress.com/issue=B194161



编辑2: DevExpress的开发人员已经分析了这个问题,并表示它实际上是 TGARPANEL 由Embarcadero组件:



http://qc.embarcadero.c om / wc / qcmain.aspx?d = 90324

解决方案

我也这样做,我使用以下例程来实现:

 程序TMyForm.PlaceInsideContainer(Container:TWinControl); 
begin
父项:=容器;
对齐:= alClient;
BorderIcons:= [];
BorderStyle:= bsNone;
ParentBackground:= True;
显示;
结束

我没有问题。我可以想象的唯一的区别可能是相关的是BorderIcons的转让,但我会怀疑会导致一个问题。


I often embed a TForm descendant into another TForm descendant like this:

var
  Form1: TForm1;
  Form2: TForm2;
begin
  Form2.Parent      := Form1;
  Form2.BorderStyle := bsNone;
  Form2.Align       := alClient;
  Form2.Show;
end;

Usually this works just fine, but sometimes the controls in Form2 are not aligned properly. Is there a general workaround for this sort of problem?

Does anybody know what is causing this "misalignment"?

I know that I could use TFrame for this kind of job, but I have a lot of library code that I would have to rewrite and I do not see any reason why the TForm in TForm approach should not work?

Edit: I have identified the component TcxListView as the culprit here, I have submitted a bug report to the component vendor (DevExpress):

http://www.devexpress.com/issue=B194161

Edit 2: The developers at DevExpress have analyzed the problem and said that it is actually a defect in the TGridPanel component by Embarcadero:

http://qc.embarcadero.com/wc/qcmain.aspx?d=90324

解决方案

I do this as well and I use the following routine to make it happen:

procedure TMyForm.PlaceInsideContainer(Container: TWinControl);
begin
  Parent := Container;
  Align := alClient;
  BorderIcons := [];
  BorderStyle := bsNone;
  ParentBackground := True;
  Show;
end;

I have no problems with this. The only difference that I could possibly imagine could be relevant is the assignment of BorderIcons, but I would doubt that causes a problem.

这篇关于在另一个TForm中嵌入TForm时如何避免出现问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆