English 中文(简体)
实施Drag和Droopality WebBrowser Control Winforms C#
原标题:Implementing Drag and Drop Functionality WebBrowser Control Winforms C#
  • 时间:2009-09-01 07:22:33
  •  标签:

我需要抓住温Form C#的WebBrowser控制区的拖拉和登普活动。 是否有办法?

问题回答

My Workarond:

如果你从代码内调航或从ous法中打航,则使用ean子成员变量探测。 如果是外部的电话,则实施“航行”活动并进行检查。

例:

内部电话:

    private void NavigateLocal(string htmlFileName)
    {
        this.localNavigate = true;
        this.webBrowser.Navigate(htmlFileName);
    }

活动方法:

    private void WebBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
    {
        if (this.localNavigate)//inside call
        {
            this.localNavigate = false;
        }
        else //call from outside
        {

            this.DoDragDrop(e.Url.ToString());
        }
    }

“六分”一用途是让浏览器告诉你,浏览器被拖走,用屏幕播放照片,处理正常的剪辑。

[ComVisible(true)]
public class Communicator
{
    private static frmMain m_mainWindow = null;


    public Communicator(frmMain mainWindow)
    {
        m_mainWindow = mainWindow;
    }
    public void exit()
    {
        m_mainWindow.Close();
    }
    public void DragStarted(object e)
    {
        m_mainWindow.DoDragEnterFromScript();
    }
}


private void frmMain_Load(object sender, EventArgs e)
{
    webBrowser1.ObjectForScripting = new Communicator(this);;
    webBrowser1.Navigate(@"about:blank");         
}
public void DoDragEnterFromScript()
{
    // Is this an executable, shortcut or batch?
    Rectangle rect = new Rectangle(0, 0, webBrowser1.Size.Width, webBrowser1.Size.Height);
    Bitmap bmp = new Bitmap(rect.Width, rect.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
    Graphics g = Graphics.FromImage(bmp);
    Point ptCon;
    ptCon = webBrowser1.PointToScreen(new Point(0, 0));

    g.CopyFromScreen(ptCon, new Point(0, 0), webBrowser1.Size, CopyPixelOperation.SourceCopy);
    pictureBox2.BackgroundImage = bmp;
    //pictureBox2.BackColor = Color.Red;

    webBrowser1.Visible = false;
    pictureBox2.Visible = true;
    pictureBox2.Location = new Point(0, 0);
    pictureBox2.Size = webBrowser1.Size;
}

public void frmMain_DragEnter(object sender, DragEventArgs e)
{
    if (!e.Data.GetDataPresent(DataFormats.FileDrop))
        return;
    string[] arrfiles = (string[])e.Data.GetData(DataFormats.FileDrop);

    // SUCCESS

}

And in the html file

var holder = document.getElementsByTagName( body )[0];
holder.ondragover = function () {
    window.external.DragStarted(event);
    return true; 
};

Dontabe在DragLeave / DragDrop之后躲藏照片箱

做 d和辍学的标准方式是否不可行?

http://www.codeproject.com/KB/cs/dragdrop.aspx

WebBrowser Customization You can also look into IDocHostUIHandler::GetDropTarget if you want to control what the WebBrowser Control does during drag-and-drop operations.

跟踪IDocHostUIHandler实施情况的最容易的方法是了解ICustomDoc的接口及其所有SetakiHandler方法(见。 这种方法有“号”的记忆。 另一种方法是利用“积极X”的东道方直接支持





相关问题
热门标签