I am trying to build a GUI with a C++ project using ROOT. It goes through a TApplication. I can create a button within a TGMainFrame (Frame 1) that will open another TGMainFrame (Frame 2). I can toggle the new window using the UnmapWindow and MapWindow functions from TGMainFrame.
However, I would like that the frame 2 appears on the right of the frame 1.
My approach is to try to get the frame 1 position on screen, and to apply it to frame 2 with an offset corresponding to frame 1 width. I tried to use GetWindowSize from gVirtualX to get the frame 1 position as I don’t find a fitting function in TGWindow, TGFrame, etc. But the numbers I get does not seem to correspond to the reality (I access window id by frame1->GetId()). Dragging the window or resizing it does not change these numbers.
Thanks for your reply.
Unfortunately, SetWMPosition does not seem to affect the positionning of my frame 1 and frame 2 (it just put them in the top left corner now by default, no matter the values I set).
The GetWMPosition provide the right values (set by user, 200 and 100) but SetWMPosition does not seem to do the job.
I tried to execute the lines you suggested and they lead to the same result I get in my project.
Alright it seems to work now, thanks !
Could you elaborate further why it is required to set the position through both SetWMPosition and Move/MoveResize please ?
Is it actually possible to get the current coordinate on screen after a window drag by user ? For instance, if I move my frame 1, the frame 2 will appear at the old position, not at the new one I expect him to be.