Tech Off Thread

2 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

HTAs and HTCs not playing well together.

Back to Forum: Tech Off
  • User profile image
    Sk4rlath

    I've got an HTA that's chromeless (no non-client areas, no titlebar, no borders - just a rectangle of drawing space), and I want to make it move around the screen when the user drags my custom titlebar. Moving it isn't the problem, the problem arises when I attempt to encapsulate the moving logic into an HTC. I get 'Access is Denied' on the window.moveTo call.

    I can get at the event.X and event.Y (the behavior uses a public:event tag to handle moving in case you want to move something else) properties just fine, so that's not the cause.

    Anyone have any idea how to fix this, or am I stuck with copying the movement logic to every chromeless window?

    Here's the HTC:

    <public:component lightweight="true">
     <public:attach event="onmousedown" onevent="down()" />
     <public:attach event="onmouseup" onevent="up()" />
     <public:attach event="onmousemove" onevent="move()" />
     <public:event id="moveEvent" name="onmove" />
     <script>
      var isDown = false;
      var downX;
      var downY;
      
      function down()
      {
       isDown = true;
       downX = event.x;
       downY = event.y;
       setCapture(true);
      }
      
      function up()
      {
       isDown = false;
       releaseCapture();
      }
      
      function move()
      {
       if (isDown)
       {
        var e;
        var toX = event.x - downX;
        var toY = event.y - downY;
        
        e = createEventObject();
        e.x = toX;
        e.y = toY;
        
        moveEvent.fire(e);
       }
      }
     </script>
    </public:component>

    And the relevant bits of HTA:
    <html>
     <head>
      ...
      <script>
       window.resizeTo(320, 240);
       
       function moveWindow()
       {
        var toX = event.x;
        var toY = event.y;
        
        window.moveTo(toX, toY);
       }
      </script>
      ...
     </head>
     <body>
      ...
      <!-- The caption class is:
      .caption
      {
       behavior: url(http://localhost/pathTo/theBehavior.htc);
      }
      -->
      <div class="caption" onmove="moveWindow()">
       ...
      </div>
      ...
     </body>
    </html>

    Both of these files are located in the same folder, being served up by the IIS included in Windows XP Tablet.

  • User profile image
    CodeJack

    Hi mate,

    I know much water has flowed under the bridges since you published this post... Expressionless

    but still, I'm having exactly the same issue as you had before. If you just could recall if you solved that problem or not?

    Waiting impassionately for you answer...

    Thanks in advance,
    Mike

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.