Paul
Wed Mar 26 12:42:22 CDT 2008
"mr_unreliable" <kindlyReplyToNewsgroup@notmail.com> wrote in message
news:%237iswM2jIHA.4164@TK2MSFTNGP02.phx.gbl...
> The demo hta above is using a "fake" statusbar, made up of
> html table elements.
>
> This one uses a "real" statusbar. That is, a "genuine microsoft"
> statusbar, taken from the (classic) vb common controls. There
> are two possible versions you could use, one from vb5 and one
> from vb6. Here are the specifics:
>
> vb5 resource: COMCTL32.OCX
> vb5 progid: COMCTL.SBarCtrl.1
> vb5 guid: 6B7E638F-850A-101B-AFC0-4210102A8DA7
>
> vb6 resource: MSCOMCTL.OCX
> vb6 progid: MSComctlLib.SBarCtrl.2
> vb6 guid: 8E3867A3-8586-11D1-B16A-00C0F0283628
>
> If you have an "older" system, you will probably find one or both
> of the ocx's mentioned above already installed. Back in those days
> microsoft supported apps programmed in vb5 and vb6. These days,
> microsoft is attempting to get us to forget about "classic" vb,
> and move on to vb.net(ugh!). With the newer systems, you may
> not have the "classic" vb ocx's unless you have installed some
> app programmed in vb5 or vb6 (where the installer has put in place
> the necessary auxiliary utilities to run the app). It goes
> without saying that if you want to use this, you should probably
> look to see if you have either of those ocx's installed.
>
> As best I can tell, you can use either ocx. There may be marginal
> differences, but I tried both, and the code in the hta worked the
> same with either one.
>
> As you can see from the hta code, I am using the guid in the object
> tag. You can probably use the progid also, but my experience is
> that I seem to have better luck using the guid.
>
> cheers, jw
>
>
>
--------------------------------------------------------------------------------
> <HTML>
> <HEAD>
>
> <script language="vbscript">
> ' --- discussion (avoiding that annoying hta "dialog bounce") ---
> ' this "trick" found on the vbScript ng, code by mikHar, 05Sept06
> ' Normally, an hta dialog will initially be shown in its "default"
> ' position and size for a brief instant. Later, when it gets
> ' around to running your script code, it will move/resize itself
> ' according to your wishes. Placing the move/resize code AHEAD
> ' of the hta tag seems to avoid that...
> ' --- end of discussion ----------------------
>
> Const wdDlg = 600, htDlg = 380 ' dialog size
> Const pxLeft = 100, pxTop = 100 ' positioning
> window.ResizeTo wdDlg,htDlg
> window.MoveTo pxLeft,pxTop
> </script>
>
> <HTA:APPLICATION ID="oHTA" APPLICATIONNAME="htaDebugDialogTemplate"
> WINDOWSTATE="normal" SCROLL = "no" BORDERSTYLE="normal"
> BORDER="thin"
> CAPTION="yes" MAXIMIZEBUTTON="no" MINIMIZEBUTTON="no"
> ICON="mru.ico"
> SHOWINTASKBAR="yes" SINGLEINSTANCE="yes" SYSMENU="yes"
> VERSION="1.0" >
>
> <TITLE> << (hta) Debug Dialog Template (with REAL
> StatusBar) Demo Script >> </TITLE>
>
> <SCRIPT LANGUAGE="vbScript">
> <!--
>
> ' --- description block --------------------------
> '
> ' Title: (hta) debug dialog with REAL StatusBar, jw 12May06
> '
> ' Description: A scripting graphical user interface (gui),
> ' appropriate for posting debugging messages or status
> msgs.
> ' The original version of this used a "fake" statusbar made
> ' up of html table elements. This one uses a "REAL"
> statusbar,
> ' ("real" meaning it's a genuine microsoft product)...
> '
> ' Author: mr_unreliable
> ' Website: none at this time (but lurks around the wsh/vbs ng's)
> '
> ' Usage: Use at you own risk, tested on win98se...
> '
> ' --- revision history ---------------------------
> ' 12May06: initial attempt (working from "regular" hta dbDlg)...
> ' 13May06: added "working clock"...
> ' 20May06: added "scroll into view" option for scrolling...
> ' 25Mar08: added "real" statusbar, i.e., from the vb comctrl ocx...
> ' --- end of description block -------------------
>
> Option Explicit
>
> ' --- global variables ---------------------------
> '
> Dim oDoc ' as document object
> Dim sbPanel2, sbPanel3 ' As Panel Object
> Dim clkTmr ' as timer (used to update clock)
> Const clkTmrInt = 995 ' clock update interval (note: LESS THAN 1
> SEC)
> '
> Dim tRun ' as long (to keep track of running time)
> Dim iItem ' as integer (to keep track of "span" tags)
> Dim iMsg ' as integer (sequential number, to keep track of
> messages)
> Const bAlignWithTop = True
> Const bAlignWithBottom = False
> '
> Const sbrText = 0
> Const sbrTime = 5
> Const sbrSpring = 1 ' Extra space divided among panels
> ' --- end of declarations and constants ----------
>
>
> ' --- INITIALIZATION ROUTINE ---------------------
>
> Sub initDialog()
> Const sMe = "[initDialog], "
>
> Set oDoc = window.document
>
> With oDoc
> ' resize text area...
> .getElementById("msgList").style.width = wdDlg - 25
> ' htClientArea, less statusbar, logo, less button, less progbar,
> less...
> .getElementById("msgList").style.height = .body.clientHeight _
> - 25 - 20 - 35 - 20 ' (and less fudge factor, but don't tell
> anybody)...
>
> ' MsgBox("Client Width: " & oDoc.body.clientWidth _
> ' & "Client Height: " & oDoc.body.clientHeight)
>
> ' re-position the logo to lie just above the (fake) statusbar...
> .getElementById("logo").style.top = .body.clientHeight - 47
> .getElementById("logo").style.left = .body.clientWidth - 215
>
> ' re-position the "etched edge" near the bottom of the form (er,
> dialog)...
> .getElementById("etchedEdge").style.top = .body.clientHeight - 26
> ' re-position the REAL statusbar at the bottom of the form (er,
> dialog)...
> .getElementById("oStatusbar").style.top = .body.clientHeight - 23
>
> ' oDoc.getElementById("btnExit").disabled = False
> .getElementById("btnExit").onClick = GetRef("btnExit_Click")
> End With
>
> oStatusbar.Font.Name = "MS Sans Serif"
> oStatusbar.Font.Size = 9 ' 10 ' point
>
> With oStatusbar.Panels
> .Item(1).Width = 50 ' sbPanel1 fixed width
>
> Set sbPanel2 = .Add(, "Panel2", "", sbrText)
> sbPanel2.AutoSize = sbrSpring ' sbPanel2 (spring means)
> stretch-to-fit
> Set sbPanel3 = .Add(, "Panel3", "", sbrText)
> sbPanel3.Width = 115 ' allow space for current time
> End With
>
> ' set clock timer, (used to update the clock)...
> ClearInterval(clkTmr) : clkTmr = setInterval("clkTimer_Event",
> clkTmrInt, "vbscript")
>
> tRun = 0 ' initialize the running time...
> iItem = 0
>
> dbPrint sMe & "finished.. "
>
> ' hiding the dbMsgs, for now...
> oDoc.getElementByID("msgLabel").style.visibility = "visible" '
> "hidden"
> oDoc.getElementByID("msgList").style.visibility = "visible" '
> "hidden"
>
> End Sub
>
>
> ' --- SIMULATE DEBUG.PRINT -----------------------
>
> Sub dbPrint(sMsg) ' simulates debug.print...
> Dim msgID ' as string
>
> ' posting messages and scrolling down (take II)...
> ' In this version, the posted messages are "wrapped" into "span
> tags",
> ' and given an "id" attribute containing the "message number",
> ' then inserted into the listing...
> msgID = "msg" & CStr(iMsg)
> oDoc.getElementById("msgList").insertAdjacentHTML "BeforeEnd", _
> "<span id=""" & msgID & """ >" & sMsg & "<br></span>"
>
> ' and the current/last span tag (message) is scrolled into view...
> oDoc.getElementByID(msgID).scrollIntoView(bAlignWithBottom)
>
> ' also, publish the current dbMessage in statusbar panel2...
> sbPanel2.Text = " " & sMsg
>
> iMsg = iMsg + 1 ' bump up for next message
> End Sub
>
>
> ' ------------------------------------------------
> ' --- EVENT HANDLERS -----------------------------
> ' ------------------------------------------------
>
> Sub clkTimer_Event() ' update the clock
> Const sMe = "[timer], "
>
> ' msgbox("timer event detected")
>
> ' update the clock in the statusbar (panel3)...
> sbPanel3.Text = " Time: " & formatDateTime(Time, vbLongTime)
>
> ' every to often, post a debug message, just for the entertainment
> value...
> tRun = tRun + 1
> ' if ((tRun mod 10) = 0) then dbPrint sMe & "elapsed time: " &
> CStr(tRun) & " secs"
> dbPrint sMe & "elapsed time: " & CStr(tRun) & " secs"
> End Sub
>
>
> Sub btnExit_Click()
> Const sMe = "[btnClick], "
> ' MsgBox("detected Click Event")
> ClearInterval(clkTmr) ' stop the clock timer
>
> ' post a notification to the debug window...
> dbPrint "" ' space
> dbPrint sMe & " ..detected Exit Button Click Event "
> dbPrint sMe & " (this window will close in 1 sec) "
>
> ' wait-a-bit, to allow for reading the msg,
> ' by setting ANOTHER timer, to close this dialog window...
> SetTimeout "Window.Close", 1000
>
> End Sub
>
>
> Sub CleanUp()
>
> ' msgbox("onUnload event detected")
> ClearInterval(clkTmr)
> End Sub
>
>
>
>
> //-->
> </SCRIPT>
> <style>
> body {font-family: ms sans serif; font-size: 10pt; font-weight:
> 400; color: Navy;
> margin-top: 4px; margin-left: 1px; margin-right: 1px;
> margin-bottom: 1px;
> height: 10px; width: 10px; border-style: none; }
>
> h3 {margin-top: 3px; margin-bottom: 2px; padding-top: 0%;
> padding-bottom: 0%;
> font-family: verdana; font-size: 8pt; font-weight: 400; color:
> Navy; }
>
> div {border-style: inset; border-width: 2;
> background-color:aliceblue;
> overflow:auto; text-align:left;
> font-family:verdana; font-size:10pt; font-weight:400;
> color:Navy; }
>
> textarea {font-family: verdana; font-size: 10pt; font-weight: 400;
> color: Navy; }
>
> button {margin-top: 7px; height: 25px; width: 100px; font-family:
> verdana; font-weight: 600;
> width: 125px; }
>
> <!-- note: these elements are moved in the initialization code -->
> h4 {position:absolute; top:100; left: 2;
> margin-top: 6px; margin-bottom: 0px; padding-top: 0%;
> padding-bottom: 0%;
> font-family: Arial; font-size: 8pt; font-weight: Normal;
> font-style: Italic;
> color: Navy; }
>
> hr {position:absolute; top:100; left: 2; margin-top: 1px;
> margin-bottom: 1px; }
>
> object {position:absolute; top:100; left: 2; margin-top: 0px;
> margin-bottom: 0px; }
> </style>
> </HEAD>
>
> <!-- this is the "mother" (a.k.a. "debug dialog") page -->
> <BODY onload="initDialog()" onUnload="CleanUp()" scroll='no'
> text='navy' bgcolor="silver" >
> <h3 id="msgLabel" > debugging messages... </h3>
> <CENTER>
> <!-- using "div" element (instead of textarea) for posting messages,
> instead of a listbox (i.e., what you would have used in
> vb)... -->
> <DIV id="msgList" >
>
> </DIV>
>
> <BUTTON id="btnExit" onclick="window.close()" >Exit</BUTTON>
> </CENTER>
>
> <h4 id="logo" ALIGN=RIGHT > jawar productions (all rights
> reserved)... </h4>
>
> <!-- using a "real" statusbar, from the (classic) vb
> omctrl's... -->
> <hr id="etchedEdge" width=99% align=center >
> <!--
> <OBJECT ID="oStatusbar" class="sb" ALIGN="absbottom" WIDTH="100%"
> HEIGHT="22px"
> CLASSID="CLSID:6B7E638F-850A-101B-AFC0-4210102A8DA7"
> </OBJECT> -->
> <OBJECT ID="oStatusbar" class="sb" ALIGN="absbottom" WIDTH="100%"
> HEIGHT="22px"
> CLASSID="CLSID:8E3867A3-8586-11D1-B16A-00C0F0283628" ></OBJECT>
> </BODY>
> </HTML>
I like this. It might be helpful to have links to the documentation
of the status bar control's methods, properties, collections, events,
etc. I found the following for Visual Studio (VB6, I assume):
http://msdn2.microsoft.com/en-us/library/aa984191(VS.71).aspx
Do you know of any better link for VB5 or VB6 documentation?
-Paul Randall