Save..
Print Preview...
Print...
I know how to create the simple page....
can someone explain how I add a regular 'File' menu with the above options.
Thanks,
Charles W
Can you show me some code which would impliment menus with
Save As...
Print Preview...
....and Print"
Thanks
Charles W
"mayayana" <mayaXX...@mindXXspring.com> wrote in message
news:7OVMg.9914$xQ1....@newsread3.news.pas.earthlink.net...
http://www.jsware.net/jsware/msicode.php3
See the MSI editor download. It's an HTA that's designed
to work like compiled software.
Picture here:
http://www.jsware.net/jsware/linkpics/msiview.gif
The specific things you want to do are a challenge,
though. For SaveAs I usually use a BrowseForFolder
window and then an InputBox to prompt for file name.
It's clunky, but I don't know any other way to do it
without extra components. For Print Preview and Print
..I'm not sure but with a WebBrowser object in VB -
which is essentially an IE instance - it's ExecWB 6, 0
for print and ExecWB 7, 0 for Print Preview.
The second parameter, where I put 0, is in the
docs as follows:
OLECMDEXECOPT_DODEFAULT = 0,
OLECMDEXECOPT_PROMPTUSER = 1,
OLECMDEXECOPT_DONTPROMPTUSER = 2,
OLECMDEXECOPT_SHOWHELP = 3
If you're going to go the ExecWB route you might
find this list of constants for the 1st parameter useful:
OLECMDID_OPEN = 1,
OLECMDID_NEW = 2,
OLECMDID_SAVE = 3,
OLECMDID_SAVEAS = 4,
OLECMDID_SAVECOPYAS = 5,
OLECMDID_PRINT = 6,
OLECMDID_PRINTPREVIEW = 7,
OLECMDID_PAGESETUP = 8,
OLECMDID_SPELL = 9,
OLECMDID_PROPERTIES = 10,
OLECMDID_CUT = 11,
OLECMDID_COPY = 12,
OLECMDID_PASTE = 13,
OLECMDID_PASTESPECIAL = 14,
OLECMDID_UNDO = 15,
OLECMDID_REDO = 16,
OLECMDID_SELECTALL = 17,
OLECMDID_CLEARSELECTION = 18,
OLECMDID_ZOOM = 19,
OLECMDID_GETZOOMRANGE = 20
OLECMDID_UPDATECOMMANDS = 21
OLECMDID_REFRESH = 22
OLECMDID_STOP = 23
OLECMDID_HIDETOOLBARS = 24
OLECMDID_SETPROGRESSMAX = 25
OLECMDID_SETPROGRESSPOS = 26
OLECMDID_SETPROGRESSTEXT = 27
OLECMDID_SETTITLE = 28
OLECMDID_SETDOWNLOADSTATE = 29
OLECMDID_STOPDOWNLOAD = 30
OLECMDID_ONTOOLBARACTIVATED = 31,
OLECMDID_FIND = 32,
OLECMDID_DELETE = 33,
OLECMDID_HTTPEQUIV = 34,
OLECMDID_HTTPEQUIV_DONE = 35,
OLECMDID_ENABLE_INTERACTION = 36,
OLECMDID_ONUNLOAD = 37
Can you simplify this for me....
What code do I need to add to a simple text page
to create 'Print Priview' and 'Print' options.
Thanks
Charles W
"mayayana" <mayaXX...@mindXXspring.com> wrote in message
news:X3_Mg.9661$bM....@newsread4.news.pas.earthlink.net...
Will this help?
URL:http://www.interclasse.com/scripts/htanotepad.php
It is possible to see a very simple example using basic HTML and script
with "Print Preview" and "Print" buttons.
Thanks
Charles W
"McKirahan" <Ne...@McKirahan.com> wrote in message
news:sNWdnXbHxdZz6ZjY...@comcast.com...
Can you use a third-party control?
ScriptX
http://www.meadroid.com/scriptx/index.asp
It isnt that I dont want to use an IE instance.....I am happy to.
The example you sent however was not easy for me to follow....
This code....
<head><h1>HTA Example</h1></head>
<body>Hello World</body>
.....produces a simple text page as an hta file.
What code do I need, to get this page to "print".
If I need to add a "Print" button then thats OK.
Once I see the basic code behind the button, I will have a
better understanding of what is involved in invoking the IE instance.
Sorry, but I'm pretty new at this.....
Thank for your help.
Charles W
"mayayana" <mayaXX...@mindXXspring.com> wrote in message
news:HAjNg.6346$v%4.4...@newsread1.news.pas.earthlink.net...
Will this help? Watch for word-wrap.
"Print Preview" is not supported...
<html>
<head>
<HTA:APPLICATION
APPLICATIONNAME="Menu"
ID="hta"
BORDER="thick"
BORDERSTYLE="normal"
CAPTION="yes"
CONTEXTMENU="yes"
INNERBORDER="no"
MAXIMIZEBUTTON="yes"
MINIMIZEBUTTON="yes"
NAVIGABLE="yes"
ICON=""
SCROLL="no"
SCROLLFLAT="no"
SELECTION="no"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="no"
SYSMENU="yes"
VERSION="1.0"
WINDOWSTATE="normal">
<style type="text/css">
body {
xfont-family:Verdana,Arial,Helvetica,sans-serif;
font:menu;
background-color:Menu;
color:MenuText;
xfont-size: 8pt;
cursor:default; //auto, text, pointer
}
iframe {
height:expression(document.body.clientHeight-MenuTable.clientHeight);
width:100%;
}
table {
xfont-family:Arial;
xfont-size:8pt;
font:menu;
padding:0pt;
border:0pt;
FILTER: progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=90);
}
td { border:1px solid Menu; }
.menuIn { border:1px inset; }
.menuOut { border:1px solid; }
.menuOver { border:1px outset; }
.menuSub { position:absolute;top=20; background-color:Menu; border=2px
outset;}
.menuSubOver { background-color:highlight;color:highlighttext; }
.menuSubOut { background-color:Menu;color:MenuText; }
</style>
<script type="text/vbscript">
Option Explicit
document.Title = HTA.ApplicationName
Dim LastChildMenu
Set LastChildMenu = Nothing
Dim LastMenu
Set LastMenu = Nothing
Sub MenuHide()
If Not LastChildMenu is Nothing Then
LastChildMenu.style.display = "none"
Set LastChildMenu = Nothing
LastMenu.classname = "menuOut"
End If
End Sub
Sub MenuOut(Menu)
If LastChildMenu is Nothing Then Menu.className = "menuOut"
End Sub
Sub MenuOver(Parent,Child)
If LastChildMenu is Nothing Then
Parent.className = "menuOver"
Else
If LastMenu is Parent Then
Parent.className = "menuIn"
Else
Call MenuHide()
Call MenuSubShow(Parent,Child)
End If
End If
End Sub
Sub MenuSubOut(Menu)
Menu.className = "menuSubOut"
End Sub
Sub MenuSubOver(Menu)
Menu.className = "menuSubOver"
End Sub
Sub MenuSubShow(Parent,Child)
If Child.style.display="block" Then
Parent.classname = "menuOver"
Child.style.display = "none"
Set LastChildMenu = Nothing
Else
Parent.classname = "menuIn"
Child.style.display = "block"
Set LastChildMenu = Child
End If
Set LastMenu = Parent
End Sub
Function printPreview()
Alert("Print Preview : http://www.meadroid.com/ScriptX")
End Function
</script>
</head>
<body leftmargin="0" topmargin="0" rightmargin="0">
<table id="MenuTable">
<tr>
<td onclick="Call MenuSubShow(Me,MyFileMenu)"
onmouseover="Call MenuOver(Me,MyFileMenu)"
onmouseout="Call MenuOut(Me)">File</td>
<td onclick="Call MenuHide()" width="100%" border="2"></td>
</tr>
</table>
<table id="MyFileMenu" class="menuSub" style="left=2;display:none;">
<tr>
<td onclick="Call MenuHide():window.print"
onmouseover="Call MenuSubOver(Me)"
onmouseout="Call MenuSubOut(Me)">Print</td>
</tr>
<tr>
<td onclick="Call MenuHide():printPreview()"
onmouseover="Call MenuSubOver(Me)"
onmouseout="Call MenuSubOut(Me)">Print Preview</td>
</tr>
<tr>
<td><hr></td>
</tr>
<tr>
<td onclick="Call MenuHide():window.close"
onmouseover="Call MenuSubOver(Me)"
onmouseout="Call MenuSubOut(Me)">Quit</td>
</tr>
</table>
<iframe id="MyFrame" application="yes" scrolling="no"></iframe>
</body>
</html>
As for actually getting a Print preview, what I meant
to say was that I think it will be a tough job that I'm
not willing to spend that much time on. Since ExecWB
is the way to get IE to show a Print Preview...and since you
don't have access to the IE instance from within your
HTA...my thought offhand was that it might work to
do something like the following:
Link to an external VBScript that creates an IE instance.
Write your HTA's innerHTML to disk as a temp. file.
Have you IE instance open that file.
Have the IE instance function in the VBScript call ExecWB
on the new IE instance.
You then basically have a second instance of IE that's
opening a copy of your HTA, but the second IE is under
your control.
I don't know for sure that all of that can work. I
wouldn't be surprised if you run into glitches. The
IE object model and DOM are just not thoroughgoing
enough. I find that they let me do nearly anything, but
often not without some fancy footwork. :) So, because
of that, I can't offer a sample of the code to do the job.
It's not just a case of a simple sample.
Theres a lot of code required so I will ask a suplimentary question....
Can I make this 'page' display as normal but place
the functionality on a web server and put a url in the file
pointing to the script....
Kind of like ...
<script type="text/vbscript" src="websource.vb">
(I'm not sure of the exact syntax)
Many thanks for your help.
Charles W
"McKirahan" <Ne...@McKirahan.com> wrote in message
news:bM-dnWK97KBcJZvY...@comcast.com...
[snip]
Have you tried it? You can but it will only work
on IE browsers as only IE supports VBScript.
Also, "Quit" (not that you want) will prompt the
user with a "do you want to close?" dialog.
Also, the browsers Menu, Tool, and Address
bars will now be present.
What are you really trying to do?
I want to be able to save the sresults as HTA files and distribute the
output files to users. They need to be able to print the page out.
...That's it in a nutshell....
I need to keep the "printing code" to an absolute minimum.
A print 'button' is all that is needed....menus take too much code.
Any advice would be appreciated......
Charles W.
"McKirahan" <Ne...@McKirahan.com> wrote in message
news:M7-dnbiUTL_FWZvY...@comcast.com...
You started out asking '... explain how I add a regular 'File' menu ...".
so we focused on giving you menues ...
> Any advice would be appreciated......
Why does it have to be an HTA?
Why not something simple like this:
<html>
<head>
<title>Print.htm</title>
</head>
<body bgcolor="white">
<input type="button" value="Print" onclick="window.print()">
<br><br>
<table border="0" width="400" style="border:solid 1px black">
<tr>
<td><b>Row 0 Col 1</b><hr></td>
<td><b>Row 0 Col 2</b><hr></td>
</tr>
<tr>
<td>Row 1 COl 1</td>
<td>Row 1 COl 2</td>
</tr>
<tr>
<td>Row 2 COl 1</td>
<td>Row 2 COl 2</td>
</tr>
</table>
</body>
</html>
That's interesting. I didn't know window had a
Print method. It's not in my IE4-era MSDN.
I went looking for an update online, with strange
results. I found the Print method under MS's list of
*all* DHTML methods, but their page for the window
object only lists a small subset of the actual window
object methods and properties:
http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_window
.asp
The page is useless, but it seems to be the official
page for the window object. ??
You are correct.... my first thought was to create a file menu
with "Print" and "Save As" options.... however I dont really need a menu
and so the buttom method is great with..........onclick="window.print()
Is there a window or documen "save" or equivalent function?
Charles W
"McKirahan" <Ne...@McKirahan.com> wrote in message
news:YqWdnXv6qZMqVZTY...@comcast.com...
Where would you have them save it?
In a folder to be determined by them ?
If so then you'll need a "Save" dialog.
You can't use "MSComDlg.CommonDialog" as it requires
a license -- though it's available if Visual Studio is installed.
I think you can get it with "vb5ccein.exe" = VB5 Creation Control.
URL:http://mail.transas.com/books/que/developer_expert/vb5cc/
So that leaves us with trying to force a File Download dialog
to at least give the user the option to Save (or Open) the page.
But wait...
If the page has any images or other links that do not specify
the full url then they will be broken when the user displays
the saved page. Or perhaps you just want the table saved
which doesn't contain any images or other links...
Or perhaps the page has no such references... What say you?
Is this for an intranet or extranet?
Have you standardized on a single browser for your visitors?
Can you predefine the local folder where it will be saved?
I may have a solution depending on your answers to the above.
Its very simple and effective but the page gives an "ActiveX warning"
if the file extension is changed to "html" and the user opens it in a
browser.
Thats why I wanted to go for "hta"... there is no warning.
There is nothing else on the page apart for the HTML table.
I would like the user to be able to save the page but printing is
much more important for me.
The files themselves, once they are created by my VB6 application,
will be distributed to users.... I dont know how important saving them
will be but it would be a nice option to have.
Thanks
Charles W
"McKirahan" <Ne...@McKirahan.com> wrote in message
news:TJydnaU4ReN9VJfY...@comcast.com...
[snip]
We'll you can try this. Watch for word-wrap.
Below are two files: "Print_Save.htm" and "Print_Save.vbs".
The significant lines in "Print_Save.htm"
(which can be in any Web page you generate) are:
<div id='NoSave'>
<script type='text/vbscript' src='Print_Save.vbs'></script>
</div>
Under IE browsers this will execute and place three buttons on
the bottom of the page: [Print] [Save] [Help]
The Save button will download the Web page, remove the
<div> section, and write the page to disk to a hardcoded path;
(Const cDIR = "C:\Temp\"). Leter, when the user clicks on
the saved page it will display without the buttons.
The document.title is updated with a prefix of "[Saved] ".
<<< Print_Save.htm >>>
<html>
<head>
<title>Print_Save.htm</title>
</head>
<body bgcolor="white">
<b>This is a table</b>
<br><br>
<table border="0" width="400" style="border:solid 1px black">
<tr>
<td><b>Row 0 Col 1</b><hr></td>
<td><b>Row 0 Col 2</b><hr></td>
</tr>
<tr>
<td>Row 1 COl 1</td>
<td>Row 1 COl 2</td>
</tr>
<tr>
<td>Row 2 COl 1</td>
<td>Row 2 COl 2</td>
</tr>
</table>
<div id='NoSave'>
<script type='text/vbscript' src='Print_Save.vbs'></script>
</div>
</body>
</html>
<<< Print_Save.vbs >>>
Option Explicit
'*
'* Delare Constants
'*
Const cVBS = "Print_Save.vbs"
Const cDBG = False
Const cDIR = "C:\Temp\"
'*
'* Declare Globals
'*
Dim strURL
strURL = window.location.href
Dim strOUT
strOUT = cDIR & Mid(strURL,InStrRev(strURL,"/")+1)
Sub VBS_Help()
'****
'* VBS_Help() = Displays "Help" usage instructions.
'****
Dim sHLP
sHLP = "Print_Save Help"
sHLP = sHLP & "^^Click 'Print' to print this page."
sHLP = sHLP & "^^Click 'Save' to save this page to:"
sHLP = sHLP & "^ " & strOUT
Alert(Replace(sHLP,"^",vbCrLf))
End Sub
Sub VBS_Save()
'****
'* VBS_Save() = Fetch, Clean, and Write a Web page.
'****
On Error Resume Next
If cDBG Then Alert(strURL)
'*
'* Fetch Page
'*
Dim oXML
'Set oXML = CreateObject("Microsoft.XMLHTTP")
Set oXML = CreateObject("MSXML2.XMLHTTP")
oXML.Open "GET",strURL,False
oXML.Send
Dim sTXT
sTXT = oXML.ResponseText
If cDBG Then Alert(sTXT)
If Err.Number <> 0 _
Or oXML.Status <> 200 Then
Alert("Save = Failed!")
Exit Sub
End If
'*
'* Clean Text
'*
Dim iDIV
iDIV = InStr(sTXT,"<div id='NoSave'>")
Dim jDIV
jDIV = InStrRev(sTXT,"</div>" & vbCrLf)
Dim sDIV
sDIV = Mid(sTXT,iDIV,jDIV+8-iDIV)
If cDBG Then Alert(sDIV)
sTXT = Replace(sTXT,sDIV,"")
If cDBG Then Alert(sTXT)
'*
'* Write File
'*
Const adSaveCreateOverWrite = 2
Const adTypeText = 2
Dim oADO
Set oADO = CreateObject("ADODB.Stream")
oADO.Type = adTypeText
oADO.Charset = "ascii"
oADO.Open
oADO.WriteText sTXT
oADO.SaveToFile strOUT, adSaveCreateOverWrite
If cDBG Then Alert("Save = Success!")
document.title = "[Saved] " & document.title
End Sub
Sub Window_Onload()
'****
'* Window_Onload() = Displays the buttons under IE.
'****
Dim aBUT(6)
aBUT(0) = "<br>"
aBUT(1) = "<input type='button' value='Print'
onclick='window.print()'"
aBUT(2) = " style='background-color:white; font-size:8pt;
width:50px'>"
aBUT(3) = "<input type='button' value='Save' onclick='VBS_Save()'
id='Save'"
aBUT(4) = " style='background-color:white; font-size:8pt;
width:50px'>"
aBUT(5) = "<input type='button' value='Help' onclick='VBS_Help()'"
aBUT(6) = " style='background-color:white; font-size:8pt;
width:50px'>"
Dim sBUT
sBUT = Join(aBUT,vbCrLf)
Dim sDIV
sDIV = document.getElementById("NoSave").innerHTML
document.getElementById("NoSave").innerHTML = sBUT & sDIV
End Sub
If you get the warning message:
"This page is accessing a data source on another domain.
Do you want to allow this ? [Yes] [No]"
and want to suppress it: (in Internet Explorer) select
Tools > Internet Options > Security > Local Intranet > Custom Level
then under "Miscellaneous > Access data sources across domains"
select the Enable radiobutton
document.title will be changed regardless of your response above.
Chnaging the value of "cDBG" to True will allow you to see
what is happening during the execution of the Save.
Thank you for all your advice....
It has provided me with a very good solution.
Charles W
"mayayana" <mayaXX...@mindXXspring.com> wrote in message
news:p4zNg.272$UG4...@newsread2.news.pas.earthlink.net...