简体   繁体   English

将Visual C ++代码转换为Borland C ++ Builder

[英]Convert Visual C++ code to Borland C++Builder

I have coded a program with Visual C++. 我已经用Visual C ++编写了程序。 But now I must put my code in a program which is coded with Borland C++Builder. 但是现在我必须将代码放入使用Borland C ++ Builder编码的程序中。 I have a WebBrowser item on my form. 我的表单上有一个WebBrowser项。 In Visual C++, I write data to a textbox, get data from the textbox, and click a button on the WebBrowser with this code: 在Visual C ++中,我将数据写入文本框,从文本框中获取数据,然后使用以下代码单击WebBrowser上的按钮:

Write Data: 写入数据:

WebBrowser1->Document->GetElementById("okul_kod")->SetAttribute("value", TextBox2->Text);

Get Data: 获取数据:

textBox17->Text = WebBrowser1->Document->GetElementById("kay_cev")->GetAttribute("value");

Button Click: 点击按钮:

WebBrowser1->Document->GetElementById("panelden_kayit")->InvokeMember("click");

I tried lots of things, and searched online, but I can't find how to convert this code to Borland C++Builder. 我尝试了很多事情,并在线搜索,但是找不到如何将此代码转换为Borland C ++ Builder。

Can you please give me a clue or advice? 您能给我一个提示或建议吗?

In C++Builder 6, its TCppWebBrowser VCL component is a thin wrapper for Internet Explorer's ActiveX control. 在C ++ Builder 6中,其TCppWebBrowser VCL组件是Internet Explorer的ActiveX控件的精简包装。 Its Document property returns an IDispatch that you can use to gain access to IE's raw DOM interfaces directly (whereas Visual C++ appears to have wrapped those interfaces a little more nicely for you). 它的Document属性返回一个IDispatch ,您可以使用该IDispatch直接访问IE的原始DOM接口(而Visual C ++似乎已经为您更好地包装了这些接口)。

Try something like this: 尝试这样的事情:

#include <mshtml.h>
#include <utilcls.h>

// helpers for interface reference counting
// could alternatively use TComInterface instead of DelphiInterface
typedef DelphiInterface<IHTMLDocument3> _di_IHTMLDocument3;
typedef DelphiInterface<IHTMLElement> _di_IHTMLElement;

...

// Write Data:
_di_IHTMLDocument3 doc = CppWebBrowser1->Document;
_di_IHTMLElement elem;
OleCheck(doc->getElementById(WideString("okul_kod"), &elem));
if (elem) OleCheck(elem->setAttribute(WideString("value"), TVariant(Edit2->Text)));

// Get Data:
_di_IHTMLDocument3 doc = CppWebBrowser1->Document;
_di_IHTMLElement elem;
OleCheck(doc->getElementById(WideString("kay_cev"), &elem));
TVariant value;
if (elem) OleCheck(elem->getAttribute(WideString("value"), 2, &value));
Edit17->Text = value;

//Button Click:
_di_IHTMLDocument3 doc = CppWebBrowser1->Document;
_di_IHTMLElement elem;
OleCheck(doc->getElementById(WideString("panelden_kayit"), &elem));
if (elem) elem->click();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM