Visual Basic 和 .NET 不是我的强项,所以如果我问了一个愚蠢的问题,请原谅我。
我正在使用从硬件设备捕获签名的 activex 组件。我正在尝试在设备的显示屏上加载 BMP 图像。
activex 附带了很好的文档,这就是负责在显示器上绘制 BMP 的函数:
该函数接受某种 HBITMAP / BitmapHandle 对象。有人可以给我一个关于如何从 URL(而不是从本地文件)加载 BMP 对象的示例吗?
我得到了另一个用 .NET 编写的示例,但我正在使用带有该 activex 的 vbscript。这是我找到的.NET 示例:
Dim WebClient As New System.Net.WebClient
Dim sign As Bitmap
Dim strSign As String
strSign = "http://www.topazsystems.com/images/Sign.bmp"
sign = New System.Drawing.Bitmap(WebClient.OpenRead(strSign))
Dim HIcon As IntPtr = sign.GetHbitmap
AxSigPlus1.TabletState = 1
AxSigPlus1.DisplayWindowRes = True
AxSigPlus1.SetBackgroundHandle(HIcon.ToInt32, 0
编辑(5/9/12):
再看一遍,activex 是一个 OCX activex 组件,而不是一个 DLL。
这是 SDK 附带的演示 vbscript 脚本:
<SCRIPT LANGUAGE="VBScript"><!--
Sub LoadSig
If document.formname.txtValue2.value="" Then
SigPlus1.ClearTablet()
MsgBox "Please re-enter your first name to display signature"
Else
SigPlus1.JustifyX=10
SigPlus1.JustifyY=10
SigPlus1.AutoKeyStart
SigPlus1.AutoKeyData=document.formname.txtValue2.value
SigPlus1.AutoKeyData=document.formname.Disclaimer.value
strDisclaimer2=document.formname.Disclaimer.value
SigPlus1.AutoKeyFinish
SigPlus1.EncryptionMode=1
SigPlus1.SigCompressionMode=2
SigPlus1.DisplayPenWidth=10
SigPlus1.JustifyMode=5
SigPlus1.SigString=document.formname.SigData.value
If strDisclaimer=strDisclaimer2 Then
If SigPlus1.NumberOfTabletPoints=0 Then
MsgBox "Name does not match. Signature cannot be displayed"
End If
Else
MsgBox "Disclaimer has been changed. Signature cannot be displayed"
End If
End If
end Sub
//--></SCRIPT>
<FORM NAME="formname">
<INPUT TYPE="hidden" NAME="SigData">
<INPUT TYPE="hidden" NAME="txtValue">
<DIV STYLE="position:absolute; top:204px; left:10px;">
<b>Disclaimer information from the previous page:</b><br><br>
<INPUT TYPE="text" size=117 name="Disclaimer">
</DIV>
<DIV STYLE="position:absolute; top:252px; left:10px;">
<br><br><br><br><br><br><br>
<b>Please re-enter your first name to display signature:</b><br><br>
<INPUT TYPE="text" NAME="txtValue2">
<input id="DoneBtn" name="DoneBtn" type="button" value="Display" onclick="LoadSig" style="BACKGROUND-COLOR: #666699; COLOR: white; FONT: bold 8pt verdana" onmouseout="window.event.srcElement.style.background = '#666699'" onmouseover="window.event.srcElement.style.background = '#AFAFAF'">
</DIV>
</FORM>
<SCRIPT LANGUAGE="JavaScript"><!--
//These Javascript functions grab the data passed via the GET method, and redistribute
//the data for use on this page
function replace(string,text,by) {
// Replaces text with by in string
var i = string.indexOf(text), newstr = '';
if ((!i) || (i == -1))
return string;
newstr += string.substring(0,i) + by;
if (i+text.length < string.length)
newstr += replace(string.substring(i+text.length,string.length),text,by);
return newstr;
}
function getParm(string,parm) {
// returns value of parm from string
var startPos = string.indexOf(parm + "=");
if (startPos > -1) {
startPos = startPos + parm.length + 1;
var endPos = string.indexOf("&",startPos);
if (endPos == -1)
endPos = string.length;
return unescape(string.substring(startPos,endPos));
}
return '';
}
var passed = replace(location.search.substring(1),"+"," ");
document.formname.SigData.value = getParm(passed,'SigData');
document.formname.txtValue.value = getParm(passed,'txtValue');
document.formname.Disclaimer.value = getParm(passed, 'Disclaimer');
strDisclaimer = document.formname.Disclaimer.value;
//--></SCRIPT>