|
|
导航: |
论坛 -> DELPHI技术
斑竹:liumazi,sephil |
|
作者: |
bios (阿贡) |
★☆☆☆☆ |
-
|
盒子中级会员 |
|
2004/2/18 17:02:25 |
标题: |
|
加入我的收藏 |
楼主: |
//---------------------------------------------------------------------------
#include <vcl.h> #pragma hdrstop
#include "Unit1.h" #include "SHDocVw_OCX.h" #include <Mshtml.h> #include <mshtmhst.h> #include <mshtmcid.h> #include <OleCtrls.hpp> //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "SHDocVw_OCX" #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } void TForm1::ExecWBEx(int cmdID,TVariant *pvaIn,TVariant *pvaOut,int nCmdExecOpt) { IDispatch * WebDocument = static_cast<IDispatch *>(CppWebBrowser->Document); IHTMLDocument2 *HTMLDocument = static_cast<IHTMLDocument2 *>(WebDocument); if(HTMLDocument) { IOleCommandTarget *pCmd; HRESULT hr=HTMLDocument->QueryInterface(IID_IOleCommandTarget,(void **)(&pCmd)); if(SUCCEEDED(hr)) { pCmd->Exec(&CGID_MSHTML,cmdID,nCmdExecOpt,pvaIn,pvaOut); } } } //---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender) { String URL="http://127.0.0.1"; TVariant V = URL; CppWebBrowser->Navigate2(&V); TVariant *abc; ExecWBEx(IDM_FIND,abc,abc,0); //想调用ie的查找框,但发现DLL错误! } //--------------------------------------------------------------------------- void __fastcall TForm1::FormShow(TObject *Sender) { OleInitialize(0); } //---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender) { OleUninitialize(); } //---------------------------------------------------------------------------
此帖子包含附件:
大小:46.4K |
----------------------------------------------
|
作者: |
bios (阿贡) |
★☆☆☆☆ |
-
|
盒子中级会员 |
|
2004/2/18 17:39:01 |
2楼: |
老大 修好了,帮忙哦!
----------------------------------------------
|
作者: |
bios (阿贡) |
★☆☆☆☆ |
-
|
盒子中级会员 |
|
2004/2/23 14:37:22 |
4楼: |
老大 有在帮偶么?
----------------------------------------------
|
作者: |
sephil (NAILY Soft) |
★☆☆☆☆ |
-
|
盒子中级会员 |
|
2004/2/24 10:10:35 |
6楼: |
//--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { OleInitialize(NULL); } //---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender) { OleUninitialize(); } //---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender) { WB->Navigate2(&(TVariant)"http://www.playicq.com"); } //---------------------------------------------------------------------------
void ExecWBEx(TCppWebBrowser* pWB, int cmdID, TVariant* pvaIn, TVariant* pvaOut, int nCmdExecOpt) { IDispatch* pWBDoc = static_cast<IDispatch*>(pWB->Document); IHTMLDocument2* doc = static_cast<IHTMLDocument2 *>(pWBDoc); if( doc ) { IOleCommandTarget* pCmd; HRESULT hr = doc->QueryInterface(IID_IOleCommandTarget,(void**)(&pCmd)); if( SUCCEEDED(hr) ) pCmd->Exec(&CGID_MSHTML, cmdID, nCmdExecOpt, pvaIn, pvaOut); } }
void __fastcall TForm1::Button2Click(TObject *Sender) { TVariant EmptyParam; ExecWBEx(WB, IDM_FIND, &EmptyParam, &EmptyParam, 0); } //---------------------------------------------------------------------------
----------------------------------------------
Copyright 2008 ? NAILY Soft Click here to redirect to my home Click here to redirect to my blog
|
作者: |
bios (阿贡) |
★☆☆☆☆ |
-
|
盒子中级会员 |
|
2004/2/24 11:25:03 |
7楼: |
晕啊 老大 这回可以了! 不过很奇怪要点两次才出来的呀!晕!
----------------------------------------------
|
|