![VB.NET源码-156个实用实例哦……](http://www.zhzx123.com/VB.NET_03.gif)
在VB.NET中为什么引用了金山词霸的xdictgrb.dll文件还是不能实现鼠标取词呢?
我在VB.NET中添加引用了金山词霸的xdictgrb.dll文件,然后直接COPY了下面这段程序但是出现了很多错误。
Option Explicit
Implements IXDictGrabSink
Private gp As GrabProxy
Private Sub Form_Load()
Set gp = New GrabProxy
With gp
.GrabEnabled = True
.GrabInterval = 30
.GrabMode = XDictGrabMouse
.AdviseGrab Me
End With
End Sub
Private Function IXDictGrabSink_QueryWord(ByVal WordString As String, ByVal lCursorX As Long, ByVal lCursorY As Long, ByVal SentenceString As String, lLoc As Long, lStart As Long) As Long
Label1.Caption = "( " & lCursorX & ", " & lCursorY & ") "
Label2.Caption = "当前语句: " & SentenceString
Label3.Caption = "当前字符: " & Mid(SentenceString, lLoc + 1, 1)
End Function
错误 1 未定义类型“IXDictGrabSink”。
2 未定义类型“GrabProxy”。
3 未定义类型“GrabProxy”。
4 未声明名称“XDictGrabMouse”。
5 “Caption”不是“System.Windows.Forms.Label”的成员。
是不是还要添加什么定义呢?
__________________________________________________________________________
ding
__________________________________________________________________________
imports XDICTGRB
试一下
__________________________________________________________________________
你的 是vb代码,不是vb.net的 代码
给你个C#的
在金山词霸中2005中带了一个XdictGrb.dll,添加引用
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Text;
using System.Windows.Forms;
using XDICTGRB;//金山词霸组件
namespace WindowsApplication1
{
public partial class Form1 : Form,IXDictGrabSink
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
GrabProxy gp = new GrabProxy();
gp.GrabInterval = 1;//指抓取时间间隔
gp.GrabMode = XDictGrabModeEnum.XDictGrabMouse;//设定取词的属性
gp.GrabEnabled = true;//是否取词的属性
gp.AdviseGrab(this);
}
//接口的实现
int IXDictGrabSink.QueryWord(string WordString, int lCursorX, int lCursorY, string SentenceString, ref int lLoc, ref int lStart)
{
this.textBox1.Text = SentenceString;//鼠标所在语句
//this.textBox1.Text = SentenceString.Substring(lLoc + 1,1);//鼠标所在字符
return 1;
}
}
}
__________________________________________________________________________
oho 被楼上的说了
__________________________________________________________________________