|
I'm trying to advise to HTMLElementEvents2
class declaration has the folowing line:
public IDispEventImpl<2,CTBar,&__uuidof(HTMLElementEvents2),&LIBID_MSHTML, 1, 0>
Here's body of OnDocumentComlete:
HRESULT __stdcall CTBar::OnDocumentComplete(IDispatch* pDisp, VARIANT* URL)<br />
{<br />
IDispatch* dispdoc;<br />
IWebBrowser2* wb;<br />
pDisp->QueryInterface(IID_IWebBrowser2,(LPVOID*)&wb);<br />
wb->get_Document(&dispdoc);<br />
dispdoc->QueryInterface(IID_IHTMLDocument2,(LPVOID*)&hDoc);<br />
hDoc->get_body(&hBody);<br />
HRESULT hr=_IDispEventLocator<2, &__uuidof(HTMLElementEvents2)>::DispEventAdvise( hBody, &__uuidof(HTMLElementEvents2));<br />
return S_OK;<br />
}
As a result i'm getting E_NOINTERFACE in hr. Why? Where's error?
|
|
|
|
|
It could be because you're not defining the proper version number in your class declaration. I've had the same problem trying to sink web browser events.
Try setting the MSHTML version to 4.0:
public IDispEventImpl<2,CTBar,&__uuidof(HTMLElementEvents2),&LIBID_MSHTML, 4, 0>
HTH,
scott.
|
|
|
|
|
Tried, no effect!
Any other suggestions?
|
|
|
|
|
Hi, everyone!
Here is a sample of the usage of allocate of STL.
When compiling it with VC6.0, some error occur.
I have added the source codes and related error
messages below.
Source:
--------
#include <vector>
#include <algorithm>
#include <iostream>
#include <functional>
using namespace std;
int main()
{
vector<int> a (2, 5);
vector<int> b (2, 7);
int *c = allocate((ptrdiff_t) a.size(), (int*)0 );
transform ( a.begin(), a.end(), b.begin(),
raw_storage_iterator<int*, int> (c), plus<int>() );
copy (&c[0], &c[2], ostream_iterator<int> (cout, " ") );
return 1;
}
--------
Error messages:
--------
C:\Program Files\Microsoft Visual Studio\MyProjects\testRawIterator\testRawIterator.cpp(12) : error C2065: 'allocate' :
undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\testRawIterator\testRawIterator.cpp(12) : error C2440: 'initializing' :
cannot convert from 'int' to 'int *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
--------
How to resolve the trouble?
Thanks in advance,
George
|
|
|
|
|
alllocate() is supposed to be a member function of your special allocator class, not a global function.
PS. I think you should get this book.
|
|
|
|
|
I'm trying to retrieve the Url of a new window for my BHO... I did what S.Rod. suggested (his code was in C#, I'm using C++/ATL)
case DISPID_NEWWINDOW2:
{
CComPtr<IDispatch> pDisp = NULL;
m_pBlankDlg = new CBlankDlg();
m_pBlankDlg->Create( NULL );
CComPtr<IUnknown> spUnk;
m_pBlankDlg->GetDlgControl( IDC_BROWSER, IID_IWebBrowser2, (void **) &spUnk );
CComQIPtr<IWebBrowser2> spWB = spUnk;
spWB->get_Application( &pDisp );
pDispParams->rgvarg[1].pdispVal = pDisp;
m_pBlankDlg->ShowWindow( SW_SHOW );
}
And in CBlankDlg :
class CBlankDlg :
public CAxDialogImpl<CBlankDlg>,
public IDispEventImpl<IDC_BROWSER,CBlankDlg>
{
...
BEGIN_SINK_MAP(CBlankDlg)
SINK_ENTRY(IDC_BROWSER, 250, BeforeNavigate2Browser)
END_SINK_MAP()
void __stdcall BeforeNavigate2Browser(LPDISPATCH pDisp, VARIANT* URL, VARIANT* Flags, VARIANT* TargetFrameName, VARIANT* PostData, VARIANT* Headers, BOOL* Cancel);
The BeforeNavigate2 event is never triggered... why?
thanks for your help!
---------------
Tired of Spam? Introducing InboxShield® for Microsoft® Outlook®
http://www.edovia.com
|
|
|
|
|
Fixed it!
spWB->get_Application(&pIDispatch);
*(pDispParams->rgvarg[1].ppdispVal) = pIDispatch;
---------------
Tired of Spam? Introducing InboxShield® for Microsoft® Outlook®
http://www.edovia.com
|
|
|
|
|
I got it to work by changing this line:
*(pDispParams->rgvarg[1].ppdispVal) = pIDispatch;
But this cancels the popup! What I want to do is to get the URL and let the popup show itself. Why won't it display?
void __stdcall CBlankDlg::BeforeNavigate2Browser(LPDISPATCH pDisp, VARIANT* URL, VARIANT* Flags, VARIANT* TargetFrameName, VARIANT* PostData, VARIANT* Headers, BOOL* Cancel)
{
CAtlString szUrl = *URL;
*Cancel = FALSE;
}
---------------
Tired of Spam? Introducing InboxShield® for Microsoft® Outlook®
http://www.edovia.com
|
|
|
|
|
Hi, everyone!
Here is a sample of the usage of inserter of STL.
When compiling it with VC6.0, some error occur.
I have added the source codes and related error
messages below.
Source:
--------
#include <iostream>
#include <vector>
#include <deque>
#include <fstream>
#include <algorithm>
using namespace std;
template <class Container>
back_insert_iterator<Container> back_inserter(Container& x) {
return back_insert_iterator<Container>(x);
}
template <class Container>
front_insert_iterator<Container> front_inserter(Container& x) {
return front_insert_iterator<Container>(x);
}
template <class Container, class Iterator>
insert_iterator<Container> inserter(Container& x, Iterator i) {
return insert_iterator<Container>(x, Container::iterator(i));
}
int main()
{
ifstream f ("c:\\example"); // file example: 1 3
deque<int> d;
copy (istream_iterator<int>(f),
istream_iterator<int>(),
back_inserter(d) );
vector<int> w (2,7);
copy (w.begin(), w.end(), front_inserter (d) );
insert_iterator<deque<int> > i = inserter (d, ++d.begin() );
*i = 9;
return 1;
}
--------
Error messages:
--------
C:\Program Files\Microsoft Visual Studio\MyProjects\testI\testI.cpp(31) : error C2667: 'back_inserter' : none of 2 overload
have a best conversion
C:\Program Files\Microsoft Visual Studio\MyProjects\testI\testI.cpp(31) : error C2668: 'back_inserter' : ambiguous call to
overloaded function
C:\Program Files\Microsoft Visual Studio\MyProjects\testI\testI.cpp(34) : error C2667: 'front_inserter' : none of 2 overload
have a best conversion
C:\Program Files\Microsoft Visual Studio\MyProjects\testI\testI.cpp(34) : error C2668: 'front_inserter' : ambiguous call to
overloaded function
C:\Program Files\Microsoft Visual Studio\MyProjects\testI\testI.cpp(36) : error C2667: 'inserter' : none of 2 overload have a
best conversion
C:\Program Files\Microsoft Visual Studio\MyProjects\testI\testI.cpp(36) : error C2668: 'inserter' : ambiguous call to
overloaded function
C:\Program Files\Microsoft Visual Studio\MyProjects\testI\testI.cpp(36) : error C2512: 'insert_iterator<class
std::deque<int,class std::allocator<int> > >' : no appropriate default constructor available
Error executing cl.exe.
--------
Thanks in advance,
George
|
|
|
|
|
Why are you defining back_inserter and family in your program? They are already provided by the standard libary. Remove those definitions and the program will compile OK.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks, Joaquín buddie!
George
|
|
|
|
|
Hi, everyone!
Here is a sample of the usage of iterator of STL.
When compiling it with VC6.0, some error occur.
I have added the source codes and related error
messages below.
Source:
--------
#include <list>
#include <iostream>
using namespace std;
int main()
{
list<int> l;
// fill l with 1 2 3 4
l.push_back(1);
l.push_back(2);
l.push_back(3);
l.push_back(4);
copy (reverse_iterator<int*, int, int&, ptrdiff_t> (l.end()),
reverse_iterator<int*, int, int&, ptrdiff_t> (l.begin()),
ostream_iterator<int> (cout, " ") );
return 1;
}
--------
Error messages:
--------
C:\Program Files\Microsoft Visual Studio\MyProjects\testRI2\testRI2.cpp(15) : error C2440: 'type cast' : cannot convert from
'class std::list<int,class std::allocator<int> >::iterator' to 'class std::reverse_iterator<int *,int,int &,int,int>'
No constructor could take the source type, or constructor overload resolution was ambiguous
C:\Program Files\Microsoft Visual Studio\MyProjects\testRI2\testRI2.cpp(16) : error C2440: 'type cast' : cannot convert from
'class std::list<int,class std::allocator<int> >::iterator' to 'class std::reverse_iterator<int *,int,int &,int,int>'
No constructor could take the source type, or constructor overload resolution was ambiguous
Error executing cl.exe.
--------
Thanks in advance,
George
|
|
|
|
|
This is not the way of obtaining a reverse iterator to a container. std::iterator is meant to support developers writing their own reverse iterators, so forget about it if you're in user mode.
Check rbegin and rend to learn how to traverse a container in reverse order.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks, Joaquín buddie!
I have tried your method, it works OK!
George
|
|
|
|
|
Hi, everyone!
Here is a sample of the usage of iterator of STL.
When compiling it with VC6.0, some error occur.
I have added the source codes and related error
messages below.
Source:
--------
#include <list>
#include <iostream>
using namespace std;
int main()
{
list<int> l;
// fill l with 1 2 3 4
reverse_bidirectional_iterator <list<int>::iterator,
list<int>::value_type,
list<int>::reference_type,
list<int>::difference_type> r (l.end());
cout << *r << " ";
r++;
cout << *r << " ";
r--;
cout << *r;
}
--------
Error and warnings:
--------
c:\Program Files\Microsoft Visual Studio\MyProjects\testRI\testRI.cpp(12) : error C2039: 'reference_type' : is not a member
of 'list<int,class std::allocator<int> >'
C:\Program Files\Microsoft Visual Studio\MyProjects\testRI\testRI.cpp(12) : error C2065: 'reference_type' : undeclared
identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\testRI\testRI.cpp(13) : error C2955: 'reverse_bidirectional_iterator' :
use of class template requires template argument list
c:\program files\microsoft visual studio\vc98\include\iterator(56) : see declaration of
'reverse_bidirectional_iterator'
C:\Program Files\Microsoft Visual Studio\MyProjects\testRI\testRI.cpp(13) : error C2514:
'std::reverse_bidirectional_iterator' : class has no constructors
c:\program files\microsoft visual studio\vc98\include\iterator(56) : see declaration of
'reverse_bidirectional_iterator'
C:\Program Files\Microsoft Visual Studio\MyProjects\testRI\testRI.cpp(13) : error C2262: 'r' : cannot be destroyed
C:\Program Files\Microsoft Visual Studio\MyProjects\testRI\testRI.cpp(14) : error C2678: binary '*' : no operator defined
which takes a left-hand operand of type 'class std::reverse_bidirectional_iterator' (or there is no acceptable conversion)
C:\Program Files\Microsoft Visual Studio\MyProjects\testRI\testRI.cpp(15) : error C2678: binary '++' : no operator defined
which takes a left-hand operand of type 'class std::reverse_bidirectional_iterator' (or there is no acceptable conversion)
C:\Program Files\Microsoft Visual Studio\MyProjects\testRI\testRI.cpp(15) : error C2678: binary '++' : no operator defined
which takes a left-hand operand of type 'class std::reverse_bidirectional_iterator' (or there is no acceptable conversion)
C:\Program Files\Microsoft Visual Studio\MyProjects\testRI\testRI.cpp(15) : error C2678: binary '++' : no operator defined
which takes a left-hand operand of type 'class std::reverse_bidirectional_iterator' (or there is no acceptable conversion)
C:\Program Files\Microsoft Visual Studio\MyProjects\testRI\testRI.cpp(16) : error C2678: binary '*' : no operator defined
which takes a left-hand operand of type 'class std::reverse_bidirectional_iterator' (or there is no acceptable conversion)
C:\Program Files\Microsoft Visual Studio\MyProjects\testRI\testRI.cpp(17) : error C2678: binary '--' : no operator defined
which takes a left-hand operand of type 'class std::reverse_bidirectional_iterator' (or there is no acceptable conversion)
C:\Program Files\Microsoft Visual Studio\MyProjects\testRI\testRI.cpp(17) : error C2678: binary '--' : no operator defined
which takes a left-hand operand of type 'class std::reverse_bidirectional_iterator' (or there is no acceptable conversion)
C:\Program Files\Microsoft Visual Studio\MyProjects\testRI\testRI.cpp(17) : error C2678: binary '--' : no operator defined
which takes a left-hand operand of type 'class std::reverse_bidirectional_iterator' (or there is no acceptable conversion)
C:\Program Files\Microsoft Visual Studio\MyProjects\testRI\testRI.cpp(18) : error C2678: binary '*' : no operator defined
which takes a left-hand operand of type 'class std::reverse_bidirectional_iterator' (or there is no acceptable conversion)
C:\Program Files\Microsoft Visual Studio\MyProjects\testRI\testRI.cpp(19) : warning C4508: 'main' : function should return a
value; 'void' return type assumed
Error executing cl.exe.
--------
How to resolve the trouble?
Thanks in advance,
George
|
|
|
|
|
Use list<int>::reference instead of list<int>::reference_type .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks, Joaquín buddie!
I have tested your method, it works OK!
But why should I use list<int>::reference instead of
list<int>::reference_type?
George
|
|
|
|
|
Because list<int>::reference_type is not defined either in VC++ 6.0 or in the standard.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks, Joaquín buddie!
Please help me with my next question, I
have just posted it.
George
|
|
|
|
|
Hey Im new to STl,
I just want to know whether MFC and STL can be mixed in a project..
I have developed a MFC Dialog application..Now i want to use list Library but im getting undeclared identifier error..I have included <list.h> hfile too.
cheers,
Super
------------------------------------------
Too much of good is bad,mix some evil in it
|
|
|
|
|
Yes, you can mix'em. This error must be due to some missing #include .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Or he might be forgetting the std:: prefix. (i.e. std::vector).
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hi, everyone!
When using stack in STL, I meet with the following trouble.
Here are the source codes and related error messages. How to
resolve the trouble? My IDE is VC6.0.
Source Codes:
--------
#include <iostream>
#include <vector>
#include <list>
#include <deque>
#include <stack>
using namespace std;
int main()
{
stack<vector<int> > s1;
stack<list<int> > s2;
stack<deque<int> > s3;
s1.push(1); s1.push(5);
cout << s1.top() << endl;
s1.pop();
cout << s1.size() << endl;
s1.empty()? cout << "empty" : cout << "not empty";
return 0;
}
--------
Error messages:
--------
C:\Program Files\Microsoft Visual Studio\MyProjects\testStack\testStack.cpp(15) : error C2664: 'push' : cannot convert
parameter 1 from 'const int' to 'const class std::vector<int,class std::allocator<int> > &'
Reason: cannot convert from 'const int' to 'const class std::vector<int,class std::allocator<int> >'
No constructor could take the source type, or constructor overload resolution was ambiguous
C:\Program Files\Microsoft Visual Studio\MyProjects\testStack\testStack.cpp(15) : error C2664: 'push' : cannot convert
parameter 1 from 'const int' to 'const class std::vector<int,class std::allocator<int> > &'
Reason: cannot convert from 'const int' to 'const class std::vector<int,class std::allocator<int> >'
No constructor could take the source type, or constructor overload resolution was ambiguous
C:\Program Files\Microsoft Visual Studio\MyProjects\testStack\testStack.cpp(16) : error C2679: binary '<<' : no operator
defined which takes a right-hand operand of type 'class std::vector<int,class std::allocator<int> >' (or there is no
acceptable
conversion)
--------
Thanks in advance,
George
|
|
|
|
|
I presume you want to create stacks contining int s, based on vector , list or deque ??? What you've actually created is a stack of vector s of int s (s1), a stack of list s of int s (s2) and a stack of deque s of int s (s3). To create stack s of int s based on vector s, list s or deque s, use
stack<int, vector<int> > s1;
stack<int, list<int> > s2;
stack<int, deque<int> > s3;
HTH
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
Thanks, Stuart buddies!
George
|
|
|
|
|