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! For a limited period, 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

  • HTTP Actions plugin updated to 2.1.0.0

    Two new actions were added to the HTTP plugin:

    • HTTP.ResumeDownload()
    • HTTP.ResumeDownloadSecure()

    With these new "Resume" actions, you can...

  • Unicode Actions plugin updated to 2.0.3.0

    A new version of the Unicode actions plugin was released.

    Changes were made to the code...

Subscribe now!

Customer Login



mindquake.com.br Webutation

Click to check at AVG ThreadLabs

All installers digitally signed

Click to visit McAfee SiteAdvisor

Mindquake.com.br is gold certified

PageRank Checker