How to get the size of an external window

Asked

Viewed 395 times

3

In my case I have an application that runs parallel to a third party application which I don’t have access to the source, I need my program to capture the size of this window to display a form of the same size at the same position.

1 answer

3


I’ll pass the basics for you to implement, first we need to find out what the Handle of the application:

var
hWindow : THandle;
begin
    hWindow := FindWindow(nil, 'Calculadora');
end;

With this we can get the positions to overlap your application:

var
Left, Top, Width, Height: Word;
begin
     GetWindowRect(hWindow, R);
     Left := R.Left;
     Top := R.Top;
     Width := R.Right - R.Left;
     Height := R.Bottom - R.Top;
end;

And then move the application to the size of your form:

Windows.MoveWindow(hWindow, Form1.ClientHeight, Form1.ClientWidth, r.right-r.left,r.bottom-r.top, true); 

Try to implement this in your application, and make the necessary changes.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.