<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.technet.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How Can I Center an HTA on the Screen?</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2005/10/10/how-can-i-center-an-hta-on-the-screen.aspx</link><description>Hey, Scripting Guy! How can I center an HTA on the screen? -- BH 
 Hey, BH. Well, we have an answer for you, although it’s not perfect: we can resize (if need be) and center your window, but there will be a momentary flash on the screen when all this</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: How Can I Center an HTA on the Screen?</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2005/10/10/how-can-i-center-an-hta-on-the-screen.aspx#3557643</link><pubDate>Sun, 10 Mar 2013 02:45:08 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3557643</guid><dc:creator>BRFX</dc:creator><description>&lt;p&gt;Another Solution to resolve the flicker is to make the script do an initial re-size to 1px and move off screen, then on Window_OnLoad bring the script back on screen (after the calculations have been made.) &lt;/p&gt;
&lt;p&gt;This should work, with a slight delay/problem:&lt;/p&gt;
&lt;p&gt;1: user will see the Program Load by additional Taskbar app being indicated, yet the application would not have appeared into view yet. Depending on how much the content loaded takes the user might think that it failed to load. &lt;/p&gt;
&lt;p&gt;Could be solved by adding &amp;nbsp;SHOWINTASKBAR=&amp;quot;no&amp;quot; to the HTA:Application portion of the &amp;lt;Head&lt;/p&gt;
&lt;p&gt;2. The Flicker might still manifest, yet should be minimal as compared without the initial resize, then move.&lt;/p&gt;
&lt;p&gt;I was able to view the flicker on my computer (Intel P4 desktop with 2GB DDR), yet not on my work laptop (Intel i5 laptop with 8GB DDR3)&lt;/p&gt;
&lt;p&gt;&amp;lt;SCRIPT Language=&amp;quot;VBScript&amp;quot;&amp;gt;&lt;/p&gt;
&lt;p&gt;window.resizeto 1,1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;#39;makes the app just 1px or as significant as 1 dead-pixel&lt;/p&gt;
&lt;p&gt;window.moveto -100,-100 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;makes the app move someplace it can&amp;#39;t be seen&lt;/p&gt;
&lt;p&gt;Sub Window_Onload&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;strComputer = &amp;quot;.&amp;quot;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Set objWMIService = GetObject(&amp;quot;winmgmts:\\&amp;quot; &amp;amp; strComputer &amp;amp; &amp;quot;\root\cimv2&amp;quot;)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Set colItems = objWMIService.ExecQuery(&amp;quot;Select * From Win32_DesktopMonitor&amp;quot;)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;For Each objItem in colItems&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;intHorizontal = objItem.ScreenWidth&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;intVertical = objItem.ScreenHeight&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Next&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; intLeft = (intHorizontal - 300) / 2&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; intTop = (intVertical - 200) / 2&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;window.resizeTo 300,200&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;window.moveTo intLeft, intTop&lt;/p&gt;
&lt;p&gt; End Sub&lt;/p&gt;
&lt;p&gt;&amp;lt;/SCRIPT&amp;gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3557643" width="1" height="1"&gt;</description></item><item><title>re: How Can I Center an HTA on the Screen?</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2005/10/10/how-can-i-center-an-hta-on-the-screen.aspx#3465976</link><pubDate>Thu, 17 Nov 2011 23:21:42 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3465976</guid><dc:creator>JV</dc:creator><description>&lt;p&gt;Since 2005 we have moved from Civil War techniques to modern methods.&lt;/p&gt;
&lt;p&gt;window.moveTo (screen.width - document.body.clientwidth)/2, (screen.height - document.body.clientheight)/2&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3465976" width="1" height="1"&gt;</description></item><item><title>re: How Can I Center an HTA on the Screen?</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2005/10/10/how-can-i-center-an-hta-on-the-screen.aspx#3465960</link><pubDate>Thu, 17 Nov 2011 21:38:10 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3465960</guid><dc:creator>Mnemonic</dc:creator><description>&lt;p&gt;This does not work if the HTA is running as a non-admin user.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3465960" width="1" height="1"&gt;</description></item><item><title>re: How Can I Center an HTA on the Screen?</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2005/10/10/how-can-i-center-an-hta-on-the-screen.aspx#3451269</link><pubDate>Tue, 06 Sep 2011 02:48:29 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3451269</guid><dc:creator>jrv</dc:creator><description>&lt;p&gt;Jim - &lt;/p&gt;
&lt;p&gt;Windows changes constantly. When this article was writen in 2005, Windows was just a little baby. &amp;nbsp;Today Windows is all grown up. &amp;nbsp;Windows can remain stable and centered without much help from the outside community.&lt;/p&gt;
&lt;p&gt;Windows is very thankful for all of your help.&lt;/p&gt;
&lt;p&gt;If you need any furthur assistance from Windows please contact you vendor.&lt;/p&gt;
&lt;p&gt;Thsnk you - The Window Washers Team.&lt;/p&gt;
&lt;p&gt;P.S. - Good luck with that long division. &amp;nbsp;Even Dr. Scripto has trouble with that.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3451269" width="1" height="1"&gt;</description></item><item><title>re: How Can I Center an HTA on the Screen?</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2005/10/10/how-can-i-center-an-hta-on-the-screen.aspx#3451265</link><pubDate>Tue, 06 Sep 2011 02:02:25 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3451265</guid><dc:creator>Jim</dc:creator><description>&lt;p&gt;or try&lt;/p&gt;
&lt;p&gt;window.moveTo (screen.width - document.body.clientwidth)/2, (screen.height - document.body.clientheight)/2&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3451265" width="1" height="1"&gt;</description></item><item><title>re: How Can I Center an HTA on the Screen?</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2005/10/10/how-can-i-center-an-hta-on-the-screen.aspx#3381642</link><pubDate>Fri, 21 Jan 2011 08:26:59 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3381642</guid><dc:creator>Fred</dc:creator><description>&lt;p&gt;Hi Derek,&lt;/p&gt;
&lt;p&gt;Maybe your computer have more than one Desktop Monitor available.&lt;/p&gt;
&lt;p&gt;Try something like this :&lt;/p&gt;
&lt;p&gt;[...]&lt;/p&gt;
&lt;p&gt;Set colItems = objWMIService.ExecQuery(&amp;quot;Select * From Win32_DesktopMonitor&amp;quot;)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; For Each objItem in colItems&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; if objItem.Availability = 3 then&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; intHorizontal = objItem.ScreenWidth&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; intVertical = objItem.ScreenHeight&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; end if&lt;/p&gt;
&lt;p&gt; &amp;nbsp; Next&lt;/p&gt;
&lt;p&gt;[...] &lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://msdn.microsoft.com/en-us/library/aa394122(VS.85).aspx"&gt;msdn.microsoft.com/.../aa394122(VS.85).aspx&lt;/a&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3381642" width="1" height="1"&gt;</description></item><item><title>re: How Can I Center an HTA on the Screen?</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2005/10/10/how-can-i-center-an-hta-on-the-screen.aspx#3379005</link><pubDate>Fri, 07 Jan 2011 23:57:22 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3379005</guid><dc:creator>Derek Ralph</dc:creator><description>&lt;p&gt;I copied and pasted the above code and when I run the HTA I get the following error:&lt;/p&gt;
&lt;p&gt;Line: 26&lt;/p&gt;
&lt;p&gt;Error: Type mismatch.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3379005" width="1" height="1"&gt;</description></item><item><title>re: How Can I Center an HTA on the Screen?</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2005/10/10/how-can-i-center-an-hta-on-the-screen.aspx#3374389</link><pubDate>Fri, 10 Dec 2010 17:23:44 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3374389</guid><dc:creator>Steven Harvey</dc:creator><description>&lt;p&gt;If you trigger the sub before the HTA:APPLICATION tag, you shouldn&amp;#39;t get the flashing window.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3374389" width="1" height="1"&gt;</description></item><item><title>re: How Can I Center an HTA on the Screen?</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2005/10/10/how-can-i-center-an-hta-on-the-screen.aspx#3353922</link><pubDate>Tue, 07 Sep 2010 06:28:01 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3353922</guid><dc:creator>John Thompson</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;To remove the flicker, rename Window_Onload to something else and call it before the body renders.&lt;/p&gt;
&lt;p&gt;......&lt;/p&gt;
&lt;p&gt;&amp;lt;/head&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;script&amp;gt;&lt;/p&gt;
&lt;p&gt;Sub DoResize &amp;#39;Do not use Window_Onload&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;window.resizeTo 800,600&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;strComputer = &amp;quot;.&amp;quot;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;Set objWMIService = GetObject(&amp;quot;Winmgmts:\\&amp;quot; &amp;amp; strComputer &amp;amp; &amp;quot;\root\cimv2&amp;quot;)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;Set colItems = objWMIService.ExecQuery(&amp;quot;Select * From Win32_DesktopMonitor&amp;quot;)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;For Each objItem in colItems&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;intHorizontal = objItem.ScreenWidth&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;intVertical = objItem.ScreenHeight&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;Next&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;intLeft = (intHorizontal - 800) / 2&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;intTop = (intVertical - 600) / 2&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;window.moveTo intLeft, intTop&lt;/p&gt;
&lt;p&gt;End Sub&lt;/p&gt;
&lt;p&gt;DoResize() &amp;#39;Run the subroutine to position the containing window (your HTA dialog) before the body is rendered.&lt;/p&gt;
&lt;p&gt;&amp;lt;/script&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;body&amp;gt;&lt;/p&gt;
&lt;p&gt;......&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3353922" width="1" height="1"&gt;</description></item></channel></rss>