EditorWindow: how to get item's rect in window space?

I’m placing items (like buttons) in a window using GUILayout. I would like to know what is the rect of each such entity in window’s coordinates. I found something here (How do you find the rect of a GUILayout item? - Questions & Answers - Unity Discussions) but it does not entirely solve my problem. My problem is more complex because I place GUI items in subwindows (created with GUI.Window) and this function (GUILayoutUtility.GetLastRect) gives me wrong values (for instance, when I try to read x and y coords of the resulting rect structure I get only zeroes). Any idea how to solve this issue?

Can you post some example code of what’s not working for you?

My code right now is quite tubby so it’s hard to quickly post some code.

The point is that this function Unity - Scripting API: GUILayoutUtility.GetLastRect works fine as long as it is called in OnGUI. When I create subwindow using {Begin/End}Windows and create GUI elements in those sub-windows, GetLastRect() returns zeroes instead of rects of controls create in sub-windows.