How do I find position of window derived from TGMainFrame

I have an class that derives from TGMainFrame. How do I find the position of the instatiated class? Also, how do I find the extents of my monitor (in the same units as the position)? I need to open a temporary TCanvas and when ever I do it typically covers my TGMainFrame derived window. I want to use the ctor that has the position and size and position it better… Thanks!

I am using root v5.06/00 on windows XP.

Ed Oltman

Hi Ed,

You can use the methods SetWMPosition(GetId(), x, y) and SetWMSize(GetId(), w, h) of TGMainFrame to tell the window manager the desired position [x,y] and the size [w,h] of your application window. The corresponding getters GetWMPosition(x,y) and GetWMSize(w,h) give you this information any time you need it. To have this window raised to the top of the stack (i.e. no sibling window can obscure it) call the method: gVirtualX->RaizeWindow(GetId());
Other useful methods might help you to find the best position on the screen. The display width and height are given by GetDisplayWidth() and GetDisplayHeight() of TClient. In case you need to take into account an already created canvas window, you could get its position from the methods GetWindowWidth(), GetWindowHeight(), GetWindowTopX() and GetWindowTopY() of TCanvas.

Cheers, Ilka