0

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?

Teemu
  • 22,918
  • 7
  • 53
  • 106

1 Answers1

5

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.

Teemu
  • 22,918
  • 7
  • 53
  • 106
  • Thanks, but didn't work? It looks like it would work but I get an error. The error is "Error: Object Doesn't Support Property or Method 'addEventListener'". Any other suggestions? – user3184214 Feb 03 '14 at 02:00
  • @user3184214 The snippet is tested and works well. Maybe you run your app in Quirks mode? Please see [this answer](http://stackoverflow.com/a/19570684/1169519). If you run the HTA with IE<9, you need to use the legacy eventhandling model, i.e. `grip.attachEvent('onmousedown', mouseDown);` etc. and `grip.detachEvent('onmousedown', mouseDown);` etc. – Teemu Feb 03 '14 at 05:09