|
|
Another WinApi wrapper function AtlMessageBox
|
|
|
|
|
Thanks to all.
Indeed more than i need
|
|
|
|
|
|
How to declare/handle strings in ATL?
|
|
|
|
|
Simple As you do in C++
char szBuffer[100];
Or
TCHAR szBuffer[100];
|
|
|
|
|
Sakthi_Vel wrote: How to declare/handle strings in ATL?
include atlstr.h , it provide you CString class!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
|
Sakthi_Vel wrote: Thanks.
my pleasure
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
Another option is to use ATL's CComBSTR[^] class.
|
|
|
|
|
Nemanja Trifunovic wrote: Another option is to use ATL's CComBSTR[^] class.
yeap you are right but, i will prefer _bstr_t
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
"If it were machines, the pair_programming seem to work, but for humans it is pair_crackdown that seems to work! " - Nisamudheen
Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
If I use WTL::CHyperLink of HLINK_UNDERLINEHOVER style and handle the WM_CTLCOLORSTATIC message at the parent dialog, underlined text font is not reset to not underlined when the cursor is removed from the control. Does anyone know how this can be fixed?
|
|
|
|
|
Dear friend,
I am new in ATL world. I want to implement IEnumString in ATL 3.0. I searched in google, but did not get appropriate example. Can anybody help me and give some example.
|
|
|
|
|
|
|
Welcome, buddy!
God bless,
Ernest Laurentin
|
|
|
|
|
Hi,
I am trying to use find_if STL method for learning purpose. I have an array of structure as
struct NewPriceLookup
{
NewPriceLookup() : m_oldprice(0.0), m_newprice(0.0)
{}
NewPriceLookup(const double& oldp, const double& newp):
m_oldprice(oldp), m_newprice(newp)
{}
double m_oldprice;
double m_newprice;
};
NewPriceLookup npLookup [5] = {NewPriceLookup(10.0, 12.0),
NewPriceLookup(12.0, 14.5),
NewPriceLookup(15.0, 17.0),
NewPriceLookup(22.0, 26.0),
NewPriceLookup(30.0, 35.0) };
vector<NewPriceLookup> OldNewPriceTable(&npLookup[0], &npLookup(5));
template<typename T1, typename T2, typename T3>
struct NewPriceGrabber : public binary_function<T1, T2, T3>
{
result_type operator()(first_argument_type arg1, second_argument_type arg2)
{
return (arg1.m_oldprice == arg2);
}
};
and somewhere in the method GetNewPrices() I am trying to do the following
.....
.....
double oldprice = 15.0;
double newprice = find_if( OldNewPriceTable.begin(), OldNewPriceTable.end(),
bind2nd(NewPriceGrabber<NewPriceLookup, double, bool>(), oldprice));
When I compile this code, I am getting all sorts of errors like pointer_to_binary_function expects 2 argument 1 provided, cannot deduce template argument etc...
Can someone please help me in getting this piece of code right?
Thanks in advance.
<div class="ForumMod">modified on Sunday, February 24, 2008 12:42 PM</div>
|
|
|
|
|
First thing - what compiler are you using? If it's VC++ 6, then....upgrade if at all possible! I've just compiled your code with VC++2005 and it seems fine, aside from a) needing const qualification on NewPriceGrabber 's operator() , b) this line
double newprice = find_if( OldNewPriceTable.begin(), OldNewPriceTable.end(),
bind2nd(NewPriceGrabber<NewPriceLookup, double, bool>(), oldprice)); which returns a vector iterator, not a double:
std::vector<NewPriceLookup>::const_iterator it = std::find_if( OldNewPriceTable.begin(), OldNewPriceTable.end(),
bind2nd(NewPriceGrabber<NewPriceLookup, double, bool>(), oldprice)); and c) I presume the '&npLookup(5) ' is a typo, 'should be '&npLookup[5] '.
My other advice would be to use Boost.Bind[^] or Boost.Lambda[^] for function binders - I find them a lot less confusing. Your example would translate to:
bool NewPriceGrabber(NewPriceLookup const& arg1, double price)
{
return (arg1.m_oldprice == price);
}
void x()
{
double oldprice = 15.0;
std::vector<NewPriceLookup>::const_iterator it = std::find_if( OldNewPriceTable.begin(), OldNewPriceTable.end(),
boost::bind(NewPriceGrabber, _1, oldprice));
} Two advantages - 1) no function object needed, 2) the bind function takes a function reference/pointer (NewPriceGrabber here) as well as 1 value for each parameter of the function. You use placeholder arguments (that's the _1 ) where you don't want to bind a parameter to a value.
|
|
|
|
|
A couple of other suggestions re: STL
- For a simple lookup table, a
map would be the preferred container, rather than use a vector of structures:
#include <map>
typedef std::map<double, double> NewPriceLookup;
void x()
{
double oldprice = 15.0;
NewPriceLookup npLookup;
npLookup.insert(std::make_pair(10.0, 12.0));
npLookup.insert(std::make_pair(12.0, 14.5));
npLookup.insert(std::make_pair(15.0, 17.0));
npLookup.insert(std::make_pair(22.0, 26.0));
npLookup.insert(std::make_pair(30.0, 35.0));
NewPriceLookup::const_iterator it = npLookup.find(oldprice);
} If you want to initialise a map , you can use Boost.Assign[^].
operator() in function objects should generally be defined to take arguments (especially structs/classes) by const reference rather than by value - it minimizes copying. Also, operator() should in general be const -qualified - it's all part of const -correctness.
|
|
|
|
|
Hi Stuart,
Thanks for your suggestions. Using STL map was so simple, I didn't realized it earlier but anyways I did wanted to learn the usage of find_if method.
I will also look into Boost libraries once I have a bit more confidence in STL itself.
Regards.
|
|
|
|
|
psychedelic_fur wrote: but anyways I did wanted to learn the usage of find_if method.
Good plan! I did wonder whether "learning to use STL" was the reason you were using vector & find_if rather than map.
psychedelic_fur wrote: I will also look into Boost libraries once I have a bit more confidence in STL itself.
I'll just reiterate that (IMO) Boost binders are a lot easier to get to grips with than STL binders - I have always had trouble working out exactly what bind2nd and bind1st will produce.
|
|
|
|
|
Yes I did used vector for that purpose, may be my example was not good.
I would really like to understand STL first before using Boost. Even though boost make the life simple it does hide you from lots of internal details and I do not want to miss on those details.
Thanks & Regards.
|
|
|
|
|
Just a tip for coming exercises: Never compare floating point types for equality. Only use integral types for equality comparisons. Floating point types should be compared by checking if their difference is smaller than some defined tolerance.
--
Time you enjoy wasting is not wasted time - Bertrand Russel
|
|
|
|
|
Hi all,
I wanted to write a browser plugin. In Firefox, I could simply write some javascript with XUL to get things to work. In Internet Explorer, from my online searching, it seems that I have to write ATL code if I want a toolbar with buttons (Explorer Band)?
Now writing Javascript for one and ATL for other seems like a lot of repeatation. I would like to use Javascript for both. Is it possible to simply write a toolbar in ATL and call some javascript code for the toolbar buttons to manipulate window elements? If so, how can I call the Javascript from ATL?
Please guide.
Viv.
|
|
|
|
|
whizdom wrote: I wanted to write a browser plugin. In Firefox, I could simply write some javascript with XUL to get things to work. In Internet Explorer, from my online searching, it seems that I have to write ATL code if I want a toolbar with buttons (Explorer Band)?
Now writing Javascript for one and ATL for other seems like a lot of repeatation. I would like to use Javascript for both. Is it possible to simply write a toolbar in ATL and call some javascript code for the toolbar buttons to manipulate window elements? If so, how can I call the Javascript from ATL?
There is a set of Windows Scripting Engine objects and interfaces. I think the appropriate COM object has a progid of "JScript" and implements IActiveScript. You will need to implement an object with IActiveScriptSite. The stuff is fairly complicated, so it'll take some time to learn.
I'm impressed that you can get XUL to work. I tried to make a program to run on Seamonkey, and I've given up on it.
Nathan
|
|
|
|
|