Hi,
I'm coding an HTML Application for a multimedia cd-rom.
The page is chromeless (no borders, nor titlebar etc..) so i implemented custom titlebar and close button.
My problem is moving the window as a normal window, with a mousedown on the titlebar.
And this is quite weird 'cause it works with any other events, as onclick and ondblclick ! desperately user-unfriendly.. :(
Please help ! Thanks.
Here's the code :
webpad.hta
to move the window, double click on its body - a click stops moving
<html><head>
<HTA:APPLICATION ID="webpad0"
APPLICATIONNAME="webpad"
BORDER="none"
INNERBORDER="no"
CAPTION="yes"
SELECTION="no"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes"
SCROLL="no"
TITLEBAR="no"
ICON="ico.ico"
NAVIGABLE="true"
SCROLLFLAT="yes"
SCROLL="no"></HTA:APPLICATION>
<link href="test.css" rel="stylesheet" type="text/css">
<title> webpad </title>
<script language="jscript">
function theerror()
{
//erreur = "Message d'erreur:\n"+ nouvelle+"\n"+fichier+"\n"+ligne;
//alert(erreur);
return true;
}
window.onerror = theerror;
// ERROR REPORTING ON/OFF (on)
</script>
<script language="vbscript">
//ONLOAD RESIZING
dim winHeight
dim winWidth
dim centerX
dim centerY
winWidth=600
winHeight=350
centerX=(screen.width/2)-(winWidth/2)
centerY=(screen.height/2)-(winHeight/2)
window.resizeto winWidth,winHeight
//window.moveto centerX,centerY
</script>
<script language="JavaScript" defer="defer">
// HERE IT IS : MOVING FUNCTIONS
var starMoving;
var posX;
var posY;
var isMoving=false;
function setPos(){
posX=event.screenX-(winWidth/2);
posY=event.screenY-12;
document.all("viewpos").innerHTML=" : x"+posX+"/y"+posY;
document.all("infos").innerHTML=isMoving;
if( isMoving == true ){
window.moveTo(posX,posY);
}
}
function moving(){
isMoving=true;
}
function stopMoving(){
isMoving=false;
}
function closeHTA(){
window.close();
}
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onmousemove="setPos()" ondblclick="moving()" onmouseup="stopMoving()">
<table id="titlebar" border="0" cellspacing="0" cellpadding="0" >
<tr>
<td width="493" align="left" valign="middle" >
<span id="menubut" > ■ webpad </span>
</td>
<td width="289" align="left" valign="middle" > </td>
<td width="20" align="center" valign="middle" id="exitButton" onMouseDown="closeHTA()">
<a href="#"><strong>x</strong></a> </td>
</tr>
</table>
<br/>
<br/>
<div id="infos"></div>
<br>
<span id="viewpos"></span>
</body></html>