Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Size HTA window on load

2,877 views
Skip to first unread message

XP

unread,
May 6, 2007, 5:24:00 PM5/6/07
to
When my HTA opens, I would like the window to be a specific size (as in
pixels, inches, or whatever) in height and width and lock at that size.

How can I do this? Can someone please post generic example code?

Thanks much in advance for your assistance...

mayayana

unread,
May 6, 2007, 6:02:53 PM5/6/07
to
In the BODY_onload sub you can use this:

'-- x and y would be your desired pixel width and height:

window.resizeTo x, y

'-- to center:
window.moveTo ((screen.availWidth \ 2) - (x \ 2)), ((screen.availHeight \
2) - (y \ 2))

That code works on IE 5 and 6. I'm not sure about IE7.

--------------

MikeB

unread,
May 6, 2007, 6:31:40 PM5/6/07
to
<html>

<HEAD>
<TITLE>This is the Application Caption</TITLE>
<SCRIPT type="text/jscript">
// Always Set Size Here to Avoid Flicker
window.moveTo(0,0);
window.resizeTo(320,240);
</SCRIPT>
<HTA:APPLICATION ID="oApp"
APPLICATIONNAME="Splash Screen"

Per my comments embedded. I hardcode the size there when possible to avoid
flicker.


"mayayana" <mayaXX...@mindXXspring.com> wrote in message
news:hgs%h.8664$j63....@newsread2.news.pas.earthlink.net...

Dennis Reinhardt

unread,
May 7, 2007, 10:29:45 PM5/7/07
to
On May 6, 5:24 pm, XP <X...@discussions.microsoft.com> wrote:
> ... and lock at that size.

> How can I do this?

You cannot easily prevent minimizing or maximising but you can set the
normal size as locked ... right in the HTA header itself. Rather
than, defining a thick border, define a dialog border:

<hta:application
border=dialog
.........


Michael Harris (MVP)

unread,
May 7, 2007, 11:12:11 PM5/7/07
to
Dennis Reinhardt wrote:
> On May 6, 5:24 pm, XP <X...@discussions.microsoft.com> wrote:
>> ... and lock at that size.
>> How can I do this?
>
> You cannot easily prevent minimizing or maximising ...

But you _can_...

<HTML>
<HEAD>


<SCRIPT type="text/jscript">
// Always Set Size Here to Avoid Flicker
window.moveTo(0,0);

window.resizeTo(400,200);
</SCRIPT>
<TITLE>Hello, World!</TITLE>
<HTA:APPLICATION ID="oHTA"
APPLICATIONNAME="myApp"
CAPTION="yes"
MINIMIZEBUTTON="no"
MAXIMIZEBUTTON="no"
BORDER=dialog
>
</HEAD>
<BODY SCROLL="no">
This HTA is...<BR>
<BR>
...is sized/moved without flicker<BR>
...has no min/max buttons <BR>
...is not resizable
</BODY>
</HTML>

--
Michael Harris
Microsoft.MVP.Scripting


0 new messages