我需要抓住温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和辍学的标准方式是否不可行?
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”的东道方直接支持。
我发现的最好办法是通过东道国控制处理<代码>Navigating的活动。 当你放弃控制档案时,这次事件火上了,当时你可以拿起档案。 骗局是,你必须知道什么构成“
另一种选择是,在载有Java式成文的超文本文件内通过<条码>
For more info on both approaches take a look at this blog post: https://weblog.west-wind.com/posts/2017/Mar/10/Dragging-and-Dropping-Images-and-Files-into-the-Web-Browser-Control
- winforms
- combobox
- fogbugz
- java
- date
- internationalization
- asp.net
- iis
- url-rewriting
- urlrewriter
- c#
- enums
- ocaml
- haxe
- algorithm
- string
- viewstate
- .net
- c++
- c
- symbol-table
- mysql
- database
- postgresql
- licensing
- migration
- vb.net
- vb6
- declaration
- vb6-migration
- python
- psycopg2
- backup
- vmware
- virtualization
- gnu-screen
- authentication
- desktop
- excel
- xll
- cultureinfo
- regioninfo
- oracle
- client
- session
- download
- html
- virtual
- constructor
- scenarios
- perl
- full-text-search
- javascript
- ajax
- testing
- oop
- inheritance
- vim
- encapsulation
- information-hiding