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

  • POP3 Actions plugin released

    A new, free actions plugin was released today. With it, the developer can check POP3...

  • Reminder: Update Serial Number Validation and/or Subscription Validation

    Next week IPInfoDB's API 2.0 will stop working. If you use an older version than...

Subscribe now!

Advertisement