把下面一小段VC6程序翻译成等价的VB6程序,本人愿意以100分+100元赠送,绝不食言.分和钱不多,全部给第一个解答的朋友,权当请朋友喝杯饮料吧,请多帮忙,谢谢了。如果有什么问题,请联系,qq:1074487struct Item
{
CString str;
RECT rect;
};cArray<Item, Item> m_pairs;
void Capture()
{
long left, top, right, bottom;
left = top = 0;
right = 800;
bottom = 600; BSTR pbstr = NULL;
BSTR pRectList = NULL;
long strCount = 0; // string count
strCount = m_ocxGetWord.GetRectStringPairs(NULL, left, top, right, bottom, &pbstr, &pRectList);
if (strCount>0)
{
m_pairs.RemoveAll(); int nLen=0, nTotalLen=0;
for (int i=0;i<strCount;i++)
{
WCHAR* pTmp1 = pbstr;
WCHAR* pTmp2 = pRectList;
WCHAR wTmp[1000];
nLen = pRectList[i*5]; // string length
wcsncpy(wTmp, pTmp1+nTotalLen, nLen);
wTmp[nLen] = 0; Item item;
item.str = wTmp;
item.rect.left = pRectList[i*5+1];
item.rect.top = pRectList[i*5+2];
item.rect.right = pRectList[i*5+3];
item.rect.bottom = pRectList[i*5+4]; m_pairs.Add(item); nTotalLen += nLen; Invalidate();
}
m_ocxGetWord.FreePairs(&pbstr, &pRectList);
}}
{
CString str;
RECT rect;
};cArray<Item, Item> m_pairs;
void Capture()
{
long left, top, right, bottom;
left = top = 0;
right = 800;
bottom = 600; BSTR pbstr = NULL;
BSTR pRectList = NULL;
long strCount = 0; // string count
strCount = m_ocxGetWord.GetRectStringPairs(NULL, left, top, right, bottom, &pbstr, &pRectList);
if (strCount>0)
{
m_pairs.RemoveAll(); int nLen=0, nTotalLen=0;
for (int i=0;i<strCount;i++)
{
WCHAR* pTmp1 = pbstr;
WCHAR* pTmp2 = pRectList;
WCHAR wTmp[1000];
nLen = pRectList[i*5]; // string length
wcsncpy(wTmp, pTmp1+nTotalLen, nLen);
wTmp[nLen] = 0; Item item;
item.str = wTmp;
item.rect.left = pRectList[i*5+1];
item.rect.top = pRectList[i*5+2];
item.rect.right = pRectList[i*5+3];
item.rect.bottom = pRectList[i*5+4]; m_pairs.Add(item); nTotalLen += nLen; Invalidate();
}
m_ocxGetWord.FreePairs(&pbstr, &pRectList);
}}
直接封成DLL
str as string
rect as RECT
End typedim m_pairs() as Itemsub Capture
dim left as long,top as long,right as long,bottom as long
left=0
top=0
right=800
bottom=600 dim pbstr as string
dim pRectlist as string
dim strCount as long
dim pTmp1 as string
dim pTmp2 as string
dim wTmp as string * 1000
dim item1 as Item
strCount=m_ocxGetWord.GetRectStringPairs(vbnull,left,top,right,bottom,pbstr,pRectList)
if strCount>0 then
dim nLen as integer,nTotalLen as integer
for i=0 to strCount-1
pTmp1=pbstr
pTmp2=pRectList
nLen=mid$(pRectList,i*5,1)
wTmp=mid$(pTmp1,nTotalLen,nLen)
item1.str=wTmp
item1.rect.left=mid$(pRectList,i*5+1,1)
item1.rect.top=mid$(pRectList,i*5+2,1)
item1.rect.right=mid$(pRectList,i*5+3,1)
item1.rect.bottom=mid$(pRectList,i*5+4,1) //增加item1 到数组m_pairs,根据实际情况设定数组上限后处理
nTotalLen=nTotalLen+nLen
Invalidate
next
m_ocxGetWord.FreePairs(pbstr,pRectList)
end if
end sub