WebBrowser.DrawtoBitmap() generating blank images for few sites consistently

后端 未结 3 581
暖寄归人
暖寄归人 2021-01-17 18:01

I\'ve been using WebBrowser.DrawtoBitmap() in my asp.net page running in separate STA thread to capture web pages as an image. But I found that I\'m getting blank images for

3条回答
  •  温柔的废话
    2021-01-17 18:53

    You're not hitting pages with Flash?

    I had to do this, in order to get my WebBrowser control to work:

    using System;
    using System.Windows.Forms;
    
    public class WebBrowserEx : WebBrowser
    {
       public WebBrowserEx()
       {
       }
    
       protected override void WndProc(ref Message m)
       {
          switch (m.Msg)
          {
             case 0x021:
             case 0x201:
             case 0x204:
             case 0x207:
                 base.DefWndProc(ref m);
                 return;
          }
          base.WndProc(ref m);
       }
    }
    

    I seriously have no idea what I was doing, I just found it somewhere and it was to enable Flash. But I think I haven't had to much problems with it since.

    I use it to do screenshots. I run it on a separate STA thread (as a windows service - nothing visible).

提交回复
热议问题