Create Button on other application window

泄露秘密 提交于 2019-12-05 15:29:24

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;

you must make Visible:= False.

var
  Hand: THandle;
  Object1: TButton;
begin
  Hand:= FindWindow('TForm1', 'Form1');
  if Hand <> 0 then
  begin
    Object1:= TButton.CreateParented(Hand);
    Object1.Caption:= 'Test';
    Object1.Visible:= False ;
    Object1.Show;
  end;
end;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!