|
What is the error? What flags do you use for FormatMessage? Is it possible that not all the messages came from the same message DLL? How do you deal with parameters?
|
|
|
|
|
I am implementing interface to handle event . I am stuck in defining _ATL_FUNC_INFO .
Sample of my code is
/////////////////////////////////////////////////////////////////////////////
class CCTIHPPCHelper;
#define EVENT_SOURCE_CTI 1
#define CTIHPPCEventDIID HiPathProCenterLibrary:IID__IMediaManagerEvents
typedef IDispEventSimpleImpl<event_source_cti, cctihppchelper,="" &ctihppceventdiid=""> SCTIHPPCEventImpl;
and in .tlh file i have
_IMediaManagerEvents : IDispatch
{
//
// Wrapper methods for error-handling
//
// Methods:
HRESULT EventOccurred (
struct IMediaEvent * MediaEvent );
};
My problem is how should i define _ATL_FUNC_INFO as parameter in "EventOccurred" is a struct type and what should be my BEGIN_SINK_MAP definition.
Is there any other way for implementing interface.
Thanks
|
|
|
|
|
Hi,
I didn't get your question completelly, but the general approach how to handle the events is very simple in ATL.
Assume you have class CWantEvents and you want to receive the event you described.
Then you have to define the sink map as follows:
<br />
BEGIN_SINK_MAP(CWantEvents)<br />
SINK_ENTRY_EX(0, __uuidof(_IMediaManagerEvents), 1, OnEventOccurred)<br />
END_SINK_MAP()<br />
<br />
void __stdcall OnEventOccurred( IMediaEvent* ipMediaEvent )<br />
{<br />
};<br />
Then when you attach to the event source (using DispEventAdvise ), you have to be able to receive such an event.
Hope this helps.
Ya, and note - the member marked in my sample as dispid might be different for you (depend on dispID of the real event method you want to receive)
|
|
|
|
|
Ok, if I got this right, event sinking is when you listen for COM events?
I am trying to listen for Internet Explorer events (idc_print, idc_printpreview) from an ActiveX control within internet explorer. I was wondering if someone can help me out or point me in the right direction.
MoMad the NoMad
|
|
|
|
|
idc_print? idc_printpreview? Take a look at the DWebBrowserEvents2 dispinterface. Those are the events you can sink. (At least what's been published by Microsoft. )
--
tlhIngan maH! Heghlu'meH QaQ jajvam!
|
|
|
|
|
In ATL6 (VS6) creating an interface like this
interface ICtrl1 : IDispatch<br />
{<br />
typedef enum {Diedel, Doedel, Doing} DUMMY;<br />
[id(1), helpstring("method Foo")] HRESULT Foo([in]DUMMY Dummy);<br />
};
in Foo.idl the file was properly compiled by MIDL.
However doing the same in ATL7 in the controls headerfile
__interface ICtrl1 : public IDispatch<br />
{<br />
typedef enum {Diedel, Doedel, Doing} DUMMY;<br />
[id(1), helpstring("method Foo")] HRESULT Foo([in] DUMMY Dummy);<br />
};
results in an error MIDL2025 : syntax error : expecting a type specification near "DUMMY".
I have no idea what I am doing wrong here
Rainer
|
|
|
|
|
I am little bit rusty in IDL, but I do not think enum inside of interface is valid syntax (granted that VC6 compiled that). Compile in VC6, use OleView on the resulting tlb, my guess is that older MIDL just silently moved that typedef out of interface definition during compilation.
|
|
|
|
|
|
Use stream manipulators. See this[^].
Pavel
Sonork 100.15206
|
|
|
|
|
Hi,
i am new to ATL.i want to send a simple mail with an attachment using the ATL DLL.Can anyone help me out of this problem?If possible pls paste the code/syntax.
Thanks for all in advance
|
|
|
|
|
Your going to need a library that supports SMTP, or implement your own version from the RFC. There are a few libs on this site, but you need to make sure that they don't make use of MFC, unless your happy to link to MFC in your ATL projects, but it will bloat them.
Here is an Win API version, but its very basic
http://www.codeproject.com/internet/zsmtp.asp[^]
This next article has a very good implementation that I can vouch for, but says its MFC based. On the whole its not, it just makes use of CString, which is now avaliable in ATL without binding to MFC. PJ points out that it does not use the MFC socket classes as they are message loop based which is no good if you need to write an NT service.
http://www.codeproject.com/internet/csmtpconn.asp[^]
Quote from a clever bloke :
"I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones." - Albert Einstein
|
|
|
|
|
ATL7 have support for SMTP out of the box
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Hi, everyone!
Please look at the following codes. I think I overload the
operator clearly. But compiler still say that it is ambiguous.
Here are the source codes and related error message.
Source:
--------
#include <iostream>
#include <map>
#include <set>
#include <string>
using namespace std;
class employee_data {
public:
employee_data() : name (""), skill(0), salary(0) {}
employee_data(string n, int s, long sa) :
name (n), skill (s), salary (sa) {}
string name;
int skill;
long salary;
friend ostream& operator<< (ostream& os, const employee_data& e);
};
ostream& operator<< (ostream& os, const employee_data& e) {
os << "employee: " << e.name << " " << e.skill << " " << e.salary;
return os;
}
class employee {
public:
employee (int i, employee_data e) :
identification_code (i), description (e) {}
int identification_code; // key expression to identify an employee
employee_data description;
bool operator< (const employee& e) const {
return identification_code < e.identification_code; }
};
int main()
{
set <employee, less<employee> > employee_set;
multiset <employee, less<employee> > employee_multiset;
map <int, employee_data, less<int> > employee_map;
multimap <int, employee_data, less<int> > employee_multimap;
employee_data ed1 ("john", 1, 5000);
employee_data ed2 ("tom", 5, 2000);
employee_data ed3 ("mary", 2, 3000);
employee e1 (1010, ed1);
employee e2 (2020, ed2);
employee e3 (3030, ed3);
pair<const int, employee_data> a[2] = { make_pair (2020, ed2),
make_pair (3030, ed3) };
employee_map.insert (&a[0], &a[2]);
employee_data d = employee_map[2020];
cout << d << endl;
return 1;
}
--------
Error message:
--------
C:\Program Files\Microsoft Visual Studio\MyProjects\testMap1\testMap1.cpp(86) : error C2593: 'operator <<' is ambiguous
--------
Thanks in advance,
George
|
|
|
|
|
Hi, everyone!
I have tried it in VC7.0 and Linux gcc. Both OK, something
wrong with VC6.0?
George
|
|
|
|
|
Templates with VC6 sort of stink. :/
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Thanks, Tim buddie!
George
|
|
|
|
|
It works OK in VC++6.0 sp5. Maybe you should consider installing that service pack.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks, Joaquín buddie!
I have installed VC7.0. I think I should give up
poor VC6.0.
Have a nice weekend,
George
|
|
|
|
|
I want my ATL component to expose a function that can accept string as an argument. What i am doing is:
STDMETHODIMP CProduction::SetCountry(BSTR name)
{
MesageBox(NULL, reinterpret_cast<char *>name, "Country" , MB_OK);
return S_OK;
}
i.e i accept string as BSTR in argument and display it in message box.
Similarly from the client side i am calling this function as
myobject.SetCountry("Indonesia");
The problem is that this is not working correctly. Both client and server program runs successfully. But the string is not correctly passed in the ATL exposed function. The MessageBox only show one character i.e "I"
Can any one tell me what is the problem and how can i acceept string in ATL exposed function. Currently i am using
[in] BSTR name.
Is this correct ?
|
|
|
|
|
That is correct, but to use it correctly you'll need to convert it, unless you're making a UNICODE build.
Check out the W2T macro;
{
USES_CONVERSION;
MessageBox(NULL,W2T(name),"Country",MB_OK);
}
will do what you want.
Steve S
[This signature space available for rent]
|
|
|
|
|
Hi, everyone!
Please look at the following source codes, I compile them
in VC6.0. I have tried map.insert(make_pair(...)) works OK.
But map.insert(interator, interator) is not working perperly.
How to resolve the trouble?
--------
#include <iostream>
#include <map>
#include <set>
#include <string>
using namespace std;
class employee_data {
public:
employee_data() : name (""), skill(0), salary(0) {}
employee_data(string n, int s, long sa) :
name (n), skill (s), salary (sa) {}
string name;
int skill;
long salary;
friend ostream& operator<< (ostream& os, const employee_data& e);
};
ostream& operator<< (ostream& os, const employee_data& e) {
os << "employee: " << e.name << " " << e.skill << " " << e.salary;
return os;
}
class employee {
public:
employee (int i, employee_data e) :
identification_code (i), description (e) {}
int identification_code; // key expression to identify an employee
employee_data description;
bool operator< (const employee& e) const {
return identification_code < e.identification_code; }
};
int main()
{
map <int, employee_data, less<int> > employee_map;
employee_data ed1 ("john", 1, 5000);
employee_data ed2 ("tom", 5, 2000);
employee_data ed3 ("mary", 2, 3000);
employee e1 (1010, ed1);
employee e2 (2020, ed2);
employee e3 (3030, ed3);
pair<int, employee_data> a[2] = { make_pair (2020, ed2),
make_pair (3030, ed3) };
employee_map.insert (&a[0], &a[2]);
return 1;
}
--------
Errors:
--------
C:\Program Files\Microsoft Visual Studio\MyProjects\testMap1\testMap1.cpp(75) : error C2664: 'class std::_Tree<int,struct
std::pair<int const ,class employee_data>,struct std::map<int,class employee_data,struct std::less<int>,class
std::allocator<cl
ass employee_data> >::_Kfn,struct std::less<int>,class std::allocator<class employee_data> >::iterator __thiscall
std::map<int,class employee_data,struct std::less<int>,class std::allocator<class employee_data> >::insert(class
std::_Tree<int,struct
std::pair<int const ,class employee_data>,struct std::map<int,class employee_data,struct std::less<int>,class
std::allocator<class employee_data> >::_Kfn,struct std::less<int>,class std::allocator<class employee_data> >::iterator,const
struct std::p
air<int const ,class employee_data> &)' : cannot convert parameter 1 from 'struct std::pair<int,class employee_data> *' to
'class std::_Tree<int,struct std::pair<int const ,class employee_data>,struct std::map<int,class employee_data,struct
std::les
s<int>,class std::allocator<class employee_data> >::_Kfn,struct std::less<int>,class std::allocator<class employee_data>
>::iterator'
No constructor could take the source type, or constructor overload resolution was ambiguous
--------
Thanks in advance,
George
|
|
|
|
|
A map stores values of type pair<const key,value) , which it is not what you're supplying. Replace the definition of a with
pair<<font color=#ff0000>const</font> int, employee_data> a[2] = ...
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks, Joaquín buddie!
George
|
|
|
|
|
Hi, everyone!
Such are the source codes of STL,
--------
template<class RandomAccessIterator, class T>
RandomAccessIterator binary_search (RandomAccessIterator first,
RandomAccessIterator last,
const T& value,
random_access_iterator_tag) {
// more efficient, but less generic algorithm
}
--------
I found there is a type "random_access_iterator_tag" in the definition
of the function. But there is not related parameter names. I think the
reason is the that fourth parameter is not used in the function, hidden the
parameter name can avoid warning in some compilers.
Am I correct?
Thanks in advance,
Geroge
|
|
|
|
|
Yes, if you specify a variable type and do not name it, you will cause the instance to be unnamed, and therefore inaccessible, which will avoid warnings if you do not use it.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
It'd probably be fairly easy to make a bot that'd post random stupid VB questions, and nobody would probably ever notice - benjymous - 21-Jan-2003
|
|
|
|
|