Results 1 to 9 of 9

Thread: HTA as HTML UI for VB6 code

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    HTA as HTML UI for VB6 code

    This is probably more of a stunt than something there is a need for. But it shows one of the ways that VB6 code can be "behind" an HTML/CSS front end.

    The provided stylesheet basically duplicates the look of a plain old VB6 Form. However you could tweak the CSS and add more HTML to have garish colors, gauche behaviors, spinning flaming logos, and popup ads galore.

    Name:  sshot.png
Views: 2513
Size:  3.9 KB


    Here is UPrinterDemo.hta itself:

    Code:
    <html>
      <head>
        <hta:application
          id=HTA
          applicationName="UPrinter Demo"
          icon="Resources/UPrinterDemo.ico"
          singleInstance=no
          border=thin
          borderStyle=raised
          sysMenu=yes
          maximizeButton=no
          minimizeButton=no
          contextMenu=no
          showInTaskBar=yes
          scroll=no
          scrollFlat=no
          navigable=no
          selection=no
          windowState=normal
          version=1.0>
        <title>UPrinter Demo</title>
        <link rel=stylesheet href="Resources/UPrinterDemo.css">
        <script language="vbscript">
          Option Explicit
    
          Private UPrinterDemo
    
          Private Sub window_onload()
    	'These need to be assigned to match the layout that the
            'stylesheet defines:
            Const WIDTH = 320
            Const HEIGHT = 241
            With window
              .resizeTo WIDTH, HEIGHT 
              .moveTo (screen.availWidth - WIDTH ) \ 2, _
                      (screen.availHeight - HEIGHT ) \ 2
            End With
            With CreateObject("Microsoft.Windows.ActCtx")
              .Manifest = "Resources\UPrinterDemo.manifest"
              Set UPrinterDemo = .CreateObject("UPrinterDemo.Demo")
            End With
            With UPrinterDemo
              Set .Document = document
              .Initialize
            End With
          End Sub
        </script>
      </head>
      <body>
        <div     id=Label1>Choose a printer</div>
        <!--     Note: select element with size > 1 means "not a dropdown" -->
        <select  id=lstPrinters size=2></select>
        <button  id=cmdPrint disabled>Print</button>
        <div     id=lblStatus class=StatusBar>Ready</div>
      </body>
    </html>
    That's pretty much it. All of the heavy lifting happens in UPrinterDemo.dll's Demo class which is clean burning, eco-friendly, high performance, VB6 native machine code!


    Name:  Packaged.jpg
Views: 2990
Size:  27.6 KB


    Requirements

    No megalithic "framework" libraries required. Fully registration-free XCopy deployment.

    This is supposed to work as far back as Windows XP, however I am uncertain whether XP SP3 is required and it probably works on XP SP2 but I have doubts about XP SP1 or before.

    Only tested on Windows 10 1709.


    The required DLLAsm 2.1 utility is included in VB6 source code form so you'll have to compile that first. Please see the ReadMe.txt file.
    Attached Files Attached Files
    Last edited by dilettante; Feb 12th, 2018 at 07:45 AM. Reason: reposted with some junk removed

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: HTA as HTML UI for VB6 code

    P.S.

    The diagram above has not been updated to show the .CSS and .ICO files I added last but they also get copied into the Resources subfolder.

    Your CSS can be inline within the .HTA and the .ICO is an optional feature.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: HTA as HTML UI for VB6 code

    Er... the demo just reads in a UTF-8 text file of Unicode CSV data and prints it with some goofy graphics effects for printers that support them.

  4. #4
    PowerPoster
    Join Date
    Sep 2012
    Posts
    2,083

    Re: HTA as HTML UI for VB6 code

    Hi dilettante, I've tested it on Win10, it can print the content of Utf8.txt into PDF, but I still need to go deeper to learn what it can be used for. Thank you for providing us with a different solution.

  5. #5
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    673

    Re: HTA as HTML UI for VB6 code

    Quote Originally Posted by dilettante View Post
    This is probably more of a stunt than something there is a need for. But it shows one of the ways that VB6 code can be "behind" an HTML/CSS front end.

    The provided stylesheet basically duplicates the look of a plain old VB6 Form. However you could tweak the CSS and add more HTML to have garish colors, gauche behaviors, spinning flaming logos, and popup ads galore.

    Name:  sshot.png
Views: 2513
Size:  3.9 KB


    Here is UPrinterDemo.hta itself:

    Code:
    <html>
      <head>
        <hta:application
          id=HTA
          applicationName="UPrinter Demo"
          icon="Resources/UPrinterDemo.ico"
          singleInstance=no
          border=thin
          borderStyle=raised
          sysMenu=yes
          maximizeButton=no
          minimizeButton=no
          contextMenu=no
          showInTaskBar=yes
          scroll=no
          scrollFlat=no
          navigable=no
          selection=no
          windowState=normal
          version=1.0>
        <title>UPrinter Demo</title>
        <link rel=stylesheet href="Resources/UPrinterDemo.css">
        <script language="vbscript">
          Option Explicit
    
          Private UPrinterDemo
    
          Private Sub window_onload()
    	'These need to be assigned to match the layout that the
            'stylesheet defines:
            Const WIDTH = 320
            Const HEIGHT = 241
            With window
              .resizeTo WIDTH, HEIGHT 
              .moveTo (screen.availWidth - WIDTH ) \ 2, _
                      (screen.availHeight - HEIGHT ) \ 2
            End With
            With CreateObject("Microsoft.Windows.ActCtx")
              .Manifest = "Resources\UPrinterDemo.manifest"
              Set UPrinterDemo = .CreateObject("UPrinterDemo.Demo")
            End With
            With UPrinterDemo
              Set .Document = document
              .Initialize
            End With
          End Sub
        </script>
      </head>
      <body>
        <div     id=Label1>Choose a printer</div>
        <!--     Note: select element with size > 1 means "not a dropdown" -->
        <select  id=lstPrinters size=2></select>
        <button  id=cmdPrint disabled>Print</button>
        <div     id=lblStatus class=StatusBar>Ready</div>
      </body>
    </html>
    That's pretty much it. All of the heavy lifting happens in UPrinterDemo.dll's Demo class which is clean burning, eco-friendly, high performance, VB6 native machine code!


    Name:  Packaged.jpg
Views: 2990
Size:  27.6 KB


    Requirements

    No megalithic "framework" libraries required. Fully registration-free XCopy deployment.

    This is supposed to work as far back as Windows XP, however I am uncertain whether XP SP3 is required and it probably works on XP SP2 but I have doubts about XP SP1 or before.

    Only tested on Windows 10 1709.


    The required DLLAsm 2.1 utility is included in VB6 source code form so you'll have to compile that first. Please see the ReadMe.txt file.
    if used xp3 may error
    Error: ActiveX component can not create object: 'Microsoft.Windows.ActCtx'

    win7 ok

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: HTA as HTML UI for VB6 code

    Funny, MSDN says it is supported on WinXP.

  7. #7
    Junior Member
    Join Date
    Dec 2016
    Posts
    22

    Re: HTA as HTML UI for VB6 code

    Info: HTA's underly "lower" security limitations (in terms of createobject) in comparison with the regular IE Browser.
    But this likewise the big con - Within enterprise environments HTA's are often blocked via GPO's.
    This affects likewise Windows Script Components (.WSC) which are more of less "open" activeX 'scripts'/'components'.

  8. #8
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: HTA as HTML UI for VB6 code

    yeah no ActCtx on XP.
    I've actually used your ActCtx demo and replaced the reg-free methods with Trick's reg-free methods to manually load COM DLL Objects on XP.

  9. #9
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: HTA as HTML UI for VB6 code

    Registration-Free Activation of COM Components: A Walkthrough

    An alternative to the direct activation context API, but available only on Windows Server 2003, is the Microsoft.Windows.ActCtx object.
    Didn't release it too.

    cheers,
    </wqw>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width