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.

Don't have Setup Factory?

If you want to purchase a license for Setup Factory 9, now is a good time! You can get 10% off the list price simply by clicking the banner below:

 

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

Security code
Refresh

Our Plugins & Examples Feed

  • Microsoft .NET Framework 4.5.2 Dependency added

    A new dependency installer was added to the site. Users of Setup Factory can now...

  • SQL Server 2014 Express (Database Only)

    A new dependency module was added to the site, now for Microsoft's SQL Server 2014...

Subscribe now!

Advertisement