2015-05-11 122 views
-1

我想編程一個屏幕保護程序,因爲我已經有了HTML5代碼,我只想使用呈現內容的WebBrowser控件。但我不知道如何退出應用程序的事件,如「點擊」,「Keydown」等WebBrowser類似乎並不知道這些事件。任何人都可以告訴我如何讓我的應用程序退出嗎?WebBrowser Click-Event

下面是一些代碼:

public Screensaver() 
{ 
    InitializeComponent(); 

    this.Load += Screensaver_Load; 
    StartBrowser(); 
} 

private void StartBrowser() 
{ 
    this.webBrowser1.DocumentText = Content; 
} 

private void Screensaver_Load(object sender, EventArgs e) 
{ 
    this.FormBorderStyle = FormBorderStyle.None; 
    this.Bounds = Screen.PrimaryScreen.Bounds; 
    Cursor.Hide(); 
    this.TopMost = true; 
    this.BackColor = Color.White; 
    this.webBrowser1.Size = new System.Drawing.Size(this.ClientSize.Width, this.ClientSize.Height); 
} 

private String Content 
{ 
    get 
    { 
     return "<html>..[long html code following]..</html>"; 
    } 
} 
+0

http://stackoverflow.com/questions/14933979/how-to -capture單擊事件換任何鍵式內式的Web瀏覽器控制 –

回答

0

您可以使用JavaScript函數在瀏覽器關閉當前應用程序,例如:

<a href="#" onclick="close_window();return false;">close</a>