2
Windows 용 양식 응용 프로그램이 있습니다. 나는 그것에 webbrowser
컨트롤을 사용하고 있습니다. 내가 ctrl + u HTML 페이지의 소스 코드를 표시 할 수있는 기능을 시뮬레이션하고 싶습니다.C# webbrowser 컨트롤, ctrl + u 시뮬레이트하는 방법
Windows 용 양식 응용 프로그램이 있습니다. 나는 그것에 webbrowser
컨트롤을 사용하고 있습니다. 내가 ctrl + u HTML 페이지의 소스 코드를 표시 할 수있는 기능을 시뮬레이션하고 싶습니다.C# webbrowser 컨트롤, ctrl + u 시뮬레이트하는 방법
잘하면이 도움이됩니다. 우리가 (크롬, Firfox, IE, .... 등) 일반 웹 브라우저에서 CTRL + U를 시뮬레이션 할 때
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
// form which contains the web browser
public partial class MainForm : Form
{
public WebBrowser web = new WebBrowser();
public MainForm()
{
web.Height = this.Height;
web.Width = this.Width;
web.Top = 0;
web.Left = 0;
web.Dock = DockStyle.Fill;
this.Controls.Add(web);
web.Navigate("http://www.google.com");
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == (Keys.Control | Keys.U))
{
SourceForm scr = new SourceForm(this.web);
scr.Show();
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
}
//the form which will be shown once you press CTRL+U
public class SourceForm : Form
{
public TextBox sourceText;
public SourceForm(WebBrowser web)
{
sourceText = new TextBox();
sourceText.Multiline = true;
sourceText.ScrollBars = ScrollBars.Both;
sourceText.Left = 0;
sourceText.Top = 0;
sourceText.Dock = DockStyle.Fill;
sourceText.Height = this.Height;
sourceText.Width = this.Width;
this.Controls.Add(sourceText);
this.sourceText.Text = web.DocumentText;
this.Text = web.DocumentTitle;
}
}
}
}
새 탭이 나타납니다하고 웹 페이지의 소스 코드가 포함되어 있습니다. 웹 브라우저 컨트롤에서이 기능을 만들고 싶습니다. – user3501155
그래서 문제가 무엇입니까? –
어떻게 할 수 있습니까? – user3501155