Click here to Skip to main content
15,888,984 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to send a click message to an listctrl ? Pin
_Flaviu16-Oct-11 19:56
_Flaviu16-Oct-11 19:56 
AnswerRe: How to send a click message to an listctrl ? Pin
«_Superman_»15-Oct-11 21:08
professional«_Superman_»15-Oct-11 21:08 
GeneralRe: How to send a click message to an listctrl ? Pin
_Flaviu15-Oct-11 22:00
_Flaviu15-Oct-11 22:00 
GeneralRe: How to send a click message to an listctrl ? Pin
Stephen Hewitt16-Oct-11 2:36
Stephen Hewitt16-Oct-11 2:36 
GeneralRe: How to send a click message to an listctrl ? Pin
_Flaviu16-Oct-11 19:56
_Flaviu16-Oct-11 19:56 
Questionsetting form element values using ie TCppWebBrowser control Pin
Andrew J. Burke15-Oct-11 3:32
Andrew J. Burke15-Oct-11 3:32 
AnswerRe: setting form element values using ie TCppWebBrowser control Pin
App_15-Oct-11 8:37
App_15-Oct-11 8:37 
GeneralRe: setting form element values using ie TCppWebBrowser control Pin
Andrew J. Burke15-Oct-11 14:50
Andrew J. Burke15-Oct-11 14:50 
/* Well I got this far I get 3 errors in the BrowserDocumentComplete event:

(C++ Error)BrowserFrm.cpp(53): E2285 Could not find match for 'TBrowserFrame::GetHTMLItem<ParentIntf>TComInterface<IHTMLElementCollection,&GUID_NULL>,char *,IHTMLFormElement * *)'

(C++ Error)BrowserFrm.cpp(58): E2285 Could not find match for 'TBrowserFrame::GetHTMLItem<ParentIntf>TComInterface<IHTMLFormElement,&GUID_NULL>,char *,IHTMLInputElement* *)'

(C++ Error)BrowserFrm.cpp(59): E2285 Could not find match for 'TBrowserFrame::GetHTMLItem<ParentIntf>TComInterface<IHTMLFormElement,&GUID_NULL>,char *,IHTMLInputElement* *)' */


//I marked the lines with the errors below:

//BrowserFrm.cpp

#include <vcl.h>
#pragma hdrstop

#include "BrowserFrm.h"
#include <utilcls.h>
#include <mshtml.h>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "SHDocVw_OCX"
#pragma resource "*.dfm"
TBrowserFrame *BrowserFrame;
//---------------------------------------------------------------------------
__fastcall TBrowserFrame::TBrowserFrame(TComponent* Owner)
: TFrame(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TBrowserFrame::Go(AnsiString url)
{
Browser->Navigate(StringToOleStr(url),0,NULL,NULL,NULL);
}
//---------------------------------------------------------------------------
template<class ParentIntf, class ItemIntf>
HRESULT __fastcall TBrowserFrame::GetHTMLItem(ParentIntf *CollectionOrElement, const
WideString &name, ItemIntf** ppIntf)
{
TVariant vName = name;
TVariant vIndex = 0;
TComInterface disp;

HRESULT hRes = CollectionOrElement->item(vName, vIndex, &disp);
if( SUCCEEDED(hRes) )
hRes = disp->QueryInterface(__uuidof(ItemIntf),(LPVOID*)ppIntf);
return hRes;
}

//---------------------------------------------------------------------------
void __fastcall TBrowserFrame::BrowserDocumentComplete(TObject *Sender,
LPDISPATCH pDisp, Variant *URL)
{
if( Browser->Document )
{
TComInterface<IHTMLDocument2>HTMLDoc;
if(SUCCEEDED(Browser->Document->QueryInterface(
IID_IHTMLDocument2,(LPVOID*)&HTMLDoc) ) )
{
TComInterface<IHTMLElementCollection>forms;
if( SUCCEEDED(HTMLDoc->get_forms(&forms)) )
{
TComInterface<IHTMLFormElement>form;
/*Line 53 error*/ if( SUCCEEDED(GetHTMLItem(forms, "loginform", &form)) )
{
TComInterface<IHTMLInputElement>userid;
TComInterface<IHTMLInputElement>password;

/*Line 58 error*/ GetHTMLItem(form, "userid", &userid);
/*Line 59 error*/ GetHTMLItem(form, "password", &password);

if( userid )
{
userid->put_value(WideString("username"));
}


if( password )
{
password->put_value(WideString("password"));
}


form->submit();
}
}
}
}
}
//---------------------------------------------------------------------------

//BrowserFrm.h file


#ifndef BrowserFrmH
#define BrowserFrmH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "SHDocVw_OCX.h"
#include <OleCtrls.hpp>

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

class TBrowserFrame : public TFrame
{
__published: // IDE-managed Components
TCppWebBrowser *Browser;
void __fastcall BrowserDocumentComplete(TObject *Sender,
LPDISPATCH pDisp, Variant *URL);

private: // User declarations
template<class ParentIntf, class ItemIntf>
HRESULT __fastcall GetHTMLItem(ParentIntf *CollectionOrElement, const
WideString &name, ItemIntf** ppIntf);

public: // User declarations
__fastcall TBrowserFrame(TComponent* Owner);
void __fastcall Go(AnsiString url);

};

//---------------------------------------------------------------------------
extern PACKAGE TBrowserFrame *BrowserFrame;
//---------------------------------------------------------------------------
#endif

-- modified 15-Oct-11 21:04pm.
GeneralRe: setting form element values using ie TCppWebBrowser control Pin
App_15-Oct-11 20:58
App_15-Oct-11 20:58 
GeneralRe: setting form element values using ie TCppWebBrowser control Pin
Andrew J. Burke16-Oct-11 6:38
Andrew J. Burke16-Oct-11 6:38 
GeneralRe: setting form element values using ie TCppWebBrowser control Pin
App_16-Oct-11 7:44
App_16-Oct-11 7:44 
GeneralRe: setting form element values using ie TCppWebBrowser control Pin
Andrew J. Burke18-Oct-11 5:16
Andrew J. Burke18-Oct-11 5:16 
QuestionClarification regarding Boolean variable Pin
pix_programmer15-Oct-11 1:01
pix_programmer15-Oct-11 1:01 
AnswerRe: Clarification regarding Boolean variable Pin
André Kraak15-Oct-11 1:18
André Kraak15-Oct-11 1:18 
GeneralRe: i would like to elaborate further Pin
Software_Developer15-Oct-11 1:47
Software_Developer15-Oct-11 1:47 
GeneralRe: Clarification regarding Boolean variable Pin
Albert Holguin15-Oct-11 7:24
professionalAlbert Holguin15-Oct-11 7:24 
AnswerRe: Clarification regarding Boolean variable Pin
MartyTPS15-Oct-11 16:48
MartyTPS15-Oct-11 16:48 
AnswerRe: Clarification regarding Boolean variable Pin
Pranit Kothari16-Oct-11 20:38
Pranit Kothari16-Oct-11 20:38 
AnswerRe: Clarification regarding Boolean variable Pin
Chuck O'Toole17-Oct-11 5:01
Chuck O'Toole17-Oct-11 5:01 
QuestionProgress Window, where to attach Pin
jkirkerx14-Oct-11 9:42
professionaljkirkerx14-Oct-11 9:42 
QuestionRe: Progress Window, where to attach Pin
David Crow14-Oct-11 10:06
David Crow14-Oct-11 10:06 
AnswerRe: Progress Window, where to attach Pin
jkirkerx14-Oct-11 10:38
professionaljkirkerx14-Oct-11 10:38 
GeneralRe: Progress Window, where to attach Pin
Richard MacCutchan14-Oct-11 23:02
mveRichard MacCutchan14-Oct-11 23:02 
GeneralRe: Progress Window, where to attach Pin
jkirkerx15-Oct-11 7:02
professionaljkirkerx15-Oct-11 7:02 
GeneralRe: Progress Window, where to attach Pin
Richard MacCutchan15-Oct-11 7:09
mveRichard MacCutchan15-Oct-11 7:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.