在其他应用程序窗口中创建按钮 [英] Create Button on other application window
问题描述
我写下面的代码,在计算器上创建一个额外的按钮,但按钮不显示:
I wrote below code to create an extra button on Calculator, but the button don't show:
var
Object1 : TButton ;
Hand: THandle;
begin
Hand:= FindWindow('CalcFrame', 'Calculator');
Object1 := TButton.CreateParented(Hand);
Object1.Show ;
end;
使用EnumChildWindow API函数运行上述代码后,我可以在计算器上获取控件,并查看创建的按钮在控制列表中,EnumChildWindow返回,但是为什么创建的按钮不显示?
I get the controls on the calculator after running the above code using EnumChildWindow API function and see the created button in control list that EnumChildWindow returns, but why does the created button not show ?
我记得我在Windows XP中使用这个代码,它的工作没有问题,但现在在Windows 7创建的按钮不会出现。
As I remember I use this code on windows XP and it works without problem but now in windows 7 the created button doesn't appear.
推荐答案
计算器和Win7中的Paint是使用.NET和WPF重建的
和
没有办法通过本地代码
特别是使用不同的
方式来绘制其控件来联系
.NET代码。
calculator and Paint in Win7 are rebuilt using .NET and WPF, and there is no way to "contact" with .NET code through native code especially WPF which use different way to paint its controls.
编辑:
使您的代码适用于本地
应用程序,您可以使用这样的代码:
edit: to make your code work for native applictions you can use code like this:
hand := FindWindow('TForm1','Form1');
object1 := TButton.Create(self);
object1.ParentWindow := hand;
这篇关于在其他应用程序窗口中创建按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!