A long time ago i was suffering with this issue too. I figured it out, and since that, i'm using this.
This will put the dx on the center of the screen always.
local screenSize = {guiGetScreenSize()}
local panelW, panelH = 300, 150 --// panelW = panel Widht | panelH = panelHeight
local panelX, panelY = screenSize[1]/2-panelW/2, screenSize[2]/2-panelH/2
--// use
addEventHandler('onClientRender', root, function()
dxDrawRectangle(panelX, panelY, panelW, panelH, tocolor(0, 0, 0, 200) )
--// if you want to make a button of course smaller, you can do like this
dxDrawRectangle(panelX, panelY, panelW, panelH - 125, tocolor(0, 0, 0, 200) )
end)