The task is to display the coordinates of the upper left corner and the size of the window as a whole in the window. The GetWindowRect function obtained the coordinates for the upper left corner, and now how is the window size as a whole? Googled such a record:

var R: TRect; begin GetWindowREct(Form1.Handle,R); Label3.Caption := IntToStr(R.Right-R.Left )+':'+IntToStr(R.Bottom-R.Top); 

I did not understand what was happening) Is it possible to do it differently?

  • Code on delphi, and in c ++ tags? Something is wrong here. - cybrex

2 answers 2

Googled such a record:

There "Form1.Handle" means HWND windows, TRect is RECT.
Do not forget that there is a window frame, and there is a client area.

    If we subtract the left one from the right coordinate, then we get the width. Almost work out. Due to the discrete nature of the pixels, it would be worth adding 1. Unless, of course, the function returns the border as the first pixel outside the window, which is highly unlikely. It seems, all the same returns.

    With a height similar.

    • Everything. Understood. Easier than I thought. The truth is not sure that the record in individual variables is correct. It outputs normally, but probably everything could be pushed into one variable like that. int a = (rect.right) - (rect.left); int b = (rect.bottom) - (rect.top); - Fant1
    • It is quite possible to do without such a monstrous number of brackets - outcast