好吧,我知道它是什么意思,但我不知道如何解决它这里是我的界面
public interface nsIDownloadProgressListener
{
nsIDOMDocument getDocument();
void setDocument(nsIDOMDocument doc);
void OnDownloadStateChange(short state, nsIDownload aDownload);
void OnStateChange(nsIWebProgress aWebProgress, nsIRequest aRequest, uint
aStateFlags, object aStatus, nsIDownload aDownload);
void OnProgressChange(nsIWebProgress WbProgress, nsIRequest aReq, int
curSelfProgress, int maxSelfProgress, int curTotalProgress, int
maxTotalProgress, nsIDownload aDownload);
void OnSecurityChange(nsIWebProgress wbProgress, nsIRequest aReq, uint
aState, nsIDownload aDownload);
}下面是我用来继承接口的类
public class DownloadProgressListenerClass : nsIDownloadProgressListener
{
#region nsIDownloadProgressListener Members
nsIDOMDocument Nothingreturned;
public nsIDOMDocument getDocument()
{
return Nothingreturned;
}
public void setDocument(nsIDOMDocument doc)
{
}
public void OnDownloadStateChange(short state, nsIDownload aDownload)
{
MessageBox.Show(aDownload.getId().ToString());
OnDownloadStateChange(state, aDownload);
}
public void OnStateChange(nsIWebProgress aWebProgress, nsIRequest aRequest, uint aStateFlags, object aStatus, nsIDownload aDownload)
{
MessageBox.Show(aDownload.getId().ToString());
}
public void OnProgressChange(nsIWebProgress WbProgress, nsIRequest aReq, int curSelfProgress, int maxSelfProgress, int curTotalProgress, int maxTotalProgress, nsIDownload aDownload)
{
MessageBox.Show(aDownload.getId().ToString());
}
public void OnSecurityChange(nsIWebProgress wbProgress, nsIRequest aReq, uint aState, nsIDownload aDownload)
{
MessageBox.Show(aDownload.getId().ToString());
}
#endregion nsIDownloadProgressListener Members
}然后,我尝试将侦听器添加到DLManager,该侦听器应该工作并报告进度
DownloadProgressListenerClass DLListener = new DownloadProgressListenerClass();
DLManager = Xpcom.GetService<nsIDownloadManager>("@mozilla.org/download-manager;1");
DLManager.addListner(DLListener);它有什么问题吗,因为它编译正确,但是当我尝试下载一个文件时,它没有触发任何东西,也没有显示它应该显示的消息框
发布于 2011-07-24 15:20:11
我怀疑您的addListener方法需要的接口类型是
代码行中的nsIDownloadProgressListener:
DLManager.addListner(DLListener);
如果是这样,请更改您的
DownloadProgressListenerClass DLListener = new DownloadProgressListenerClass();
转到
nsIDownloadProgressListener DLListener = new DownloadProgressListenerClass();
如果你需要解释,请告诉我。
https://stackoverflow.com/questions/6805370
复制相似问题