We only have partial control of the ZOrder (the order of the layering of Windows/Controls that are displayed). You can use the :SetZOrder() method to set an order relative to other Lua windows with higher values displaying in front of lower values. However, we have somewhat limited control with how our windows order in relation to the built-in UI elements.
SetZOrder(-1) will force a Lua window to stay always behind the Turbine UI elements (similar to HWND_BOTTOM in the Windows SetWindowPos API function except the window will stay at the bottom of the ZOrder regardless of focus and you can assign lower values which are valid relative to other Lua windows).
SetZOrder(0) will display the Lua window initially in front of most UI elements but it will be subject to falling behind any UI element that gets focus - for instance, you display your window and then open the inventory, the bags will display over your window until the user clicks on your window to bring it to front. The built-in toolbar doesn't seem to behave like a standard UI element since it seems to stay behind Lua windows when SetZOrder(0) is used.
SetZOrder(1) or any higher value will force the Lua window to stay in front of all Turbine UI elements regardless of focus (similar to HWND_TOPMOST in SetWindowPos terminology except you can assign higher values which are valid relative to other Lua windows).
Basically, windows with the same ZOrder will layer based on focus within their assigned layer of ZOrder and most of the built-in UI elements are treated as ZOrder=0. So windows with ZOrder=-2 will always be behind all elements with a higher ZOrder, but within those windows, the one that gets focus will be in front of the others of the same ZOrder. Similarly windows with ZOrder=5 will be in front of all windows with ZOrder<5 but behind all windows with ZOrder>5.
Note, using SetZOrder on a control will order the control relative to other controls on the same window, but the window's ZOrder determines whether the entire window (and it's controls) is in front of or behind another window.
Also, using SetStretchMode() will allow a control to draw outside the bounds of it's parent (think Owner in Windows terms), sometimes overlaying elements that it should not - this appears to be a bug but since SetStretchMode() is an undocumented method, there has been no response from Turbine whether this is indeed a bug.
Last edited by Garan : 09-02-2011 at 11:13 PM.