Reputation: 27
I am playing around with HTA Applications, I am making a program launcher for a usb device.
I have the caption
set to "no"
so that I can make a flat UI application. Because I disabled the caption I have no bar to move the window around.
I have tried all sorts of things but cant figure it out. I want a little tab in the bottom right corner to move the window around the screen. Not like a square, but a triangle to fit in the corner. Can anyone help me with this?
Upvotes: 0
Views: 1884
Reputation: 23406
Here's a simple script which moves the window.
window.onload = function () {
var grip = document.getElementById('grip'),
oX, oY,
mouseDown = function (e) {
if (e.offsetY + e.offsetX < 0) return;
oX = e.screenX;
oY = e.screenY;
window.addEventListener('mousemove', mouseMove);
window.addEventListener('mouseup', mouseUp);
},
mouseMove = function (e) {
window.moveTo(screenX + e.screenX - oX, screenY + e.screenY - oY);
oX = e.screenX;
oY = e.screenY;
},
gripMouseMove = function (e) {
this.style.cursor = (e.offsetY + e.offsetX > -1) ? 'move' : 'default';
},
mouseUp = function (e) {
window.removeEventListener('mousemove', mouseMove);
window.removeEventListener('mouseup', mouseUp);
};
grip.addEventListener('mousedown', mouseDown);
grip.addEventListener('mousemove', gripMouseMove);
}
The HTML & CSS
<div id="grip"></div>
#grip {
position: fixed;
bottom: 0px;
right: 0px;
border-bottom: 25px solid #ff0000;
border-left: 25px solid transparent;
}
Notice, that the only visible part of the #grip
is the border-bottom
of the div
.
Upvotes: 5