Posts 1 - 10 of 15
First | Prev. | 1 2 | Next | Last
|
|
putra n9
Posts: 18
Joined: 2010-11-23
|
hi,
I want to know how to convert a code below in C++. Before this i write a code in VB. Can give me a detail code on C++?
Public WithEvents instHtmlButton As mshtml.HTMLButtonElement
Private Function instHtmlButton_onclick() As Boolean Handles instHtmlButton.onclick
MessageBox.Show("OK")
End Function
Private Sub IEModule_DocumentComplete(ByVal pDisp As Object, ByVal url As String) Handles Me.DocumentComplete
Me.instHtmlButton = Nothing
If (Not IsNothing(Me.HTMLDocumentObj())) Then
Me.instHtmlButton = Me.HTMLDocument.getElementById("sampleButton")
End If
End Sub
TQ |
|
Posted 12 Jan, 2011 11:10:01
|
|
Top
|
|
putra n9
Posts: 18
Joined: 2010-11-23
|
hi,
i try to convert the code in C++ but it does not working at all. Can somebody help me to resolve the problem. Following are my code after converted.
//IEModule.h
#pragma once
using namespace System;
using namespace System::ComponentModel;
using namespace System::Windows::Forms;
using namespace System::Runtime::InteropServices;
namespace plan_B
{
//Add-in Express for Internet Explorer Module
[ComVisible(true), GuidAttribute("FB97E652-108E-430E-8383-D6EA33957299")]
public ref class IEModule : public AddinExpress::IE::ADXIEModule
{
public:
IEModule(void)
{
InitializeComponent();
}
IEModule(IContainer^ container)
{
container->Add(this);
InitializeComponent();
}
public:
virtual System::ComponentModel::IContainer^ GetContainer() override;
[ComRegisterFunctionAttribute]
static void RegisterIEModule(System::Type^ t);
[ComUnregisterFunctionAttribute]
static void UnregisterIEModule(System::Type^ t);
[ComVisible(true)]
ref class IECustomContextMenuCommands :
public AddinExpress::IE::ADXIEModule::ADXIEContextMenuCommandDispatcher
{
};
[ComVisible(true)]
ref class IECustomCommands :
public AddinExpress::IE::ADXIEModule::ADXIECommandDispatcher
{
};
inline Interop::SHDocVw::WebBrowser^ IEApp()
{
return dynamic_cast<Interop::SHDocVw::WebBrowser^>(IEObj);
}
inline mshtml::HTMLDocument^ HTMLDocument()
{
return dynamic_cast<mshtml::HTMLDocument^>(HTMLDocumentObj);
}
//mshtml::HTMLButtonElement ^instHtmlButtonMailvD;
mshtml::IHTMLElement ^instHtmlButtonMailvD;
protected:
~IEModule()
{
if (components)
{
delete components;
}
}
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container^ components;
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
components = gcnew System::ComponentModel::Container();
//
// IEModule
//
this->ModuleName = L"plan_B";
this->DocumentComplete += gcnew System::EventHandler(this, &IEModule::IEModule_DocumentComplete);
this->instHtmlButtonMailvD->onclick += gcnew System::EventHandler(this, &IEModule::instHtmlButtonMailvD_onclick);
}
void IEModule_DocumentComplete(Object ^pDisp, String ^url);
bool instHtmlButtonMailvD_onclick();
};
}
//IEmodule.cpp
#include "StdAfx.h"
#include "IEModule.h"
namespace plan_B
{
//Add-in Express for Internet Explorer Module Implementation
System::ComponentModel::IContainer^ IEModule::GetContainer()
{
if (components == nullptr)
components = gcnew System::ComponentModel::Container();
return components;
}
void IEModule::RegisterIEModule(System::Type^ t)
{
AddinExpress::IE::ADXIEModule::RegisterIEModuleInternal(t);
}
void IEModule::UnregisterIEModule(System::Type^ t)
{
AddinExpress::IE::ADXIEModule::UnregisterIEModuleInternal(t);
}
void IEModule::IEModule_DocumentComplete(Object ^pDisp, String ^url)
{
this->instHtmlButtonMailvD = nullptr;
if (this->HTMLDocumentObj != nullptr)
{
this->instHtmlButtonMailvD = this->HTMLDocument()->getElementById("jenis_compose");
MessageBox::Show("OK");
}
}
bool IEModule::instHtmlButtonMailvD_onclick()
{
try
{
if (this->HTMLDocumentObj != nullptr)
{
if (this->HTMLDocument()->activeElement != nullptr)
{
MessageBox::Show("OK");
}
}
}
catch (Exception ^ex)
{
MessageBox::Show(ex->ToString());
}
return false;
}
}
TQ. |
|
Posted 13 Jan, 2011 01:30:10
|
|
Top
|
|
Sergey Grischenko
Add-in Express team
Posts: 7233
Joined: 2004-07-05
|
Hi Putra.
What exactly doesn't work? Do you get any exceptions? |
|
Posted 13 Jan, 2011 05:51:09
|
|
Top
|
|
putra n9
Posts: 18
Joined: 2010-11-23
|
hi Sergey,
thanks for reply. when i compile the program the following error occurs that referring on code below.
error C3352: 'void IEModule::IEModule_DocumentComplete(System::Object ^,System::String ^)' : the specified function does not match the delegate type 'void (System::Object ^,System::EventArgs ^)'
and
error C3352: 'bool IEModule::instHtmlButtonMailvD_onclick(void)' : the specified function does not match the delegate type 'void (System::Object ^,System::EventArgs ^)'
this->DocumentComplete += gcnew System::EventHandler(this, &IEModule::IEModule_DocumentComplete);
this->instHtmlButtonMailvD->onclick += gcnew System::EventHandler(this, &IEModule::instHtmlButtonMailvD_onclick);
TQ |
|
Posted 13 Jan, 2011 10:27:07
|
|
Top
|
|
Sergey Grischenko
Add-in Express team
Posts: 7233
Joined: 2004-07-05
|
Please use the iemodule designer to add IE events. You just need to open IEModule.h in the design mode. |
|
Posted 13 Jan, 2011 11:52:44
|
|
Top
|
|
putra n9
Posts: 18
Joined: 2010-11-23
|
If you don't mind, can give me some examples regarding the design mode in IEModule.h.
Really thanks. |
|
Posted 14 Jan, 2011 08:38:39
|
|
Top
|
|
Sergey Grischenko
Add-in Express team
Posts: 7233
Joined: 2004-07-05
|
You just need double click on the IEModule.h file and Visual Studion will open the designer.
Another way is right click on the IEModule.h file and choose the View Designer option in the context menu. |
|
Posted 15 Jan, 2011 07:42:46
|
|
Top
|
|
putra n9
Posts: 18
Joined: 2010-11-23
|
Actually, I'm trying to develop Add-on for IE using ADXIE Addon (ADX IEModule) in C++, the idea is like this :
1) When i open my web page (http://localhost/test.html),
IE will show a message box "Welcome".
For that solution, i used DocumentComplete method like following code.
void IEModule_DocumentComplete(System::Object^ pDisp, System::String^ url)
{
if (HTMLDocument()->url == "http://localhost/test.php")
{
System::Windows::Forms::MessageBox::Show("Welcome");
}
}
Problem : When the web page has been loaded, the message box doesn't appear,
because i don't know how to set the event handler for IEModule_DocumentComplete.
When i set the event handler like following
this->DocumentComplete += gcnew
System::EventHandler(this,&IEModule::IEModule_DocumentComplete);
Error : 'void MyIEAddon1::IEModule::IEModule_DocumentComplete(System::Object ^,
System::String ^)' : the specified function does not match the delegate type
'void (System::Object ^,System::EventArgs ^)'
Question : What a correct code to set the event handler for DocumentComplete?
Really need your help on this problem.
TQ. |
|
Posted 15 Jan, 2011 08:08:07
|
|
Top
|
|
Sergey Grischenko
Add-in Express team
Posts: 7233
Joined: 2004-07-05
|
Hi Putra.
When the web page has been loaded, the message box doesn't appear,
because i don't know how to set the event handler for IEModule_DocumentComplete.
Please do the following:
1. Right click on the IEModule.h
2. Choose the View Designer option.
3. Go to the Properties windows and click on the Events tab.
4. Double click on the DocumentComplete event handler.
After this is done, Add-in express should generate the code automatically. |
|
Posted 17 Jan, 2011 07:59:49
|
|
Top
|
|
putra n9
Posts: 18
Joined: 2010-11-23
|
Hi Sergey,
really thanks, it's done successfully. One of my problem settled, just another one problem that i am trying to solve it. In the same project, i am trying to detect whether the button "OK" on my web page exist or not.
Example : In test.html, there is a code to create button "OK" like
<input id="btuOK" name="btuOK" type="button" value="OK">
Is it correct if i use declaration like
mshtml::HTMLButtonElement^ btuOK;
OR
mshtml::IHTMLElement^ btuOK;
as a button variable?
Then, i use the following code as my method btuOK_onclick.
private : System::Void btuOK_onclick(){
//If button OK clicked
MessageBox::Show("OK");
}
Is it correct?
TQ. |
|
Posted 18 Jan, 2011 01:29:15
|
|
Top
|
|
Posts 1 - 10 of 15
First | Prev. | 1 2 | Next | Last
|