Center Dialogs

  • Print

If your installer built with Setup Factory uses dialogs with custom sizes, you may notice that the dialogs won't show centered when you jump from a small dialog to a larger dialog or vice-versa. With this script, the new dialogs will always remain centered relative to the position of the former dialog.

How it works

  • Place this into the Global functions:
     
    function getScreenCenter()
      local tScreenCenter = {};
      local tProps = Screen.GetProperties();
      local hWnd = tProps.WindowHandle;
      local tPos = Window.GetPos(hWnd);
      local tSize = Window.GetSize(hWnd);
     
      tScreenCenter.X = tPos.X + tSize.Width/2;
      tScreenCenter.Y = tPos.Y + tSize.Height/2;
      return tScreenCenter;
    end
     
    function setScreenCenter(tScreenCenter)
      local tProps = Screen.GetProperties();
      local hWnd = tProps.WindowHandle;
      local tPos = Window.GetPos(hWnd);
      local tSize = Window.GetSize(hWnd);
      local CurrentDialog = {};
     
      CurrentDialog.X = tPos.X + tSize.Width/2;
      CurrentDialog.Y = tPos.Y + tSize.Height/2;
      local x = tPos.X + (tScreenCenter.X - CurrentDialog.X);
      local y = tPos.Y + (tScreenCenter.Y - CurrentDialog.Y);
      Window.SetPos(hWnd, x, y);
    end
     
  • Place this into each On Preload script of your dialogs:
     
    if (tScreenCenter ~= nil) then
      setScreenCenter(tScreenCenter);
    end
     
  • Place this into each On Back and On Next scripts of your dialogs:
     
    tScreenCenter = getScreenCenter();
     

With this code, the center of each dialog will not move when you navigate in the screens of your installer.

 

Add a comment (For questions, please use the contact form!)

Security code
Refresh

Our Plugins & Examples Feed

  • Dependency module for Setup Factory: Visual C/C++ 2010 SP1

    New dependency modules to add runtime support for applications developed with Microsoft Visual C/C++ 2010...

  • LuaFileSystem 1.5.0 for AutoPlay Media Studio 8

    LuaFileSystem is a Lua library developed to complement the set of functions related to...

Subscribe now!

Do you need help?

clockWe provide customer support for Indigo Rose software development products since 2008!
Please contact us if you need assistance for designing, debugging, or finishing your project on time.