English 中文(简体)
将非《维也纳条约法公约》窗口添加到《维也纳条约法公约》的统一点
原标题:Adding non-VCL window into VCL align queue

一些背景( 继续) TLabel和Tome Box Captions Flicker on Resize:

  • So, I have an application that loads different plugins and creates a new tab on a TPageControl for each one.
  • Each DLL has a TForm associated with it.
  • The forms are created with their parent hWnd as the new TTabSheet. Since the TTabSheets aren t a parent of the form as far as VCL is concerned (didn t want to use dynamic RTL, and plugins made in other languages) I have to handle resizes manually.

我似乎正在讨论许多新问题(,但伟大的学习经验),涉及这种“插图”的应用类型。

因此,我目前的斗争正试图把 does带入关塔布特,但将直接改写。

Since this would be easier to explain with a picture: Visual representation of question Now I could manually do the alignment and the resize, but I d much rather have the VCL alignment procedures (alClient, alTop, etc) do it for me. That way I would just have to set the plugins alignment on its form without thinking.

在研究了《维也纳条约法公约》的渊源之后,我开始通过《统一守则》和《守则》的呼声。 基本上,TControl获得WM_ RESIZE:

  1. Call Realign() which calls AlignControl()
  2. AlignControl() will get the client rect and call AlignControls()
  3. AlignControls() will call DoAlign() for each TAlignment type in this order: alTop, alBottom, alLeft, alRight, alClient, alCustom, alNone
  4. DoAlign() will loop through FControls and FWinControls (which are TLists) and will align them appropriately

因此,我的想法是,如果我建立一个新的TWinControl,使其处理原始产品表格(window),并将它列入FControls清单,使之与我的工作适当一致。

Of course I m here, so it failed miserably. I even get an AV when exiting the application about an invalid window handle. My guess is that the TWinControl I created is trying to free the handle of the plugins form (window) which doesn t exist any more.

我尝试的是:

procedure AddHandleToControlList(AHandle: DWORD; Align: TAlign);
var
  NewWinControl : TWinControl;
begin
  NewWinControl := TWinControl.Create(frmMain);
  NewWinControl.WindowHandle := AHandle;
  NewWinControl.Align := Align;
  NewWinControl.Width := frmMain.ClientWidth;
  NewWinControl.Height := 30;
  NewWinControl.Parent := frmMain;
end;

procedure AddHandleToControlList(AHandle: DWORD; Align: TAlign);
var
  NewWinControl : TWinControl;
begin
  NewWinControl := TWinControl.Create(frmMain);
  NewWinControl.WindowHandle := AHandle;
  NewWinControl.Align := Align;
  NewWinControl.Width := frmMain.ClientWidth;
  NewWinControl.Height := 30;
  TWinControl(frmMain).Insert(NewWinControl);
end;

Soooo, thoughts?

EDIT 1:

Ok, so this correctly adds the control to the list and conforms the the TAlign set (why is it that I spend 8 hours trying to figure something out, I post here, and then the answer just appears...oh well someone might find this question and my ramblings useful):

procedure AddHandleToControlList(AHandle: DWORD; AName: PChar; ATop, ALeft, AWidth, AHeight: Integer; AAlign: TAlign);
var
  NewWinControl : TWinControl;
begin
  NewWinControl := TWinControl.Create(frmMain);
  With NewWinControl Do
    begin
    Name := AName;
    Top := ATop;
    Left := ALeft;
    Width := AWidth;
    Height := AHeight;
    Align := AAlign;
    WindowHandle := AHandle;
    Visible := True;
  end;
  TWinControl(frmMain).InsertControl(NewWinControl);
end;

现在的问题是,在申请结束时,我就错了AV......。 我将继续!

EDIT 2: Ok, so it is TWinControl.DestroyWindowHandle that raises the AV because the window handle doesn t exist any more. I m trying to think of a clean solution.

最佳回答

从<代码>TWinControl中选取一个新类别,并超越其虚拟<代码>DestroyWindowHandle()方法,不免除 HWNDTWinControl.DestroyWindowHandle(>的缺席执行,请Win32 2008/6DestroyWnd()

问题回答

暂无回答




相关问题
determining the character set to use

my delphi 2009 app has a basic translation system that uses GNUGetText. i had used some win API calls to prepare the fonts. i thought it was working correctly until recently when someone from Malta ...

Help with strange Delphi 5 IDE problems

Ok, I m going nuts here. For the last (almost) four years, I ve been putting up with some extremely bad behavior from my Delphi 5 IDE. Problems include: Seemingly random errors in coride50.bpl ...

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How convert string to integer in Oxygene

In Delphi, there is a function StrToInt() that converts a string to an integer value; there is also IntToStr(), which does the reverse. These functions doesn t appear to be part of Oxygene, and I can ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签