private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            MessageBox.Show("Loaded!");

            string testHtml = @"
                    <html>
                        <head>
                            <script type=""text/javascript"">
                                var a=2;var b=3;
                                document.write(a+""_""+b);
                            </script>
                        </head>
                        <body>Hello there!</body>
                    </html>";


            mshtml.IHTMLDocument2 htmlDoc = (mshtml.IHTMLDocument2)webBrowser1.Document.DomDocument;     // IHTMLDocument2 has the write capability (IHTMLDocument3 does not)
            htmlDoc.close();
            htmlDoc.open("about:blank");

            object html = testHtml;

            htmlDoc.write(html);
            html = null;
        }
示例#2
0
        private void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            mshtml.IHTMLDocument2 doc = webBrowser1.Document as mshtml.IHTMLDocument2;
            doc.execCommand("Print", true, 0);
            doc.close();

            ViewModel.SetPrintControlsVisibility(false);
        }
示例#3
0
        private void File_Print(object sender, RoutedEventArgs e)
        {
            string printContents;

            printContents = ViewModel.GetPrintContents();

            mshtml.IHTMLDocument2 doc = webBrowser1.Document as mshtml.IHTMLDocument2;
            doc.clear();
            doc.write(printContents);
            doc.execCommand("Print", true, 0);
            doc.close();
        }
示例#4
0
        private void File_PrintPreview(object sender, RoutedEventArgs e)
        {
            string printContents;

            printContents = ViewModel.GetPrintContents();

            mshtml.IHTMLDocument2 doc = webBrowser1.Document as mshtml.IHTMLDocument2;
            doc.clear();
            doc.write(printContents);
            doc.close();

            ViewModel.SetPrintControlsVisibility(true);
        }