【发布时间】:2011-09-30 13:29:48
【问题描述】:
我在 StackOverflow 上阅读了一些帖子,但没有一个对我有用。这是我用来在表单上显示标准计算器窗口的代码:
procedure TForm1.Button1Click(Sender: TObject);
var
Tmp: Cardinal;
R: TRect;
begin
CalcWindow := FindWindow(nil, 'Calculator');
if (CalcWindow <> 0) then
begin
GetWindowThreadProcessID(CalcWindow, CalcProcessID);
Tmp := GetWindowLong(CalcWindow, GWL_STYLE);
Tmp := (Tmp and not WS_POPUP) or WS_CHILD;
SetWindowLong(CalcWindow, GWL_STYLE, Tmp);
GetWindowRect(CalcWindow, R);
SetForegroundWindow(CalcWindow);
Windows.SetParent(CalcWindow, Panel1.Handle);
SetWindowPos(CalcWindow, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE or SWP_FRAMECHANGED);
AttachThreadInput(GetCurrentThreadID(), CalcWindow, True);
end;
end;
它确实在我的表单上显示了窗口,但是玻璃边框丢失了,有时(尤其是当我移动我的表单时),很难将焦点恢复到嵌入的窗口(我需要点击几次)。
这可能是什么原因造成的?另外,您是否发现使用此方法可能会遇到任何潜在问题?
感谢您的宝贵时间。
【问题讨论】:
-
也许彼得下面的following post 与您相关。我没有看到您更改计算器的边框样式。
-
谢谢,但删除标题栏会使窗口失去主菜单。
-
众所周知,要让它发挥作用非常困难。为什么不嵌入原生 Delphi 计算器控件?
-
我希望能够嵌入任何应用程序,计算器只是一个例子。
-
@Pateman 我建议不要尝试将应用程序嵌入到您的应用程序中。