可以在主窗体的FormCreate事件中,写
void __fastcall TMAIN::FormCreate(TObject *Sender)
{
WideString str;
str = ExtractFileDir(Application-> ExeName) + "//HTML//index.htm " ;
CppWebBrowser1-> Navigate(str);
m_bOver = 0;
}
其中m_bOver在.h文件中定义
private:
bool m_bOver;
然后在写
void __fastcall TMAIN::CppWebBrowser1BeforeNavigate2(TObject *Sender,
LPDISPATCH pDisp, Variant *URL, Variant *Flags,
Variant *TargetFrameName, Variant *PostData, Variant *Headers,
VARIANT_BOOL *Cancel)
{
String surl;
surl = RightStr((WideString)(*URL), 5);
if (logon-> DBComboBoxlevel-> Text == "超级用户 ")
{
if (surl == "mg_qw ") //判断网页上文字超连接的名称
{
Employeefileclerk-> ShowModal();
*Cancel = true;
}
if (surl == "mg_qe ")
{
EmployeefileclerkSelect-> ShowModal();
*Cancel = true;
}
}
}
还用到了头文件#include <StrUtils.hpp>
更复杂的需要写注册表,可以参考 < <程序员(2002)> > 年合订本189页行舟写的文章
在C++Builder的CppWebBrowser调用窗体
最新推荐文章于 2018-04-26 00:37:55 发布