Jump to content

Function:centerWindow


Recommended Posts

Posted

function centerWindow(center_window) 
    local screenW,screenH=guiGetScreenSize() 
    local windowW,windowH=guiGetSize(center_window,false) 
    local x,y = (screenW-windowW)/2,(screenH-windowH)/2 
    guiSetPosition(center_window,x,y,false) 
end 
  

Example

  
local wnd = guiCreateWindow(...) 
centerWindow(wnd) 
  

Posted

You could make it;

function centerWindow(window) 
    local resX,resY = guiGetScreenSize() 
    local w,h = guiGetSize(window,false) 
    guiSetPosition(window,(resX/2)-(w/2),(resY/2)-(h/2),false) 
end 

Retired

Posted
2 lines are needed
guiSetProperty( gui-window, "HorizontalAlignment", "Centre") 
guiSetProperty( gui-window, "VerticalAlignment", "Centre") 

I think, shut up.

Posted

laserlaser, please respect the forum rules and don't use bad language, edit your post.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...